diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IOpenable.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IOpenable.java index 4339c4cc2d9..f640b79a653 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IOpenable.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IOpenable.java @@ -48,6 +48,7 @@ public interface IOpenable extends IBufferChangedListener{ * by updating the element's structure and properties as necessary. */ void makeConsistent(IProgressMonitor progress) throws CModelException; + void makeConsistent(IProgressMonitor progress, boolean forced) throws CModelException; /** * Opens this element and all parent elements that are not already open. diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Openable.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Openable.java index 5fb09178a5b..90d0c019e07 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Openable.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Openable.java @@ -216,7 +216,11 @@ public abstract class Openable extends Parent implements IOpenable, IBufferChang * @see org.eclipse.cdt.core.model.IOpenable#makeConsistent(IProgressMonitor) */ public void makeConsistent(IProgressMonitor pm) throws CModelException { - if (!isConsistent()) { + makeConsistent(pm, false); + } + + public void makeConsistent(IProgressMonitor pm, boolean forced) throws CModelException { + if (!isConsistent() || forced) { buildStructure((OpenableInfo)getElementInfo(), pm); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java index 3cf9dc93fc5..d40387bf0de 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/TranslationUnit.java @@ -440,7 +440,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit { * @see org.eclipse.cdt.core.model.IOpenable#makeConsistent(IProgressMonitor) */ public void makeConsistent(IProgressMonitor pm) throws CModelException { - if (!isConsistent()) { + makeConsistent(pm, false); + } + public void makeConsistent(IProgressMonitor pm, boolean forced) throws CModelException { + if (!isConsistent() || forced) { // create a new info and make it the current info OpenableInfo info = (OpenableInfo) createElementInfo(); buildStructure(info, pm); diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog index 1117e35442e..af9f445df1f 100644 --- a/core/org.eclipse.cdt.ui/ChangeLog +++ b/core/org.eclipse.cdt.ui/ChangeLog @@ -4,6 +4,10 @@ the include and defined symbol information for a standard make project. * src/org/eclipse/cdt/ui/wizards/BuildPathInfoBlock.java +2003-07-04 Victor Mozgin + Fix for PR 39476: Preference listeners for task tags do not work. + Fix for PR 39477: Task tags options dialogs ask for project rebuilds. + 2003-06-27 Andrew Niefer Changes for C/C++ Search: Added: diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index cd7bf5e92fe..fe064dcf432 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.model.ISourceRange; import org.eclipse.cdt.core.model.ISourceReference; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.internal.core.model.IWorkingCopy; +import org.eclipse.cdt.internal.ui.editor.asm.AsmTextTools; import org.eclipse.cdt.internal.ui.IContextMenuConstants; import org.eclipse.cdt.internal.ui.text.CPairMatcher; import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration; @@ -836,6 +837,15 @@ public class CEditor extends TextEditor implements ISelectionChangedListener { setKeyBindingScopes(new String [] { "org.eclipse.cdt.ui.cEditorScope" } ); } + /* (non-Javadoc) + * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent) + */ + protected boolean affectsTextPresentation(PropertyChangeEvent event) { + CTextTools textTools = CUIPlugin.getDefault().getTextTools(); + AsmTextTools asmTools = CUIPlugin.getDefault().getAsmTextTools(); + return textTools.affectsBehavior(event) || asmTools.affectsBehavior(event); + } + /** * Handles a property change event describing a change * of the C core's preferences and updates the preference diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java index 7e60038515c..633c9130a2b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/OptionsConfigurationBlock.java @@ -17,6 +17,10 @@ import java.util.Map; import java.util.StringTokenizer; import org.eclipse.core.resources.IncrementalProjectBuilder; +import org.eclipse.core.resources.IFile; +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.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor; @@ -41,11 +45,17 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableWithProgress; -import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.ui.IEditorInput; + import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.CModelException; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.util.ExceptionHandler; +import org.eclipse.cdt.internal.ui.util.EditorUtility; import org.eclipse.cdt.internal.ui.wizards.IStatusChangeListener; /** @@ -314,26 +324,27 @@ public abstract class OptionsConfigurationBlock { if (hasChanges) { - boolean doBuild= false; - String[] strings= getFullBuildDialogStrings(fProject == null); + boolean doReParse = false; + String[] strings = getFullReParseDialogStrings(fProject == null); if (strings != null) { - MessageDialog dialog= new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); + MessageDialog dialog = new MessageDialog(getShell(), strings[0], null, strings[1], MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2); int res= dialog.open(); if (res == 0) { - doBuild= true; + doReParse = true; } else if (res != 1) { return false; // cancel pressed } } setOptions(actualOptions); - if (doBuild) { - doFullBuild(); + if (doReParse) { + doFullReParse(); } } return true; } protected abstract String[] getFullBuildDialogStrings(boolean workspaceSettings); + protected abstract String[] getFullReParseDialogStrings(boolean workspaceSettings); protected void doFullBuild() { ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell()); @@ -363,7 +374,73 @@ public abstract class OptionsConfigurationBlock { String message= PreferencesMessages.getString("OptionsConfigurationBlock.builderror.message"); //$NON-NLS-1$ ExceptionHandler.handle(e, getShell(), title, message); } - } + } + + protected void doFullReParse() { + ProgressMonitorDialog dialog= new ProgressMonitorDialog(getShell()); + try { + dialog.run(true, true, new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException { + monitor.beginTask("", 1); //$NON-NLS-1$ + + if (fProject != null) { + monitor.setTaskName(PreferencesMessages.getFormattedString("OptionsConfigurationBlock.parseproject.taskname", fProject.getElementName())); //$NON-NLS-1$ + reParseHierarchy(fProject.getResource(), monitor); + } else { + monitor.setTaskName(PreferencesMessages.getString("OptionsConfigurationBlock.parseall.taskname")); //$NON-NLS-1$ + reParseHierarchy(CUIPlugin.getWorkspace().getRoot(), monitor); + } + + monitor.done(); + } + }); + } catch (InterruptedException e) { + // cancelled by user + } catch (InvocationTargetException e) { + String title= PreferencesMessages.getString("OptionsConfigurationBlock.parseerror.title"); //$NON-NLS-1$ + String message= PreferencesMessages.getString("OptionsConfigurationBlock.parseerror.message"); //$NON-NLS-1$ + ExceptionHandler.handle(e, getShell(), title, message); + } + } + + protected void reParseHierarchy(IResource root, final IProgressMonitor monitor) { + try { + root.accept( + new IResourceProxyVisitor() { + public boolean visit(IResourceProxy proxy) { + switch(proxy.getType()) { + case IResource.FILE : + IFile file = (IFile)proxy.requestResource(); + CoreModel cModel = CCorePlugin.getDefault().getCoreModel(); + + if (cModel.isTranslationUnit(file)) { + ITranslationUnit translationUnit = (ITranslationUnit)cModel.create(file); + + try { + IEditorInput input = EditorUtility.getEditorInput(file); + if (input != null) { + ITranslationUnit workingCopy = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input); + if (workingCopy != null) { + // We have a copy in an editor - use it + translationUnit = workingCopy; + } + } + + translationUnit.makeConsistent(monitor, true /*forced*/); + } catch (CModelException e) { + } + } + + return false; // Do not look into file's structure + } + + return true; + } + } + , IResource.NONE); + } catch (CoreException e) { + } + } public void performDefaults() { fWorkingValues= getDefaultOptions(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties index d3be009d62e..3efaf8eda5c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties @@ -16,6 +16,13 @@ OptionsConfigurationBlock.buildall.taskname=Build all... OptionsConfigurationBlock.buildproject.taskname=Build project ''{0}''... +OptionsConfigurationBlock.parseerror.title=Preference Changes +OptionsConfigurationBlock.parseerror.message=Problem while parsing. Check log for details. + +OptionsConfigurationBlock.parseall.taskname=Parse all... +OptionsConfigurationBlock.parseproject.taskname=Parse project ''{0}''... + + TodoTaskPreferencePage.title=Task Tags TodoTaskPropertyPage.useworkspacesettings.label=Use &workspace settings @@ -36,6 +43,10 @@ TodoTaskConfigurationBlock.needsbuild.title=Task Tags Settings Changed TodoTaskConfigurationBlock.needsfullbuild.message=The task tags settings have changed. A full rebuild is required to make changes effective. Do the full build now? TodoTaskConfigurationBlock.needsprojectbuild.message=The task tags settings have changed. A rebuild of the project is required to make changes effective. Do the project build now? +TodoTaskConfigurationBlock.needsparse.title=Task Tags Settings Changed +TodoTaskConfigurationBlock.needsfullparse.message=The task tags settings have changed. A full re-parse is required to make changes effective. Do the full re-parse now? +TodoTaskConfigurationBlock.needsprojectparse.message=The task tags settings have changed. Re-parsing of the project is required to make changes effective. Do the project re-parse now? + TodoTaskInputDialog.new.title=New Task Tag TodoTaskInputDialog.edit.title=Edit Task Tag TodoTaskInputDialog.name.label=T&ag: diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java index acb827d360f..81ca19108ee 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java @@ -225,7 +225,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { return super.performOk(enabled); } - + protected String[] getFullBuildDialogStrings(boolean workspaceSettings) { String title= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsbuild.title"); //$NON-NLS-1$ String message; @@ -235,6 +235,17 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsprojectbuild.message"); //$NON-NLS-1$ } return new String[] { title, message }; + } + + protected String[] getFullReParseDialogStrings(boolean workspaceSettings) { + String title= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsparse.title"); //$NON-NLS-1$ + String message; + if (fProject == null) { + message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsfullparse.message"); //$NON-NLS-1$ + } else { + message= PreferencesMessages.getString("TodoTaskConfigurationBlock.needsprojectparse.message"); //$NON-NLS-1$ + } + return new String[] { title, message }; } /* (non-Javadoc)