1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 426675: fix "index update with modified files" for a sub-directory

Change-Id: I3dad716cd11a464c97ee35fdabb8b9762238ccf3
Signed-off-by: Wei Li <wei.r.li@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/34434
Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
Wei Li 2014-10-06 07:57:29 +00:00 committed by Sergey Prigogin
parent d9cefc1e0c
commit 856b684824
3 changed files with 30 additions and 22 deletions

View file

@ -44,13 +44,13 @@ public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate
if(!(fSelection instanceof IStructuredSelection) && !(fSelection instanceof ITextSelection)) {
return;
}
ICProject[] projects = getSelectedCProjects();
doRun(projects);
ICElement[] elements = getSelectedCElements();
doRun(elements);
}
protected void doRun(ICProject[] projects) {
protected void doRun(ICElement[] elements) {
try {
CCorePlugin.getIndexManager().update(projects, getUpdateOptions());
CCorePlugin.getIndexManager().update(elements, getUpdateOptions());
} catch (CoreException e) {
CUIPlugin.log(e);
}
@ -70,20 +70,20 @@ public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate
public boolean isEnabledFor(ISelection selection) {
selectionChanged(null, selection);
ICProject[] project = getSelectedCProjects();
return project.length > 0;
ICElement[] elements = getSelectedCElements();
return elements.length > 0;
}
protected ICProject[] getSelectedCProjects() {
ArrayList<ICProject> tuSelection= new ArrayList<ICProject>();
protected ICElement[] getSelectedCElements() {
ArrayList<ICElement> tuSelection= new ArrayList<ICElement>();
if(fSelection instanceof IStructuredSelection) {
IStructuredSelection resources = SelectionConverter.convertSelectionToResources(fSelection);
for (Iterator<?> i= resources.iterator(); i.hasNext();) {
Object o= i.next();
if(o instanceof IResource) {
ICProject cproject= CCorePlugin.getDefault().getCoreModel().create(((IResource)o).getProject());
if(cproject != null) {
tuSelection.add(cproject);
ICElement celement= CCorePlugin.getDefault().getCoreModel().create((IResource)o);
if(celement != null) {
tuSelection.add(celement);
}
}
}
@ -96,6 +96,6 @@ public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate
}
}
}
return tuSelection.toArray(new ICProject[tuSelection.size()]);
return tuSelection.toArray(new ICElement[tuSelection.size()]);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2013 Wind River Systems, Inc. and others.
* Copyright (c) 2007, 2014 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -7,21 +7,29 @@
*
* Contributors:
* Markus Schorn - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.actions;
import java.util.LinkedHashSet;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICProject;
public class RebuildIndexAction extends AbstractUpdateIndexAction {
@Override
protected void doRun(ICProject[] projects) {
for (ICProject proj : projects) {
if(proj != null) {
CCorePlugin.getIndexManager().reindex(proj);
protected void doRun(ICElement[] elements) {
Set<ICProject> projects = new LinkedHashSet<>();
for (ICElement element : elements) {
if (element != null) {
projects.add(element.getCProject());
}
}
for (ICProject project : projects) {
CCorePlugin.getIndexManager().reindex(project);
}
}
@Override

View file

@ -16,7 +16,7 @@ import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.actions.AbstractUpdateIndexAction;
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
@ -34,13 +34,13 @@ public class FindUnresolvedIncludesProjectAction extends AbstractUpdateIndexActi
}
@Override
protected void doRun(ICProject[] projects) {
if (projects.length == 0) {
protected void doRun(ICElement[] elements) {
if (elements.length == 0) {
StatusLineHandler.showStatusLineMessage(fSite, CSearchMessages.CSearchOperation_operationUnavailable_message);
return;
}
ISearchQuery searchJob= new CSearchUnresolvedIncludesQuery(projects);
ISearchQuery searchJob= new CSearchUnresolvedIncludesQuery(elements);
StatusLineHandler.clearStatusLine(fSite);
NewSearchUI.activateSearchResultView();