mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Run reconciler when new file is added to index, bug 276605.
This commit is contained in:
parent
ed13924735
commit
a3b3eae7ab
7 changed files with 69 additions and 21 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -51,4 +51,10 @@ public interface IIndexChangeEvent {
|
||||||
* <code>true</code>, the files of the set have been written after the index was cleared.
|
* <code>true</code>, the files of the set have been written after the index was cleared.
|
||||||
*/
|
*/
|
||||||
public Set<IIndexFileLocation> getFilesWritten();
|
public Set<IIndexFileLocation> getFilesWritten();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns <code>true</code> when a new file had been added to the index.
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public boolean hasNewFile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -50,10 +50,14 @@ public class IndexChangeEvent implements IIndexChangeEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCleared() {
|
public boolean isCleared() {
|
||||||
return fChangeEvent.fCleared;
|
return fChangeEvent.isCleared();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReloaded() {
|
public boolean isReloaded() {
|
||||||
return fChangeEvent.fReloaded;
|
return fChangeEvent.isReloaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasNewFile() {
|
||||||
|
return fChangeEvent.hasNewFiles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,21 +232,48 @@ public class PDOM extends PlatformObject implements IPDOM {
|
||||||
public static class ChangeEvent {
|
public static class ChangeEvent {
|
||||||
public Set<IIndexFileLocation> fClearedFiles= new HashSet<IIndexFileLocation>();
|
public Set<IIndexFileLocation> fClearedFiles= new HashSet<IIndexFileLocation>();
|
||||||
public Set<IIndexFileLocation> fFilesWritten= new HashSet<IIndexFileLocation>();
|
public Set<IIndexFileLocation> fFilesWritten= new HashSet<IIndexFileLocation>();
|
||||||
public boolean fCleared= false;
|
private boolean fCleared= false;
|
||||||
public boolean fReloaded= false;
|
private boolean fReloaded= false;
|
||||||
|
private boolean fNewFiles= false;
|
||||||
|
|
||||||
private void setCleared() {
|
public void clear() {
|
||||||
fReloaded= false;
|
fReloaded= false;
|
||||||
fCleared= true;
|
fCleared= false;
|
||||||
|
fNewFiles= false;
|
||||||
|
|
||||||
fClearedFiles.clear();
|
fClearedFiles.clear();
|
||||||
fFilesWritten.clear();
|
fFilesWritten.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
private void setCleared() {
|
||||||
fReloaded= fCleared= false;
|
fCleared= true;
|
||||||
|
fReloaded= false;
|
||||||
|
fNewFiles= false;
|
||||||
|
|
||||||
fClearedFiles.clear();
|
fClearedFiles.clear();
|
||||||
fFilesWritten.clear();
|
fFilesWritten.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isCleared() {
|
||||||
|
return fCleared;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReloaded() {
|
||||||
|
fReloaded= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isReloaded() {
|
||||||
|
return fReloaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasNewFiles() {
|
||||||
|
fNewFiles = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasNewFiles() {
|
||||||
|
return fNewFiles;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static interface IListener {
|
public static interface IListener {
|
||||||
public void handleChange(PDOM pdom, ChangeEvent event);
|
public void handleChange(PDOM pdom, ChangeEvent event);
|
||||||
|
@ -414,6 +441,7 @@ public class PDOM extends PlatformObject implements IPDOM {
|
||||||
PDOMFile pdomFile = new PDOMFile(linkage, location, linkageID);
|
PDOMFile pdomFile = new PDOMFile(linkage, location, linkageID);
|
||||||
getFileIndex().insert(pdomFile.getRecord());
|
getFileIndex().insert(pdomFile.getRecord());
|
||||||
file= pdomFile;
|
file= pdomFile;
|
||||||
|
fEvent.setHasNewFiles();
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ public class PDOMProxy implements IPDOM {
|
||||||
pdom.addListener(listener);
|
pdom.addListener(listener);
|
||||||
}
|
}
|
||||||
ChangeEvent event= new ChangeEvent();
|
ChangeEvent event= new ChangeEvent();
|
||||||
event.fReloaded= true;
|
event.setReloaded();
|
||||||
for (Iterator<IListener> iterator = fListeners.iterator(); iterator.hasNext();) {
|
for (Iterator<IListener> iterator = fListeners.iterator(); iterator.hasNext();) {
|
||||||
IListener listener = iterator.next();
|
IListener listener = iterator.next();
|
||||||
listener.handleChange(fDelegate, event);
|
listener.handleChange(fDelegate, event);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -42,7 +42,7 @@ public class TriggerNotificationTask implements IPDOMIndexerTask {
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) {
|
public void run(IProgressMonitor monitor) {
|
||||||
ChangeEvent event= new ChangeEvent();
|
ChangeEvent event= new ChangeEvent();
|
||||||
event.fReloaded= true;
|
event.setReloaded();
|
||||||
fManager.handleChange(fPDOM, event);
|
fManager.handleChange(fPDOM, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,14 +24,16 @@ import java.util.Map;
|
||||||
import java.util.MissingResourceException;
|
import java.util.MissingResourceException;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import com.ibm.icu.text.MessageFormat;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
|
import org.eclipse.cdt.core.cdtvariables.ICdtVariableManager;
|
||||||
import org.eclipse.cdt.core.cdtvariables.IUserVarSupplier;
|
import org.eclipse.cdt.core.cdtvariables.IUserVarSupplier;
|
||||||
import org.eclipse.cdt.core.dom.CDOM;
|
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
|
import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager;
|
||||||
import org.eclipse.cdt.core.index.IIndexManager;
|
import org.eclipse.cdt.core.index.IIndexManager;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
|
@ -81,8 +83,6 @@ import org.eclipse.core.runtime.content.IContentType;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
import com.ibm.icu.text.MessageFormat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* CCorePlugin is the life-cycle owner of the core plug-in, and starting point for access to many core APIs.
|
* CCorePlugin is the life-cycle owner of the core plug-in, and starting point for access to many core APIs.
|
||||||
*
|
*
|
||||||
|
@ -94,6 +94,10 @@ public class CCorePlugin extends Plugin {
|
||||||
public static final int STATUS_CDTPROJECT_EXISTS = 1;
|
public static final int STATUS_CDTPROJECT_EXISTS = 1;
|
||||||
public static final int STATUS_CDTPROJECT_MISMATCH = 2;
|
public static final int STATUS_CDTPROJECT_MISMATCH = 2;
|
||||||
public static final int CDT_PROJECT_NATURE_ID_MISMATCH = 3;
|
public static final int CDT_PROJECT_NATURE_ID_MISMATCH = 3;
|
||||||
|
/**
|
||||||
|
* Status code for core exception that is thrown if a pdom grew larger than the supported limit.
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
public static final int STATUS_PDOM_TOO_LARGE = 4;
|
public static final int STATUS_PDOM_TOO_LARGE = 4;
|
||||||
|
|
||||||
public static final String PLUGIN_ID = "org.eclipse.cdt.core"; //$NON-NLS-1$
|
public static final String PLUGIN_ID = "org.eclipse.cdt.core"; //$NON-NLS-1$
|
||||||
|
@ -1004,8 +1008,12 @@ public class CCorePlugin extends Plugin {
|
||||||
return getPluginPreferences().getBoolean(PREF_USE_STRUCTURAL_PARSE_MODE);
|
return getPluginPreferences().getBoolean(PREF_USE_STRUCTURAL_PARSE_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CDOM getDOM() {
|
/**
|
||||||
return CDOM.getInstance();
|
* @deprecated use {@link ITranslationUnit} or {@link ILanguage} to construct ASTs, instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public org.eclipse.cdt.core.dom.CDOM getDOM() {
|
||||||
|
return org.eclipse.cdt.core.dom.CDOM.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICdtVariableManager getCdtVariableManager(){
|
public ICdtVariableManager getCdtVariableManager(){
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -265,8 +265,10 @@ public class CReconciler extends MonoReconciler {
|
||||||
* @see org.eclipse.cdt.core.index.IIndexChangeListener#indexChanged(org.eclipse.cdt.core.index.IIndexChangeEvent)
|
* @see org.eclipse.cdt.core.index.IIndexChangeListener#indexChanged(org.eclipse.cdt.core.index.IIndexChangeEvent)
|
||||||
*/
|
*/
|
||||||
public void indexChanged(IIndexChangeEvent event) {
|
public void indexChanged(IIndexChangeEvent event) {
|
||||||
if (!fIndexChanged && !fIgnoreChanges && isRelevantProject(event.getAffectedProject())) {
|
if (!fIndexChanged && isRelevantProject(event.getAffectedProject())) {
|
||||||
fIndexChanged= true;
|
if (!fIgnoreChanges || event.isCleared() || event.isReloaded() || event.hasNewFile()) {
|
||||||
|
fIndexChanged= true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue