diff --git a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeReference.java b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeReference.java index 85325c7ce5d..b0003d4c324 100644 --- a/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeReference.java +++ b/core/org.eclipse.cdt.core/browser/org/eclipse/cdt/core/browser/TypeReference.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2006 QNX Software Systems and others. + * Copyright (c) 2004, 2007 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 @@ -7,11 +7,14 @@ * * Contributors: * QNX Software Systems - initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.browser; +import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.CoreModelUtil; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ITranslationUnit; @@ -135,24 +138,22 @@ public class TypeReference implements ITypeReference { ICElement elem = CoreModel.getDefault().create(path); if (elem instanceof ITranslationUnit) unit = (ITranslationUnit) elem; - } - - if (unit == null) { - IProject project = getProject(); - if (project != null) { - ICProject cProject = findCProject(project); - if (cProject != null) { - IPath path = getLocation(); - ICElement elem = CoreModel.getDefault().createTranslationUnitFrom(cProject, path); - if (elem instanceof ITranslationUnit) - unit = (ITranslationUnit) elem; + else { + try { + unit= CoreModelUtil.findTranslationUnitForLocation(path, findCProject(getProject())); + } catch (CModelException e) { + CCorePlugin.log(e); } } } + return unit; } private ICProject findCProject(IProject project) { + if (project == null) { + return null; + } try { ICProject[] cProjects = CoreModel.getDefault().getCModel().getCProjects(); if (cProjects != null) { diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index efcfcd36b4d..0228b37469d 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -942,15 +942,14 @@ description="%CNavigationActionSet.description" visible="false" id="org.eclipse.cdt.ui.NavigationActionSet"> - + 0) { - for (int i = 0; i < files.length; i++) { - IFile file = files[i]; - ITranslationUnit tu= findTranslationUnit(file); - if (tu != null) { - return tu; - } - } - } - else { - CoreModel coreModel = CoreModel.getDefault(); - ITranslationUnit tu= null; - if (preferredProject != null) { - tu= coreModel.createTranslationUnitFrom(preferredProject, location); - } - if (tu == null) { - ICProject[] projects= coreModel.getCModel().getCProjects(); - for (int i = 0; i < projects.length && tu == null; i++) { - ICProject project = projects[i]; - if (!project.equals(preferredProject)) { - tu= coreModel.createTranslationUnitFrom(project, location); - } - } - } - return tu; - } - return null; + return CoreModelUtil.findTranslationUnitForLocation(location, preferredProject); } /** diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties index bc1a8742152..92bea65ab41 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties @@ -48,7 +48,7 @@ BinaryParserBlock.desc=Set required binary parser for this project BaseIndexerBlock.label=C/C++ Indexer BaseIndexerBlock.desc=C/C++ Indexer setting for this project. -BaseIndexerBlock.comboLabel=Select Indexer +BaseIndexerBlock.comboLabel=Select indexer ReferenceBlock.label= Projects ReferenceBlock.desc= Referenced C/C++ Projects diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java index b323232b1f5..aba112685fb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/OpenElementInCallHierarchyAction.java @@ -28,7 +28,7 @@ import org.eclipse.cdt.core.browser.ITypeInfo; import org.eclipse.cdt.core.browser.ITypeReference; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeDialog; +import org.eclipse.cdt.internal.ui.browser.opentype.ElementSelectionDialog; public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionDelegate { @@ -42,7 +42,7 @@ public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionD } public void run(IAction action) { - OpenTypeDialog dialog = new OpenTypeDialog(getShell()); + ElementSelectionDialog dialog = new ElementSelectionDialog(getShell()); configureDialog(dialog); int result = dialog.open(); if (result != IDialogConstants.OK_ID) @@ -67,7 +67,7 @@ public class OpenElementInCallHierarchyAction implements IWorkbenchWindowActionD } } - private void configureDialog(OpenTypeDialog dialog) { + private void configureDialog(ElementSelectionDialog dialog) { dialog.setDialogSettings(getClass().getName()); dialog.setVisibleTypes(VISIBLE_TYPES); dialog.setTitle(CHMessages.OpenElementInCallHierarchyAction_title); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java index 5558408a098..0a59ac86289 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/IndexerPreferencePage.java @@ -27,25 +27,30 @@ import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.cdt.ui.dialogs.CacheSizeBlock; import org.eclipse.cdt.ui.dialogs.ICOptionContainer; import org.eclipse.cdt.ui.dialogs.IndexerBlock; +import org.eclipse.cdt.ui.dialogs.IndexerStrategyBlock; public class IndexerPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, ICOptionContainer { private IndexerBlock fOptionBlock; private CacheSizeBlock fCacheBlock; + private IndexerStrategyBlock fStrategyBlock; public IndexerPreferencePage(){ fOptionBlock = new IndexerBlock(); + fStrategyBlock= new IndexerStrategyBlock(this); fCacheBlock= new CacheSizeBlock(this); } protected Control createContents(Composite parent) { + GridLayout gl; Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new GridLayout()); - GridData gd= new GridData(); - composite.setLayoutData(gd); + composite.setLayout(gl= new GridLayout()); + composite.setLayoutData(new GridData()); + gl.verticalSpacing= 0; fOptionBlock.createControl(composite); + fStrategyBlock.createControl(composite); fCacheBlock.createControl(composite); return composite; @@ -59,6 +64,10 @@ public class IndexerPreferencePage extends PreferencePage implements setErrorMessage(fOptionBlock.getErrorMessage()); setValid(false); } + else if (!fStrategyBlock.isValid()) { + setErrorMessage(fStrategyBlock.getErrorMessage()); + setValid(false); + } else if (!fCacheBlock.isValid()) { setErrorMessage(fCacheBlock.getErrorMessage()); setValid(false); @@ -80,6 +89,7 @@ public class IndexerPreferencePage extends PreferencePage implements public boolean performOk() { try { fOptionBlock.performApply(new NullProgressMonitor()); + fStrategyBlock.performApply(new NullProgressMonitor()); fCacheBlock.performApply(new NullProgressMonitor()); } catch (CoreException e) {} return true; @@ -87,6 +97,8 @@ public class IndexerPreferencePage extends PreferencePage implements public void performDefaults() { fOptionBlock.performDefaults(); + fStrategyBlock.performDefaults(); fCacheBlock.performDefaults(); + updateContainer(); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAction.java index 79984591ec1..3cb16a35feb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/OpenTypeInHierarchyAction.java @@ -28,7 +28,7 @@ import org.eclipse.cdt.core.browser.ITypeInfo; import org.eclipse.cdt.core.browser.ITypeReference; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.internal.ui.browser.opentype.OpenTypeDialog; +import org.eclipse.cdt.internal.ui.browser.opentype.ElementSelectionDialog; public class OpenTypeInHierarchyAction implements IWorkbenchWindowActionDelegate { @@ -42,7 +42,7 @@ public class OpenTypeInHierarchyAction implements IWorkbenchWindowActionDelegate } public void run(IAction action) { - OpenTypeDialog dialog = new OpenTypeDialog(getShell()); + ElementSelectionDialog dialog = new ElementSelectionDialog(getShell()); configureDialog(dialog); int result = dialog.open(); if (result != IDialogConstants.OK_ID) @@ -67,7 +67,7 @@ public class OpenTypeInHierarchyAction implements IWorkbenchWindowActionDelegate } } - private void configureDialog(OpenTypeDialog dialog) { + private void configureDialog(ElementSelectionDialog dialog) { dialog.setDialogSettings(getClass().getName()); dialog.setVisibleTypes(VISIBLE_TYPES); dialog.setTitle(Messages.OpenTypeInHierarchyAction_title);