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

Merge remote-tracking branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2012-01-03 17:57:57 -05:00
commit 23b841b96c
302 changed files with 6978 additions and 3378 deletions

View file

@ -128,12 +128,7 @@ public class MakeCorePlugin extends Plugin {
public static void log(Throwable e) {
if (e instanceof InvocationTargetException)
e = ((InvocationTargetException) e).getTargetException();
IStatus status = null;
if (e instanceof CoreException)
status = ((CoreException) e).getStatus();
else
status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, e.getMessage(), e);
log(status);
log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, e.getMessage(), new Exception()));
}
public static void log(IStatus status) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2010 QNX Software Systems and others.
* Copyright (c) 2000, 2011 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -45,11 +45,9 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
/**
@ -65,7 +63,7 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
/** presentation of the content, i.e. for MakeView tree of for BuildTargetDialog table */
protected boolean bFlatten;
protected StructuredViewer viewer;
protected TreeViewer viewer;
/**
* Default constructor.
@ -84,9 +82,6 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
bFlatten = flat;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
@Override
public Object[] getChildren(Object obj) {
if (obj instanceof IWorkspaceRoot) {
@ -154,9 +149,6 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
return new Object[0];
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
*/
@Override
public Object getParent(Object obj) {
if (obj instanceof IMakeTarget) {
@ -173,17 +165,11 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
*/
@Override
public boolean hasChildren(Object obj) {
return getChildren(obj).length > 0;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
*/
@Override
public Object[] getElements(Object obj) {
if (bFlatten) {
@ -198,9 +184,6 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
return getChildren(obj);
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
@Override
public void dispose() {
if (viewer != null) {
@ -208,15 +191,12 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
}
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
if (this.viewer == null) {
MakeCorePlugin.getDefault().getTargetManager().addListener(this);
}
this.viewer = (StructuredViewer) viewer;
this.viewer = (TreeViewer) viewer;
IWorkspace oldWorkspace = null;
IWorkspace newWorkspace = null;
if (oldInput instanceof IWorkspace) {
@ -248,147 +228,123 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.IMakeTargetListener#targetChanged(org.eclipse.cdt.make.core.MakeTargetEvent)
/**
* Refresh the whole view.
*/
@Override
public void targetChanged(final MakeTargetEvent event) {
final Control ctrl = viewer.getControl();
if (ctrl != null && !ctrl.isDisposed()) {
switch (event.getType()) {
case MakeTargetEvent.PROJECT_ADDED :
case MakeTargetEvent.PROJECT_REMOVED :
ctrl.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (!ctrl.isDisposed()) {
viewer.refresh();
}
}
});
break;
case MakeTargetEvent.TARGET_ADD :
case MakeTargetEvent.TARGET_CHANGED :
case MakeTargetEvent.TARGET_REMOVED :
ctrl.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (!ctrl.isDisposed()) {
if (bFlatten) {
viewer.refresh();
} else {
//We can't just call refresh on the container target that
//has been created since it may be that the container has
//been filtered out and the filters in the viewer don't know
//any better how to call out to the filter selection again.
//Instead we walk to the root project container and refresh it.
Set<IContainer> containers = new HashSet<IContainer>();
IMakeTarget[] targets = event.getTargets();
for (IMakeTarget target : targets) {
IContainer container = target.getContainer();
while(!(container instanceof IProject) && container.getParent()!=null) {
container = container.getParent();
}
containers.add(container);
}
for (IContainer container : containers) {
viewer.refresh(container);
}
}
}
}
});
break;
private void refreshView() {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
viewer.refresh();
}
}
});
}
private void processDelta(IResourceDelta delta) {
// Bail out if the widget was disposed.
Control ctrl = viewer.getControl();
if (ctrl == null || ctrl.isDisposed() || delta == null) {
/**
* Refresh the project tree or the project subtree (in case of drill-down adapter) in the view.
*/
private void refreshProjectTree(final IProject project) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (viewer == null || viewer.getControl() == null || viewer.getControl().isDisposed())
return;
if (viewer.getTree().getItemCount() <= 0) {
return;
}
Object firstItem = viewer.getTree().getItem(0).getData();
IContainer parentContainer = null;
boolean isDrilledDown = !(firstItem instanceof IProject);
if (!isDrilledDown) {
// view shows projects
viewer.refresh(project);
} else {
// drill-down adapter in the game
if (firstItem instanceof IResource) {
parentContainer = ((IResource) firstItem).getParent();
} else if (firstItem instanceof TargetSourceContainer) {
parentContainer = ((TargetSourceContainer) firstItem).getContainer().getParent();
} else if (firstItem instanceof IMakeTarget) {
parentContainer = ((IMakeTarget) firstItem).getContainer();
}
if (parentContainer != null && project.equals(parentContainer.getProject())) {
viewer.refresh();
}
}
}
});
}
@Override
public void targetChanged(MakeTargetEvent event) {
// Additions/removal of projects. Only notifications for projects having applicable builder come here.
int type = event.getType();
if (type == MakeTargetEvent.PROJECT_ADDED || type == MakeTargetEvent.PROJECT_REMOVED) {
refreshView();
return;
}
IResourceDelta[] affectedChildren = delta.getAffectedChildren(IResourceDelta.CHANGED);
// Not interested in Content changes.
for (int i = 0; i < affectedChildren.length; i++) {
if ((affectedChildren[i].getFlags() & IResourceDelta.TYPE) != 0) {
return;
}
IMakeTarget[] targets = event.getTargets();
if (targets == null) {
return;
}
// Handle changed children recursively.
for (int i = 0; i < affectedChildren.length; i++) {
processDelta(affectedChildren[i]);
Set<IProject> affectedProjects = new HashSet<IProject>();
for (IMakeTarget target : event.getTargets()) {
IContainer container = target.getContainer();
affectedProjects.add(container.getProject());
}
// Get the affected resource
final IResource resource = delta.getResource();
// Handle removed children. Issue one update for all removals.
affectedChildren = delta.getAffectedChildren(IResourceDelta.REMOVED);
if (affectedChildren.length > 0) {
final ArrayList<IResource> affected = new ArrayList<IResource>(affectedChildren.length);
for (int i = 0; i < affectedChildren.length; i++) {
if (affectedChildren[i].getResource().getType() == IResource.FOLDER) {
affected.add(affectedChildren[i].getResource());
}
}
if (!affected.isEmpty()) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (viewer == null || viewer.getControl() == null || viewer.getControl().isDisposed())
return;
if (viewer instanceof AbstractTreeViewer) {
((AbstractTreeViewer) viewer).remove(affected.toArray());
} else {
viewer.refresh(resource);
}
}
});
}
}
// Handle added children. Issue one update for all insertions.
affectedChildren = delta.getAffectedChildren(IResourceDelta.ADDED);
if (affectedChildren.length > 0) {
final ArrayList<IResource> affected = new ArrayList<IResource>(affectedChildren.length);
for (int i = 0; i < affectedChildren.length; i++) {
if (affectedChildren[i].getResource().getType() == IResource.FOLDER) {
affected.add(affectedChildren[i].getResource());
}
}
if (!affected.isEmpty()) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (viewer == null || viewer.getControl() == null || viewer.getControl().isDisposed())
return;
if (viewer instanceof AbstractTreeViewer) {
((AbstractTreeViewer) viewer).add(resource, affected.toArray());
} else {
viewer.refresh(resource);
}
}
});
}
// If the view is being filtered, adding/removing targets can
// result in showing or hiding containers or the project itself
for (IProject project : affectedProjects) {
refreshProjectTree(project);
}
}
private void collectAffectedProjects(IResourceDelta delta, Set<IProject> affectedProjects) {
if (affectedProjects.contains(delta.getResource().getProject())) {
return;
}
for (IResourceDelta d : delta.getAffectedChildren(IResourceDelta.ADDED | IResourceDelta.REMOVED)) {
// handle folders only, additions/removal of projects are dealt with in #targetChanged(MakeTargetEvent)
IResource rc = d.getResource();
if (rc.getType() == IResource.FOLDER) {
IProject project = rc.getProject();
if (MakeCorePlugin.getDefault().getTargetManager().hasTargetBuilder(project)) {
affectedProjects.add(project);
return;
}
}
}
for (IResourceDelta d : delta.getAffectedChildren(IResourceDelta.CHANGED)) {
collectAffectedProjects(d, affectedProjects);
}
}
/* (non-Javadoc)
* @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
*/
@Override
public void resourceChanged(IResourceChangeEvent event) {
final IResourceDelta delta = event.getDelta();
Control ctrl = viewer.getControl();
if (ctrl != null && !ctrl.isDisposed())
processDelta(delta);
IResourceDelta delta = event.getDelta();
if (delta == null) {
return;
}
Set<IProject> affectedProjects = new HashSet<IProject>();
collectAffectedProjects(delta, affectedProjects);
// If the view is being filtered or source roots shown,
// adding/removing resources can structurally affect the tree
// starting with the project
for (IProject project : affectedProjects) {
refreshProjectTree(project);
}
}
/**
@ -397,34 +353,29 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
* @since 7.1
*/
@Override
public void handleEvent(final CProjectDescriptionEvent event) {
Display display = Display.getDefault();
display.asyncExec(new Runnable() {
@Override
public void run() {
ICDescriptionDelta delta = event.getDefaultSettingCfgDelta();
if (delta==null)
return;
public void handleEvent(CProjectDescriptionEvent event) {
ICDescriptionDelta delta = event.getDefaultSettingCfgDelta();
if (delta==null)
return;
int flags = delta.getChangeFlags();
if ( ((flags & ICDescriptionDelta.SOURCE_ADDED) != 0) ||
((flags & ICDescriptionDelta.SOURCE_REMOVED) != 0) ) {
int flags = delta.getChangeFlags();
if ( ((flags & ICDescriptionDelta.SOURCE_ADDED) != 0) ||
((flags & ICDescriptionDelta.SOURCE_REMOVED) != 0) ) {
IProject project = null;
ICSettingObject setting = delta.getOldSetting();
if (setting==null)
setting = delta.getNewSetting();
IProject project = null;
ICSettingObject setting = delta.getOldSetting();
if (setting == null) {
setting = delta.getNewSetting();
}
if (setting instanceof ICConfigurationDescription)
project = ((ICConfigurationDescription) setting).getProjectDescription().getProject();
if (project!=null)
viewer.refresh(project);
else
viewer.refresh();
if (setting instanceof ICConfigurationDescription) {
project = ((ICConfigurationDescription) setting).getProjectDescription().getProject();
if (project != null) {
// refresh source roots under the project
refreshProjectTree(project);
}
}
});
}
}
/**
@ -435,12 +386,7 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
@Override
public void preferenceChange(PreferenceChangeEvent event) {
if (event.getKey().equals(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT)) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
viewer.refresh();
}
});
refreshView();
}
}

View file

@ -23,7 +23,6 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.IDialogSettings;
@ -57,54 +56,66 @@ public class FilterEmtpyFoldersAction extends Action {
setToolTipText(MakeUIPlugin.getResourceString("FilterEmptyFolderAction.tooltip")); //$NON-NLS-1$
setChecked(getSettings().getBoolean(FILTER_EMPTY_FOLDERS));
MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_FILTER); //$NON-NLS-1$
fViewer.addFilter(new ViewerFilter() {
//Check the make targets of the specified container, and if they don't exist, run
//through the children looking for the first match that we can find that contains
//a make target.
private boolean hasMakeTargets(IContainer container) throws CoreException {
IMakeTarget [] targets = MakeCorePlugin.getDefault().getTargetManager().getTargets(container);
if(targets != null && targets.length > 0) {
return true;
}
fViewer.addFilter(new ViewerFilter() {
/**
* Run through the children looking for the first match that we can find that contains
* a make target.
*/
private boolean hasMakeTargets(final IContainer parentContainer) {
final boolean [] haveTargets = new boolean[1];
haveTargets[0] = false;
IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
@Override
public boolean visit(IResourceProxy proxy) throws CoreException {
public boolean visit(IResourceProxy proxy) {
if(haveTargets[0]) {
return false; //We found what we were looking for
return false; // We found what we were looking for
}
if(proxy.getType() != IResource.FOLDER) {
return true; //We only look at folders for content
int rcType = proxy.getType();
if(rcType != IResource.PROJECT && rcType != IResource.FOLDER) {
return false; // Ignore non-containers
}
IContainer folder = (IContainer) proxy.requestResource();
IMakeTarget [] targets = MakeCorePlugin.getDefault().getTargetManager().getTargets(folder);
if(targets != null && targets.length > 0) {
haveTargets[0] = true;
return false;
IContainer subFolder = (IContainer) proxy.requestResource();
if (!(parentContainer instanceof IProject) && !subFolder.equals(parentContainer)
&& CCorePlugin.showSourceRootsAtTopOfProject() && MakeContentProvider.isSourceEntry(subFolder)) {
return false; // Skip source folders showing up second time as regular folders
}
return true; //Keep looking
try {
IMakeTarget [] targets = MakeCorePlugin.getDefault().getTargetManager().getTargets(subFolder);
if(targets != null && targets.length > 0) {
haveTargets[0] = true;
return false; // Found a target
}
} catch (Exception e) {
// log any problem then ignore it
MakeUIPlugin.log(e);
}
return true; // Keep looking
}
};
container.accept(visitor, IResource.NONE);
try {
parentContainer.accept(visitor, IResource.NONE);
} catch (Exception e) {
// log any problem then ignore it
MakeUIPlugin.log(e);
}
return haveTargets[0];
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (isChecked()) {
IContainer container = null;
if (element instanceof IContainer) {
container = (IContainer)element;
if (!(container instanceof IProject)) {
container = (IContainer) element;
if (parentElement instanceof IProject && !(container instanceof IProject)) {
// under subfolders do not show source roots second time (when filtered)
if (CCorePlugin.showSourceRootsAtTopOfProject() && MakeContentProvider.isSourceEntry(container))
return false;
@ -113,12 +124,8 @@ public class FilterEmtpyFoldersAction extends Action {
container = ((TargetSourceContainer) element).getContainer();
}
if (container!=null) {
try {
return hasMakeTargets(container);
} catch(Exception ex) {
return false;
}
if (container != null) {
return hasMakeTargets(container);
}
}
return true;
@ -126,9 +133,6 @@ public class FilterEmtpyFoldersAction extends Action {
});
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.Action#run()
*/
@Override
public void run() {
fViewer.refresh();

View file

@ -141,7 +141,9 @@ Option.Posix.Warn.Pedandic=Pedantic (-pedantic)
Option.Posix.Warn.PedErrors=Pedantic warnings as errors (-pedantic-errors)
Option.Posix.Warn.nowarn=Inhibit all warnings (-w)
Option.Posix.Warn.allwarn=All warnings (-Wall)
Option.Posix.Warn.extrawarn=Extra warnings (-Wextra)
Option.Posix.Warn.toerrs=Warnings as errors (-Werror)
Option.Posix.Warn.wconversion=Implicit conversion warnings (-Wconversion)
Option.Posix.Verbose=Verbose (-v)
Option.OtherFlags=Other flags

View file

@ -1202,6 +1202,14 @@
id="gnu.c.compiler.option.warnings.allwarn"
valueType="boolean">
</option>
<option
defaultValue="false"
name="%Option.Posix.Warn.extrawarn"
category="gnu.c.compiler.category.warnings"
command="-Wextra"
id="gnu.c.compiler.option.warnings.extrawarn"
valueType="boolean">
</option>
<option
defaultValue="false"
name="%Option.Posix.Warn.toerrs"
@ -1210,6 +1218,14 @@
id="gnu.c.compiler.option.warnings.toerrors"
valueType="boolean">
</option>
<option
defaultValue="false"
name="%Option.Posix.Warn.wconversion"
category="gnu.c.compiler.category.warnings"
command="-Wconversion"
id="gnu.c.compiler.option.warnings.wconversion"
valueType="boolean">
</option>
<optionCategory
owner="cdt.managedbuild.tool.gnu.c.compiler"
name="%OptionCategory.Misc"
@ -1515,6 +1531,14 @@
id="gnu.cpp.compiler.option.warnings.allwarn"
valueType="boolean">
</option>
<option
defaultValue="false"
name="%Option.Posix.Warn.extrawarn"
category="gnu.cpp.compiler.category.warnings"
command="-Wextra"
id="gnu.cpp.compiler.option.warnings.extrawarn"
valueType="boolean">
</option>
<option
defaultValue="false"
name="%Option.Posix.Warn.toerrs"
@ -1523,6 +1547,14 @@
id="gnu.cpp.compiler.option.warnings.toerrors"
valueType="boolean">
</option>
<option
defaultValue="false"
name="%Option.Posix.Warn.wconversion"
category="gnu.cpp.compiler.category.warnings"
command="-Wconversion"
id="gnu.cpp.compiler.option.warnings.wconversion"
valueType="boolean">
</option>
<optionCategory
owner="cdt.managedbuild.tool.gnu.cpp.compiler"
name="%OptionCategory.Misc"

View file

@ -5,7 +5,6 @@
<classpathentry kind="src" path="parser"/>
<classpathentry kind="src" path="suite"/>
<classpathentry kind="src" path="regression"/>
<classpathentry kind="src" path="templateengine"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>

View file

@ -32,7 +32,6 @@ Export-Package: org.eclipse.cdt.core.cdescriptor.tests,
org.eclipse.cdt.core.testplugin,
org.eclipse.cdt.core.testplugin.util,
org.eclipse.cdt.core.tests,
org.eclipse.cdt.core.tests.templateengine,
org.eclipse.cdt.core.winreg.tests,
org.eclipse.cdt.internal.index.tests;x-internal:=true,
org.eclipse.cdt.internal.pdom.tests;x-internal:=true,

View file

@ -25,8 +25,7 @@ source.. = model/,\
parser/,\
suite/,\
misc/,\
regression/,\
templateengine/
regression/
jre.compilation.profile=JavaSE-1.6
javacSource=1.6

View file

@ -9367,6 +9367,33 @@ public class AST2CPPTests extends AST2BaseTest {
parseAndCheckBindings();
}
// namespace std {
// template <class T1, class T2> struct pair {
// T1 first;
// T2 second;
// };
//
// template <typename T, typename U> T begin(const pair<T, U>& p) {
// return p.first;
// }
// template <typename T, typename U> U end(const pair<T, U>& p) {
// return p.second;
// }
// }
// struct S {
// int x;
// };
//
// int main() {
// S arr[5];
// std::pair<S*, S*> p{arr, arr + 5};
// for (const auto& r : p)
// r.x;
// }
public void testAutoTypeInRangeBasedFor_332883c() throws Exception {
parseAndCheckBindings();
}
// struct S {
// void f();
// };

View file

@ -5638,4 +5638,55 @@ public class AST2TemplateTests extends AST2BaseTest {
public void testTemplateAmbiguityInDeleteExpression_364225() throws Exception {
parseAndCheckBindings();
}
// template <typename T> void foo(T);
// template <typename T> void foo(T, typename T::type* = 0);
// int main() {
// foo(0);
// }
public void testSyntaxFailureInstantiatingFunctionTemplate_365981a() throws Exception {
parseAndCheckBindings();
}
// template <typename T> bool bar(T);
// template <typename T> bool bar(T, void(T::*)() = 0);
// void test() {
// bar(0);
// }
public void testSyntaxFailureInstantiatingFunctionTemplate_365981b() throws Exception {
parseAndCheckBindings();
}
// template<typename _Tp> class vector {};
// template<typename T> struct bar {
// void foo() {
// vector<T> index;
// for (const auto& entry : index) {
// }
// }
// };
public void testResolvingAutoTypeWithDependentExpression_367472() throws Exception {
parseAndCheckBindings();
}
// void foo(int, int);
// template <typename... Args> void bar(Args... args) {
// foo(1,2,args...);
// foo(args...);
// }
public void testPackExpansionsAsArguments_367560() throws Exception {
parseAndCheckBindings();
}
// template <typename> class A;
// template <typename T> class A<void (T::*)()> {};
// template <typename T> class A<void (T::*)() const> {};
//
// struct S {};
// int main() {
// A<void (S::*)()> m;
// }
public void testDeductionForConstFunctionType_367562() throws Exception {
parseAndCheckBindings();
}
}

View file

@ -84,6 +84,8 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
}
protected IASTName findName(String section, int len) {
if (len == 0)
len= section.length();
for (int i = 0; i < strategy.getAstCount(); i++) {
IASTTranslationUnit ast = strategy.getAst(i);
final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
@ -260,30 +262,36 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
this.cpp = cpp;
}
@Override
public ICProject getCProject() {
return cproject;
}
@Override
public StringBuilder[] getTestData() {
return testData;
}
@Override
public int getAstCount() {
return 1;
}
@Override
public IASTTranslationUnit getAst(int index) {
if (index != 0)
throw new IllegalArgumentException();
return ast;
}
@Override
public StringBuilder getAstSource(int index) {
if (index != 0)
throw new IllegalArgumentException();
return testData[1];
}
@Override
public void setUp() throws Exception {
cproject = cpp ? CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
: CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
@ -308,6 +316,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile);
}
@Override
public void tearDown() throws Exception {
if (index != null) {
index.releaseReadLock();
@ -317,10 +326,12 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
}
}
@Override
public IIndex getIndex() {
return index;
}
@Override
public boolean isCompositeIndex() {
return false;
}
@ -337,30 +348,36 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
this.cpp = cpp;
}
@Override
public ICProject getCProject() {
return cproject;
}
@Override
public StringBuilder[] getTestData() {
return testData;
}
@Override
public int getAstCount() {
return 1;
}
@Override
public IASTTranslationUnit getAst(int index) {
if (index != 0)
throw new IllegalArgumentException();
return ast;
}
@Override
public StringBuilder getAstSource(int index) {
if (index != 0)
throw new IllegalArgumentException();
return testData[1];
}
@Override
public void setUp() throws Exception {
cproject = cpp ? CProjectHelper.createCCProject(getName()+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
: CProjectHelper.createCProject(getName()+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
@ -385,6 +402,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile);
}
@Override
public void tearDown() throws Exception {
if (index != null) {
index.releaseReadLock();
@ -394,10 +412,12 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
}
}
@Override
public IIndex getIndex() {
return index;
}
@Override
public boolean isCompositeIndex() {
return false;
}
@ -425,26 +445,32 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
asts = new ArrayList<IASTTranslationUnit>();
}
@Override
public ICProject getCProject() {
return cproject;
}
@Override
public StringBuilder[] getTestData() {
return testData;
}
@Override
public int getAstCount() {
return asts.size();
}
@Override
public IASTTranslationUnit getAst(int index) {
return asts.get(index);
}
@Override
public StringBuilder getAstSource(int index) {
return astSources.get(index);
}
@Override
public void setUp() throws Exception {
cproject = cpp ? CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
: CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
@ -487,6 +513,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
}
}
@Override
public void tearDown() throws Exception {
if (index != null) {
index.releaseReadLock();
@ -496,10 +523,12 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
}
}
@Override
public IIndex getIndex() {
return index;
}
@Override
public boolean isCompositeIndex() {
return false;
}
@ -516,10 +545,12 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
this.cpp = cpp;
}
@Override
public ICProject getCProject() {
return cproject;
}
@Override
public void tearDown() throws Exception {
if (index != null) {
index.releaseReadLock();
@ -532,6 +563,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
}
}
@Override
public void setUp() throws Exception {
cproject= cpp ? CProjectHelper.createCCProject("OnlineContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER)
: CProjectHelper.createCProject("OnlineContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
@ -580,30 +612,36 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
return referenced;
}
@Override
public int getAstCount() {
return 1;
}
@Override
public IASTTranslationUnit getAst(int index) {
if (index != 0)
throw new IllegalArgumentException();
return ast;
}
@Override
public StringBuilder getAstSource(int index) {
if (index != 0)
throw new IllegalArgumentException();
return testData[1];
}
@Override
public IIndex getIndex() {
return index;
}
@Override
public StringBuilder[] getTestData() {
return testData;
}
@Override
public boolean isCompositeIndex() {
return true;
}

View file

@ -2394,7 +2394,8 @@ public class IndexBugsTests extends BaseTestCase {
final Set<IFolder> folders = new HashSet<IFolder>();
folders.add(root);
root.accept(new IResourceVisitor() {
public boolean visit(final IResource resource) throws CoreException {
@Override
public boolean visit(final IResource resource) throws CoreException {
if (resource instanceof IFile) {
files.add((IFile) resource);
} else if (resource instanceof IFolder) {
@ -2431,4 +2432,42 @@ public class IndexBugsTests extends BaseTestCase {
index.releaseReadLock();
}
}
// // context.c
// #define A B
// #include "b.h" // file name is important to reproduce the issue
// #include "a.h" // file name is important to reproduce the issue
// // a.h and b.h
// int A;
public void testUpdatingHeaderInContext_367315() throws Exception {
String[] contents= getContentsForTest(2);
final IIndexManager indexManager = CCorePlugin.getIndexManager();
TestSourceReader.createFile(fCProject.getProject(), "context.c", contents[0]);
IFile ah= TestSourceReader.createFile(fCProject.getProject(), "a.h", contents[1]);
IFile bh= TestSourceReader.createFile(fCProject.getProject(), "b.h", contents[1]);
indexManager.reindex(fCProject);
waitForIndexer();
fIndex.acquireReadLock();
try {
IIndexBinding[] vars = fIndex.findBindings("B".toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
assertEquals(1, vars.length);
assertEquals(2, fIndex.findDefinitions(vars[0]).length);
} finally {
fIndex.releaseReadLock();
}
final CoreModel coreModel = CCorePlugin.getDefault().getCoreModel();
ICElement[] selection = new ICElement[] {coreModel.create(ah), coreModel.create(bh)};
indexManager.update(selection, IIndexManager.UPDATE_ALL);
waitForIndexer();
fIndex.acquireReadLock();
try {
IIndexBinding[] vars = fIndex.findBindings("B".toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor());
assertEquals(1, vars.length);
assertEquals(2, fIndex.findDefinitions(vars[0]).length);
} finally {
fIndex.releaseReadLock();
}
}
}

View file

@ -76,13 +76,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public ProjectWithDepProj() {setStrategy(new ReferencedProject(true));}
public static TestSuite suite() {return suite(ProjectWithDepProj.class);}
// template <typename T= int> class XT;
// #include "header.h"
// template <typename T> class XT {};
// void test() {
// XT<> x;
// };
@Override
public void testDefaultTemplateArgInHeader_264988() throws Exception {
// Not supported across projects (the composite index does not merge
@ -1908,4 +1901,33 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
public void testUsageOfClassTemplateOutsideOfClassBody_357320() throws Exception {
getBindingFromASTName("m1", 0, ICPPMethod.class);
}
// template <typename> struct foo;
// template <> struct foo<int> {
// typedef int type;
// };
// #include "header.h"
// template <typename> struct foo {};
// int main() {
// typedef foo<int>::type type; // ERROR HERE: 'foo<int>::type' could not be
// }
public void testSpecializationInIndex_367563a() throws Exception {
getBindingFromASTName("type type", 4, ITypedef.class);
}
// template <typename> struct foo;
// template <typename T> struct foo<T*> {
// typedef int type;
// };
// #include "header.h"
// template <typename> struct foo {};
// int main() {
// typedef foo<int*>::type type; // ERROR HERE: 'foo<int>::type' could not be
// }
public void testSpecializationInIndex_367563b() throws Exception {
getBindingFromASTName("type type", 4, ITypedef.class);
}
}

View file

@ -12,6 +12,8 @@ package org.eclipse.cdt.internal.index.tests;
import junit.framework.TestSuite;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
@ -131,12 +133,55 @@ public class IndexMultiVariantHeaderTest extends IndexBindingResolutionTestBase
// y = 0;
// z = 0;
// }
public void _testSignificantMacroDetection() throws Exception {
// TODO(sprigogin): For this test to work REPORT_SIGNIFICANT_MACROS flag
// should be passed to CPreprocessor.expandMacro method. See
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=197989#c92 for details.
public void testSignificantMacroDetection() throws Exception {
getBindingFromASTName("x = 0", 1, ICPPVariable.class);
getBindingFromASTName("y = 0", 1, ICPPVariable.class);
getBindingFromASTName("z = 0", 1, ICPPVariable.class);
}
// b.h
// #ifndef _B
// #define _B
// #define SIG // This internal modification is not propagated
// #endif
// a.h
// #include "b.h"
// #ifdef SIG // Not significant, because it is defined in "b.h"
// #endif
// a.cpp *
// #include "a.h"
public void testSignificantMacroDetection_367753a() throws Exception {
IASTName includeName= findName("a.h", 0);
IASTPreprocessorIncludeStatement inc= (IASTPreprocessorIncludeStatement) includeName.getParent();
assertTrue(inc.isResolved());
assertEquals("{}", inc.getSignificantMacros().toString());
assertNotNull(inc.getImportedIndexFile());
}
// c.h
// #define SIG // This internal modification is not propagated
// b.h
// #ifndef _B
// #define _B
// #include "c.h"
// #endif
// a.h
// #include "b.h"
// #ifdef SIG // Not significant, because it is defined in "c.h"
// #endif
// a.cpp *
// #include "a.h"
public void testSignificantMacroDetection_367753b() throws Exception {
IASTName includeName= findName("a.h", 0);
IASTPreprocessorIncludeStatement inc= (IASTPreprocessorIncludeStatement) includeName.getParent();
assertTrue(inc.isResolved());
assertEquals("{}", inc.getSignificantMacros().toString());
assertNotNull(inc.getImportedIndexFile());
}
}

View file

@ -136,10 +136,12 @@ public class DBTest extends BaseTestCase {
this.key = key;
}
@Override
public int compare(long record) throws CoreException {
return db.getString(db.getRecPtr(record + 4)).compare(key, true);
}
@Override
public boolean visit(long record) throws CoreException {
this.record = record;
return false;
@ -185,6 +187,7 @@ public class DBTest extends BaseTestCase {
};
IBTreeComparator comparator = new IBTreeComparator() {
@Override
public int compare(long record1, long record2) throws CoreException {
IString string1 = db.getString(db.getRecPtr(record1 + 4));
IString string2 = db.getString(db.getRecPtr(record2 + 4));
@ -221,9 +224,10 @@ public class DBTest extends BaseTestCase {
assertCMP("", EQ, "", true);
assertCMP("", EQ, "", false);
doTrials(1000, 1, ShortString.MAX_LENGTH, r, true);
doTrials(1000, 1, ShortString.MAX_LENGTH, r, false);
doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH/2, r, true);
doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH/2, r, false);
doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH, r, true);
doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH, r, false);
assertCMP("a", LT, "b", true);
assertCMP("aa", LT, "ab", true);
@ -239,8 +243,8 @@ public class DBTest extends BaseTestCase {
public void testLongStringComparison() throws CoreException {
Random r= new Random(314159265);
doTrials(100, ShortString.MAX_LENGTH+1, ShortString.MAX_LENGTH*2, r, true);
doTrials(100, ShortString.MAX_LENGTH+1, ShortString.MAX_LENGTH*2, r, false);
doTrials(100, ShortString.MAX_BYTE_LENGTH+1, ShortString.MAX_BYTE_LENGTH*2, r, true);
doTrials(100, ShortString.MAX_BYTE_LENGTH+1, ShortString.MAX_BYTE_LENGTH*2, r, false);
}
private void doTrials(int n, int min, int max, Random r, boolean caseSensitive) throws CoreException {

View file

@ -21,14 +21,11 @@ import org.eclipse.cdt.core.index.IIndexFileLocation;
import org.eclipse.cdt.core.index.IndexLocationFactory;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMProjectIndexLocationConverter;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.osgi.framework.Bundle;
/**
* Tests behavior related to location representation in the PDOM
@ -40,15 +37,13 @@ public class PDOMLocationTests extends BaseTestCase {
return suite(PDOMLocationTests.class);
}
@Override
protected void setUp() throws Exception {
cproject= CProjectHelper.createCCProject("PDOMLocationTests"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
Bundle b = CTestPlugin.getDefault().getBundle();
CharSequence[] testData = TestSourceReader.getContentsForTest(b, "parser", getClass(), getName(), 3);
super.setUp();
}
@Override
protected void tearDown() throws Exception {
if (cproject != null) {
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
* Norbert Ploett (Siemens AG)
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
* Norbert Ploett (Siemens AG)
*******************************************************************************/
package org.eclipse.cdt.core.suite;
@ -30,7 +30,6 @@ import org.eclipse.cdt.core.model.tests.WorkingCopyTests;
import org.eclipse.cdt.core.parser.tests.ParserTestSuite;
import org.eclipse.cdt.core.parser.tests.rewrite.RewriteTests;
import org.eclipse.cdt.core.resources.tests.RefreshScopeTests;
import org.eclipse.cdt.core.tests.templateengine.AllTemplateEngineTests;
import org.eclipse.cdt.internal.index.tests.IndexTests;
import org.eclipse.cdt.internal.pdom.tests.PDOMTests;
import org.eclipse.cdt.utils.CdtVariableResolverTest;
@ -82,12 +81,9 @@ public class AutomatedIntegrationSuite extends TestSuite {
// Add in PDOM tests
suite.addTest(PDOMTests.suite());
suite.addTest(IndexTests.suite());
suite.addTest(AllTemplateEngineTests.suite());
suite.addTest(RefreshScopeTests.suite());
return suite;
}
}

View file

@ -105,9 +105,12 @@ public class TestSourceReader {
contents.remove(0);
content = new StringBuilder();
}
int idx= line.indexOf(testName);
if (idx != -1 && !Character.isJavaIdentifierPart(line.charAt(idx + testName.length()))) {
return contents.toArray(new StringBuilder[contents.size()]);
if (line.length() > 0 && !contents.isEmpty()) {
int idx= line.indexOf(testName);
if (idx != -1 && !Character.isJavaIdentifierPart(line.charAt(idx + testName.length()))) {
return contents.toArray(new StringBuilder[contents.size()]);
}
contents.clear();
}
}
}
@ -229,6 +232,7 @@ public class TestSourceReader {
final IWorkspace ws = ResourcesPlugin.getWorkspace();
final IFile result[] = new IFile[1];
ws.run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
//Obtain file handle
IFile file = container.getFile(filePath);

View file

@ -14,6 +14,7 @@ import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -72,7 +73,7 @@ import org.eclipse.core.runtime.preferences.IScopeContext;
public class CDataUtil {
private static final String EMPTY = ""; //$NON-NLS-1$
private static final String DELIM = " "; //$NON-NLS-1$
private static Random randomNumber;
public static final String[] EMPTY_STRING_ARRAY = new String[0];
@ -96,14 +97,14 @@ public class CDataUtil {
}
return i;
}
public static String genId(String baseId){
String suffix = new Integer(genRandomNumber()).toString();
return baseId != null ?
return baseId != null ?
new StringBuffer(baseId).append(".").append(suffix).toString() //$NON-NLS-1$
: suffix;
}
public static boolean objectsEqual(Object o1, Object o2){
if(o1 == null)
return o2 == null;
@ -126,7 +127,7 @@ public class CDataUtil {
for(int i = 1; i < array.length; i++){
buf.append(separator).append(array[i]);
}
return buf.toString();
}
@ -146,7 +147,7 @@ public class CDataUtil {
public static ICSettingEntry[] resolveEntries(ICSettingEntry entries[], ICConfigurationDescription cfgDes){
if(entries.length == 0)
return entries;
ArrayList<ICSettingEntry> out = new ArrayList<ICSettingEntry>(entries.length);
ICdtVariableManager mngr = CCorePlugin.getDefault().getCdtVariableManager();
@ -190,14 +191,14 @@ public class CDataUtil {
private static ICSettingEntry[] createResolvedEntry(ICSettingEntry entry, ICConfigurationDescription cfg, ICdtVariableManager mngr){
if(entry.isResolved())
return new ICSettingEntry[] { entry };
String name = entry.getName();
String[] names = new String[] { name }; // default value
try {
if ((entry.getKind() != ICSettingEntry.MACRO) &&
mngr.isStringListValue(name, cfg)) {
names = mngr.resolveStringListValue(name, EMPTY, DELIM, cfg);
names = mngr.resolveStringListValue(name, EMPTY, DELIM, cfg);
} else {
names[0] = mngr.resolveValue(name, EMPTY, DELIM, cfg);
}
@ -206,7 +207,7 @@ public class CDataUtil {
}
ICSettingEntry[] result = new ICSettingEntry[names.length];
for (int k=0; k<names.length; k++) {
String value = null;
IPath[] exclusionFilters = null;
@ -253,11 +254,11 @@ public class CDataUtil {
}
return result;
}
private static IPath resolvePath(ICdtVariableManager mngr, ICConfigurationDescription cfg, IPath path){
if(path == null)
return null;
try {
String unresolved = path.toString();
String resolved = mngr.resolveValue(unresolved, EMPTY, DELIM, cfg);
@ -266,7 +267,7 @@ public class CDataUtil {
} catch (CdtVariableException e) {
CCorePlugin.log(e);
}
return path;
}
@ -293,10 +294,10 @@ public class CDataUtil {
break;
case ICLanguageSettingEntry.LIBRARY_FILE:
ICLibraryFileEntry libFile = (ICLibraryFileEntry)entry;
entry = new CLibraryFileEntry(entry.getName(),
entry = new CLibraryFileEntry(entry.getName(),
flags,
libFile.getSourceAttachmentPath(),
libFile.getSourceAttachmentRootPath(),
libFile.getSourceAttachmentPath(),
libFile.getSourceAttachmentRootPath(),
libFile.getSourceAttachmentPrefixMapping()
);
break;
@ -308,7 +309,7 @@ public class CDataUtil {
return createEntry(kind, name, value, exclusionPatterns, flags, null, null, null);
}
public static ICSettingEntry createEntry(int kind, String name, String value, IPath[] exclusionPatterns, int flags, IPath srcPath, IPath srcRootPath, IPath srcPrefixMapping){
ICSettingEntry entry = null;
switch (kind){
@ -354,7 +355,7 @@ public class CDataUtil {
else
exts = CDefaultLanguageData.EMPTY_STRING_ARRAY;
}
if(exts == null)
exts = CDefaultLanguageData.EMPTY_STRING_ARRAY;
return exts;
@ -380,14 +381,14 @@ public class CDataUtil {
exts = list.toArray(new String[list.size()]);
}
}
if(exts == null)
exts = CDefaultLanguageData.EMPTY_STRING_ARRAY;
return exts;
}
public static String[] getContentTypeFileSpecs (IProject project, IContentType type) {
String[] globalSpecs = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
String[] globalSpecs = type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC);
IContentTypeSettings settings = null;
if (project != null) {
IScopeContext projectScope = new ProjectScope(project);
@ -403,16 +404,16 @@ public class CDataUtil {
for (int j=0; j<specs.length; j++) {
projSpecs[i] = specs[j];
i++;
}
}
for (int j=0; j<globalSpecs.length; j++) {
projSpecs[i] = globalSpecs[j];
i++;
}
}
return projSpecs;
}
}
}
return globalSpecs;
return globalSpecs;
}
public static CLanguageData findLanguagDataForFile(String fileName, IProject project, CFolderData fData){
@ -435,11 +436,11 @@ public class CDataUtil {
}
return data;
}
public static CLanguageData findLanguageDataForExtension(String ext, CLanguageData datas[]/*, boolean src*/){
CLanguageData data;
for(int i = 0; i < datas.length; i++){
data = datas[i];
data = datas[i];
String exts[] = data.getSourceExtensions();
/* if(src){
if(setting.getSourceContentType() == null){
@ -450,7 +451,7 @@ public class CDataUtil {
exts = setting.getHeaderExtensions();
}
}
*/
*/
if(exts != null && exts.length != 0){
for(int j = 0; j < exts.length; j++){
if(ext.equals(exts[j]))
@ -474,7 +475,7 @@ public class CDataUtil {
public static PathSettingsContainer createRcDataHolder(CConfigurationData data){
PathSettingsContainer h = PathSettingsContainer.createRootContainer();
h.setValue(data.getRootFolderData());
CResourceData[] rcDatas = data.getResourceDatas();
CResourceData rcData;
@ -486,22 +487,22 @@ public class CDataUtil {
}
return h;
}
public static CConfigurationData createEmptyData(String id, String name, CDataFactory factory, boolean performLangAdjustment){
if(id == null)
id = genId(null);
CConfigurationData data = factory.createConfigurationdata(id, name, null, false);
if(data.getRootFolderData() == null){
CFolderData foData = factory.createFolderData(data, null, genId(data.getId()), false, Path.EMPTY);
factory.link(data, foData);
}
if(data.getBuildData() == null){
CBuildData bData = factory.createBuildData(data, null, genId(data.getId()), null, false);
factory.link(data, bData);
}
if(data.getTargetPlatformData() == null){
CTargetPlatformData tpData = factory.createTargetPlatformData(data, null, genId(data.getId()), null, false);
factory.link(data, tpData);
@ -509,7 +510,7 @@ public class CDataUtil {
if(performLangAdjustment)
adjustConfig(data, factory);
return data;
}
@ -517,18 +518,18 @@ public class CDataUtil {
LanguageManager mngr = LanguageManager.getInstance();
ILanguageDescriptor dess[] = mngr.getLanguageDescriptors();
Map<String, ILanguageDescriptor[]> map = mngr.getContentTypeIdToLanguageDescriptionsMap();
CResourceData[] rcDatas = cfg.getResourceDatas();
for(int i = 0; i < rcDatas.length; i++){
if(rcDatas[i].getType() == ICSettingBase.SETTING_FOLDER){
adjustFolderData(cfg, (CFolderData)rcDatas[i], factory, dess, new HashMap<String, ILanguageDescriptor[]>(map));
}
}
return cfg;
}
private static void adjustFolderData(CConfigurationData cfgData, CFolderData data, CDataFactory factory, ILanguageDescriptor dess[], HashMap<String, ILanguageDescriptor[]> map){
Map<String, ILanguageDescriptor> langMap = new HashMap<String, ILanguageDescriptor>();
for(int i = 0; i < dess.length; i++){
@ -551,38 +552,38 @@ public class CDataUtil {
for(int q = 0; q < langs.length; q++){
langMap.remove(langs[q].getId());
}
adjustLanguageData(data, lData, langs[0]);
}
}
}
}
if(!langMap.isEmpty()){
addLangs(cfgData, data, factory, langMap, map);
}
}
private static CLanguageData adjustLanguageData(CFolderData data, CLanguageData lData, ILanguageDescriptor des){
String [] cTypeIds = des.getContentTypeIds();
String srcIds[] = lData.getSourceContentTypeIds();
Set<String> landTypes = new HashSet<String>(Arrays.asList(cTypeIds));
landTypes.removeAll(Arrays.asList(srcIds));
if(landTypes.size() != 0){
List<String> srcList = new ArrayList<String>();
srcList.addAll(landTypes);
lData.setSourceContentTypeIds(srcList.toArray(new String[srcList.size()]));
}
if(!des.getId().equals(lData.getLanguageId())){
lData.setLanguageId(des.getId());
}
return lData;
}
private static void addLangs(CConfigurationData cfgData, CFolderData data, CDataFactory factory, Map<String, ILanguageDescriptor> langMap, Map<String, ILanguageDescriptor[]> cTypeToLangMap){
List<ILanguageDescriptor> list = new ArrayList<ILanguageDescriptor>(langMap.values());
ILanguageDescriptor des;
@ -599,10 +600,10 @@ public class CDataUtil {
}
}
}
if(addLang){
CLanguageData lData = factory.createLanguageData(cfgData, data, genId(data.getId()), des.getName(), des.getId(),
ICLanguageSettingEntry.INCLUDE_FILE
CLanguageData lData = factory.createLanguageData(cfgData, data, genId(data.getId()), des.getName(), des.getId(),
ICLanguageSettingEntry.INCLUDE_FILE
| ICLanguageSettingEntry.INCLUDE_PATH
| ICLanguageSettingEntry.MACRO
| ICLanguageSettingEntry.MACRO_FILE,
@ -611,7 +612,7 @@ public class CDataUtil {
}
}
}
public static boolean isExcluded(IPath path, ICSourceEntry[] entries){
for(int i = 0; i < entries.length; i++){
if(!isExcluded(path, entries[i]))
@ -619,16 +620,16 @@ public class CDataUtil {
}
return true;
}
public static boolean isExcluded(IPath path, ICSourceEntry entry){
IPath entryPath = new Path(entry.getName());
if(path.isPrefixOf(entryPath))
return false;
if(!entryPath.isPrefixOf(path))
return true;
if(path.segmentCount() == 0)
return false;
char[][] exclusions = entry.fullExclusionPatternChars();
@ -637,13 +638,13 @@ public class CDataUtil {
public static boolean isOnSourceEntry(IPath path, ICSourceEntry entry){
IPath entryPath = new Path(entry.getName());
if(path.equals(entryPath))
return true;
if(!entryPath.isPrefixOf(path))
return false;
if(path.segmentCount() == 0)
return true;
char[][] exclusions = entry.fullExclusionPatternChars();
@ -659,10 +660,10 @@ public class CDataUtil {
}
/**
*
*
* @param ein - initial source entries
* @param aus - resulting source entries
* @return - true if they are equal
* @return - true if they are equal
*/
public static boolean isEqual(ICSourceEntry[] ein, ICSourceEntry[] aus) {
if (ein == null || aus == null) return (ein == null && aus == null);
@ -676,14 +677,14 @@ public class CDataUtil {
found = true;
break;
}
return false; // contents is changed !
return false; // contents is changed !
}
if (!found)
if (!found)
return false; // name is not found !
}
return true; // all entries are equal by name and contents
}
public static ICSourceEntry[] setExcluded(IPath path, boolean isFolder, boolean excluded, ICSourceEntry[] entries) throws CoreException {
return setExcluded(path, isFolder, excluded, entries, true);
}
@ -702,14 +703,14 @@ public class CDataUtil {
public static ICSourceEntry[] setExcluded(IPath path, boolean isFolder, boolean excluded, ICSourceEntry[] entries, boolean throwExceptionOnErr) throws CoreException {
if(isExcluded(path, entries) == excluded)
return entries;
ICSourceEntry[] newEntries;
if(excluded){
List<ICSourceEntry> includeList = new ArrayList<ICSourceEntry>(entries.length);
List<ICSourceEntry> excludeList = new ArrayList<ICSourceEntry>(entries.length);
sortEntries(path, false, entries, includeList, excludeList);
for(int i = 0; i < includeList.size(); i++){
ICSourceEntry oldEntry = includeList.get(i);
List<IPath> tmp = new ArrayList<IPath>(1);
@ -718,7 +719,7 @@ public class CDataUtil {
if(newEntry != null)
excludeList.add(newEntry);
}
newEntries = excludeList.toArray(new ICSourceEntry[excludeList.size()]);
} else {
List<ICSourceEntry> includeList = new ArrayList<ICSourceEntry>(entries.length + 1);
@ -730,7 +731,7 @@ public class CDataUtil {
if(includeExclusion(path, includeList) >= 0)
included = true;
}
if(!included){
if(isFolder){
includeList.add(new CSourceEntry(path, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED));
@ -740,14 +741,14 @@ public class CDataUtil {
return null;
}
}
includeList.addAll(excludeList);
newEntries = includeList.toArray(new ICSourceEntry[includeList.size()]);
}
return newEntries;
}
private static int includeExclusion(IPath path, List<ICSourceEntry> entries){
for(int i = 0; i < entries.size(); i++){
ICSourceEntry entry = entries.get(i);
@ -759,7 +760,7 @@ public class CDataUtil {
}
return -1;
}
private static ICSourceEntry include(IPath path, ICSourceEntry entry){
IPath[] exclusions = entry.getExclusionPatterns();
IPath entryPath = new Path(entry.getName());
@ -778,7 +779,7 @@ public class CDataUtil {
}
return null;
}
private static void sortIncludingExcludingEntries(IPath path, ICSourceEntry[] entries, List<ICSourceEntry> including, List<ICSourceEntry> excluding){
for(int i = 0; i < entries.length; i++){
IPath entryPath = new Path(entries[i].getName());
@ -805,7 +806,7 @@ public class CDataUtil {
}
return new ICSourceEntry[]{entry};
}
private static ICOutputEntry[] getDefaultOutputEntries(boolean absolute, IProject project){
ICOutputEntry entry;
if(absolute){
@ -822,14 +823,14 @@ public class CDataUtil {
public static ICOutputEntry[] adjustEntries(ICOutputEntry entries[], boolean makeAbsolute, IProject project){
if(entries == null || entries.length == 0)
return getDefaultOutputEntries(makeAbsolute, project);
return makeAbsolute ? makeAbsolute(project, entries) : makeRelative(project, entries);
}
public static ICSourceEntry[] adjustEntries(ICSourceEntry entries[], boolean makeAbsolute, IProject project){
if(entries == null || entries.length == 0)
return getDefaultSourceEntries(makeAbsolute, project);
ICSourceEntry ei, ej;
LinkedHashMap<ICSourceEntry, List<IPath>> map = new LinkedHashMap<ICSourceEntry, List<IPath>>();
for(int i = 0; i < entries.length; i++){
@ -839,7 +840,7 @@ public class CDataUtil {
ej = entries[j];
if(ei == ej)
continue;
IPath ejPath = new Path(ej.getName());
if(!isExcluded(ejPath, ei)){
if(list == null)
@ -847,7 +848,7 @@ public class CDataUtil {
list.add(ejPath);
}
}
map.put(ei, list);
}
List<ICSourceEntry> resultList = new ArrayList<ICSourceEntry>(entries.length);
@ -863,19 +864,28 @@ public class CDataUtil {
resultList.add(se);
}
}
if(makeAbsolute){
if(project != null)
resultList = makeAbsolute(project, resultList);
} else {
resultList = makeRelative(project, resultList);
}
return resultList.toArray(new ICSourceEntry[resultList.size()]);
ICSourceEntry[] resultArray = resultList.toArray(new ICSourceEntry[resultList.size()]);
Arrays.sort(resultArray, new Comparator<ICSourceEntry>() {
@Override
public int compare(ICSourceEntry o1, ICSourceEntry o2) {
return o1.getFullPath().toString().compareTo(o2.getFullPath().toString());
}
});
return resultArray;
}
private static List<ICSourceEntry> makeRelative(IProject project, List<ICSourceEntry> list){
int size = list.size();
for(int i = 0; i < size; i++){
list.set(i, makeRelative(project, list.get(i)));
}
@ -884,7 +894,7 @@ public class CDataUtil {
private static List<ICSourceEntry> makeAbsolute(IProject project, List<ICSourceEntry> list){
int size = list.size();
for(int i = 0; i < size; i++){
list.set(i, makeAbsolute(project, list.get(i)));
}
@ -939,26 +949,26 @@ public class CDataUtil {
public static ICSourceEntry addExcludePaths(ICSourceEntry entry, Collection<IPath> paths, boolean removePrefix){
IPath entryPath = new Path(entry.getName());
IPath[] oldExclusions = entry.getExclusionPatterns();
// List newExList = new ArrayList(oldExclusions.length + paths.size());
// List newExList = new ArrayList(oldExclusions.length + paths.size());
LinkedHashSet<IPath> newSet = new LinkedHashSet<IPath>();
if(removePrefix){
removePrefix(entryPath, paths, newSet);
} else {
newSet.addAll(paths);
}
for(Iterator<IPath> iter = newSet.iterator(); iter.hasNext();){
IPath path = iter.next();
if(path.segmentCount() == 0)
return null;
}
newSet.addAll(Arrays.asList(oldExclusions));
IPath[] newExclusions = newSet.toArray(new IPath[newSet.size()]);
return new CSourceEntry(entry.getName(), newExclusions, entry.getFlags());
}
private static void sortEntries(IPath path, boolean byExclude, ICSourceEntry[] entries, List<ICSourceEntry> included, List<ICSourceEntry> excluded){
for(int i = 0; i < entries.length; i++){
if(byExclude ? isExcluded(path, entries[i]) : !isOnSourceEntry(path, entries[i])){
@ -970,11 +980,11 @@ public class CDataUtil {
}
}
}
public static Map<EntryNameKey, ICSettingEntry> fillEntriesMapByNameKey(Map<EntryNameKey, ICSettingEntry> map, ICSettingEntry[] entries){
if(map == null)
map = new LinkedHashMap<EntryNameKey, ICSettingEntry>();
for(int i = 0; i < entries.length; i++){
ICSettingEntry entry = entries[i];
map.put(new EntryNameKey(entry), entry);
@ -985,14 +995,14 @@ public class CDataUtil {
public static Map<EntryContentsKey, ICSettingEntry> fillEntriesMapByContentsKey(Map<EntryContentsKey, ICSettingEntry> map, ICSettingEntry[] entries){
if(map == null)
map = new LinkedHashMap<EntryContentsKey, ICSettingEntry>();
for(int i = 0; i < entries.length; i++){
ICSettingEntry entry = entries[i];
map.put(new EntryContentsKey(entry), entry);
}
return map;
}
public static boolean getBoolean(ICStorageElement el, String attr, boolean defaultValue){
if(el != null){
String tmp = el.getAttribute(attr);
@ -1023,14 +1033,14 @@ public class CDataUtil {
public static void setInteger(ICStorageElement el, String attr, int value){
el.setAttribute(attr, new Integer(value).toString());
}
public static ICExclusionPatternPathEntry addRemoveExclusionsToEntry(ICExclusionPatternPathEntry entry, IPath[] paths, boolean add) throws IllegalArgumentException{
if(paths == null || paths.length == 0)
return entry;
Set<IPath> set = mergeRemovingDups(entry.getExclusionPatterns(), paths, add);
IPath exclusions[] = set.toArray(new IPath[set.size()]);
return (ICExclusionPatternPathEntry)createEntry(entry.getKind(), entry.getName(), null, exclusions, entry.getFlags());
}
@ -1043,7 +1053,7 @@ public class CDataUtil {
set.removeAll(Arrays.asList(o2));
return set;
}
public static ICExclusionPatternPathEntry makeAbsolute(IProject project, ICExclusionPatternPathEntry entry, boolean force){
if(!entry.isValueWorkspacePath() && !force)
return entry;
@ -1056,14 +1066,14 @@ public class CDataUtil {
}
return entry;
}
public static ICExclusionPatternPathEntry makeRelative(IProject project, ICExclusionPatternPathEntry entry, boolean force){
if(!entry.isValueWorkspacePath() && !force)
return entry;
IPath path = new Path(entry.getName());
IPath projPath = project.getFullPath();
if(path.isAbsolute()){
if(projPath.isPrefixOf(path))
path = path.removeFirstSegments(projPath.segmentCount()).makeRelative();
@ -1073,22 +1083,22 @@ public class CDataUtil {
}
return entry;
}
public static ICExclusionPatternPathEntry[] makeRelative(IProject project, ICExclusionPatternPathEntry[] entries, boolean force){
if(entries == null)
return null;
ICExclusionPatternPathEntry[] relEntries = (ICExclusionPatternPathEntry[])Array.newInstance(entries.getClass().getComponentType(), entries.length);
for(int i = 0; i < entries.length; i++){
relEntries[i] = makeRelative(project, entries[i], force);
}
return relEntries;
}
public static ICExclusionPatternPathEntry[] makeAbsolute(IProject project, ICExclusionPatternPathEntry[] entries, boolean force){
if(entries == null)
return null;
ICExclusionPatternPathEntry[] relEntries = (ICExclusionPatternPathEntry[])Array.newInstance(entries.getClass().getComponentType(), entries.length);
for(int i = 0; i < entries.length; i++){
relEntries[i] = makeAbsolute(project, entries[i], force);

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Doug Schaefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@ -19,7 +19,6 @@ package org.eclipse.cdt.core.dom.ast;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTBinaryExpression extends IASTExpression {
/**
* Node property that describes the relationship between an
* <code>IASTBinaryExpression</code> and an <code>IASTExpression</code>
@ -271,10 +270,12 @@ public interface IASTBinaryExpression extends IASTExpression {
/**
* @since 5.1
*/
@Override
public IASTBinaryExpression copy();
/**
* @since 5.3
*/
@Override
public IASTBinaryExpression copy(CopyStyle style);
}

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Bryan Wilkinson (QNX)
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Bryan Wilkinson (QNX)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.IName;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface IASTName extends IASTNode, IName {
/**
* Constant sentinel.
*/
@ -32,12 +31,14 @@ public interface IASTName extends IASTNode, IName {
/**
* Returns the name including qualification and template arguments.
*/
@Override
public char[] toCharArray();
/**
* Same as {@link #toCharArray()}.
* @since 5.1
*/
@Override
public String toString();
/**
@ -101,11 +102,13 @@ public interface IASTName extends IASTNode, IName {
/**
* @since 5.1
*/
@Override
public IASTName copy();
/**
* @since 5.3
*/
@Override
public IASTName copy(CopyStyle style);
/**

View file

@ -18,7 +18,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
* @noimplement This interface is not intended to be implemented by clients.
*/
public interface ICPPClassTemplate extends ICPPTemplateDefinition, ICPPClassType {
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException;
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations();
/**
* Returns a deferred instance that allows lookups within this class template.

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Anton Leherbauer (Wind River Systems) - initial API and implementation
* Markus Schorn (Wind River Systems)
* Mike Kucera (IBM)
* Anton Leherbauer (Wind River Systems) - initial API and implementation
* Markus Schorn (Wind River Systems)
* Mike Kucera (IBM)
*******************************************************************************/
package org.eclipse.cdt.core.dom.parser;
@ -106,14 +106,15 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
protected abstract ParserLanguage getParserLanguage();
@Deprecated
@Override
public IASTTranslationUnit getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader reader,
IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, IIndex index,
IParserLogService log) throws CoreException {
return getASTTranslationUnit(reader, scanInfo, fileCreator, index, 0, log);
}
@Override
@Deprecated
@Override
public IASTTranslationUnit getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader reader,
IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory codeReaderFactory,
IIndex index, int options, IParserLogService log) throws CoreException {
@ -136,6 +137,7 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
if (log instanceof ICanceler) {
canceler= (ICanceler) log;
canceler.setCancelable(new ICancelable() {
@Override
public void cancel() {
scanner.cancel();
parser.cancel();
@ -155,6 +157,7 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
}
@Deprecated
@Override
public IASTCompletionNode getCompletionNode(org.eclipse.cdt.core.parser.CodeReader reader,
IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, IIndex index,
IParserLogService log, int offset) throws CoreException {
@ -189,12 +192,13 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
*/
protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion, int options) {
ParserMode mode;
if (forCompletion)
if (forCompletion) {
mode= ParserMode.COMPLETION_PARSE;
else if ((options & OPTION_SKIP_FUNCTION_BODIES) != 0)
} else if ((options & OPTION_SKIP_FUNCTION_BODIES) != 0) {
mode= ParserMode.STRUCTURAL_PARSE;
else
} else {
mode= ParserMode.COMPLETE_PARSE;
}
ISourceCodeParser parser= createParser(scanner, mode, log, index);
if ((options & OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS) != 0) {
@ -224,6 +228,7 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
return new CPreprocessor(content, scanInfo, getParserLanguage(), log, getScannerExtensionConfiguration(scanInfo), fcp);
}
@Override
@Deprecated
public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) {
IASTNode selectedNode= ast.getNodeSelector(null).findNode(start, length);
@ -243,12 +248,13 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
return collector.getNames();
}
@Override
public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) {
// use default model builder
return null;
}
private ICLanguageKeywords cLanguageKeywords = null;
private ICLanguageKeywords cLanguageKeywords;
private synchronized ICLanguageKeywords getCLanguageKeywords() {
if (cLanguageKeywords == null)
@ -265,15 +271,18 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements
return super.getAdapter(adapter);
}
// for backwards compatibility
// For backwards compatibility
@Override
public String[] getBuiltinTypes() {
return getCLanguageKeywords().getBuiltinTypes();
}
@Override
public String[] getKeywords() {
return getCLanguageKeywords().getKeywords();
}
@Override
public String[] getPreprocessorKeywords() {
return getCLanguageKeywords().getPreprocessorKeywords();
}

View file

@ -20,7 +20,7 @@ import java.util.List;
* @author Doug Schaefer
*/
public class CharArrayObjectMap <T> extends CharTable {
public static final CharArrayObjectMap<Object> EMPTY_MAP = new CharArrayObjectMap<Object>(0) {
public static final CharArrayObjectMap<?> EMPTY_MAP = new CharArrayObjectMap<Object>(0) {
@Override
public Object clone() { return this; }
@Override

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom;
@ -15,15 +15,14 @@ import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.core.runtime.CoreException;
public class Linkage implements ILinkage {
public static final ILinkage NO_LINKAGE = new Linkage(NO_LINKAGE_ID, NO_LINKAGE_NAME);
public static final ILinkage C_LINKAGE = new Linkage(C_LINKAGE_ID, C_LINKAGE_NAME);
public static final ILinkage CPP_LINKAGE = new Linkage(CPP_LINKAGE_ID, CPP_LINKAGE_NAME);
public static final ILinkage FORTRAN_LINKAGE = new Linkage(FORTRAN_LINKAGE_ID, FORTRAN_LINKAGE_NAME);
public static final ILinkage OBJC_LINKAGE = new Linkage(OBJC_LINKAGE_ID, OBJC_LINKAGE_NAME);
private static final ILinkage[] LINKAGES= {C_LINKAGE, CPP_LINKAGE, FORTRAN_LINKAGE, OBJC_LINKAGE};
private static final ILinkage[] INDEX_LINKAGES= {C_LINKAGE, CPP_LINKAGE, FORTRAN_LINKAGE};
private static final ILinkage[] LINKAGES= { C_LINKAGE, CPP_LINKAGE, FORTRAN_LINKAGE, OBJC_LINKAGE };
private static final ILinkage[] INDEX_LINKAGES= { C_LINKAGE, CPP_LINKAGE, FORTRAN_LINKAGE };
public static final ILinkage[] getIndexerLinkages() {
return INDEX_LINKAGES;
@ -46,13 +45,18 @@ public class Linkage implements ILinkage {
private int fID;
private String fName;
private Linkage(int id, String name) {
fID= id;
fName= name;
}
@Override
public int getLinkageID() {
return fID;
}
@Override
public String getLinkageName() {
return fName;
}

View file

@ -6,10 +6,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM Rational Software) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Yuan Zhang / Beth Tibbitts (IBM Research)
* Bryan Wilkinson (QNX)
* John Camelon (IBM Rational Software) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* Yuan Zhang / Beth Tibbitts (IBM Research)
* Bryan Wilkinson (QNX)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
@ -31,14 +31,12 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
* Implementation for names in C translation units.
*/
public class CASTName extends ASTNode implements IASTName, IASTCompletionContext {
private final char[] name;
private static final char[] EMPTY_CHAR_ARRAY = {};
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private IBinding binding = null;
private IBinding binding;
public CASTName(char[] name) {
this.name = name;
@ -48,10 +46,12 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
name = EMPTY_CHAR_ARRAY;
}
public CASTName copy() {
@Override
public CASTName copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CASTName copy(CopyStyle style) {
CASTName copy = new CASTName(name == null ? null : name.clone());
copy.setOffsetAndLength(this);
@ -61,7 +61,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return copy;
}
public IBinding resolveBinding() {
@Override
public IBinding resolveBinding() {
if (binding == null) {
CVisitor.createBinding(this);
}
@ -69,19 +70,23 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return binding;
}
public IBinding resolvePreBinding() {
@Override
public IBinding resolvePreBinding() {
return resolveBinding();
}
public IBinding getBinding() {
@Override
public IBinding getBinding() {
return binding;
}
public IBinding getPreBinding() {
@Override
public IBinding getPreBinding() {
return binding;
}
public IASTCompletionContext getCompletionContext() {
@Override
public IASTCompletionContext getCompletionContext() {
IASTNode node = getParent();
while (node != null) {
if (node instanceof IASTCompletionContext) {
@ -95,7 +100,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return null;
}
public void setBinding(IBinding binding) {
@Override
public void setBinding(IBinding binding) {
this.binding = binding;
}
@ -107,14 +113,17 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return new String(name);
}
public char[] toCharArray() {
@Override
public char[] toCharArray() {
return name;
}
@Override
public char[] getSimpleID() {
return name;
}
@Override
public char[] getLookupKey() {
return name;
}
@ -146,6 +155,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
}
@Override
public int getRoleOfName(boolean allowResolution) {
IASTNode parent = getParent();
if (parent instanceof IASTInternalNameOwner) {
@ -157,7 +167,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return IASTNameOwner.r_unclear;
}
public boolean isDeclaration() {
@Override
public boolean isDeclaration() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
@ -172,8 +183,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return false;
}
public boolean isReference() {
@Override
public boolean isReference() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
@ -187,7 +198,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return false;
}
public boolean isDefinition() {
@Override
public boolean isDefinition() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
@ -201,10 +213,12 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return false;
}
@Override
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}
@Override
public IBinding[] findBindings(IASTName n, boolean isPrefix) {
IASTNode parent = getParent();
if (parent instanceof IASTElaboratedTypeSpecifier) {
@ -247,6 +261,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
return (IBinding[])ArrayUtil.removeNulls(IBinding.class, bindings);
}
@Override
public IASTName getLastName() {
return this;
}

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
* IBM - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -35,10 +35,10 @@ public class CPPASTFunctionDefinition extends ASTNode
private IASTDeclSpecifier declSpecifier;
private IASTFunctionDeclarator declarator;
private IASTStatement bodyStatement;
private ICPPASTConstructorChainInitializer[] memInits = null;
private ICPPASTConstructorChainInitializer[] memInits;
private int memInitPos= -1;
private boolean fDeleted= false;
private boolean fDefaulted= false;
private boolean fDeleted;
private boolean fDefaulted;
public CPPASTFunctionDefinition() {
}
@ -50,10 +50,12 @@ public class CPPASTFunctionDefinition extends ASTNode
setBody(bodyStatement);
}
@Override
public CPPASTFunctionDefinition copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CPPASTFunctionDefinition copy(CopyStyle style) {
CPPASTFunctionDefinition copy = new CPPASTFunctionDefinition();
copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style));
@ -61,8 +63,7 @@ public class CPPASTFunctionDefinition extends ASTNode
if (declarator != null) {
IASTDeclarator outer = ASTQueries.findOutermostDeclarator(declarator);
outer = outer.copy(style);
copy.setDeclarator((IASTFunctionDeclarator) ASTQueries
.findTypeRelevantDeclarator(outer));
copy.setDeclarator((IASTFunctionDeclarator) ASTQueries.findTypeRelevantDeclarator(outer));
}
copy.setBody(bodyStatement == null ? null : bodyStatement.copy(style));
@ -79,11 +80,13 @@ public class CPPASTFunctionDefinition extends ASTNode
return copy;
}
@Override
public IASTDeclSpecifier getDeclSpecifier() {
return declSpecifier;
}
public void setDeclSpecifier(IASTDeclSpecifier declSpec) {
@Override
public void setDeclSpecifier(IASTDeclSpecifier declSpec) {
assertNotFrozen();
declSpecifier = declSpec;
if (declSpec != null) {
@ -92,11 +95,13 @@ public class CPPASTFunctionDefinition extends ASTNode
}
}
public IASTFunctionDeclarator getDeclarator() {
@Override
public IASTFunctionDeclarator getDeclarator() {
return declarator;
}
public void setDeclarator(IASTFunctionDeclarator declarator) {
@Override
public void setDeclarator(IASTFunctionDeclarator declarator) {
assertNotFrozen();
this.declarator = declarator;
if (declarator != null) {
@ -106,11 +111,13 @@ public class CPPASTFunctionDefinition extends ASTNode
}
}
public IASTStatement getBody() {
@Override
public IASTStatement getBody() {
return bodyStatement;
}
public void setBody(IASTStatement statement) {
@Override
public void setBody(IASTStatement statement) {
assertNotFrozen();
bodyStatement = statement;
if (statement != null) {
@ -119,6 +126,7 @@ public class CPPASTFunctionDefinition extends ASTNode
}
}
@Override
public void addMemberInitializer(ICPPASTConstructorChainInitializer initializer) {
assertNotFrozen();
if (initializer != null) {
@ -128,6 +136,7 @@ public class CPPASTFunctionDefinition extends ASTNode
}
}
@Override
public ICPPASTConstructorChainInitializer[] getMemberInitializers() {
if (memInits == null)
return ICPPASTConstructorChainInitializer.EMPTY_CONSTRUCTORCHAININITIALIZER_ARRAY;
@ -136,23 +145,28 @@ public class CPPASTFunctionDefinition extends ASTNode
ICPPASTConstructorChainInitializer.class, memInits, memInitPos);
}
@Override
public IScope getScope() {
return ((ICPPASTFunctionDeclarator) declarator).getFunctionScope();
}
@Override
public boolean isDefaulted() {
return fDefaulted;
}
@Override
public boolean isDeleted() {
return fDeleted;
}
@Override
public void setIsDefaulted(boolean isDefaulted) {
assertNotFrozen();
fDefaulted= isDefaulted;
}
@Override
public void setIsDeleted(boolean isDeleted) {
assertNotFrozen();
fDeleted= isDeleted;
@ -203,6 +217,7 @@ public class CPPASTFunctionDefinition extends ASTNode
return true;
}
@Override
public void replace(IASTNode child, IASTNode other) {
if (bodyStatement == child) {
other.setPropertyInParent(bodyStatement.getPropertyInParent());

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Markus Schorn - initial API and implementation
* Markus Schorn - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -46,9 +46,9 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
}
}
private IBinding fBinding = null;
private byte fResolutionDepth = 0;
private boolean fIsFinal= false;
private IBinding fBinding;
private byte fResolutionDepth;
private boolean fIsFinal;
public final void incResolutionDepth() {
if (fBinding == null && ++fResolutionDepth > MAX_RESOLUTION_DEPTH) {
@ -66,6 +66,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
* Resolves the name at least up to the intermediate binding and returns it.
* @see ICPPTwoPhaseBinding
*/
@Override
public IBinding resolvePreBinding() {
if (fBinding == null) {
if (++fResolutionDepth > MAX_RESOLUTION_DEPTH) {
@ -77,7 +78,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return fBinding;
}
public IBinding resolveBinding() {
@Override
public IBinding resolveBinding() {
if (fBinding == null) {
if (++fResolutionDepth > MAX_RESOLUTION_DEPTH) {
setBinding(new RecursionResolvingBinding(this));
@ -105,7 +107,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
* Otherwise the intermediate or final binding for this name is returned.
* @see ICPPTwoPhaseBinding
*/
public IBinding getPreBinding() {
@Override
public IBinding getPreBinding() {
return fBinding;
}
@ -114,7 +117,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
* Otherwise the final binding for this name is returned.
* @see ICPPTwoPhaseBinding
*/
public IBinding getBinding() {
@Override
public IBinding getBinding() {
final IBinding cand= fBinding;
if (cand == null)
return null;
@ -137,11 +141,13 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
fIsFinal= true;
}
@Override
public void setBinding(IBinding binding) {
fBinding= binding;
fResolutionDepth= 0;
}
@Override
public IASTName getLastName() {
return this;
}
@ -151,6 +157,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return new String(toCharArray());
}
@Override
public IASTCompletionContext getCompletionContext() {
IASTNode node = getParent();
while (node != null) {
@ -163,6 +170,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return null;
}
@Override
public int getRoleOfName(boolean allowResolution) {
IASTNode parent = getParent();
if (parent instanceof IASTInternalNameOwner) {
@ -174,7 +182,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return IASTNameOwner.r_unclear;
}
public boolean isDeclaration() {
@Override
public boolean isDeclaration() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
@ -189,7 +198,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return false;
}
public boolean isReference() {
@Override
public boolean isReference() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
@ -198,7 +208,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return false;
}
public boolean isDefinition() {
@Override
public boolean isDefinition() {
IASTNode parent = getParent();
if (parent instanceof IASTNameOwner) {
int role = ((IASTNameOwner) parent).getRoleForName(this);
@ -207,9 +218,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTName#getLinkage()
*/
@Override
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}

View file

@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
* John Camelon (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -24,15 +24,14 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
/**
* Represents a template declaration.
*/
public class CPPASTTemplateDeclaration extends ASTNode implements
ICPPASTInternalTemplateDeclaration, IASTAmbiguityParent {
public class CPPASTTemplateDeclaration extends ASTNode
implements ICPPASTInternalTemplateDeclaration, IASTAmbiguityParent {
private boolean exported;
private byte isAssociatedWithLastName= -1;
private short nestingLevel= -1;
private IASTDeclaration declaration;
private ICPPTemplateScope templateScope;
private ICPPASTTemplateParameter[] parameters = null;
private ICPPASTTemplateParameter[] parameters;
private int parametersPos= -1;
public CPPASTTemplateDeclaration() {
@ -42,10 +41,12 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
setDeclaration(declaration);
}
@Override
public CPPASTTemplateDeclaration copy() {
return copy(CopyStyle.withoutLocations);
}
@Override
public CPPASTTemplateDeclaration copy(CopyStyle style) {
CPPASTTemplateDeclaration copy = new CPPASTTemplateDeclaration();
copy.setDeclaration(declaration == null ? null : declaration.copy(style));
@ -59,20 +60,24 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
return copy;
}
@Override
public boolean isExported() {
return exported;
}
public void setExported(boolean value) {
@Override
public void setExported(boolean value) {
assertNotFrozen();
exported = value;
}
public IASTDeclaration getDeclaration() {
@Override
public IASTDeclaration getDeclaration() {
return declaration;
}
public void setDeclaration(IASTDeclaration declaration) {
@Override
public void setDeclaration(IASTDeclaration declaration) {
assertNotFrozen();
this.declaration = declaration;
if (declaration != null) {
@ -81,13 +86,15 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
}
}
public ICPPASTTemplateParameter[] getTemplateParameters() {
@Override
public ICPPASTTemplateParameter[] getTemplateParameters() {
if (parameters == null) return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY;
parameters = (ICPPASTTemplateParameter[]) ArrayUtil.removeNullsAfter(ICPPASTTemplateParameter.class, parameters, parametersPos);
return parameters;
}
public void addTemplateParameter(ICPPASTTemplateParameter parm) {
@Override
public void addTemplateParameter(ICPPASTTemplateParameter parm) {
assertNotFrozen();
if (parm != null) {
parameters = (ICPPASTTemplateParameter[]) ArrayUtil.append(ICPPASTTemplateParameter.class, parameters, ++parametersPos, parm);
@ -97,6 +104,7 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
}
@Deprecated
@Override
public void addTemplateParamter(ICPPASTTemplateParameter param) {
addTemplateParameter(param);
}
@ -128,13 +136,15 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
return true;
}
@Override
public ICPPTemplateScope getScope() {
if (templateScope == null)
templateScope = new CPPTemplateScope(this);
return templateScope;
}
public void replace(IASTNode child, IASTNode other) {
@Override
public void replace(IASTNode child, IASTNode other) {
if (declaration == child) {
other.setParent(child.getParent());
other.setPropertyInParent(child.getPropertyInParent());
@ -142,6 +152,7 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
}
}
@Override
public short getNestingLevel() {
if (nestingLevel == -1) {
CPPTemplates.associateTemplateDeclarations(this);
@ -150,6 +161,7 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
return nestingLevel;
}
@Override
public boolean isAssociatedWithLastName() {
if (isAssociatedWithLastName == -1)
CPPTemplates.associateTemplateDeclarations(this);
@ -158,10 +170,12 @@ public class CPPASTTemplateDeclaration extends ASTNode implements
return isAssociatedWithLastName != 0;
}
@Override
public void setAssociatedWithLastName(boolean value) {
isAssociatedWithLastName= value ? (byte) 1 : (byte) 0;
}
@Override
public void setNestingLevel(short level) {
assert level >= 0;
nestingLevel= level;

View file

@ -77,6 +77,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
super(physicalNode);
}
@Override
public EScopeKind getKind() {
return EScopeKind.eClassType;
}
@ -270,6 +271,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
return true;
}
@Override
public ICPPConstructor[] getConstructors() {
return getConstructors(null, true);
}
@ -277,7 +279,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
private ICPPConstructor[] getConstructors(IASTName forName, boolean forceResolve) {
populateCache();
final CharArrayObjectMap nameMap = bindings;
final CharArrayObjectMap<Object> nameMap = bindings;
if (nameMap == null)
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
@ -365,6 +367,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getClassType()
*/
@Override
public ICPPClassType getClassType() {
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode();
final IASTName name = compSpec.getName();
@ -378,6 +381,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods()
*/
@Override
public ICPPMethod[] getImplicitMethods() {
if (implicits == null)
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;

View file

@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope;
@ -36,8 +35,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
@ -47,26 +46,26 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClassTemplate,
ICPPInternalClassTemplate, ICPPInternalClassTypeMixinHost {
private ICPPClassTemplate fIndexBinding= null;
private boolean checkedIndex= false;
private ICPPClassTemplatePartialSpecialization[] partialSpecializations = null;
private ICPPDeferredClassInstance fDeferredInstance;
private boolean addedPartialSpecializationsOfIndex;
public CPPClassTemplate(IASTName name) {
super(name);
}
public void checkForDefinition() {
@Override
public void checkForDefinition() {
// Ambiguity resolution ensures that definitions are resolved.
}
@Override
public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {
partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.append(
ICPPClassTemplatePartialSpecialization.class, partialSpecializations, spec);
}
@Override
public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier() {
if (definition != null) {
IASTNode node = definition.getParent();
@ -78,6 +77,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
return null;
}
@Override
public ICPPClassScope getCompositeScope() {
if (definition == null) {
checkForDefinition();
@ -93,15 +93,16 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
}
// Forward declarations must be backed up from the index.
checkForIndexBinding();
if (fIndexBinding != null) {
IScope scope = fIndexBinding.getCompositeScope();
ICPPClassTemplate ib = getIndexBinding();
if (ib != null) {
IScope scope = ib.getCompositeScope();
if (scope instanceof ICPPClassScope)
return (ICPPClassScope) scope;
}
return null;
}
@Override
public int getKey() {
if (definition != null) {
ICPPASTCompositeTypeSpecifier cts= getCompositeTypeSpecifier();
@ -124,11 +125,25 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
return ICPPASTElaboratedTypeSpecifier.k_class;
}
@Override
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
if (!addedPartialSpecializationsOfIndex) {
addedPartialSpecializationsOfIndex= true;
ICPPClassTemplate ib = getIndexBinding();
if (ib != null) {
IIndexFileSet fs = getTemplateName().getTranslationUnit().getIndexFileSet();
for (ICPPClassTemplatePartialSpecialization spec : ib.getPartialSpecializations()) {
if (spec instanceof IIndexBinding && fs.containsDeclaration((IIndexBinding) spec)) {
addPartialSpecialization(spec);
}
}
}
}
partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.trim(ICPPClassTemplatePartialSpecialization.class, partialSpecializations);
return partialSpecializations;
}
@Override
public boolean isSameType(IType type) {
if (type == this)
return true;
@ -137,42 +152,52 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
return false;
}
@Override
public ICPPBase[] getBases() {
return ClassTypeHelper.getBases(this);
}
@Override
public IField[] getFields() {
return ClassTypeHelper.getFields(this);
}
@Override
public ICPPField[] getDeclaredFields() {
return ClassTypeHelper.getDeclaredFields(this);
}
@Override
public ICPPMethod[] getMethods() {
return ClassTypeHelper.getMethods(this);
}
@Override
public ICPPMethod[] getAllDeclaredMethods() {
return ClassTypeHelper.getAllDeclaredMethods(this);
}
@Override
public ICPPMethod[] getDeclaredMethods() {
return ClassTypeHelper.getDeclaredMethods(this);
}
@Override
public ICPPConstructor[] getConstructors() {
return ClassTypeHelper.getConstructors(this);
}
@Override
public IBinding[] getFriends() {
return ClassTypeHelper.getFriends(this);
}
@Override
public ICPPClassType[] getNestedClasses() {
return ClassTypeHelper.getNestedClasses(this);
}
@Override
public IField findField(String name) {
return ClassTypeHelper.findField(this, name);
}
@ -194,10 +219,12 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
return ASTTypeUtil.getType(this);
}
@Override
public boolean isAnonymous() {
return false;
}
@Override
public final ICPPDeferredClassInstance asDeferredInstance() throws DOMException {
if (fDeferredInstance == null) {
fDeferredInstance= createDeferredInstance();
@ -210,10 +237,11 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
return new CPPDeferredClassInstance(this, args, getCompositeScope());
}
@Override
public ICPPTemplateArgument getDefaultArgFromIndex(int paramPos) throws DOMException {
checkForIndexBinding();
if (fIndexBinding != null) {
ICPPTemplateParameter[] params = fIndexBinding.getTemplateParameters();
ICPPClassTemplate ib = getIndexBinding();
if (ib != null) {
ICPPTemplateParameter[] params = ib.getTemplateParameters();
if (paramPos < params.length) {
ICPPTemplateParameter param = params[paramPos];
return param.getDefaultValue();
@ -221,21 +249,4 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass
}
return null;
}
private void checkForIndexBinding() {
if (checkedIndex)
return;
checkedIndex= true;
IASTTranslationUnit tu;
if (definition != null) {
tu= definition.getTranslationUnit();
} else {
tu= declarations[0].getTranslationUnit();
}
IIndex index= tu.getIndex();
if (index != null) {
fIndexBinding= (ICPPClassTemplate) index.adaptBinding(this);
}
}
}

View file

@ -40,11 +40,13 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas
fClassTemplate= template;
}
@Override
public ICPPTemplateParameter[] getTemplateParameters() {
ICPPClassTemplatePartialSpecialization template = (ICPPClassTemplatePartialSpecialization) getSpecializedBinding();
return template.getTemplateParameters();
}
@Override
public synchronized final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
if (instances == null)
instances = new ObjectMap(2);
@ -52,6 +54,7 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas
instances.put(key, instance);
}
@Override
public synchronized final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
if (instances != null) {
String key= ASTTypeUtil.getArgumentListString(arguments, true);
@ -60,6 +63,7 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas
return null;
}
@Override
public synchronized ICPPTemplateInstance[] getAllInstances() {
if (instances != null) {
ICPPTemplateInstance[] result= new ICPPTemplateInstance[instances.size()];
@ -71,10 +75,12 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas
return ICPPTemplateInstance.EMPTY_TEMPLATE_INSTANCE_ARRAY;
}
@Override
public IBinding resolveTemplateParameter(ICPPTemplateParameter param) {
return param;
}
@Override
public ICPPDeferredClassInstance asDeferredInstance() throws DOMException {
if (fDeferredInstance == null) {
ICPPTemplateArgument[] args = CPPTemplates.templateParametersAsArguments(getTemplateParameters());
@ -83,10 +89,12 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas
return fDeferredInstance;
}
@Override
public ICPPClassTemplate getPrimaryClassTemplate() {
return fClassTemplate;
}
@Override
public ICPPTemplateArgument[] getTemplateArguments() throws DOMException {
ICPPTemplateArgument[] args = ((ICPPClassTemplatePartialSpecialization) getSpecializedBinding()).getTemplateArguments();
final IBinding owner = getOwner();
@ -96,10 +104,12 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas
return CPPTemplates.instantiateArguments(args, getTemplateParameterMap(), -1, null);
}
@Override
public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
@Override
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY;
}
@ -118,11 +128,13 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas
return CPPTemplates.getArgumentMap(getPrimaryClassTemplate(), getTemplateParameterMap());
}
@Override
@Deprecated
public IType[] getArguments() throws DOMException {
return CPPTemplates.getArguments(getTemplateArguments());
}
@Override
public ICPPTemplateArgument getDefaultArgFromIndex(int paramPos) throws DOMException {
// no default arguments for partial specializations
return null;

View file

@ -39,7 +39,8 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
super(orig, owner, argumentMap);
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
@Override
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
if (fPartialSpecs == null) {
ICPPClassTemplate origTemplate= (ICPPClassTemplate) getSpecializedBinding();
ICPPClassTemplatePartialSpecialization[] orig = origTemplate.getPartialSpecializations();
@ -52,6 +53,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
return fPartialSpecs;
}
@Override
public ICPPTemplateParameter[] getTemplateParameters() {
// mstodo if we specialize the template parameters (because of its default values), it will
// be less error prone to use the defaults.
@ -59,6 +61,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
return template.getTemplateParameters();
}
@Override
public synchronized final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
if (instances == null)
instances = new ObjectMap(2);
@ -66,6 +69,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
instances.put(key, instance);
}
@Override
public synchronized final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
if (instances != null) {
String key= ASTTypeUtil.getArgumentListString(arguments, true);
@ -74,6 +78,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
return null;
}
@Override
public synchronized ICPPTemplateInstance[] getAllInstances() {
if (instances != null) {
ICPPTemplateInstance[] result= new ICPPTemplateInstance[instances.size()];
@ -85,6 +90,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
return ICPPTemplateInstance.EMPTY_TEMPLATE_INSTANCE_ARRAY;
}
@Override
public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {
}
@ -93,10 +99,12 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
return getName();
}
@Override
public IBinding resolveTemplateParameter(ICPPTemplateParameter param) {
return param;
}
@Override
public ICPPDeferredClassInstance asDeferredInstance() throws DOMException {
if (fDeferredInstance == null) {
ICPPTemplateArgument[] args = CPPTemplates.templateParametersAsArguments(getTemplateParameters());
@ -105,6 +113,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
return fDeferredInstance;
}
@Override
public ICPPTemplateArgument getDefaultArgFromIndex(int paramPos) throws DOMException {
return null;
}

View file

@ -38,7 +38,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
*/
public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
private CharArrayObjectMap labels = CharArrayObjectMap.EMPTY_MAP;
private CharArrayObjectMap<IBinding> labels = CharArrayObjectMap.emptyMap();
/**
* @param physicalNode
@ -47,6 +47,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
super(physicalNode);
}
@Override
public EScopeKind getKind() {
return EScopeKind.eLocal;
}
@ -61,7 +62,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
return;
if (labels == CharArrayObjectMap.EMPTY_MAP)
labels = new CharArrayObjectMap(2);
labels = new CharArrayObjectMap<IBinding>(2);
labels.put(binding.getNameCharArray(), binding);
}
@ -70,7 +71,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getBinding(int, char[])
*/
public IBinding getBinding(IASTName name) {
return (IBinding) labels.get(name.getLookupKey());
return labels.get(name.getLookupKey());
}
/* (non-Javadoc)
@ -84,7 +85,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
for (int i = 0; i < labels.size(); i++) {
char[] key = labels.keyAt(i);
if (CharArrayUtils.equals(key, n)) {
bindings.add((IBinding) labels.get(key));
bindings.add(labels.get(key));
}
}
@ -108,7 +109,8 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope#getBodyScope()
*/
public IScope getBodyScope() {
@Override
public IScope getBodyScope() {
IASTFunctionDeclarator fnDtor = (IASTFunctionDeclarator) getPhysicalNode();
IASTNode parent = fnDtor.getParent();
if (parent instanceof IASTFunctionDefinition) {

View file

@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
@ -28,11 +29,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.Linkage;
@ -48,6 +52,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
public CPPTemplateProblem(IASTNode node, int id, char[] arg) {
super(node, id, arg);
}
@Override
public ICPPTemplateParameter[] getTemplateParameters() {
return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY;
}
@ -62,6 +67,10 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
private ICPPTemplateParameter[] templateParameters;
private ObjectMap instances;
private ICPPClassTemplate indexBinding= null;
private boolean checkedIndex= false;
public CPPTemplateDefinition(IASTName name) {
if (name != null) {
ASTNodeProperty prop = name.getPropertyInParent();
@ -85,6 +94,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
}
}
@Override
public final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
if (instances == null)
instances = new ObjectMap(2);
@ -92,14 +102,46 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
instances.put(key, instance);
}
@Override
public final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
if (instances != null) {
String key= ASTTypeUtil.getArgumentListString(arguments, true);
return (ICPPTemplateInstance) instances.get(key);
ICPPTemplateInstance cand = (ICPPTemplateInstance) instances.get(key);
if (cand != null)
return cand;
}
final ICPPClassTemplate ib = getIndexBinding();
if (ib instanceof ICPPInstanceCache) {
ICPPTemplateInstance cand= ((ICPPInstanceCache) ib).getInstance(arguments);
if (cand instanceof IIndexBinding &&
getTemplateName().getTranslationUnit().getIndexFileSet().containsDeclaration((IIndexBinding) cand)) {
return cand;
}
}
return null;
}
protected ICPPClassTemplate getIndexBinding() {
if (!checkedIndex) {
checkedIndex= true;
IASTName name= getTemplateName();
if (name != null) {
IASTTranslationUnit tu = name.getTranslationUnit();
if (tu != null) {
IIndex index= tu.getIndex();
if (index != null) {
IIndexBinding ib = index.adaptBinding(this);
if (ib instanceof ICPPClassTemplate)
indexBinding= (ICPPClassTemplate) ib;
}
}
}
}
return indexBinding;
}
@Override
public ICPPTemplateInstance[] getAllInstances() {
if (instances != null) {
ICPPTemplateInstance[] result= new ICPPTemplateInstance[instances.size()];
@ -122,6 +164,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/
@Override
public String getName() {
return new String(getNameCharArray());
}
@ -129,6 +172,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray()
*/
@Override
public char[] getNameCharArray() {
return getTemplateName().getSimpleID();
}
@ -136,6 +180,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
*/
@Override
public IScope getScope() {
return CPPVisitor.getContainingScope(getTemplateName());
}
@ -143,6 +188,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
*/
@Override
public String[] getQualifiedName() {
return CPPVisitor.getQualifiedName(this);
}
@ -150,6 +196,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
*/
@Override
public char[][] getQualifiedNameCharArray() {
return CPPVisitor.getQualifiedNameCharArray(this);
}
@ -157,6 +204,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
*/
@Override
public boolean isGloballyQualified() {
return true;
}
@ -164,6 +212,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition#getParameters()
*/
@Override
public ICPPTemplateParameter[] getTemplateParameters() {
if (templateParameters == null) {
ICPPASTTemplateDeclaration template = CPPTemplates.getTemplateDeclaration(getTemplateName());
@ -186,6 +235,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
*/
@Override
public void addDefinition(IASTNode node) {
if (node instanceof ICPPASTCompositeTypeSpecifier) {
node = ((ICPPASTCompositeTypeSpecifier)node).getName();
@ -203,6 +253,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
*/
@Override
public void addDeclaration(IASTNode node) {
if (node instanceof ICPPASTElaboratedTypeSpecifier) {
node = ((ICPPASTElaboratedTypeSpecifier)node).getName();
@ -227,6 +278,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
}
}
@Override
public IBinding resolveTemplateParameter(ICPPTemplateParameter templateParameter) {
int pos= templateParameter.getParameterPosition();
@ -286,6 +338,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDeclarations()
*/
@Override
public IASTNode[] getDeclarations() {
return declarations;
}
@ -293,14 +346,17 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDefinition()
*/
@Override
public IASTNode getDefinition() {
return definition;
}
@Override
public ILinkage getLinkage() {
return Linkage.CPP_LINKAGE;
}
@Override
public final IBinding getOwner() {
IASTName templateName= getTemplateName();
if (templateName == null)

View file

@ -57,10 +57,12 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
fIsParameterPack= isPack;
}
@Override
public final boolean isParameterPack() {
return fIsParameterPack;
}
@Override
public ICPPScope asScope() {
if (unknownScope == null) {
IASTName n = null;
@ -72,6 +74,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
return unknownScope;
}
@Override
public ICPPTemplateParameter[] getTemplateParameters() {
if (templateParameters == null) {
ICPPASTTemplatedTypeTemplateParameter template = (ICPPASTTemplatedTypeTemplateParameter) getPrimaryDeclaration().getParent();
@ -88,6 +91,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
return templateParameters;
}
@Override
public IBinding resolveTemplateParameter(ICPPTemplateParameter templateParameter) {
return templateParameter;
}
@ -96,6 +100,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY;
}
@Override
public IType getDefault() {
IASTName[] nds = getDeclarations();
if (nds == null || nds.length == 0)
@ -120,6 +125,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
return null;
}
@Override
public ICPPTemplateArgument getDefaultValue() {
IType d= getDefault();
if (d == null)
@ -128,46 +134,59 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
return new CPPTemplateArgument(d);
}
@Override
public ICPPBase[] getBases() {
return ICPPBase.EMPTY_BASE_ARRAY;
}
@Override
public IField[] getFields() {
return IField.EMPTY_FIELD_ARRAY;
}
@Override
public IField findField(String name) {
return null;
}
@Override
public ICPPField[] getDeclaredFields() {
return ICPPField.EMPTY_CPPFIELD_ARRAY;
}
@Override
public ICPPMethod[] getMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
@Override
public ICPPMethod[] getAllDeclaredMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
@Override
public ICPPMethod[] getDeclaredMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
@Override
public ICPPConstructor[] getConstructors() {
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
}
@Override
public IBinding[] getFriends() {
return IBinding.EMPTY_BINDING_ARRAY;
}
@Override
public ICPPClassType[] getNestedClasses() {
return ICPPClassType.EMPTY_CLASS_ARRAY;
}
@Override
public int getKey() {
return 0;
}
@Override
public IScope getCompositeScope() {
return null;
}
public boolean isSameType(IType type) {
@Override
public boolean isSameType(IType type) {
if (type == this)
return true;
if (type instanceof ITypedef)
@ -178,10 +197,12 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
return getParameterID() == ((ICPPTemplateParameter) type).getParameterID();
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
@Override
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY;
}
@Override
public final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
if (instances == null)
instances = new ObjectMap(2);
@ -189,6 +210,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
instances.put(key, instance);
}
@Override
public final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
if (instances != null) {
String key= ASTTypeUtil.getArgumentListString(arguments, true);
@ -197,6 +219,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
return null;
}
@Override
public ICPPTemplateInstance[] getAllInstances() {
if (instances != null) {
ICPPTemplateInstance[] result= new ICPPTemplateInstance[instances.size()];
@ -208,14 +231,17 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
return ICPPTemplateInstance.EMPTY_TEMPLATE_INSTANCE_ARRAY;
}
@Override
public IASTName getUnknownName() {
return new CPPASTName(getNameCharArray());
}
@Override
public boolean isAnonymous() {
return false;
}
@Override
public ICPPDeferredClassInstance asDeferredInstance() {
return null;
}

View file

@ -44,7 +44,7 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope {
* This field needs to be protected when used in PDOMCPPUnknownScope,
* don't use it outside of {@link #getOrCreateBinding(IASTName, int)}
*/
private CharArrayObjectMap map;
private CharArrayObjectMap<IBinding[]> map;
public CPPUnknownScope(ICPPUnknownBinding binding, IASTName name) {
super();
@ -57,41 +57,26 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope {
return EScopeKind.eClassType;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName()
*/
@Override
public IName getScopeName() {
return scopeName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#getParent()
*/
@Override
public IScope getParent() throws DOMException {
return binding.getScope();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
*/
@Override
public IBinding[] find(String name) {
return null;
return IBinding.EMPTY_BINDING_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#getPhysicalNode()
*/
@Override
public IASTNode getPhysicalNode() {
return scopeName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName)
*/
@Override
public void addName(IASTName name) {
}
@ -101,9 +86,6 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope {
return getBinding(name, resolve, IIndexFileSet.EMPTY);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean)
*/
@Override
public IBinding getBinding(final IASTName name, boolean resolve, IIndexFileSet fileSet) {
boolean type= false;
@ -152,10 +134,10 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope {
protected IBinding getOrCreateBinding(final IASTName name, int idx) {
if (map == null)
map = new CharArrayObjectMap(2);
map = new CharArrayObjectMap<IBinding[]>(2);
final char[] c = name.getLookupKey();
IBinding[] o = (IBinding[]) map.get(c);
IBinding[] o = map.get(c);
if (o == null) {
o = new IBinding[3];
map.put(c, o);
@ -210,9 +192,6 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope {
// do nothing, this is part of template magic and not a normal scope
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope#getUnknownBinding()
*/
@Override
public ICPPBinding getScopeBinding() {
return binding;

View file

@ -320,7 +320,9 @@ class BaseClassLookup {
return;
fCollected= true;
data.foundItems = CPPSemantics.mergePrefixResults((CharArrayObjectMap) data.foundItems, fBindings, true);
@SuppressWarnings("unchecked")
final CharArrayObjectMap<Object> resultMap = (CharArrayObjectMap<Object>) data.foundItems;
data.foundItems = CPPSemantics.mergePrefixResults(resultMap, fBindings, true);
for (int i= 0; i < fChildren.size(); i++) {
BaseClassLookup child = fChildren.get(i);
child.collectResultForContentAssist(data);

View file

@ -2276,7 +2276,8 @@ public class CPPSemantics {
private static ICPPFunction[] selectByArgumentCount(LookupData data, ICPPFunction[] functions) throws DOMException {
assert data.forDeclaration() == null;
int argumentCount = data.getFunctionArgumentCount();
final int argumentCount = data.getFunctionArgumentCount();
final int packExpansionCount= data.getFunctionArgumentPackExpansionCount();
// Trim the list down to the set of viable functions
ICPPFunction[] result= new ICPPFunction[functions.length];
@ -2300,11 +2301,11 @@ public class CPPSemantics {
numArgs--;
boolean ok;
if (numArgs > numPars) {
// more arguments than parameters --> need ellipsis or parameter pack
if (numArgs-packExpansionCount > numPars) {
// More arguments than parameters --> need ellipsis or parameter pack
ok= fn.takesVarArgs() || fn.hasParameterPack();
} else {
ok = numArgs >= fn.getRequiredArgumentCount();
ok = numArgs >= fn.getRequiredArgumentCount() || packExpansionCount > 0;
}
if (ok) {
if (fn instanceof IIndexBinding) {

View file

@ -98,6 +98,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
import org.eclipse.cdt.internal.core.dom.parser.Value;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
@ -1143,7 +1144,7 @@ public class CPPTemplates {
IType newMemberOfClass = instantiateType(memberOfClass, tpMap, packOffset, within);
if (!(newMemberOfClass instanceof ICPPClassType || newMemberOfClass instanceof UniqueType
|| newMemberOfClass instanceof ICPPUnknownBinding)) {
newMemberOfClass = memberOfClass;
return new ProblemType(ISemanticProblem.BINDING_INVALID_TYPE);
}
if (newNestedType != nestedType || newMemberOfClass != memberOfClass) {
return new CPPPointerToMemberType(newNestedType, newMemberOfClass,
@ -2342,6 +2343,8 @@ public class CPPTemplates {
}
}
}
} else if (t != owner) {
return new ProblemBinding(unknown.getUnknownName(), IProblemBinding.SEMANTIC_BAD_SCOPE);
}
}

View file

@ -1927,7 +1927,7 @@ public class CPPVisitor extends ASTQueries {
beginExpr= expr.copy();
} else if (type instanceof ICPPClassType) {
ICPPClassType ct= (ICPPClassType) type;
if (ct.getCompositeScope().find(BEGIN_STR).length > 0) {
if (CPPSemantics.findBindings(ct.getCompositeScope(), BEGIN_STR, true).length > 0) {
final CPPASTName name = new CPPASTName(BEGIN);
name.setOffset(((ASTNode) forInit).getOffset());
beginExpr= new CPPASTFunctionCallExpression(

View file

@ -52,6 +52,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
@ -341,7 +342,7 @@ public class LookupData {
if (foundItems instanceof Object[])
return ((Object[]) foundItems).length != 0;
if (foundItems instanceof CharArrayObjectMap)
return ((CharArrayObjectMap) foundItems).size() != 0;
return ((CharArrayObjectMap<?>) foundItems).size() != 0;
return false;
}
@ -533,6 +534,17 @@ public class LookupData {
return 0;
}
public int getFunctionArgumentPackExpansionCount() {
int count= 0;
if (functionArgs != null) {
for (IASTInitializerClause arg : functionArgs) {
if (arg instanceof ICPPASTPackExpansionExpression)
count++;
}
}
return count;
}
public boolean hasFunctionArguments() {
return functionArgs != null;
}

View file

@ -293,7 +293,7 @@ public class TemplateArgumentDeduction {
p= getArgumentTypeForDeduction(p, a instanceof ICPPReferenceType);
a= SemanticUtil.getNestedType(a, SemanticUtil.REF | SemanticUtil.TDEF);
TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(tmplParams, null, map, 0);
if (!deduct.fromType(p, a, false)) {
if (!deduct.fromType(p, a, true)) {
return null;
}
@ -664,18 +664,24 @@ public class TemplateArgumentDeduction {
} else if (p instanceof ICPPPointerToMemberType) {
if (!(a instanceof ICPPPointerToMemberType))
return false;
if (!fromType(((ICPPPointerToMemberType) p).getMemberOfClass(),
((ICPPPointerToMemberType) a).getMemberOfClass(), false)) {
final ICPPPointerToMemberType ptrP = (ICPPPointerToMemberType) p;
final ICPPPointerToMemberType ptrA = (ICPPPointerToMemberType) a;
if (!allowCVQConversion && (ptrP.isConst() != ptrA.isConst() || ptrP.isVolatile() != ptrA.isVolatile()))
return false;
if (!fromType(ptrP.getMemberOfClass(), ptrA.getMemberOfClass(), false)) {
return false;
}
p = ((ICPPPointerToMemberType) p).getType();
a = ((ICPPPointerToMemberType) a).getType();
p = ptrP.getType();
a = ptrA.getType();
} else if (p instanceof IPointerType) {
if (!(a instanceof IPointerType)) {
if (!(a instanceof IPointerType))
return false;
}
p = ((IPointerType) p).getType();
a = ((IPointerType) a).getType();
final IPointerType ptrP = (IPointerType) p;
final IPointerType ptrA = (IPointerType) a;
if (!allowCVQConversion && (ptrP.isConst() != ptrA.isConst() || ptrP.isVolatile() != ptrA.isVolatile()))
return false;
p = ptrP.getType();
a = ptrA.getType();
} else if (p instanceof ICPPReferenceType) {
if (!(a instanceof ICPPReferenceType)) {
return false;
@ -730,10 +736,10 @@ public class TemplateArgumentDeduction {
if (remaining != CVQualifier.NONE) {
a= SemanticUtil.addQualifiers(a, remaining.isConst(), remaining.isVolatile(), remaining.isRestrict());
}
} else if (p instanceof IFunctionType) {
if (!(a instanceof IFunctionType))
} else if (p instanceof ICPPFunctionType) {
if (!(a instanceof ICPPFunctionType))
return false;
return fromFunctionType((IFunctionType) p, (IFunctionType) a);
return fromFunctionType((ICPPFunctionType) p, (ICPPFunctionType) a);
} else if (p instanceof ICPPTemplateParameter) {
ICPPTemplateArgument current= fDeducedArgs.getArgument(((ICPPTemplateParameter) p).getParameterID(), fPackOffset);
if (current != null) {
@ -820,7 +826,10 @@ public class TemplateArgumentDeduction {
return true;
}
private boolean fromFunctionType(IFunctionType ftp, IFunctionType fta) throws DOMException {
private boolean fromFunctionType(ICPPFunctionType ftp, ICPPFunctionType fta) throws DOMException {
if (ftp.isConst() != fta.isConst() || ftp.isVolatile() != fta.isVolatile())
return false;
if (!fromType(ftp.getReturnType(), fta.getReturnType(), false))
return false;

View file

@ -30,7 +30,7 @@ public class ASTLiteralNode implements IASTNode {
public ASTLiteralNode(String code) {
fCode= code;
}
@Override
public String getRawSignature() {
return fCode;

View file

@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
import java.util.List;
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
@ -144,6 +146,24 @@ public class ASTWriter {
* @return <code>true</code> if the blank line between the nodes is needed.
*/
public static boolean requireBlankLineInBetween(IASTNode node1, IASTNode node2) {
if (node1 instanceof ContainerNode) {
List<IASTNode> nodes = ((ContainerNode) node1).getNodes();
if (!nodes.isEmpty()) {
node1 = nodes.get(nodes.size() - 1);
}
}
if (node2 instanceof ContainerNode) {
List<IASTNode> nodes = ((ContainerNode) node2).getNodes();
if (!nodes.isEmpty()) {
node2 = nodes.get(0);
}
}
while (node1 instanceof ICPPASTTemplateDeclaration) {
node1 = ((ICPPASTTemplateDeclaration) node1).getDeclaration();
}
while (node2 instanceof ICPPASTTemplateDeclaration) {
node2 = ((ICPPASTTemplateDeclaration) node2).getDeclaration();
}
if (node1 instanceof ICPPASTVisibilityLabel && node2 instanceof ICPPASTVisibilityLabel) {
return true;
}

View file

@ -132,6 +132,7 @@ public class ASTWriterVisitor extends ASTVisitor {
}
public void visit(ASTLiteralNode lit) {
insertBlankLineIfNeeded(lit);
scribe.print(lit.getRawSignature());
}

View file

@ -58,16 +58,14 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationMap;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTRewriteAnalyzer;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriter;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ContainerNode;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ProblemRuntimeException;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
import org.eclipse.cdt.internal.core.dom.rewrite.util.FileHelper;
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
import org.eclipse.cdt.internal.formatter.CCodeFormatter;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
@ -77,7 +75,6 @@ import org.eclipse.jface.text.TextUtilities;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.text.edits.InsertEdit;
import org.eclipse.text.edits.MalformedTreeException;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
@ -557,36 +554,51 @@ public class ChangeGenerator extends ASTVisitor {
}
private void handleAppends(IASTTranslationUnit tu) {
ASTWriter synthWriter = new ASTWriter();
synthWriter.setModificationStore(modificationStore);
List<ASTModification> modifications = getModifications(tu, ModificationKind.APPEND_CHILD);
if (modifications.isEmpty())
return;
for (ASTModification modification : getModifications(tu, ModificationKind.APPEND_CHILD)) {
IASTNode targetNode = modification.getTargetNode();
IASTFileLocation targetLocation = targetNode.getFileLocation();
String currentFile = targetLocation.getFileName();
IPath implPath = new Path(currentFile);
IFile relevantFile= ResourceLookup.selectFileForLocation(implPath, null);
if (relevantFile == null || !relevantFile.exists()) { // If not in workspace or local file system
throw new UnhandledASTModificationException(modification);
IASTNode prevNode = null;
IASTDeclaration[] declarations = tu.getDeclarations();
if (declarations.length != 0) {
prevNode = declarations[declarations.length - 1];
} else {
IASTPreprocessorStatement[] preprocessorStatements = tu.getAllPreprocessorStatements();
if (preprocessorStatements.length != 0) {
prevNode = preprocessorStatements[preprocessorStatements.length - 1];
}
MultiTextEdit edit;
if (changes.containsKey(relevantFile)) {
edit = changes.get(relevantFile);
} else {
edit = new MultiTextEdit();
changes.put(relevantFile, edit);
}
String code = synthWriter.write(modification.getNewNode(), commentMap);
if (targetNode instanceof IASTTranslationUnit &&
((IASTTranslationUnit) targetNode).getDeclarations().length > 0) {
IASTTranslationUnit targetTu = (IASTTranslationUnit) targetNode;
IASTDeclaration lastDecl = targetTu.getDeclarations()[targetTu.getDeclarations().length - 1];
targetLocation = lastDecl.getFileLocation();
}
String lineDelimiter = FileHelper.determineLineDelimiter(tu.getRawSignature());
edit.addChild(new InsertEdit(endOffset(targetLocation), lineDelimiter + lineDelimiter + code));
}
int offset = prevNode != null ? getEndOffsetIncludingComments(prevNode) : 0;
String source = tu.getRawSignature();
int endOffset = skipTrailingBlankLines(source, offset);
ChangeGeneratorWriterVisitor writer =
new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
IASTNode newNode = null;
for (ASTModification modification : modifications) {
boolean first = newNode == null;
newNode = modification.getNewNode();
if (first) {
if (prevNode != null) {
writer.newLine();
if (ASTWriter.requireBlankLineInBetween(prevNode, newNode)) {
writer.newLine();
}
}
}
newNode.accept(writer);
}
if (prevNode != null) {
IASTNode nextNode = getNextSiblingOrPreprocessorNode(prevNode);
if (nextNode != null && ASTWriter.requireBlankLineInBetween(newNode, nextNode)) {
writer.newLine();
}
}
String code = writer.toString();
IFile file = FileHelper.getFileFromNode(tu);
MultiTextEdit parentEdit = getEdit(tu, file);
parentEdit.addChild(new ReplaceEdit(offset, endOffset - offset, code));
}
/**
@ -1016,6 +1028,13 @@ public class ChangeGenerator extends ASTVisitor {
if (modification.getKind() != ModificationKind.APPEND_CHILD)
return false;
IASTNode node = modification.getNewNode();
if (node instanceof ContainerNode) {
for (IASTNode containedNode : ((ContainerNode) node).getNodes()) {
if (!(containedNode instanceof IASTDeclaration || containedNode instanceof IASTStatement))
return false;
}
return true;
}
return node instanceof IASTDeclaration || node instanceof IASTStatement;
}

View file

@ -7,15 +7,13 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Institute for Software - initial API and implementation
* Institute for Software - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
public class UnhandledASTModificationException extends RuntimeException {
private static final long serialVersionUID = 1L;
private final ASTModification illegalModification;
public UnhandledASTModificationException(ASTModification illegalModification) {

View file

@ -47,7 +47,6 @@ import org.eclipse.core.runtime.CoreException;
* Code reader factory, that fakes code readers for header files already stored in the index.
*/
public final class IndexBasedFileContentProvider extends InternalFileContentProvider {
private static final class NeedToParseException extends Exception {}
private static final String GAP = "__gap__"; //$NON-NLS-1$
private final IIndex fIndex;
@ -135,7 +134,7 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv
// Report pragma once inclusions, only if no exception was thrown.
fPragmaOnce.putAll(newPragmaOnce);
return new InternalFileContent(path, macros, directives, files, toList(preLoaded));
} catch (NeedToParseException e) {
} catch (DependsOnOutdatedFileException e) {
}
}
} catch (CoreException e) {
@ -188,7 +187,7 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv
Map<IIndexFileLocation, IFileNomination> newPragmaOnce,
LinkedHashSet<IIndexFile> preLoaded, List<IIndexFile> files,
List<IIndexMacro> macros, List<ICPPUsingDirective> usingDirectives,
Set<IIndexFile> preventRecursion) throws CoreException, NeedToParseException {
Set<IIndexFile> preventRecursion) throws CoreException, DependsOnOutdatedFileException {
if (file.equals(stopAt))
return true;
@ -211,8 +210,6 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv
final Object[] pds;
if (fRelatedIndexerTask != null) {
IndexFileContent content= fRelatedIndexerTask.getFileContent(fLinkage, ifl, file);
if (content == null)
throw new NeedToParseException();
uds= content.getUsingDirectives();
pds= content.getPreprocessingDirectives();
} else {
@ -252,7 +249,7 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv
@Override
public InternalFileContent getContentForContextToHeaderGap(String path,
IMacroDictionary macroDictionary) {
IMacroDictionary macroDictionary) throws DependsOnOutdatedFileException {
if (fContextToHeaderGap == null) {
return null;
}
@ -268,12 +265,8 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv
ArrayList<IIndexMacro> macros= new ArrayList<IIndexMacro>();
ArrayList<ICPPUsingDirective> directives= new ArrayList<ICPPUsingDirective>();
LinkedHashSet<IIndexFile> preLoaded= new LinkedHashSet<IIndexFile>();
try {
if (!collectFileContent(contextFile, targetFile, newPragmaOnce, preLoaded,
filesIncluded, macros, directives, new HashSet<IIndexFile>())) {
return null;
}
} catch (NeedToParseException e) {
if (!collectFileContent(contextFile, targetFile, newPragmaOnce, preLoaded,
filesIncluded, macros, directives, new HashSet<IIndexFile>())) {
return null;
}
@ -302,4 +295,14 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv
}
return IIndexFile.EMPTY_FILE_ARRAY;
}
@Override
public String getContextPath() {
if (fContextToHeaderGap != null)
try {
return fPathResolver.getASTPath(fContextToHeaderGap[0].getLocation());
} catch (CoreException e) {
}
return null;
}
}

View file

@ -36,7 +36,8 @@ public class CompositeCPPClassTemplate extends CompositeCPPClassType
super(cf, ct);
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
@Override
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
try {
final CIndex cIndex = (CIndex) ((CPPCompositesFactory) cf).getContext();
IIndexFragmentBinding[] bindings = cIndex.findEquivalentBindings(rbinding);
@ -59,22 +60,27 @@ public class CompositeCPPClassTemplate extends CompositeCPPClassType
}
}
@Override
public ICPPTemplateParameter[] getTemplateParameters() {
return TemplateInstanceUtil.convert(cf, ((ICPPClassTemplate) rbinding).getTemplateParameters());
}
@Override
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
return CompositeInstanceCache.getCache(cf, rbinding).getInstance(arguments);
}
@Override
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
CompositeInstanceCache.getCache(cf, rbinding).addInstance(arguments, instance);
}
@Override
public ICPPTemplateInstance[] getAllInstances() {
return CompositeInstanceCache.getCache(cf, rbinding).getAllInstances();
}
@Override
public ICPPDeferredClassInstance asDeferredInstance() throws DOMException {
CompositeInstanceCache cache= CompositeInstanceCache.getCache(cf, rbinding);
synchronized (cache) {

View file

@ -32,8 +32,8 @@ CompositeCPPClassSpecialization implements ICPPClassTemplate, ICPPInstanceCache{
super(cf, rbinding);
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations()
throws DOMException {
@Override
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
ICPPClassTemplatePartialSpecialization[] result= ((ICPPClassTemplate) rbinding).getPartialSpecializations();
for (int i= 0; i < result.length; i++) {
result[i]= (ICPPClassTemplatePartialSpecialization) cf.getCompositeBinding((IIndexFragmentBinding)result[i]);
@ -41,23 +41,28 @@ CompositeCPPClassSpecialization implements ICPPClassTemplate, ICPPInstanceCache{
return result;
}
@Override
public ICPPTemplateParameter[] getTemplateParameters() {
return TemplateInstanceUtil.convert(cf, ((ICPPClassTemplate) rbinding).getTemplateParameters());
}
@Override
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
return CompositeInstanceCache.getCache(cf, rbinding).getInstance(arguments);
}
@Override
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
CompositeInstanceCache.getCache(cf, rbinding).addInstance(arguments, instance);
}
@Override
public ICPPTemplateInstance[] getAllInstances() {
return CompositeInstanceCache.getCache(cf, rbinding).getAllInstances();
}
@Override
public ICPPDeferredClassInstance asDeferredInstance() throws DOMException {
CompositeInstanceCache cache= CompositeInstanceCache.getCache(cf, rbinding);
synchronized (cache) {

View file

@ -57,6 +57,7 @@ import org.eclipse.cdt.internal.core.parser.IMacroDictionary;
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException;
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.FileVersion;
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind;
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider.DependsOnOutdatedFileException;
import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions;
import org.eclipse.cdt.internal.core.parser.scanner.MacroDefinitionParser.InvalidMacroDefinitionException;
import org.eclipse.cdt.internal.core.parser.scanner.ScannerContext.BranchKind;
@ -133,7 +134,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
@Override
public boolean visitValue(char[] macro, char[] value) {
PreprocessorMacro m = fMacroDictionary.get(macro);
return m != null && CharArrayUtils.equals(m.getExpansion(), value);
return m != null && CharArrayUtils.equals(SignificantMacros.shortenValue(m.getExpansion()), value);
}
private boolean isDefined(char[] macro) {
@ -246,7 +247,6 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
private final LocationMap fLocationMap;
private CharArraySet fPreventInclusion= new CharArraySet(0);
private final Lexer fRootLexer;
private final ScannerContext fRootContext;
protected ScannerContext fCurrentContext;
@ -297,13 +297,16 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
fMacroExpander= new MacroExpander(this, fMacroDictionary, fLocationMap, fLexOptions);
fIncludeFileResolutionHeuristics= fFileContentProvider.getIncludeHeuristics();
final String filePath= fRootContent.getFileLocation();
configureIncludeSearchPath(new File(filePath).getParentFile(), info);
String contextPath= fFileContentProvider.getContextPath();
if (contextPath == null) {
contextPath= fRootContent.getFileLocation();
}
configureIncludeSearchPath(new File(contextPath).getParentFile(), info);
setupMacroDictionary(configuration, info, language);
ILocationCtx ctx= fLocationMap.pushTranslationUnit(filePath, fRootContent.getSource());
fRootLexer= new Lexer(fRootContent.getSource(), fLexOptions, this, this);
fRootContext= fCurrentContext= new ScannerContext(ctx, null, fRootLexer);
ILocationCtx ctx= fLocationMap.pushTranslationUnit(fRootContent.getFileLocation(), fRootContent.getSource());
Lexer lexer = new Lexer(fRootContent.getSource(), fLexOptions, this, this);
fRootContext= fCurrentContext= new ScannerContext(ctx, null, lexer);
if (info instanceof IExtendedScannerInfo) {
final IExtendedScannerInfo einfo= (IExtendedScannerInfo) info;
fPreIncludedFiles= new String[][] { einfo.getMacroFiles(), einfo.getIncludeFiles() };
@ -346,11 +349,11 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
@Override
public void setContentAssistMode(int offset) {
fContentAssistLimit= offset;
fRootLexer.setContentAssistMode(offset);
fRootContext.getLexer().setContentAssistMode(offset);
}
public boolean isContentAssistMode() {
return fRootLexer.isContentAssistMode();
return fRootContext.getLexer().isContentAssistMode();
}
@Override
@ -466,10 +469,16 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
fPreIncludedFiles= null;
}
final String location = fLocationMap.getTranslationUnitPath();
InternalFileContent content= fFileContentProvider.getContentForContextToHeaderGap(location,
fMacroDictionaryFacade);
InternalFileContent content;
try {
content = fFileContentProvider.getContentForContextToHeaderGap(location,
fMacroDictionaryFacade);
} catch (DependsOnOutdatedFileException e) {
// Abort the parser, handled by the abstract indexer task.
throw new RuntimeException(e);
}
if (content != null && content.getKind() == InclusionKind.FOUND_IN_INDEX) {
processInclusionFromIndex(0, location, content, false);
processInclusionFromIndex(0, content, false);
}
detectIncludeGuard(location, fRootContent.getSource(), fRootContext);
@ -577,7 +586,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
}
try {
t= internalFetchToken(fRootContext, CHECK_NUMBERS, false);
t= internalFetchToken(fRootContext, CHECK_NUMBERS | REPORT_SIGNIFICANT_MACROS | IGNORE_UNDEFINED_SIGNIFICANT_MACROS, false);
} catch (OffsetLimitReachedException e) {
fHandledCompletion= true;
throw e;
@ -1463,7 +1472,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
} catch (CoreException e) {
}
processInclusionFromIndex(poundOffset, path, fi, true);
processInclusionFromIndex(poundOffset, fi, true);
break;
case USE_SOURCE:
// Will be parsed
@ -1502,7 +1511,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
}
}
private void processInclusionFromIndex(int offset, String path, InternalFileContent fi, boolean updateContext) {
private void processInclusionFromIndex(int offset, InternalFileContent fi, boolean updateContext) {
List<IIndexMacro> mdefs= fi.getMacroDefinitions();
for (IIndexMacro macro : mdefs) {
addMacroDefinition(macro);

View file

@ -25,6 +25,7 @@ import org.eclipse.cdt.core.index.IIndexFileLocation;
import org.eclipse.cdt.core.parser.ISignificantMacros;
import org.eclipse.cdt.core.parser.IncludeFileContentProvider;
import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics;
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
import org.eclipse.cdt.internal.core.parser.IMacroDictionary;
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind;
@ -32,6 +33,15 @@ import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.Inclusio
* Internal implementation of the file content providers
*/
public abstract class InternalFileContentProvider extends IncludeFileContentProvider {
public static final class DependsOnOutdatedFileException extends Exception {
public final Object fTu;
public final IIndexFragmentFile fIndexFile;
public DependsOnOutdatedFileException(Object tu, IIndexFragmentFile file) {
fTu= tu;
fIndexFile= file;
}
}
private IIncludeFileResolutionHeuristics fIncludeResolutionHeuristics;
private final Map<String, IFileNomination> fPragmaOnce= new HashMap<String, IFileNomination>();
private final Map<String, List<ISignificantMacros>> fLoadedVersions= new HashMap<String, List<ISignificantMacros>>();
@ -64,9 +74,10 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv
* or <code>null</code> if this cannot be done.
* @param filePath the absolute location of the file.
* @param macroDictionary macros defined at the inclusion point.
* @throws DependsOnOutdatedFileException
*/
public InternalFileContent getContentForContextToHeaderGap(String filePath,
IMacroDictionary macroDictionary) {
IMacroDictionary macroDictionary) throws DependsOnOutdatedFileException {
return null;
}
@ -123,5 +134,12 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv
}
list.add(sig);
}
}
/**
* Return the path of the context of <code>null</code>, if there is no context.
*/
public String getContextPath() {
return null;
}
}

View file

@ -330,14 +330,29 @@ final class ScannerContext {
}
public void internalModification(char[] macroName) {
if (fInternalModifications != null)
fInternalModifications.put(macroName);
final CharArraySet collector = findModificationCollector();
if (collector != null)
collector.put(macroName);
}
private CharArraySet findModificationCollector() {
ScannerContext ctx= this;
do {
final CharArraySet collector = ctx.fInternalModifications;
if (collector != null)
return collector;
ctx= ctx.getParent();
} while (ctx != null);
return null;
}
public void significantMacro(IMacroBinding macro) {
final char[] macroName= macro.getNameCharArray();
if (fInternalModifications != null && !fInternalModifications.containsKey(macroName)) {
fSignificantMacros.put(macroName, macro.getExpansion());
final char[] expansion = macro.getExpansion();
if (expansion != null)
fSignificantMacros.put(macroName, SignificantMacros.shortenValue(expansion));
}
}
@ -370,23 +385,28 @@ final class ScannerContext {
return;
if (fParent != null) {
final CharArraySet local = fParent.fInternalModifications;
if (local != null) {
final CharArrayObjectMap<char[]> significant = fParent.fSignificantMacros;
for (int i=0; i<fSignificantMacros.size(); i++) {
final char[] name = fSignificantMacros.keyAt(i);
if (!local.containsKey(name)) {
final char[] value= fSignificantMacros.getAt(i);
if (value == SignificantMacros.DEFINED) {
if (!local.containsKey(name)) {
fParent.addSignificantMacroDefined(name);
CharArraySet collector = fParent.findModificationCollector();
if (collector != null) {
// Propagate internal modifications to first interested parent.
collector.addAll(fInternalModifications);
// Propagate significant macros to direct parent, if it is interested.
if (collector == fParent.fInternalModifications) {
final CharArrayObjectMap<char[]> significant = fParent.fSignificantMacros;
for (int i=0; i<fSignificantMacros.size(); i++) {
final char[] name = fSignificantMacros.keyAt(i);
if (!collector.containsKey(name)) {
final char[] value= fSignificantMacros.getAt(i);
if (value == SignificantMacros.DEFINED) {
if (!collector.containsKey(name)) {
fParent.addSignificantMacroDefined(name);
}
} else {
significant.put(name, value);
}
} else {
significant.put(name, value);
}
}
}
local.addAll(fInternalModifications);
}
}
fInternalModifications= null;
@ -398,18 +418,21 @@ final class ScannerContext {
return;
sm.accept(new ISignificantMacros.IVisitor() {
@Override
public boolean visitValue(char[] macro, char[] value) {
if (!fInternalModifications.containsKey(macro)) {
fSignificantMacros.put(macro, value);
}
return true;
}
@Override
public boolean visitUndefined(char[] macro) {
if (!fInternalModifications.containsKey(macro)) {
fSignificantMacros.put(macro, SignificantMacros.UNDEFINED);
}
return true;
}
@Override
public boolean visitDefined(char[] macro) {
if (!fInternalModifications.containsKey(macro)) {
fSignificantMacros.put(macro, SignificantMacros.DEFINED);

View file

@ -28,11 +28,10 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
* A <code>null</code> string is encoded as a single comma.
*/
public class SignificantMacros implements ISignificantMacros {
public static final char[] UNDEFINED = {};
public static final char[] DEFINED = {};
private static final int ENCODED_UNDEFINED = Character.MAX_VALUE;
private static final int ENCODED_DEFINED = Character.MAX_VALUE-1;
public static final char[] DEFINED = {0};
public static final char[] UNDEFINED = {1};
private static final Comparator<Object> SORTER = new Comparator<Object>() {
@Override
public int compare(Object o1, Object o2) {
return CharArrayUtils.compare((char[])o1, (char[])o2);
}
@ -58,13 +57,7 @@ public class SignificantMacros implements ISignificantMacros {
char[] name= (char[]) key;
char[] value= sigMacros.get(name);
buffer.append((char) name.length).append(name);
if (value == DEFINED) {
buffer.append((char) ENCODED_DEFINED);
} else if (value == UNDEFINED) {
buffer.append((char) ENCODED_UNDEFINED);
} else {
buffer.append((char) value.length).append(value);
}
buffer.append((char) value.length).append(value);
}
int len= buffer.length();
char[] result= new char[len];
@ -93,6 +86,7 @@ public class SignificantMacros implements ISignificantMacros {
&& CharArrayUtils.equals(fEncoded, ((SignificantMacros) obj).fEncoded);
}
@Override
public boolean accept(IVisitor visitor) {
final char[] encoded = fEncoded;
final int len = encoded.length;
@ -102,28 +96,27 @@ public class SignificantMacros implements ISignificantMacros {
int v= i + len1;
if (v >= len)
break;
final int len2 = encoded[v++];
if (v+len2 > len)
break;
char[] macro= extract(encoded, i, len1);
final int len2 = encoded[v++];
switch(len2) {
case ENCODED_UNDEFINED:
i= v;
if (!visitor.visitUndefined(macro))
return false;
break;
case ENCODED_DEFINED:
i= v;
if (!visitor.visitDefined(macro))
return false;
break;
default:
i= v+len2;
if (i > len)
break;
if (!visitor.visitValue(macro, extract(encoded, v, len2)))
return false;
break;
}
i= v+len2;
if (len2 == 1) {
if (encoded[v] == UNDEFINED[0]) {
if (!visitor.visitUndefined(macro))
return false;
continue;
}
if (encoded[v] == DEFINED[0]) {
if (!visitor.visitDefined(macro))
return false;
continue;
}
}
final char[] value = extract(encoded, v, len2);
if (!visitor.visitValue(macro, value))
return false;
}
return true;
}
@ -134,6 +127,7 @@ public class SignificantMacros implements ISignificantMacros {
return value;
}
@Override
public char[] encode() {
return fEncoded;
}
@ -147,14 +141,17 @@ public class SignificantMacros implements ISignificantMacros {
final StringBuilder buf= new StringBuilder();
buf.append('{');
accept(new IVisitor() {
@Override
public boolean visitValue(char[] macro, char[] value) {
buf.append(macro).append('=').append(value).append(',');
return true;
}
@Override
public boolean visitUndefined(char[] macro) {
buf.append(macro).append('=').append("null,");
return true;
}
@Override
public boolean visitDefined(char[] macro) {
buf.append(macro).append('=').append("*,");
return true;
@ -166,4 +163,19 @@ public class SignificantMacros implements ISignificantMacros {
buf.append('}');
return buf.toString();
}
public static char[] shortenValue(char[] expansion) {
if (expansion.length <= 16)
return expansion;
char[] result= new char[16];
System.arraycopy(expansion, 0, result, 0, 8);
StreamHasher hasher= new StreamHasher();
hasher.addChunk(expansion);
long hash= hasher.computeHash();
for(int i= 0; i<8; i++) {
result[8+i]= (char) (hash & 0xff);
hash= hash >> 1;
}
return result;
}
}

View file

@ -24,6 +24,7 @@ import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
@ -54,6 +55,7 @@ import org.eclipse.cdt.internal.core.index.IWritableIndex;
import org.eclipse.cdt.internal.core.index.IndexBasedFileContentProvider;
import org.eclipse.cdt.internal.core.parser.IMacroDictionary;
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider;
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider.DependsOnOutdatedFileException;
import org.eclipse.cdt.internal.core.parser.util.LRUCache;
import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.runtime.CoreException;
@ -783,7 +785,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
return;
final Object tu = locTask.fTu;
final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, tu);
parseFile(tu, linkageID, ifl, scannerInfo, null, monitor);
parseFile(tu, getLanguage(tu, linkageID), ifl, scannerInfo, null, monitor);
}
}
@ -817,7 +819,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
return;
final Object tu = locTask.fTu;
final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, tu);
parseFile(tu, linkageID, ifl, scannerInfo, null, monitor);
parseFile(tu, getLanguage(tu, linkageID), ifl, scannerInfo, null, monitor);
if (locTask.isCompleted())
it.remove();
@ -870,8 +872,24 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
return;
final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, contextTu);
FileContext ctx= new FileContext(ctxFile, headerFile);
parseFile(tu, linkageID, ifl, scannerInfo, ctx, monitor);
final AbstractLanguage language = getLanguage(contextTu, linkageID);
final FileContext ctx= new FileContext(ctxFile, headerFile);
Set<IIndexFile> dependencies= null;
boolean done= false;
while (!done) {
done= true;
DependsOnOutdatedFileException d= parseFile(tu, language, ifl, scannerInfo, ctx, monitor);
if (d != null) {
// File was not parsed, because there is a dependency that needs to be
// handled before
if (dependencies == null)
dependencies= new HashSet<IIndexFile>();
if (dependencies.add(d.fIndexFile)) {
if (parseFile(d.fTu, language, d.fIndexFile.getLocation(), scannerInfo, new FileContext(ctxFile, d.fIndexFile), monitor) == null)
done= false;
}
}
}
if (!ctx.fLostPragmaOnceSemantics)
return;
@ -929,21 +947,9 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
}
private void parseFile(Object tu, int linkageID, IIndexFileLocation ifl, IScannerInfo scanInfo,
private DependsOnOutdatedFileException parseFile(Object tu, AbstractLanguage lang, IIndexFileLocation ifl, IScannerInfo scanInfo,
FileContext ctx, IProgressMonitor pm) throws CoreException, InterruptedException {
IPath path= getLabel(ifl);
AbstractLanguage[] langs= fResolver.getLanguages(tu, true);
AbstractLanguage lang= null;
for (AbstractLanguage lang2 : langs) {
if (lang2.getLinkageID() == linkageID) {
lang= lang2;
break;
}
}
if (lang == null) {
return;
}
Throwable th= null;
try {
if (fShowActivity) {
@ -951,18 +957,21 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
}
pm.subTask(getMessage(MessageKind.parsingFileTask,
path.lastSegment(), path.removeLastSegments(1).toString()));
long start= System.currentTimeMillis();
FileContent codeReader= fResolver.getCodeReader(tu);
IIndexFile[] ctxFiles = ctx == null ? null : new IIndexFile[] {ctx.fContext, ctx.fOldFile};
final boolean isSource = fResolver.isSourceUnit(tu);
IASTTranslationUnit ast= createAST(tu, lang, codeReader, scanInfo, fASTOptions, ctxFiles, pm);
long start= System.currentTimeMillis();
IASTTranslationUnit ast= createAST(lang, codeReader, scanInfo, isSource, fASTOptions, ctx, pm);
fStatistics.fParsingTime += System.currentTimeMillis() - start;
if (ast != null) {
writeToIndex(linkageID, ast, codeReader.getContentsHash(), ctx, pm);
writeToIndex(lang.getLinkageID(), ast, codeReader.getContentsHash(), ctx, pm);
}
} catch (CoreException e) {
th= e;
} catch (RuntimeException e) {
final Throwable cause = e.getCause();
if (cause instanceof DependsOnOutdatedFileException)
return (DependsOnOutdatedFileException) cause;
th= e;
} catch (StackOverflowError e) {
th= e;
@ -976,6 +985,16 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
if (th != null) {
swallowError(path, th);
}
return null;
}
private AbstractLanguage getLanguage(Object tu, int linkageID) {
for (AbstractLanguage language : fResolver.getLanguages(tu, true)) {
if (language.getLinkageID() == linkageID) {
return language;
}
}
return null;
}
private IPath getLabel(IIndexFileLocation ifl) {
@ -1033,13 +1052,13 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
return e;
}
private final IASTTranslationUnit createAST(Object tu, AbstractLanguage language,
FileContent codeReader, IScannerInfo scanInfo, int options,
IIndexFile[] ctx2header, IProgressMonitor pm) throws CoreException {
private final IASTTranslationUnit createAST(AbstractLanguage language, FileContent codeReader,
IScannerInfo scanInfo, boolean isSource, int options,
FileContext ctx, IProgressMonitor pm) throws CoreException {
if (codeReader == null) {
return null;
}
if (fResolver.isSourceUnit(tu)) {
if (isSource) {
options |= ILanguage.OPTION_IS_SOURCE_UNIT;
}
if (fFileSizeLimit > 0 && fResolver.getFileSize(codeReader.getFileLocation()) > fFileSizeLimit) {
@ -1048,6 +1067,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
}
return null;
}
final IIndexFile[] ctx2header = ctx == null ? null : new IIndexFile[] {ctx.fContext, ctx.fOldFile};
if (fCodeReaderFactory == null) {
InternalFileContentProvider fileContentProvider = createInternalFileContentProvider();
if (fIsFastIndexer) {
@ -1163,14 +1183,14 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
}
public final IndexFileContent getFileContent(int linkageID, IIndexFileLocation ifl,
IIndexFile file) throws CoreException {
IIndexFile file) throws CoreException, DependsOnOutdatedFileException {
LinkageTask map = findRequestMap(linkageID);
if (map != null) {
LocationTask request= map.find(ifl);
if (request != null) {
FileVersionTask task= request.findVersion(file);
if (task != null && task.fOutdated)
return null;
throw new DependsOnOutdatedFileException(request.fTu, task.fIndexFile);
}
}
IndexFileContent fc= fIndexContentCache.get(file);

View file

@ -212,10 +212,11 @@ public class PDOM extends PlatformObject implements IPDOM {
* 120.0 - Enumerators in global index, bug 356235
* 120.1 - Specializations of using declarations, bug 357293.
* 121.0 - Multiple variants of included header file, bug 197989.
* 122.0 - Compacting strings
*/
private static final int MIN_SUPPORTED_VERSION= version(121, 0);
private static final int MAX_SUPPORTED_VERSION= version(121, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(121, 0);
private static final int MIN_SUPPORTED_VERSION= version(122, 0);
private static final int MAX_SUPPORTED_VERSION= version(122, Short.MAX_VALUE);
private static final int DEFAULT_VERSION = version(122, 0);
private static int version(int major, int minor) {
return (major << 16) + minor;

View file

@ -252,17 +252,47 @@ final class Chunk {
fBuffer[++idx]= (byte)(value);
}
public void putChars(final long offset, char[] chars, int start, int len) {
assert fLocked;
fDirty= true;
int idx= recPtrToIndex(offset)-1;
final int end= start+len;
for (int i = start; i < end; i++) {
char value= chars[i];
fBuffer[++idx]= (byte)(value >> 8);
fBuffer[++idx]= (byte)(value);
}
}
public void putCharsAsBytes(final long offset, char[] chars, int start, int len) {
assert fLocked;
fDirty= true;
int idx= recPtrToIndex(offset)-1;
final int end= start+len;
for (int i = start; i < end; i++) {
char value= chars[i];
fBuffer[++idx]= (byte)(value);
}
}
public char getChar(final long offset) {
int idx= recPtrToIndex( offset );
return (char) (((fBuffer[idx] << 8) | (fBuffer[++idx] & 0xff)));
}
public void getCharArray(final long offset, final char[] result) {
public void getChars(final long offset, final char[] result, int start, int len) {
final ByteBuffer buf= ByteBuffer.wrap(fBuffer);
buf.position(recPtrToIndex( offset ));
buf.asCharBuffer().get(result);
buf.asCharBuffer().get(result, start, len);
}
public void getCharsFromBytes(final long offset, final char[] result, int start, int len) {
final int pos = recPtrToIndex(offset);
for (int i = 0; i < len; i++) {
result[start+i] = (char) (fBuffer[pos+i] & 0xff);
}
}
void clear(final long offset, final int length) {
assert fLocked;
fDirty= true;

View file

@ -530,25 +530,42 @@ public class Database {
}
public IString newString(String string) throws CoreException {
if (string.length() > ShortString.MAX_LENGTH)
return new LongString(this, string);
else
return new ShortString(this, string);
return newString(string.toCharArray());
}
public IString newString(char[] chars) throws CoreException {
if (chars.length > ShortString.MAX_LENGTH)
return new LongString(this, chars);
int len= chars.length;
int bytelen;
final boolean useBytes = useBytes(chars);
if (useBytes) {
bytelen= len;
} else {
bytelen= 2*len;
}
if (bytelen > ShortString.MAX_BYTE_LENGTH)
return new LongString(this, chars, useBytes);
else
return new ShortString(this, chars);
return new ShortString(this, chars, useBytes);
}
private boolean useBytes(char[] chars) {
for (char c : chars) {
if ((c & 0xff00) != 0)
return false;
}
return true;
}
public IString getString(long offset) throws CoreException {
int length = getInt(offset);
if (length > ShortString.MAX_LENGTH)
final int l = getInt(offset);
int bytelen= l<0 ? -l : 2*l;
if (bytelen > ShortString.MAX_BYTE_LENGTH) {
return new LongString(this, offset);
else
return new ShortString(this, offset);
}
return new ShortString(this, offset);
}
/**

View file

@ -13,8 +13,6 @@
package org.eclipse.cdt.internal.core.pdom.db;
import java.util.NoSuchElementException;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.core.runtime.CoreException;
@ -48,73 +46,117 @@ public class LongString implements IString {
this.record = record;
}
private interface IWriter {
public void writeChars(int start, int length, long p) throws CoreException;
}
public LongString(Database db, final char[] chars, boolean useBytes) throws CoreException {
final int numChars1 = useBytes ? NUM_CHARS1*2 : NUM_CHARS1;
final int numCharsn = useBytes ? NUM_CHARSN*2 : NUM_CHARSN;
private long createString(int length, IWriter writer) throws CoreException {
// write the first record
long firstRecord = db.malloc(Database.MAX_MALLOC_SIZE);
int start = 0;
db.putInt(firstRecord, length);
writer.writeChars(start, NUM_CHARS1, firstRecord + CHARS1);
this.db = db;
this.record = db.malloc(Database.MAX_MALLOC_SIZE);
// Write the first record
final int length = chars.length;
db.putInt(this.record, useBytes ? -length : length);
Chunk chunk= db.getChunk(this.record);
if (useBytes) {
chunk.putCharsAsBytes(this.record + CHARS1, chars, 0, numChars1);
} else {
chunk.putChars(this.record + CHARS1, chars, 0, numChars1);
}
// write the subsequent records
long lastNext = firstRecord + NEXT1;
start += NUM_CHARS1;
while (length - start > NUM_CHARSN) {
long lastNext = this.record + NEXT1;
int start = numChars1;
while (length-start > numCharsn) {
long nextRecord = db.malloc(Database.MAX_MALLOC_SIZE);
db.putRecPtr(lastNext, nextRecord);
writer.writeChars(start, NUM_CHARSN, nextRecord + CHARSN);
start += NUM_CHARSN;
chunk= db.getChunk(nextRecord);
if (useBytes) {
chunk.putCharsAsBytes(nextRecord + CHARSN, chars, start, numCharsn);
} else {
chunk.putChars(nextRecord + CHARSN, chars, start, numCharsn);
}
start += numCharsn;
lastNext = nextRecord + NEXTN;
}
// Write the final record
length -= start;
long finalRecord = db.malloc(CHARSN + (length) * 2);
db.putRecPtr(lastNext, finalRecord);
writer.writeChars(start, length, finalRecord + CHARSN);
return firstRecord;
}
public LongString(Database db, final String string) throws CoreException {
this.db = db;
this.record = createString(string.length(), new IWriter() {
public void writeChars(int start, int length, long p) throws CoreException {
for (int i = start; i < start + length; ++i) {
LongString.this.db.putChar(p, string.charAt(i));
p += 2;
}
}
});
}
public LongString(Database db, final char[] chars) throws CoreException {
this.db = db;
this.record = createString(chars.length, new IWriter() {
public void writeChars(int start, int length, long p) throws CoreException {
for (int i = start; i < start + length; ++i) {
LongString.this.db.putChar(p, chars[i]);
p += 2;
}
}
});
// Write last record
int remaining= length - start;
long nextRecord = db.malloc(CHARSN + (useBytes ? remaining : remaining*2));
db.putRecPtr(lastNext, nextRecord);
chunk= db.getChunk(nextRecord);
if (useBytes) {
chunk.putCharsAsBytes(nextRecord + CHARSN, chars, start, remaining);
} else {
chunk.putChars(nextRecord + CHARSN, chars, start, remaining);
}
}
@Override
public long getRecord() {
return record;
}
@Override
public char[] getChars() throws CoreException {
int length = db.getInt(record + LENGTH);
final boolean useBytes = length < 0;
int numChars1 = NUM_CHARS1;
int numCharsn = NUM_CHARSN;
if (useBytes) {
length= -length;
numChars1 *= 2;
numCharsn *= 2;
}
final char[] chars = new char[length];
// First record
long p = record;
Chunk chunk= db.getChunk(p);
if (useBytes) {
chunk.getCharsFromBytes(p+CHARS1, chars, 0, numChars1);
} else {
chunk.getChars(p+CHARS1, chars, 0, numChars1);
}
int start= numChars1;
p= record + NEXT1;
// Other records
while (start < length) {
p = db.getRecPtr(p);
int partLen= Math.min(length-start, numCharsn);
chunk= db.getChunk(p);
if (useBytes) {
chunk.getCharsFromBytes(p+CHARSN, chars, start, partLen);
} else {
chunk.getChars(p+CHARSN, chars, start, partLen);
}
start+= partLen;
p=p+NEXTN;
}
return chars;
}
@Override
public void delete() throws CoreException {
int length = db.getInt(record + LENGTH) - NUM_CHARS1;
int length = db.getInt(record + LENGTH);
final boolean useBytes = length < 0;
int numChars1 = NUM_CHARS1;
int numCharsn = NUM_CHARSN;
if (useBytes) {
length= -length;
numChars1 *= 2;
numCharsn *= 2;
}
long nextRecord = db.getRecPtr(record + NEXT1);
db.free(record);
length-= numChars1;
// Middle records
while (length > NUM_CHARSN) {
length -= NUM_CHARSN;
while (length > numCharsn) {
length -= numCharsn;
long nextnext = db.getRecPtr(nextRecord + NEXTN);
db.free(nextRecord);
nextRecord = nextnext;
@ -147,19 +189,6 @@ public class LongString implements IString {
return false;
}
private class HashCodeComputer implements IReader {
private int fHashcode= 0;
public int getHashcode() {
return fHashcode;
}
public void appendChar(char c) {
fHashcode = 31*fHashcode + c;
}
}
/**
* Compatible with {@link String#hashCode()}
*/
@ -167,224 +196,53 @@ public class LongString implements IString {
public int hashCode() {
int h = hash;
if (h == 0) {
HashCodeComputer hcc;
char chars[];
try {
int length = db.getInt(record + LENGTH);
hcc = new HashCodeComputer();
readChars(length, hcc);
h= hcc.getHashcode();
hash = h;
chars = getChars();
final int len = chars.length;
for (int i = 0; i < len; i++) {
h = 31*h + chars[i];
}
} catch (CoreException e) {
}
hash = h;
}
return h;
}
@Override
public int compare(IString string, boolean caseSensitive) throws CoreException {
if (string instanceof LongString)
return compare((LongString)string, caseSensitive);
else if (string instanceof ShortString)
return compare((ShortString)string, caseSensitive);
else
throw new IllegalArgumentException();
return ShortString.compare(getChars(), string.getChars(), caseSensitive);
}
public int compare(char[] other, boolean caseSensitive) throws CoreException {
CharIterator i1 = new CharIterator();
int i2 = 0;
int n2 = other.length;
while (i1.hasNext() && i2 < n2) {
int cmp= ShortString.compareChars(i1.next(), other[i2], caseSensitive);
if(cmp!=0)
return cmp;
++i2;
}
if (!i1.hasNext() && i2 != n2)
return -1;
else if (i2 == n2 && i1.hasNext())
return 1;
else
return 0;
}
public int compare(ShortString other, boolean caseSensitive) throws CoreException {
CharIterator i1 = new CharIterator();
int index2 = 0;
int length2 = other.getLength();
while (i1.hasNext() && index2<length2) {
int cmp= ShortString.compareChars(i1.next(), other.charAt(index2), caseSensitive);
if(cmp!=0)
return cmp;
index2++;
}
if (!i1.hasNext() && index2 != length2)
return -1;
else if (index2 == length2 && i1.hasNext())
return 1;
else
return 0;
}
public int compare(LongString other, boolean caseSensitive) throws CoreException {
CharIterator i1 = new CharIterator();
CharIterator i2 = other.new CharIterator();
while (i1.hasNext() && i2.hasNext()) {
int cmp= ShortString.compareChars(i1.next(), i2.next(), caseSensitive);
if(cmp!=0)
return cmp;
}
if (!i1.hasNext() && i2.hasNext())
return -1;
else if (!i2.hasNext() && i1.hasNext())
return 1;
else
return 0;
}
@Override
public int compare(String other, boolean caseSensitive) throws CoreException {
CharIterator i1 = new CharIterator();
int i2 = 0;
int n2 = other.length();
while (i1.hasNext() && i2 < n2) {
int cmp= ShortString.compareChars(i1.next(), other.charAt(i2), caseSensitive);
if(cmp!=0)
return cmp;
++i2;
}
if (!i1.hasNext() && i2 != n2)
return -1;
else if (i2 == n2 && i1.hasNext())
return 1;
else
return 0;
return ShortString.compare(getChars(), other.toCharArray(), caseSensitive);
}
public int comparePrefix(char[] other, boolean caseSensitive) throws CoreException {
CharIterator i1 = new CharIterator();
int i2 = 0;
int n2 = other.length;
while (i1.hasNext() && i2 < n2) {
int cmp= ShortString.compareChars(i1.next(), other[i2], caseSensitive);
if(cmp!=0)
return cmp;
++i2;
}
if (!i1.hasNext() && i2 != n2)
return -1;
else
return 0;
}
private interface IReader {
public void appendChar(char c);
@Override
public int compare(char[] other, boolean caseSensitive) throws CoreException {
return ShortString.compare(getChars(), other, caseSensitive);
}
private void readChars(int length, IReader reader) throws CoreException {
// First record
long p = record + CHARS1;
for (int i = 0; i < NUM_CHARS1; ++i) {
reader.appendChar(db.getChar(p));
p += 2;
}
length -= NUM_CHARS1;
long nextRecord = db.getRecPtr(record + NEXT1);
// Middle records
while (length > NUM_CHARSN) {
p = nextRecord + CHARSN;
for (int i = 0; i < NUM_CHARSN; ++i) {
reader.appendChar(db.getChar(p));
p += 2;
}
length -= NUM_CHARSN;
nextRecord = db.getRecPtr(nextRecord + NEXTN);
}
// Last record
p = nextRecord + CHARSN;
for (int i = 0; i < length; ++i) {
reader.appendChar(db.getChar(p));
p += 2;
}
}
/**
* Convenience class for sequential access to LongString characters
*/
private class CharIterator {
long p;
int count;
int length;
public CharIterator() throws CoreException {
p = record + CHARS1;
length = db.getInt(record + LENGTH);
}
public char next() throws CoreException {
char result = db.getChar(p);
p += 2;
count++;
if(count>length) {
throw new NoSuchElementException();
}
if(count == NUM_CHARS1) {
p = db.getRecPtr(record + NEXT1) + CHARSN;
}
if(count > NUM_CHARS1 && ((count-NUM_CHARS1) % NUM_CHARSN)==0) {
p = db.getRecPtr(p-(NUM_CHARSN*2)-4) + CHARSN;
}
return result;
}
public boolean hasNext() {
return count<length;
}
}
public char[] getChars() throws CoreException {
int length = db.getInt(record + LENGTH);
final char[] chars = new char[length];
readChars(length, new IReader() {
int cp = 0;
public void appendChar(char c) {
chars[cp++] = c;
}
});
return chars;
}
public String getString() throws CoreException {
int length = db.getInt(record + LENGTH);
final StringBuilder buffer = new StringBuilder(length);
readChars(length, new IReader() {
public void appendChar(char c) {
buffer.append(c);
}
});
return buffer.toString();
}
@Override
public int compareCompatibleWithIgnoreCase(IString string) throws CoreException {
int cmp= compare(string, false);
return cmp==0 ? compare(string, true) : cmp;
return ShortString.compareCompatibleWithIgnoreCase(getChars(), string.getChars());
}
@Override
public int comparePrefix(char[] other, boolean caseSensitive) throws CoreException {
return ShortString.comparePrefix(getChars(), other, caseSensitive);
}
public int compareCompatibleWithIgnoreCase(char[] chars) throws CoreException {
int cmp= compare(chars, false);
return cmp==0 ? compare(chars, true) : cmp;
@Override
public String getString() throws CoreException {
return new String(getChars());
}
@Override
public int compareCompatibleWithIgnoreCase(char[] other) throws CoreException {
return ShortString.compareCompatibleWithIgnoreCase(getChars(), other);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2009 QNX Software Systems and others.
* Copyright (c) 2006, 2011 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -13,6 +13,7 @@
package org.eclipse.cdt.internal.core.pdom.db;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.core.runtime.CoreException;
/**
@ -28,57 +29,53 @@ public class ShortString implements IString {
private static final int LENGTH = 0;
private static final int CHARS = 4;
public static final int MAX_LENGTH = (Database.MAX_MALLOC_SIZE - CHARS) / 2;
public static final int MAX_BYTE_LENGTH = Database.MAX_MALLOC_SIZE - CHARS;
public ShortString(Database db, long offset) {
this.db = db;
this.record = offset;
}
public ShortString(Database db, char[] chars) throws CoreException {
public ShortString(Database db, char[] chars, boolean useBytes) throws CoreException {
final int n = chars.length;
this.db = db;
this.record = db.malloc(CHARS + chars.length * 2);
this.record = db.malloc(CHARS + (useBytes ? n : 2*n));
Chunk chunk = db.getChunk(record);
chunk.putInt(record + LENGTH, (char)chars.length);
int n = chars.length;
chunk.putInt(record + LENGTH, useBytes ? -n : n);
long p = record + CHARS;
for (int i = 0; i < n; ++i) {
chunk.putChar(p, chars[i]);
p += 2;
}
}
public ShortString(Database db, String string) throws CoreException {
this.db = db;
this.record = db.malloc(CHARS + string.length() * 2);
Chunk chunk = db.getChunk(record);
chunk.putInt(record + LENGTH, string.length());
int n = string.length();
long p = record + CHARS;
for (int i = 0; i < n; ++i) {
chunk.putChar(p, string.charAt(i));
p += 2;
if (useBytes) {
chunk.putCharsAsBytes(p, chars, 0, n);
} else {
chunk.putChars(p, chars, 0, n);
}
}
@Override
public long getRecord() {
return record;
}
@Override
public void delete() throws CoreException {
db.free(record);
}
@Override
public char[] getChars() throws CoreException {
Chunk chunk = db.getChunk(record);
int length = chunk.getInt(record + LENGTH);
char[] chars = new char[length];
chunk.getCharArray(record + CHARS, chars);
final Chunk chunk = db.getChunk(record);
final int l = chunk.getInt(record + LENGTH);
final int length = Math.abs(l);
final char[] chars = new char[length];
if (l < 0) {
chunk.getCharsFromBytes(record + CHARS, chars, 0, length);
} else {
chunk.getChars(record + CHARS, chars, 0, length);
}
return chars;
}
@Override
public String getString() throws CoreException {
return new String(getChars());
}
@ -102,49 +99,22 @@ public class ShortString implements IString {
if (n1 != n2)
return false;
long p1 = record + CHARS;
long p2 = string.record + CHARS;
for (int i = 0; i < n1; ++i) {
if (chunk1.getChar(p1) != chunk2.getChar(p2))
return false;
p1 += 2;
p2 += 2;
}
return true;
} else if (obj instanceof char[]) {
return CharArrayUtils.equals(getChars(), string.getChars());
}
if (obj instanceof char[]) {
char[] chars = (char[])obj;
Chunk chunk = db.getChunk(record);
// Make sure size is the same
int n = chunk.getInt(record);
if (n != chars.length)
if (getLength() != chars.length)
return false;
// Check each character
long p = record + CHARS;
for (int i = 0; i < n; ++i) {
if (chunk.getChar(p) != chars[i])
return false;
p += 2;
}
return true;
return CharArrayUtils.equals(getChars(), chars);
} else if (obj instanceof String) {
String string = (String)obj;
Chunk chunk = db.getChunk(record);
// Make sure size is the same
int n = chunk.getInt(record);
if (n != string.length())
if (getLength() != string.length())
return false;
// Check each character
long p = record + CHARS;
for (int i = 0; i < n; ++i) {
if (chunk.getChar(p) != string.charAt(i))
return false;
p += 2;
}
return true;
return CharArrayUtils.equals(getChars(), string.toCharArray());
}
} catch (CoreException e) {
CCorePlugin.log(e);
@ -173,112 +143,48 @@ public class ShortString implements IString {
return h;
}
public static int compare(final char[] chars, char[] other, boolean caseSensitive) {
final int n = Math.min(chars.length, other.length);
for (int i=0; i<n; i++) {
int cmp= compareChars(chars[i], other[i], caseSensitive);
if (cmp != 0)
return cmp;
}
return chars.length - other.length;
}
@Override
public int compare(char[] other, boolean caseSensitive) throws CoreException {
Chunk chunk = db.getChunk(record);
long i1 = record + CHARS;
int i2 = 0;
long n1 = i1 + chunk.getInt(record + LENGTH) * 2;
int n2 = other.length;
while (i1 < n1 && i2 < n2) {
int cmp= compareChars(chunk.getChar(i1), other[i2], caseSensitive);
if (cmp != 0)
return cmp;
i1 += 2;
++i2;
}
if (i1 == n1 && i2 != n2)
return -1;
else if (i2 == n2 && i1 != n1)
return 1;
else
return 0;
return compare(getChars(), other, caseSensitive);
}
@Override
public int compare(IString string, boolean caseSensitive) throws CoreException {
if (string instanceof ShortString)
return compare((ShortString)string, caseSensitive);
else if (string instanceof LongString)
return - ((LongString)string).compare(this, caseSensitive);
else
throw new IllegalArgumentException();
return compare(getChars(), string.getChars(), caseSensitive);
}
public int compare(ShortString other, boolean caseSensitive) throws CoreException {
Chunk chunk1 = db.getChunk(record);
Chunk chunk2 = other.db.getChunk(other.record);
long i1 = record + CHARS;
long i2 = other.record + CHARS;
long n1 = i1 + chunk1.getInt(record + LENGTH) * 2;
long n2 = i2 + chunk2.getInt(other.record + LENGTH) * 2;
while (i1 < n1 && i2 < n2) {
int cmp= compareChars(chunk1.getChar(i1), chunk2.getChar(i2), caseSensitive);
if (cmp != 0)
return cmp;
i1 += 2;
i2 += 2;
}
if (i1 == n1 && i2 != n2)
return -1;
else if (i2 == n2 && i1 != n1)
return 1;
else
return 0;
}
@Override
public int compare(String other, boolean caseSensitive) throws CoreException {
Chunk chunk = db.getChunk(record);
long i1 = record + CHARS;
int i2 = 0;
long n1 = i1 + chunk.getInt(record + LENGTH) * 2;
int n2 = other.length();
while (i1 < n1 && i2 < n2) {
int cmp= compareChars(chunk.getChar(i1), other.charAt(i2), caseSensitive);
if (cmp != 0)
return cmp;
i1 += 2;
++i2;
}
if (i1 == n1 && i2 != n2)
return -1;
else if (i2 == n2 && i1 != n1)
return 1;
else
return 0;
return compare(getChars(), other.toCharArray(), caseSensitive);
}
@Override
public int compareCompatibleWithIgnoreCase(IString string) throws CoreException {
if (string instanceof ShortString)
return compareCompatibleWithIgnoreCase((ShortString)string);
else if (string instanceof LongString)
return - ((LongString)string).compareCompatibleWithIgnoreCase(this);
else
throw new IllegalArgumentException();
return compareCompatibleWithIgnoreCase(string.getChars());
}
public int compareCompatibleWithIgnoreCase(ShortString other) throws CoreException {
Chunk chunk1 = db.getChunk(record);
Chunk chunk2 = other.db.getChunk(other.record);
@Override
public int compareCompatibleWithIgnoreCase(char[] other) throws CoreException {
return compareCompatibleWithIgnoreCase(getChars(), other);
}
long i1 = record + CHARS;
long i2 = other.record + CHARS;
long n1 = i1 + chunk1.getInt(record + LENGTH) * 2;
long n2 = i2 + chunk2.getInt(other.record + LENGTH) * 2;
public static int compareCompatibleWithIgnoreCase(final char[] chars, char[] other) {
final int n = Math.min(chars.length, other.length);
int sensitiveCmp= 0;
while (i1 < n1 && i2 < n2) {
final char c1= chunk1.getChar(i1);
final char c2= chunk2.getChar(i2);
for (int i=0; i<n; i++) {
final char c1= chars[i];
final char c2= other[i];
if (c1 != c2) {
int cmp= compareChars(c1, c2, false); // insensitive
if (cmp != 0)
@ -287,93 +193,40 @@ public class ShortString implements IString {
if (sensitiveCmp == 0) {
if (c1 < c2) {
sensitiveCmp= -1;
}
else {
} else {
sensitiveCmp= 1;
}
}
}
i1 += 2;
i2 += 2;
}
int cmp= chars.length - other.length;
if (cmp != 0)
return cmp;
if (i1 == n1 && i2 != n2)
return -1;
else if (i2 == n2 && i1 != n1)
return 1;
return sensitiveCmp;
}
public int compareCompatibleWithIgnoreCase(char[] chars) throws CoreException {
Chunk chunk1 = db.getChunk(record);
long i1 = record + CHARS;
int i2 = 0;
long n1 = i1 + chunk1.getInt(record + LENGTH) * 2;
int n2 = chars.length;
int sensitiveCmp= 0;
while (i1 < n1 && i2 < n2) {
final char c1= chunk1.getChar(i1);
final char c2= chars[i2];
if (c1 != c2) {
int cmp= compareChars(c1, c2, false); // insensitive
if (cmp != 0)
return cmp;
if (sensitiveCmp == 0) {
if (c1 < c2) {
sensitiveCmp= -1;
}
else {
sensitiveCmp= 1;
}
}
}
i1 += 2;
i2++;
}
if (i1 == n1 && i2 != n2)
return -1;
else if (i2 == n2 && i1 != n1)
return 1;
return sensitiveCmp;
}
@Override
public int comparePrefix(char[] other, boolean caseSensitive) throws CoreException {
Chunk chunk = db.getChunk(record);
return comparePrefix(getChars(), other, caseSensitive);
}
public static int comparePrefix(final char[] chars, char[] other, boolean caseSensitive) {
final int n = Math.min(chars.length, other.length);
long i1 = record + CHARS;
int i2 = 0;
long n1 = i1 + chunk.getInt(record + LENGTH) * 2;
int n2 = other.length;
while (i1 < n1 && i2 < n2) {
int cmp= compareChars(chunk.getChar(i1), other[i2], caseSensitive);
for (int i=0; i<n; i++) {
int cmp= compareChars(chars[i], other[i], caseSensitive);
if (cmp != 0)
return cmp;
i1 += 2;
++i2;
}
if (i1 == n1 && i2 != n2)
if (chars.length < other.length)
return -1;
else
return 0;
return 0;
}
public char charAt(int i) throws CoreException {
long ptr = record + CHARS + (i * 2);
return db.getChar(ptr);
}
public int getLength() throws CoreException {
return db.getInt(record + LENGTH);
public final int getLength() throws CoreException {
return Math.abs(db.getInt(record + LENGTH));
}
/**

View file

@ -87,6 +87,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
return IIndexCPPBindingConstants.CPP_CLASS_TEMPLATE;
}
@Override
public ICPPTemplateParameter[] getTemplateParameters() {
if (params == null) {
try {
@ -209,7 +210,8 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
getDB().putRecPtr(record + FIRST_PARTIAL, partial.getRecord());
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
@Override
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
try {
ArrayList<PDOMCPPClassTemplatePartialSpecialization> partials =
new ArrayList<PDOMCPPClassTemplatePartialSpecialization>();
@ -262,18 +264,22 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
return SemanticUtil.isSameOwner(getOwner(), ctype.getOwner());
}
@Override
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
return PDOMInstanceCache.getCache(this).getInstance(arguments);
}
@Override
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
PDOMInstanceCache.getCache(this).addInstance(arguments, instance);
}
@Override
public ICPPTemplateInstance[] getAllInstances() {
return PDOMInstanceCache.getCache(this).getAllInstances();
}
@Override
public ICPPTemplateParameter adaptTemplateParameter(ICPPTemplateParameter param) {
// Template parameters are identified by their position in the parameter list.
int pos = param.getParameterPosition();
@ -296,6 +302,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
return null;
}
@Override
public ICPPDeferredClassInstance asDeferredInstance() throws DOMException {
PDOMInstanceCache cache= PDOMInstanceCache.getCache(this);
synchronized (cache) {

View file

@ -11,7 +11,6 @@
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
@ -67,7 +66,7 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
}
@Override
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY;
}
@ -102,6 +101,7 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
return CPPClassTemplatePartialSpecialization.isSamePartialClassSpecialization(this, rhs);
}
@Override
public ICPPClassTemplate getPrimaryClassTemplate() {
if (fPrimaryTemplate == null) {
try {
@ -114,6 +114,7 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
return fPrimaryTemplate;
}
@Override
public void setArguments(ICPPTemplateArgument[] templateArguments) throws CoreException {
final Database db = getPDOM().getDB();
long oldRec = db.getRecPtr(record+ARGUMENTS);
@ -124,6 +125,7 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
}
}
@Override
public ICPPTemplateArgument[] getTemplateArguments() {
try {
final long rec= getPDOM().getDB().getRecPtr(record+ARGUMENTS);
@ -134,6 +136,7 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla
}
}
@Override
@Deprecated
public IType[] getArguments() {
return CPPTemplates.getArguments(getTemplateArguments());

View file

@ -64,19 +64,23 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
return IIndexCPPBindingConstants.CPP_CLASS_TEMPLATE_SPECIALIZATION;
}
@Override
public ICPPTemplateParameter[] getTemplateParameters() {
ICPPClassTemplate template = (ICPPClassTemplate) getSpecializedBinding();
return template.getTemplateParameters();
}
@Override
public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
return PDOMInstanceCache.getCache(this).getInstance(arguments);
}
@Override
public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
PDOMInstanceCache.getCache(this).addInstance(arguments, instance);
}
@Override
public ICPPTemplateInstance[] getAllInstances() {
return PDOMInstanceCache.getCache(this).getAllInstances();
}
@ -153,7 +157,8 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
return ((ICPPClassType) owner1).isSameType((ICPPClassType) owner2);
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
@Override
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() {
ICPPClassTemplate origTemplate= (ICPPClassTemplate) getSpecializedBinding();
ICPPClassTemplatePartialSpecialization[] orig = origTemplate.getPartialSpecializations();
ICPPClassTemplatePartialSpecialization[] spec = new ICPPClassTemplatePartialSpecialization[orig.length];
@ -163,6 +168,7 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization
return spec;
}
@Override
public ICPPDeferredClassInstance asDeferredInstance() throws DOMException {
PDOMInstanceCache cache= PDOMInstanceCache.getCache(this);
synchronized (cache) {

View file

@ -2623,61 +2623,91 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
return formatOverloadedLeftShiftChain(node);
}
// To improve speed of the algorithm we flatten homogeneous nested binary expressions
// to reduce overall depth of the expression tree.
List<IASTExpression> operands = getOperandsOfMultiExpression(node);
Runnable tailFormatter = endsWithMacroExpansion(node) ? null : scribe.takeTailFormatter();
Alignment expressionAlignment= scribe.createAlignment(
Alignment alignment= scribe.createAlignment(
Alignment.BINARY_EXPRESSION,
preferences.alignment_for_binary_expression,
Alignment.R_OUTERMOST,
2,
operands.size(),
scribe.scanner.getCurrentPosition());
scribe.enterAlignment(expressionAlignment);
scribe.enterAlignment(alignment);
boolean ok = false;
do {
try {
final IASTExpression op1= node.getOperand1();
// Left operand
op1.accept(this);
scribe.printTrailingComment();
for (int i = 0; i < operands.size(); i++) {
final IASTExpression operand = operands.get(i);
// In case of macros we may have already passed the operator position.
if (i > 0 && scribe.scanner.getCurrentPosition() < operand.getFileLocation().getNodeOffset()) {
scribe.alignFragment(alignment, i);
// In case of macros we may have already passed the operator position.
if (scribe.scanner.getCurrentPosition() < node.getOperand2().getFileLocation().getNodeOffset()) {
scribe.alignFragment(expressionAlignment, 1);
// Operator
final int nextToken= peekNextToken();
// In case of C++ alternative operators, like 'and', 'or', etc. a space
boolean forceSpace= Character.isJavaIdentifierStart(peekNextChar());
// Operator
final int nextToken= peekNextToken();
// In case of C++ alternative operators, like 'and', 'not', etc. a space
boolean forceSpace= Character.isJavaIdentifierStart(peekNextChar());
switch (node.getOperator()) {
case IASTBinaryExpression.op_pmdot:
case IASTBinaryExpression.op_pmarrow:
scribe.printNextToken(nextToken, false);
break;
switch (node.getOperator()) {
case IASTBinaryExpression.op_pmdot:
case IASTBinaryExpression.op_pmarrow:
scribe.printNextToken(nextToken, false);
break;
default:
scribe.printNextToken(nextToken, forceSpace || preferences.insert_space_before_binary_operator);
if (forceSpace || preferences.insert_space_after_binary_operator) {
scribe.space();
}
}
}
default:
scribe.printNextToken(nextToken, forceSpace || preferences.insert_space_before_binary_operator);
if (forceSpace || preferences.insert_space_after_binary_operator) {
scribe.space();
}
}
scribe.printTrailingComment();
}
if (i == alignment.fragmentCount - 1) {
scribe.setTailFormatter(tailFormatter);
}
operand.accept(this);
scribe.restartAtOffset(getNodeEndLocation(operand));
scribe.printTrailingComment();
}
// Right operand
final IASTExpression op2= node.getOperand2();
op2.accept(this);
if (tailFormatter != null)
tailFormatter.run();
scribe.runTailFormatter();
ok = true;
} catch (AlignmentException e) {
scribe.redoAlignment(e);
}
} while (!ok);
scribe.exitAlignment(expressionAlignment, true);
scribe.exitAlignment(alignment, true);
return PROCESS_SKIP;
}
/**
* Traverses a chain of nested homogeneous left-to-right-associative binary expressions and
* returns a list of their operands in left-to-right order. For example, for the expression
* a + b * c + d, it will return a list containing expressions: a, b * c, and d.
*
* @param binaryExpression the top-level binary expression
* @return a list of expression operands from left to right
*/
private List<IASTExpression> getOperandsOfMultiExpression(IASTBinaryExpression binaryExpression) {
int operator = binaryExpression.getOperator();
List<IASTExpression> operands = new ArrayList<IASTExpression>(2);
IASTExpression node;
do {
operands.add(binaryExpression.getOperand2());
node = binaryExpression.getOperand1();
if (!(node instanceof IASTBinaryExpression)) {
break;
}
binaryExpression = (IASTBinaryExpression) node;
} while (binaryExpression.getOperator() == operator);
operands.add(node);
Collections.reverse(operands);
return operands;
}
private int formatAssignment(IASTBinaryExpression node) {
Runnable tailFormatter = scribe.takeTailFormatter();
final IASTExpression op1= node.getOperand1();

View file

@ -311,7 +311,7 @@ public class Alignment {
this.fragmentIndentations[i] = this.breakIndentationLevel;
return wasSplit = true;
}
} while (--i >= 0);
} while ((this.fragmentBreaks[i] != BREAK || (this.mode & M_INDENT_ON_COLUMN) != 0) && --i >= 0);
break;
/* # aligned fragment

View file

@ -29,4 +29,4 @@ ProcessRunner.argumentsMismatch=Argument type mismatch:
ProcessRunner.error=-->Error:
ProcessRunner.success=-->Success:
ProcessRunner.info=-->Info:
ProcessHelper.fileNotFound=File not found:
ProcessHelper.fileNotFound=File not found: ''{0}''

View file

@ -6,8 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bala Torati (Symbian) - Initial API and implementation
* Mark Espiritu (VastSystems) - bug 215283
* Bala Torati (Symbian) - Initial API and implementation
* Mark Espiritu (VastSystems) - bug 215283
* Raphael Zulliger (Indel AG) - [367482] fixed resource leak
*******************************************************************************/
package org.eclipse.cdt.core.templateengine.process;
@ -20,7 +21,6 @@ import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.net.URL;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@ -29,9 +29,10 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import com.ibm.icu.text.MessageFormat;
/**
* Acts as Helper class for process the processes i.e., copy, replace and append
* files.
* Acts as helper class for process the processes i.e., copy, replace and append files.
*/
public class ProcessHelper {
public static final String CONDITION = "condition"; //$NON-NLS-1$
@ -45,15 +46,15 @@ public class ProcessHelper {
*
* @param fileContents contents which are appended to the file.
* @param toFile a file to append contents.
* @throws IOException,
* exception while writing contents into a file
*
* @throws IOException exception while writing contents into a file
* @since 4.0
*/
public static void appendFile(String fileContents, File toFile) throws IOException {
RandomAccessFile raf = null;
if (!toFile.exists()) {
throw new FileNotFoundException(" The specified destination file does not exists "); //$NON-NLS-1$
throw new FileNotFoundException(MessageFormat.format(
TemplateEngineMessages.getString("ProcessHelper.fileNotFound"), //$NON-NLS-1$
toFile.getPath()));
} else {
try {
raf = new RandomAccessFile(toFile, "rw"); //$NON-NLS-1$
@ -69,7 +70,7 @@ public class ProcessHelper {
/**
* This method returns a vector of all replace marker strings. (e.g.,
* $(item), vector contains 'item' as one item. , ) is the end pattern.
* $(item), vector contains 'item' as one item) is the end pattern.
*
* @param str A given string possibly containing markers.
* @return the set of names occurring within markers
@ -77,14 +78,16 @@ public class ProcessHelper {
*/
public static Set<String> getReplaceKeys(String str) {
Set<String> replaceStrings = new HashSet<String>();
int start= 0, end= 0;
int start= 0;
int end= 0;
while ((start = str.indexOf(START_PATTERN, start)) >= 0) {
end = str.indexOf(END_PATTERN, start);
if (end != -1) {
replaceStrings.add(str.substring(start + START_PATTERN.length(), end));
start = end + END_PATTERN.length();
} else
} else {
start++;
}
}
return replaceStrings;
}
@ -93,19 +96,18 @@ public class ProcessHelper {
* This method takes a URL as parameter to read the contents, and to add
* into a string buffer.
*
* @param source
* URL to read the contents.
* @return string, contents of a file specified in the URL source path.
* @throws IOException
*
* @param source URL to read the contents.
* @return string contents of a file specified in the URL source path.
* @since 4.0
*/
public static String readFromFile(URL source) throws IOException {
char[] chars = new char[4092];
InputStreamReader contentsReader = null;
StringBuffer buffer = new StringBuffer();
StringBuilder buffer = new StringBuilder();
if (!new java.io.File(source.getFile()).exists()) {
throw new FileNotFoundException(TemplateEngineMessages.getString("ProcessHelper.fileNotFound") + source.getFile()); //$NON-NLS-1$
throw new FileNotFoundException(MessageFormat.format(
TemplateEngineMessages.getString("ProcessHelper.fileNotFound"), //$NON-NLS-1$
source.getFile()));
} else {
contentsReader = new InputStreamReader(source.openStream());
int c;
@ -124,12 +126,8 @@ public class ProcessHelper {
* This method reads contents from source, and writes the contents into
* destination file.
*
* @param source
* URL to read the contents.
* @param dest
* destination file to write the contents.
* @throws IOException
*
* @param source URL to read the contents.
* @param dest destination file to write the contents.
* @since 4.0
*/
public static void copyBinaryFile(URL source, File dest) throws IOException {
@ -137,22 +135,30 @@ public class ProcessHelper {
if (source != null && dest != null) {
File file = new File(source.getFile());
if (file.isFile()) {
FileInputStream fis = new FileInputStream(file);
FileOutputStream fos = new FileOutputStream(dest);
int ch;
while (true) {
ch = fis.read(bytes);
if (ch == -1) {
break;
FileInputStream in = null;
FileOutputStream out = null;
try {
in = new FileInputStream(file);
out = new FileOutputStream(dest);
int len;
while ((len = in.read(bytes)) != -1) {
out.write(bytes, 0, len);
}
} finally {
try {
if (in != null)
in.close();
} finally {
if (out != null)
out.close();
}
fos.write(bytes, 0, ch);
}
}
}
}
/**
* This method Creates the Directories in the parent Folder.
* This method creates the directories in the parent folder.
* @param projectHandle
* @param parentFolder
* @throws CoreException
@ -169,18 +175,17 @@ public class ProcessHelper {
parentFolder.create(true, true, null);
}
/**
* @param string
* @param macros
* @param valueStore
* @return the Macro Value after expanding the Macros.
* @return the macro value after expanding the macros.
*
* @since 4.0
*/
public static String getValueAfterExpandingMacros(String string, Set<String> macros, Map<String, String> valueStore) {
for (Iterator<String> i = macros.iterator(); i.hasNext();) {
String key = i.next();
public static String getValueAfterExpandingMacros(String string, Set<String> macros,
Map<String, String> valueStore) {
for (String key : macros) {
String value = valueStore.get(key);
if (value != null) {
string = string.replace(START_PATTERN + key + END_PATTERN, value);

View file

@ -467,14 +467,14 @@ public:
return name;
}
int getSystemId() const {
return systemId;
}
void setName(char* name) {
this->name = name;
}
int getSystemId() const {
return systemId;
}
void setSystemId(int systemId) {
this->systemId = systemId;
}
@ -542,14 +542,14 @@ public:
return i;
}
bool isOk() const {
return ok;
}
void setI(int i) {
this->i = i;
}
bool isOk() const {
return ok;
}
void setOk(bool ok) {
this->ok = ok;
}
@ -1173,7 +1173,6 @@ private:
};
#endif /* A_H_ */
//=
#ifndef A_H_
#define A_H_
@ -1195,9 +1194,7 @@ inline void Person::setId(int id) {
this->id = id;
}
#endif /* A_H_ */
//!No Methods Separate Definition
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
//@.config
@ -1248,7 +1245,6 @@ inline void test::setI(int i) {
this->i = i;
}
#endif /* TEST_H_ */
//!Bug 323780 "Generate Getters and Setters..." crashes
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
@ -1349,7 +1345,6 @@ public:
//@Test.cxx
//=
int Test::getTestField() const {
return testField;
}
@ -1390,7 +1385,6 @@ public:
//@component_b/implementation/Test.cpp
//=
int Test::getTestField() const {
return testField;
}
@ -1451,7 +1445,7 @@ public:
int test;
};
#endif /* A_H_ */
//!Bug ??? - Getter for an array field
//!Bug 319278 - Getter for an array field
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
//@.config
filename=A.h
@ -1479,3 +1473,36 @@ public:
}
};
#endif /* A_H_ */
//!Bug 352258 - Avoiding reserved names
//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest
//@.config
filename=A.h
getters=mClass
setters=mClass
//@A.h
#ifndef A_H_
#define A_H_
class getClass {
private:
int /*$*/mClass/*$$*/;
};
#endif /* A_H_ */
//=
#ifndef A_H_
#define A_H_
class getClass {
private:
int mClass;
public:
int getClass1() const {
return mClass;
}
void setClass(int _class) {
mClass = _class;
}
};
#endif /* A_H_ */

View file

@ -17,8 +17,6 @@ public:
inline bool X::a(int int1) const {
}
//!Param const and reference and pointer two params
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -38,8 +36,6 @@ public:
inline bool X::xy(int int1, int i) const {
}
//!Test if TemplateMethod stays in header
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -62,15 +58,13 @@ public:
template<class T>
inline void A<T>::test() {
}
//@A.cpp
#include "A.h"
//=
#include "A.h"
//!class template member functions
//!Class template member functions
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
@ -102,9 +96,7 @@ A<T>::A() {
template<class T>
inline void A<T>::test() {
}
//!member class
//!Member class
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
@ -144,8 +136,6 @@ public:
inline void A::test() {
}
//!Method declared in otherwise empty class
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -165,7 +155,6 @@ public:
//@A.cpp
//=
void A::test() {
}
//!Implement in existing namespace
@ -205,7 +194,7 @@ void ClassInNamespace::test2() {
}
}
//!virtual method in the middle of con/destructor, without parameters and void return value
//!Virtual method in the middle of con/destructor, without parameters and void return value
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
@ -287,8 +276,6 @@ A::A() {
void A::foo() {
}
//!Method at beginning, without parameters, void return value and const
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -348,8 +335,6 @@ A::A() {
int A::foo() {
}
//!Method with two int parameters
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -379,8 +364,6 @@ A::A() {
int A::foo(int param1, int param2) {
}
//!Method defined in header
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -408,8 +391,6 @@ A::A() {
inline void A::test() {
}
//!Implement a function at end of source file
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -426,7 +407,6 @@ void function_with_impl() {
void function() {
}
//!Implement with namespace
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -453,7 +433,6 @@ void Namespace::ClassInNamespace::other_test() {
void Namespace::ClassInNamespace::test() {
}
//!Implement function within namespace
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -524,7 +503,7 @@ int test2() {
}
}
//!class template member functions with multiple templates
//!Class template member functions with multiple templates
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
@ -538,7 +517,7 @@ public:
};
template<class T, class U>
A<T,U>::A() {
A<T, U>::A() {
}
//=
@ -550,15 +529,13 @@ public:
};
template<class T, class U>
A<T,U>::A() {
A<T, U>::A() {
}
template<class T, class U>
inline void A<T, U>::test() {
}
//!with default parameters
//!With default parameters
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
@ -578,7 +555,7 @@ public:
void Class::test(int param1, int param2, int param3) {
}
//!static method
//!Static method
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
@ -672,7 +649,6 @@ class TestClass {
inline void nspace::TestClass::testMethod() {
}
#endif /* TESTCLASS_H_ */
//!Bug 290110 Source-> Implement Method
@ -736,8 +712,6 @@ A::~A() {
void n1::n2::A::B::testmethod2() {
}
//!Bug 337040 - Insert definition in empty implementation file (.cxx)
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -753,7 +727,6 @@ public:
//@A.cxx
//=
void TestClass::foo() {
}
//!Bug 355006 - NPE implementing template function
@ -773,7 +746,6 @@ void func(T&);
template<typename T>
inline void func(T&) {
}
//!Bug 363111 - Remove explicit in constructor definition
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
@ -789,6 +761,5 @@ public:
//@A.cpp
//=
TestClass::TestClass() {
}

View file

@ -18,7 +18,6 @@ inline void A::member() {
// return comment
return;
}
//!ClassToHeaderTopCommentOrder
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -41,7 +40,6 @@ class A {
inline void A::member() {
return;
}
//!ClassToHeaderCatchComment
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -68,7 +66,6 @@ try {
catch (int i) {
// catch comment
}
//!ClassToHeaderTopComment
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -89,7 +86,6 @@ class A {
inline void A::member() {
return;
}
//!ClassToHeaderTemplateTopComment
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -114,7 +110,6 @@ template<typename T>
inline T A::member() {
return T();
}
//!ClassToHeaderTrailingComment
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -133,7 +128,6 @@ class A {
inline void A::member() {
return;
} // Trailing comment
//!ClassToHeaderTrailingCommentWithTryBlock
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config

View file

@ -93,7 +93,6 @@ void /*$*/member/*$$*/() {
//@A.h
//=
void member() {
// body comment
return;
@ -115,7 +114,6 @@ void /*$*/member/*$$*/() {
//@A.h
//=
// Top comment
void member() {
// body comment

View file

@ -34,7 +34,6 @@ public:
inline A::A(int x, int y) :
a(x), b(y) {
}
//!TestConstructorToggleInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -85,7 +84,6 @@ int main() {
A::A(int x, int y) :
a(x), b(y) {
}
//!TestConstructorToggleInImplementationToClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -154,7 +152,6 @@ public:
inline A::~A() {
}
//!TestDestructorToggleInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -199,7 +196,6 @@ int main() {
A::~A() {
}
//!TestDestructorToggleInImplementationToClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config

View file

@ -20,7 +20,6 @@ class A {
inline void A::member(int a, int b) {
return;
}
//!TestDefaultParameterInitializerInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -57,7 +56,6 @@ int main() {
void A::member(int a, int b) {
return;
}
//!TestDefaultParameterInitializerInImplementationToClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config

View file

@ -54,7 +54,6 @@ int main() {
int freeFunction(int* a, int& b) {
return 42;
}
//!TestFreeFunctionToggleFromImplementationToHeaderWithDeclaration
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -172,7 +171,6 @@ try {
}
catch (std::exception& e) {
}
//!TestFreeFunction
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -260,4 +258,3 @@ void freefunction() {
}
}

View file

@ -1,4 +1,4 @@
//!TestSimpleNamespaceInClassToInHeader
//!Test simple namespace in class to in header
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -30,7 +30,7 @@ inline void A::foo() {
}
}
//!TestSimpleNamespaceInHeaderToImplementationWithinNSDefinition
//!Test simple namespace in header to implementation within namespace definition
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -80,8 +80,7 @@ void A::foo() {
}
}
//!TestSimpleNamespaceInHeaderToImplementationWithNSDefinitionInImpl
//!Test simple namespace in header to implementation with namespace definition in implementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -134,7 +133,7 @@ void A::foo() {
}
}
//!TestSimpleNamespaceInHeaderToImplementationWithNamespaceQualifiedName
//!Test simple namespace in header to implementation with namespace qualified name
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -184,7 +183,6 @@ void A::foo() {
}
}
//!TestSimpleNamespaceFromImplementationToInHeader
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config

View file

@ -24,7 +24,6 @@ class A {
inline void A::B::member(int a, int b) {
return;
}
//!TestNestedClassInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -65,7 +64,6 @@ int main() {
void A::B::member(int a, int b) {
return;
}
//!TestNestedClassInImplementationToClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config

View file

@ -1,4 +1,4 @@
//!TestZeroLengthSelection
//!Test zero length selection
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -16,8 +16,7 @@ class A {
inline void A::member() {
return;
}
//!TestSubstringSelection
//!Test substring selection
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -35,8 +34,7 @@ class A {
inline void A::member() {
return;
}
//!TestBodySelection
//!Test body selection
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -54,8 +52,7 @@ class A {
inline void A::member() {
return;
}
//!TestBodySelectionWithConfusingName
//!Test body selection with confusing name
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -75,8 +72,7 @@ inline void A::member() {
int abcd = 42;
return;
}
//!TestLeftBorderSelection
//!Test left border selection
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -94,8 +90,7 @@ class A {
inline void A::member() {
return;
}
//!TestRightBorderSelection
//!Test right border selection
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -113,8 +108,7 @@ class A {
inline void A::member() {
return;
}
//!TestOverlappingSelection
//!Test overlapping selection
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -132,4 +126,3 @@ class A {
inline void A::member() {
return;
}

View file

@ -1,4 +1,4 @@
//!TestSimpleFunctionInClassToInHeader
//!Test simple function in class to in header
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -28,8 +28,7 @@ private:
inline int A::function() {
return 0;
}
//!TestSimpleFunctionInHeaderToImplementation
//!Test simple function in header to implementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -73,7 +72,6 @@ int main() {
int A::function() {
return 0;
}
//!TestSimpleFunctionInImplementationToInClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config

View file

@ -1,4 +1,4 @@
//!TestTemplateFunctionInClassToInHeader
//!Test template function in class to in header
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -27,8 +27,7 @@ template<typename T, typename U>
inline T A<T, U>::B::member() {
return T();
}
//!TestTemplateFunctionInHeaderToInClass
//!Test template function in header to in class
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -57,7 +56,7 @@ class A {
}
};
};
//!TestTemplateFunctionInHeaderToInClassWithTemplateSelected
//!Test template function in header to in class with template selected
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -78,8 +77,7 @@ template<typename T>
inline T A::foo() {
return T();
}
//!TestComplexTemplateFunctionFromInClassToInheader
//!Test complex template function from in class to in header
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h
@ -105,8 +103,7 @@ template<typename U, typename V>
inline void A<T, S>::foo(const U& u, const V& v) {
return;
}
//!TestComplexTemplateFunctionFromInHeaderToInClass
//!Test complex template function from in header to in class
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
filename=A.h

View file

@ -30,7 +30,6 @@ try {
catch (std::exception& e1) {
return;
}
//!TestTryCatchFromInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -77,7 +76,6 @@ try {
catch (std::exception& e1) {
return;
}
//!TestTryCatchFromInImplementationToClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -160,7 +158,6 @@ catch (std::exception& e1) {
catch (std::exception& e2) {
return;
}
//!TestMultipleTryCatchFromInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -213,7 +210,6 @@ catch (std::exception& e1) {
catch (std::exception& e2) {
return;
}
//!TestMultipleTryCatchFromInImplementationToClass
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config
@ -263,4 +259,4 @@ class A {
catch (std::exception& e2) {
return;
}
};
};

View file

@ -18,7 +18,6 @@ class A {
inline int A::foo() {
return 0;
}
//!TestVirtualSpecifierFromInHeaderToImplementation
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//%CPP
@ -52,7 +51,6 @@ int main() {
int A::foo() {
return 0;
}
//!TestVirtualSpecifierFromImplementationToHeader
//#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest
//@.config

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bala Torati (Symbian) - Initial API and implementation
* Bala Torati (Symbian) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.tests.templateengine;
package org.eclipse.cdt.ui.tests.templateengine;
import junit.framework.Test;
import junit.framework.TestSuite;
@ -20,7 +20,6 @@ import junit.framework.TestSuite;
*
* @since 4.0
*/
public class AllTemplateEngineTests extends TestSuite {
public static void main(String[] args) {
@ -31,7 +30,7 @@ public class AllTemplateEngineTests extends TestSuite {
* Since the TemplateEngine consists of UI(Wizard).
* A TestWizard is created to which the dynamically generated
* UIPages are added. The Wizard is launched from here.
* The TestCases created to test the TemplateEngine is initialised here.
* The TestCases created to test the TemplateEngine is initialized here.
* @return
*
* @since 4.0

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bala Torati (Symbian) - Initial API and implementation
* Bala Torati (Symbian) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.tests.templateengine;
package org.eclipse.cdt.ui.tests.templateengine;
import java.io.IOException;
import java.net.URL;
@ -34,26 +34,22 @@ import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
/**
*
* All supporting functions which are not part of Testing class.
*
* @since 4.0
*/
public class TemplateEngineTestsHelper {
public static final String LOGGER_FILE_NAME="TemplateEngineTests"; //$NON-NLS-1$
public static final String LOGGER_FILE_NAME = "TemplateEngineTests"; //$NON-NLS-1$
/**
* get the url of a xml template, by passing the xml file name.
* Returns the url of a xml template, by passing the xml file name.
* @param templateName
* @return URL
*/
public static URL getTemplateURL(String templateName){
Bundle bundle = Platform.getBundle(CTestPlugin.PLUGIN_ID);
URL url = FileLocator.find(bundle, new Path("resources/templateengine/"+templateName), null); //$NON-NLS-1$
if ( url != null )
{
URL url = FileLocator.find(bundle, new Path("resources/templateengine/" + templateName), null); //$NON-NLS-1$
if (url != null) {
try {
url = FileLocator.toFileURL(url);
} catch (IOException e) {
@ -65,19 +61,19 @@ public class TemplateEngineTestsHelper {
public static TemplateCore[] getTestTemplates() {
TemplateCore[] templates = TemplateEngine.getDefault().getTemplates();
List testTemplates = new ArrayList();
for (int i =0; i < templates.length; i++) {
List<TemplateCore> testTemplates = new ArrayList<TemplateCore>();
for (int i = 0; i < templates.length; i++) {
if (templates[i].getTemplateType().equals("TestTemplate")) {
testTemplates.add(templates[i]);
}
}
return (TemplateCore[]) testTemplates.toArray(new TemplateCore[testTemplates.size()]);
return testTemplates.toArray(new TemplateCore[testTemplates.size()]);
}
public static int getChildCount(TemplateDescriptor templateDescriptor, String propertyGroupID){
List list = templateDescriptor.getPropertyGroupList();
List<Element> list = templateDescriptor.getPropertyGroupList();
for (int i = 0, l = list.size(); i < l; i++) {
Element element = (Element) list.get(i);
Element element = list.get(i);
NamedNodeMap attributes = element.getAttributes();
for (int j = 0, l1 = attributes.getLength(); j < l1; j++) {
String value = attributes.item(j).getNodeValue();
@ -90,7 +86,7 @@ public class TemplateEngineTestsHelper {
}
public static boolean failIfErrorStatus(IStatus[] statuses) {
for(int i=0; i<statuses.length; i++) {
for(int i = 0; i < statuses.length; i++) {
IStatus status = statuses[i];
if (status.getCode() == IStatus.ERROR) {
Assert.fail(status.getMessage());
@ -112,5 +108,4 @@ public class TemplateEngineTestsHelper {
workspaceDesc.setAutoBuilding(false);
workspace.setDescription(workspaceDesc);
}
}

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Ferguson (Symbian) - Initial API and implementation
* Andrew Ferguson (Symbian) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.ui.tests.templateengine;
@ -49,7 +49,7 @@ public class TestExtraPagesProvider implements IPagesAfterTemplateSelectionProvi
* An example implementation of {@link IWizardDataPage} for test purposes.
*/
static class MyPage extends AbstractWizardDataPage implements IWizardDataPage {
String labelText , dataKey, dataValue;
String labelText, dataKey, dataValue;
public MyPage(String labelText, String dataKey, String dataValue) {
super("CustomTestPageName", "Title", null);
@ -59,7 +59,7 @@ public class TestExtraPagesProvider implements IPagesAfterTemplateSelectionProvi
this.dataValue= dataValue;
}
public Map getPageData() {
public Map<String, String> getPageData() {
return Collections.singletonMap(dataKey, dataValue);
}

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bala Torati (Symbian) - Initial API and implementation
* Bala Torati (Symbian) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.tests.templateengine;
package org.eclipse.cdt.ui.tests.templateengine;
import java.io.File;
import java.util.Map;
@ -28,7 +28,6 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
public class TestProcesses extends BaseTestCase {
private static final String workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toOSString();
private static final String PROJECT_NAME = "TemplateEngineTestsProject"; //$NON-NLS-1$
private static final String SOURCE_FOLDER = "Source"; //$NON-NLS-1$
@ -63,7 +62,7 @@ public class TestProcesses extends BaseTestCase {
public void testAddFile() {
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AddFile"); //$NON-NLS-1$
Map valueStore = template.getValueStore();
Map<String, String> valueStore = template.getValueStore();
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
@ -84,7 +83,7 @@ public class TestProcesses extends BaseTestCase {
public void testAddFiles() {
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AddFiles"); //$NON-NLS-1$
Map valueStore = template.getValueStore();
Map<String, String> valueStore = template.getValueStore();
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
@ -105,7 +104,7 @@ public class TestProcesses extends BaseTestCase {
public void testAddLink() {
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AddLink"); //$NON-NLS-1$
Map valueStore = template.getValueStore();
Map<String, String> valueStore = template.getValueStore();
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
@ -131,7 +130,7 @@ public class TestProcesses extends BaseTestCase {
public void testAppend() {
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*Append"); //$NON-NLS-1$
Map valueStore = template.getValueStore();
Map<String, String> valueStore = template.getValueStore();
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
@ -160,7 +159,7 @@ public class TestProcesses extends BaseTestCase {
public void testAppendCreate() {
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AppendCreate"); //$NON-NLS-1$
Map valueStore = template.getValueStore();
Map<String, String> valueStore = template.getValueStore();
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
@ -184,7 +183,7 @@ public class TestProcesses extends BaseTestCase {
public void testCopy() {
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*Copy"); //$NON-NLS-1$
Map valueStore = template.getValueStore();
Map<String, String> valueStore = template.getValueStore();
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
@ -213,7 +212,7 @@ public class TestProcesses extends BaseTestCase {
public void testCreateResourceIdentifier() {
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*CreateResourceIdentifier"); //$NON-NLS-1$
Map valueStore = template.getValueStore();
Map<String, String> valueStore = template.getValueStore();
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$
@ -237,7 +236,7 @@ public class TestProcesses extends BaseTestCase {
public void testCreateSourceFolder() {
TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*CreateSourceFolder"); //$NON-NLS-1$
Map valueStore = template.getValueStore();
Map<String, String> valueStore = template.getValueStore();
valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$
valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$
valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$

View file

@ -6,10 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bala Torati (Symbian) - Initial API and implementation
* Bala Torati (Symbian) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.tests.templateengine;
package org.eclipse.cdt.ui.tests.templateengine;
import java.util.Iterator;
import java.util.Map;
@ -18,7 +17,6 @@ import java.util.Set;
import org.eclipse.cdt.core.templateengine.SharedDefaults;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
/**
* Executes all the test cases of SharedDefaults backend functionality
*/
@ -36,7 +34,6 @@ public class TestSharedDefaults extends BaseTestCase {
/*
* @see TestCase#tearDown()
*/
protected void tearDown(){
sharedDefaults = null;
}
@ -45,47 +42,39 @@ public class TestSharedDefaults extends BaseTestCase {
* This test checks if data gets added to the back end
* New data gets persisted in SharedDefault XML file
*/
public void testAddToBackEndStorage() {
Map actualSharedDefaults=sharedDefaults.getSharedDefaultsMap();
Map<String, String> actualSharedDefaults= sharedDefaults.getSharedDefaultsMap();
actualSharedDefaults.put("provider.name","eclipse"); //$NON-NLS-1$ //$NON-NLS-2$
actualSharedDefaults.put("copyright","Symbian Software Ltd."); //$NON-NLS-1$ //$NON-NLS-2$
actualSharedDefaults.put("author","Bala Torati"); //$NON-NLS-1$ //$NON-NLS-2$
Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap();
Map<String, String> expectedSharedDefaults= sharedDefaults.getSharedDefaultsMap();
assertEquals("Contents are different :", //$NON-NLS-1$
expectedSharedDefaults,
actualSharedDefaults);
}
/**
* This tests the updateToBackEndStorage of SharedDefaults
* to verify whether the key-value pair gets updated with new value
* New data gets persisted in SharedDefault XML file
*/
public void testUpdateToBackEndStorage() {
Map actualSharedDefaults = sharedDefaults.getSharedDefaultsMap();
Set keySet = actualSharedDefaults.keySet();
Iterator iterator = keySet.iterator();
Map<String, String> actualSharedDefaults = sharedDefaults.getSharedDefaultsMap();
while (iterator.hasNext()) {
Object key = iterator.next();
Object value = actualSharedDefaults.get(key);
String keyName = (String)key;
String valueName = (String)value;
if (keyName.equals("org.eclipse.cdt.templateengine.project.HelloWorld.basename")){ //$NON-NLS-1$
valueName = "Astala Vista"; //$NON-NLS-1$
actualSharedDefaults.put(keyName, valueName);
sharedDefaults.updateToBackEndStorage("org.eclipse.cdt.templateengine.project.HelloWorld.basename", valueName); //$NON-NLS-1$
for (Map.Entry<String, String> entry : actualSharedDefaults.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.equals("org.eclipse.cdt.templateengine.project.HelloWorld.basename")) { //$NON-NLS-1$
entry.setValue("Astala Vista"); //$NON-NLS-1$
sharedDefaults.updateToBackEndStorage("org.eclipse.cdt.templateengine.project.HelloWorld.basename", value); //$NON-NLS-1$
break;
}
}
Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap();
Map<String, String> expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap();
assertEquals("Contents are different :", //$NON-NLS-1$
expectedSharedDefaults,
@ -96,25 +85,23 @@ public class TestSharedDefaults extends BaseTestCase {
* This tests the deleteBackEndStorage of SharedDefaults
* to verify whether the key-value pair gets deleted at the backend
*/
public void testDeleteBackEndStorage() {
Map actualSharedDefaults=sharedDefaults.getSharedDefaultsMap();
Set keySet = actualSharedDefaults.keySet();
Iterator iterator = keySet.iterator();
Map<String, String> actualSharedDefaults= sharedDefaults.getSharedDefaultsMap();
Set<String> keySet = actualSharedDefaults.keySet();
Iterator<String> iterator = keySet.iterator();
String keyName = null;
while (iterator.hasNext()) {
Object key = iterator.next();
keyName = (String)key;
String key = iterator.next();
keyName = key;
if (keyName.equals("org.eclipse.cdt.templateengine.project.HelloWorld.basename")) { //$NON-NLS-1$
actualSharedDefaults.remove(keyName);
break;
}
}
sharedDefaults.deleteBackEndStorage(new String[]{keyName});
Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap();
sharedDefaults.deleteBackEndStorage(new String[] { keyName });
Map<String, String> expectedSharedDefaults= sharedDefaults.getSharedDefaultsMap();
assertEquals("Contents are different :", //$NON-NLS-1$
expectedSharedDefaults,

View file

@ -8,7 +8,7 @@
* Contributors:
* Bala Torati (Symbian) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.tests.templateengine;
package org.eclipse.cdt.ui.tests.templateengine;
import org.eclipse.cdt.core.templateengine.TemplateCore;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bala Torati (Symbian) - Initial API and implementation
* Bala Torati (Symbian) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.tests.templateengine;
package org.eclipse.cdt.ui.tests.templateengine;
import org.eclipse.cdt.core.templateengine.TemplateEngine;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
@ -17,8 +17,6 @@ import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
* Test the functionality of TemplateEngine.
*/
public class TestTemplateEngine extends BaseTestCase {
TemplateEngine templateEngine = null;
/*
@ -26,7 +24,6 @@ public class TestTemplateEngine extends BaseTestCase {
*/
protected void setUp() throws Exception {
super.setUp();
templateEngine = TemplateEngine.getDefault();
}
@ -59,5 +56,4 @@ public class TestTemplateEngine extends BaseTestCase {
public void testSingleton() {
assertSame(templateEngine, TemplateEngine.getDefault());
}
}

View file

@ -8,7 +8,7 @@
* Contributors:
* Andrew Ferguson (Symbian) - Initial Implementation
*******************************************************************************/
package org.eclipse.cdt.core.tests.templateengine;
package org.eclipse.cdt.ui.tests.templateengine;
import java.util.Arrays;
import java.util.HashSet;

View file

@ -6,9 +6,9 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Bala Torati (Symbian) - Initial API and implementation
* Bala Torati (Symbian) - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.tests.templateengine;
package org.eclipse.cdt.ui.tests.templateengine;
import java.util.Iterator;
import java.util.Map;
@ -17,13 +17,10 @@ import org.eclipse.cdt.core.templateengine.TemplateCore;
import org.eclipse.cdt.core.templateengine.TemplateDescriptor;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
/**
* Test the functionality of the ValueStore class.
*/
public class TestValueStore extends BaseTestCase {
/**
* setUp is called before execution of test method.
*/
@ -44,12 +41,11 @@ public class TestValueStore extends BaseTestCase {
/**
* Test ValueStore for Not Null condition.
*
*/
public void testValueStoreNotNull(){
TemplateCore[] templates = TemplateEngineTestsHelper.getTestTemplates();
for (int i=0; i <templates.length; i++) {
Map valueStore = templates[i].getValueStore();
for (int i = 0; i < templates.length; i++) {
Map<String, String> valueStore = templates[i].getValueStore();
assertNotNull(valueStore);
}
}
@ -60,18 +56,16 @@ public class TestValueStore extends BaseTestCase {
*/
public void testCompareValueStoreWithTemplateDefaluts(){
TemplateCore[] templates = TemplateEngineTestsHelper.getTestTemplates();
for (int i=0; i <templates.length; i++) {
Map valueStore = templates[i].getValueStore();
for (int i = 0; i < templates.length; i++) {
Map<String, String> valueStore = templates[i].getValueStore();
TemplateDescriptor templateDescriptor = templates[i].getTemplateDescriptor();
Map templateDefaults = templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement());
Map<String, String> templateDefaults = templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement());
Iterator defaultsIterator = templateDefaults.keySet().iterator();
while(defaultsIterator.hasNext()){
String key = (String)defaultsIterator.next();
Iterator<String> defaultsIterator = templateDefaults.keySet().iterator();
while (defaultsIterator.hasNext()){
String key = defaultsIterator.next();
assertNotNull(valueStore.get(key));
}
}
}
}

View file

@ -24,6 +24,7 @@ import org.eclipse.cdt.ui.tests.outline.OutlineTestSuite;
import org.eclipse.cdt.ui.tests.quickfix.AssistQuickFixTest;
import org.eclipse.cdt.ui.tests.refactoring.RefactoringTestSuite;
import org.eclipse.cdt.ui.tests.search.SearchTestSuite;
import org.eclipse.cdt.ui.tests.templateengine.AllTemplateEngineTests;
import org.eclipse.cdt.ui.tests.text.TextTestSuite;
import org.eclipse.cdt.ui.tests.text.contentassist.ContentAssistTestSuite;
import org.eclipse.cdt.ui.tests.text.contentassist2.ContentAssist2TestSuite;
@ -101,5 +102,7 @@ public class AutomatedSuite extends TestSuite {
// tests from package org.eclipse.cdt.ui.tests.misc
addTest(MiscTestSuite.suite());
addTest(AllTemplateEngineTests.suite());
}
}

View file

@ -13,9 +13,7 @@
******************************************************************************/
package org.eclipse.cdt.ui.tests.refactoring.gettersandsetters;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
import org.eclipse.core.resources.IFile;
@ -23,12 +21,12 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.ui.tests.refactoring.RefactoringTest;
import org.eclipse.cdt.ui.tests.refactoring.TestSourceFile;
import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescriptor.AccessorKind;
import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GenerateGettersAndSettersRefactoring;
import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterContext;
@ -38,11 +36,11 @@ import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterCon
public class GenerateGettersAndSettersTest extends RefactoringTest {
protected boolean fatalError;
private int warnings;
private List<String> selectedGetters;
private List<String> selectedSetters;
private int infos;
private String[] selectedGetters;
private String[] selectedSetters;
private GenerateGettersAndSettersRefactoring refactoring;
private boolean definitionSeparate;
private int infos;
/**
* @param name
@ -88,17 +86,11 @@ public class GenerateGettersAndSettersTest extends RefactoringTest {
private void selectFields() {
GetterSetterContext context = refactoring.getContext();
for (IASTSimpleDeclaration currentDecl : context.existingFields) {
String name = currentDecl.getDeclarators()[0].getName().getRawSignature();
if (selectedGetters.contains(name)) {
selectedGetters.remove(name);
context.selectedFunctions.add(context.createGetterInserter(currentDecl));
}
if (selectedSetters.contains(name)) {
selectedSetters.remove(name);
context.selectedFunctions.add(context.createSetterInserter(currentDecl));
}
for (String name : selectedGetters) {
context.selectAccessorForField(name, AccessorKind.GETTER);
}
for (String name : selectedSetters) {
context.selectAccessorForField(name, AccessorKind.SETTER);
}
}
@ -111,13 +103,7 @@ public class GenerateGettersAndSettersTest extends RefactoringTest {
String setters = refactoringProperties.getProperty("setters", ""); //$NON-NLS-1$ //$NON-NLS-2$
definitionSeparate = Boolean.valueOf(refactoringProperties.getProperty("definitionSeparate", "false"));
selectedGetters = new ArrayList<String>();
for (String getterName : getters.split(",")) { //$NON-NLS-1$
selectedGetters.add(getterName);
}
selectedSetters = new ArrayList<String>();
for (String setterName : setters.split(",")) { //$NON-NLS-1$
selectedSetters.add(setterName);
}
selectedGetters = getters.split(",");
selectedSetters = setters.split(",");
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2010 Wind River Systems, Inc. and others.
* Copyright (c) 2006, 2011 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -12,6 +12,7 @@
package org.eclipse.cdt.ui.tests.text;
import java.io.File;
import java.lang.ref.WeakReference;
import java.net.URI;
import java.net.URISyntaxException;
@ -110,8 +111,8 @@ public class BasicCEditorTest extends BaseUITestCase {
}
}
private static CEditor fEditor;
private static SourceViewer fSourceViewer;
private CEditor fEditor;
private SourceViewer fSourceViewer;
private ICProject fCProject;
private IProject fNonCProject;
private StyledText fTextWidget;
@ -443,6 +444,24 @@ public class BasicCEditorTest extends BaseUITestCase {
assertTrue(part instanceof CEditor);
}
public void testLeakingInstanceAfterClose() throws Exception {
final String file= "/ceditor/src/main.cpp";
fCProject= EditorTestHelper.createCProject("ceditor", "resources/ceditor", false, false);
setUpEditor(file);
fSourceViewer= EditorTestHelper.getSourceViewer(fEditor);
assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 0, 10000, 100));
WeakReference<CEditor> ref = new WeakReference<CEditor>(fEditor);
EditorTestHelper.closeEditor(fEditor);
fEditor = null;
fSourceViewer = null;
int ngc = 10;
while (ref.get() != null && ngc-- > 0) {
System.gc();
Thread.sleep(200);
}
assertNull("CEditor instance seems to be leaking after close", ref.get());
}
/**
* Type characters into the styled text.
*

View file

@ -328,15 +328,22 @@ HideCFiles.description= Hides all C files
HideHeaderFiles.label= Header files
HideHeaderFiles.description= Hides all Header files
HideUsingDirective.label= Using directive
HideUsingDirective.description= Hides using directives
HideMacroDirective.label= Macro directive
HideMacroDirective.description= Hides Macro directives
HideAnonymousStruct.label= Anonymous structs and enums
HideAnonymousStruct.navigator.label= C/C++ anonymous structs and enums
HideAnonymousStruct.description= Hides all anonymous structs and enums
ForwardDeclarationFilter.label= Forward declaration
ForwardDeclarationFilter.navigator.label= C/C++ forward declaration
ForwardDeclarationFilter.description= Hides forward declarations, unless found in a header file.
HideMacroDirective.label= Macro directive
HideMacroDirective.navigator.label= C/C++ macro directive
HideMacroDirective.description= Hides Macro directives
HideUsingDirective.label= Using directive
HideUsingDirective.navigator.label= C/C++ using directive
HideUsingDirective.description= Hides using directives
#
WorkInProgress.name=Work In Progress

View file

@ -136,14 +136,54 @@
class="org.eclipse.cdt.internal.ui.filters.NonCElementFilter"
id="org.eclipse.cdt.internal.ui.CView.NonCElementFilter">
</filter>
<!-- C/C++ Outline Page -->
<filter
targetId="org.eclipse.cdt.ui.COutlinePage"
targetId="org.eclipse.cdt.ui.CView"
name="%HideAnonymousStruct.label"
enabled="true"
description="%HideAnonymousStruct.description"
class="org.eclipse.cdt.internal.ui.filters.AnonymousStructFilter"
id="org.eclipse.cdt.internal.ui.CView.AnonymousStructFilter">
</filter>
<filter
targetId="org.eclipse.cdt.ui.CView"
name="%ForwardDeclarationFilter.label"
enabled="true"
description="%ForwardDeclarationFilter.description"
class="org.eclipse.cdt.internal.ui.filters.ForwardDeclarationFilter"
id="org.eclipse.cdt.internal.ui.CView.ForwardDeclarationFilter">
</filter>
<filter
targetId="org.eclipse.cdt.ui.CView"
name="%HideMacroDirective.label"
enabled="false"
description="%HideMacroDirective.description"
class="org.eclipse.cdt.internal.ui.filters.MacroDirectiveFilter"
id="org.eclipse.cdt.internal.ui.CView.MacroDirectiveFilter">
</filter>
<filter
targetId="org.eclipse.cdt.ui.CView"
name="%HideUsingDirective.label"
enabled="false"
description="%HideUsingDirective.description"
class="org.eclipse.cdt.internal.ui.filters.UsingDirectiveFilter"
id="org.eclipse.cdt.ui.COutlinePage.UsingDeclarationFilter">
id="org.eclipse.cdt.internal.ui.CView.UsingDeclarationFilter">
</filter>
<!-- C/C++ Outline Page -->
<filter
targetId="org.eclipse.cdt.ui.COutlinePage"
name="%HideAnonymousStruct.label"
enabled="false"
description="%HideAnonymousStruct.description"
class="org.eclipse.cdt.internal.ui.filters.AnonymousStructFilter"
id="org.eclipse.cdt.ui.COutlinePage.AnonymousStructFilter">
</filter>
<filter
targetId="org.eclipse.cdt.ui.COutlinePage"
name="%ForwardDeclarationFilter.label"
enabled="false"
description="%ForwardDeclarationFilter.description"
class="org.eclipse.cdt.internal.ui.filters.ForwardDeclarationFilter"
id="org.eclipse.cdt.ui.COutlinePage.ForwardDeclarationFilter">
</filter>
<filter
targetId="org.eclipse.cdt.ui.COutlinePage"
@ -155,11 +195,11 @@
</filter>
<filter
targetId="org.eclipse.cdt.ui.COutlinePage"
name="%ForwardDeclarationFilter.label"
name="%HideUsingDirective.label"
enabled="false"
description="%ForwardDeclarationFilter.description"
class="org.eclipse.cdt.internal.ui.filters.ForwardDeclarationFilter"
id="org.eclipse.cdt.ui.COutlinePage.ForwardDeclarationFilter">
description="%HideUsingDirective.description"
class="org.eclipse.cdt.internal.ui.filters.UsingDirectiveFilter"
id="org.eclipse.cdt.ui.COutlinePage.UsingDeclarationFilter">
</filter>
<!-- Asm Outline Page -->
<filter
@ -578,6 +618,258 @@
label="%Dummy.label"
value="240, 216, 168">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.c_multi_line_comment"
isEditable="false"
label="%Dummy.label"
value="63, 127, 95">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.c_single_line_comment"
isEditable="false"
label="%Dummy.label"
value="63, 127, 95">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.c_keyword"
isEditable="false"
label="%Dummy.label"
value="127, 0, 85">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.c_type"
isEditable="false"
label="%Dummy.label"
value="127, 0, 85">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.c_string"
isEditable="false"
label="%Dummy.label"
value="42, 0, 255">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.c_operators"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.c_braces"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.c_numbers"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.c_default"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.pp_directive"
isEditable="false"
label="%Dummy.label"
value="127, 0, 85">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.pp_directive"
isEditable="false"
label="%Dummy.label"
value="127, 0, 85">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.pp_default"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.pp_header"
isEditable="false"
label="%Dummy.label"
value="42, 0, 255">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.asm_directive"
isEditable="false"
label="%Dummy.label"
value="127, 0, 85">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.asm_label"
isEditable="false"
label="%Dummy.label"
value="127, 0, 85">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.c_comment_task_tag"
isEditable="false"
label="%Dummy.label"
value="127, 159, 191">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.internal.ui.text.doctools.doxygen.multi"
isEditable="false"
label="%Dummy.label"
value="63, 95, 191">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.internal.ui.text.doctools.doxygen.single"
isEditable="false"
label="%Dummy.label"
value="63, 95, 191">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.internal.ui.text.doctools.doxygen.recognizedTag"
isEditable="false"
label="%Dummy.label"
value="127, 159, 191">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.staticFieldHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 192">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.fieldHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 192">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.methodDeclarationHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.staticMethodHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.functionDeclarationHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.functionHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.localVariableDeclarationHighlighting"
isEditable="false"
label="%Dummy.label"
value="128, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.localVariableHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.globalVariableHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.parameterVariableHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.templateParameterHighlighting"
isEditable="false"
label="%Dummy.label"
value="100, 70, 50">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.methodHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.classHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 80, 50">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.enumHighlighting"
isEditable="false"
label="%Dummy.label"
value="100, 70, 50">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.macroSubstitutionHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.macroDefinitionHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.typedefHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 80, 50">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.namespaceHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.labelHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.enumeratorHighlighting"
isEditable="false"
label="%Dummy.label"
value="0, 0, 192">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.problemHighlighting"
isEditable="false"
label="%Dummy.label"
value="224, 0, 0">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.externalSDKHighlighting"
isEditable="false"
label="%Dummy.label"
value="100, 40, 128">
</colorDefinition>
<colorDefinition
id="org.eclipse.cdt.ui.overloadedOperatorHighlighting"
isEditable="false"
label="%Dummy.label"
value="200, 100, 0">
</colorDefinition>
<theme
id="org.eclipse.ui.ide.systemDefault">
<colorOverride
@ -596,6 +888,170 @@
id="org.eclipse.cdt.ui.content_assist_parameters_foreground"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.c_multi_line_comment"
value="COLOR_LIST_SELECTION">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.c_single_line_comment"
value="COLOR_LIST_SELECTION">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.c_keyword"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.c_type"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.c_string"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.c_operators"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.c_braces"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.c_numbers"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.c_default"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.pp_directive"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.pp_default"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.pp_header"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.asm_directive"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.asm_label"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.c_comment_task_tag"
value="COLOR_WIDGET_NORMAL_SHADOW">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.internal.ui.text.doctools.doxygen.multi"
value="COLOR_LIST_SELECTION">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.internal.ui.text.doctools.doxygen.single"
value="COLOR_LIST_SELECTION">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.internal.ui.text.doctools.doxygen.recognizedTag"
value="COLOR_WIDGET_NORMAL_SHADOW">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.staticFieldHighlighting"
value="COLOR_LIST_SELECTION">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.fieldHighlighting"
value="COLOR_LIST_SELECTION">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.methodDeclarationHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.staticMethodHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.functionDeclarationHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.functionHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.localVariableDeclarationHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.localVariableHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.globalVariableHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.parameterVariableHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.templateParameterHighlighting"
value="COLOR_WIDGET_DARK_SHADOW">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.methodHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.classHighlighting"
value="COLOR_WIDGET_DARK_SHADOW">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.enumHighlighting"
value="COLOR_WIDGET_DARK_SHADOW">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.macroSubstitutionHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.macroDefinitionHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.typedefHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.namespaceHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.labelHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.enumeratorHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.problemHighlighting"
value="COLOR_WIDGET_DARK_SHADOW">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.externalSDKHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
<colorOverride
id="org.eclipse.cdt.ui.overloadedOperatorHighlighting"
value="COLOR_LIST_FOREGROUND">
</colorOverride>
</theme>
</extension>
@ -2958,10 +3414,6 @@
point="org.eclipse.core.runtime.preferences">
<initializer class="org.eclipse.cdt.ui.CUIPreferenceInitializer"/>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer class="org.eclipse.cdt.ui.text.doctools.doxygen.DoxygenHelper"/>
</extension>
<!-- Default folding -->
<extension
@ -3405,6 +3857,28 @@
description="%HideNonCElements.description"
id="org.eclipse.cdt.ui.navigator.filters.NonCElementFilter"
name="%HideNonCElements.label"/>
<commonFilter
activeByDefault="true"
class="org.eclipse.cdt.internal.ui.filters.AnonymousStructFilter"
description="%HideAnonymousStruct.description"
id="org.eclipse.cdt.ui.navigator.filters.AnonymousStructFilter"
name="%HideAnonymousStruct.navigator.label"/>
<commonFilter
activeByDefault="true"
class="org.eclipse.cdt.internal.ui.filters.ForwardDeclarationFilter"
description="%ForwardDeclarationFilter.description"
id="org.eclipse.cdt.ui.navigator.filters.ForwardDeclarationFilter"
name="%ForwardDeclarationFilter.navigator.label"/>
<commonFilter
class="org.eclipse.cdt.internal.ui.filters.MacroDirectiveFilter"
description="%HideMacroDirective.description"
id="org.eclipse.cdt.ui.navigator.filters.MacroDirectiveFilter"
name="%HideMacroDirective.navigator.label"/>
<commonFilter
class="org.eclipse.cdt.internal.ui.filters.UsingDirectiveFilter"
description="%HideUsingDirective.description"
id="org.eclipse.cdt.ui.navigator.filters.UsingDirectiveFilter"
name="%HideUsingDirective.navigator.label"/>
</extension>
<extension
point="org.eclipse.ui.navigator.linkHelper">

View file

@ -52,7 +52,7 @@ import org.eclipse.cdt.ui.CDTUITools;
import org.eclipse.cdt.ui.CElementGrouping;
import org.eclipse.cdt.ui.IncludesGrouping;
import org.eclipse.cdt.ui.NamespacesGrouping;
/**
* A base content provider for C elements. It provides access to the
* C element hierarchy without listening to changes in the C model.
@ -83,11 +83,11 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
protected boolean fNamespacesGrouping= false;
protected boolean fMemberGrouping= false;
protected boolean fMacroGrouping= false;
public BaseCElementContentProvider() {
this(false, false);
}
public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) {
fProvideMembers= provideMembers;
fProvideWorkingCopy= provideWorkingCopy;
@ -161,7 +161,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
public boolean isMemberGroupingEnabled() {
return fMemberGrouping;
}
/**
* Enable/disable member grouping by common namespace.
* @param enable
@ -169,14 +169,14 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
public void setMemberGrouping(boolean enable) {
fMemberGrouping = enable;
}
/**
* @return whether grouping of macros is enabled
*/
public boolean isMacroGroupingEnabled() {
return fMacroGrouping;
}
/**
* Enable/disable marco grouping
* @param enable
@ -188,25 +188,29 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
/* (non-Cdoc)
* Method declared on IContentProvider.
*/
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
/* (non-Cdoc)
* Method declared on IContentProvider.
*/
@Override
public void dispose() {
}
/* (non-Cdoc)
* Method declared on IStructuredContentProvider.
*/
@Override
public Object[] getElements(Object parent) {
return getChildren(parent);
}
/* (non-Cdoc)
* Method declared on ITreeContentProvider.
*/
@Override
public Object[] getChildren(Object element) {
if (!exists(element))
return NO_CHILDREN;
@ -263,6 +267,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
*
* @see ITreeContentProvider
*/
@Override
public boolean hasChildren(Object element) {
if (fProvideMembers) {
// assume TUs and binary files are never empty
@ -303,7 +308,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
return true;
}
}
if (element instanceof CElementGrouping) {
return true;
}
@ -311,10 +316,11 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
Object[] children= getChildren(element);
return (children != null) && children.length > 0;
}
/* (non-Cdoc)
* Method declared on ITreeContentProvider.
*/
@Override
public Object getParent(Object element) {
if (!exists(element)) {
return null;
@ -398,7 +404,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
}
return parent;
}
protected Object[] getCProjects(ICModel cModel) throws CModelException {
Object[] objects = cModel.getCProjects();
try {
@ -415,7 +421,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
protected Object[] getSourceRoots(ICProject cproject) throws CModelException {
if (!cproject.getProject().isOpen())
return NO_CHILDREN;
List<ICElement> list= new ArrayList<ICElement>();
ICElement[] children = cproject.getChildren();
for (ICElement child : children) {
@ -426,8 +432,8 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
list.add(c2[k]);
} else if (CCorePlugin.showSourceRootsAtTopOfProject()) {
list.add(child);
} else if (child instanceof ISourceRoot &&
child.getResource().getParent().equals(cproject.getProject())) {
} else if (child instanceof ISourceRoot &&
child.getResource().getParent().equals(cproject.getProject())) {
list.add(child);
}
}
@ -579,7 +585,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
}
} catch (CModelException e) {
}
Object[] result = children;
if (missingElements.size() > 0) {
result = concatenate(result, missingElements.toArray());
@ -593,7 +599,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
}
private List<ICElement> getMissingElements(ICContainer container, ICElement[] elements) {
// nested source roots may be filtered out below the project root,
// nested source roots may be filtered out below the project root,
// we need to find them to add them back in
List<ICElement> missingElements = new ArrayList<ICElement>();
try {
@ -643,7 +649,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider {
}
return filterNonCResources(members, cproject);
}
private Object[] filterNonCResources(Object[] objects, ICProject cproject) throws CModelException {
ICElement[] binaries = null;
ICElement[] archives = null;

View file

@ -25,6 +25,7 @@ public class CActionFilter implements IActionFilter {
public CActionFilter() {
}
@Override
public boolean testAttribute(Object target, String name, String value) {
ICElement element = (ICElement) target;
IResource resource = element.getResource();

View file

@ -31,33 +31,35 @@ import org.eclipse.cdt.core.model.ICElement;
* Implements basic UI support for C elements.
*/
public class CElementAdapterFactory implements IAdapterFactory {
private static Class<?>[] PROPERTIES= new Class[] {
IPropertySource.class,
IResource.class,
IWorkbenchAdapter.class,
IPersistableElement.class,
IDeferredWorkbenchAdapter.class,
IActionFilter.class
IActionFilter.class
};
private static CWorkbenchAdapter fgCWorkbenchAdapter;
private static CActionFilter fgCActionFilter;
/**
* @see CElementAdapterFactory#getAdapterList
*/
@Override
public Class<?>[] getAdapterList() {
return PROPERTIES;
}
/**
* @see CElementAdapterFactory#getAdapter
*/
*/
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Object getAdapter(Object element, Class key) {
ICElement celem = (ICElement) element;
if (IPropertySource.class.equals(key)) {
return getPropertySource(celem);
} else if (IResource.class.isAssignableFrom(key)) {
@ -74,12 +76,12 @@ public class CElementAdapterFactory implements IAdapterFactory {
} else if (IActionFilter.class.equals(key)) {
return getActionFilter(celem);
}
return null;
return null;
}
private IPropertySource getPropertySource(ICElement celement) {
if (celement instanceof IBinary) {
return new BinaryPropertySource((IBinary)celement);
return new BinaryPropertySource((IBinary)celement);
}
IResource res = celement.getResource();
if (res != null) {
@ -88,7 +90,7 @@ public class CElementAdapterFactory implements IAdapterFactory {
}
return new ResourcePropertySource(res);
}
return new CElementPropertySource(celement);
return new CElementPropertySource(celement);
}
private IResource getResource(ICElement celement) {
@ -105,7 +107,7 @@ public class CElementAdapterFactory implements IAdapterFactory {
}
return fgCWorkbenchAdapter;
}
private IActionFilter getActionFilter(ICElement celement) {
if (fgCActionFilter == null) {
fgCActionFilter = new CActionFilter();

View file

@ -11,31 +11,32 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.jface.viewers.IBasicPropertyConstants;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.PropertyDescriptor;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.ui.CUIPlugin;
public class CElementPropertySource implements IPropertySource {
private final static String LABEL= "CElementProperties.name"; //$NON-NLS-1$
private ICElement fCElement;
// Property Descriptors
static private IPropertyDescriptor[] fgPropertyDescriptors;
static {
// resource name
String displayName= CUIPlugin.getResourceString(LABEL);
PropertyDescriptor descriptor= new PropertyDescriptor(IBasicPropertyConstants.P_TEXT, displayName);
descriptor.setAlwaysIncompatible(true);
fgPropertyDescriptors= new IPropertyDescriptor[] { descriptor };
}
public CElementPropertySource(ICElement elem) {
fCElement= elem;
}
@ -43,13 +44,15 @@ public class CElementPropertySource implements IPropertySource {
/**
* @see IPropertySource#getPropertyDescriptors
*/
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
return fgPropertyDescriptors;
}
/**
* @see IPropertySource#getPropertyValue
*/
*/
@Override
public Object getPropertyValue(Object name) {
if (name.equals(IBasicPropertyConstants.P_TEXT)) {
return fCElement.getElementName();
@ -59,27 +62,31 @@ public class CElementPropertySource implements IPropertySource {
/**
* @see IPropertySource#setPropertyValue
*/
*/
@Override
public void setPropertyValue(Object name, Object value) {
}
/**
* @see IPropertySource#getEditableValue
*/
*/
@Override
public Object getEditableValue() {
return null;
}
/**
* @see IPropertySource#isPropertySet
*/
*/
@Override
public boolean isPropertySet(Object property) {
return false;
}
/**
* @see IPropertySource#resetPropertyValue
*/
*/
@Override
public void resetPropertyValue(Object property) {
}
}

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