From 93e5a9c520b4cada6a170fc37c7faa9d5c4fb8ad Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Fri, 7 Mar 2008 11:30:16 +0000 Subject: [PATCH] Fix for 215884: Inactive code highlighting isn't in accordance with content-assist. --- .../src/org/eclipse/cdt/core/CCorePlugin.java | 1 - .../core/CCorePreferenceInitializer.java | 3 ++- .../CContentAssistInvocationContext.java | 24 +++++++++---------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 48faad53db1..5587cf3c31d 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -325,7 +325,6 @@ public class CCorePlugin extends Plugin { // do harmless stuff first. cdtLog = new CDTLogWriter(CCorePlugin.getDefault().getStateLocation().append(".log").toFile()); //$NON-NLS-1$ configurePluginDebugOptions(); - getPluginPreferences().setDefault(PREF_USE_STRUCTURAL_PARSE_MODE, false); PositionTrackerManager.getInstance().install(); // new project model needs to register the resource listener first. diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java index ca03cbfd078..74f9d75c58f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 QNX Software Systems and others. + * Copyright (c) 2000, 2008 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 @@ -59,6 +59,7 @@ public class CCorePreferenceInitializer extends AbstractPreferenceInitializer { } defaultPreferences.putBoolean(CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, true); + defaultPreferences.putBoolean(CCorePlugin.PREF_USE_STRUCTURAL_PARSE_MODE, false); // indexer defaults IndexerPreferences.initializeDefaultPreferences(defaultPreferences); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java index 7635fc31485..aa31346639b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistInvocationContext.java @@ -24,6 +24,7 @@ import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext; import org.eclipse.cdt.ui.text.contentassist.ICEditorContentAssistInvocationContext; @@ -120,26 +121,23 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont ICProject proj= getProject(); if (proj == null) return null; - try{ + try { IIndexManager manager= CCorePlugin.getIndexManager(); - if (manager.isProjectIndexed(proj)) { - fIndex = CCorePlugin.getIndexManager().getIndex(proj, - IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT); + fIndex = manager.getIndex(proj, IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT); - try { - fIndex.acquireReadLock(); - } catch (InterruptedException e) { - fIndex = null; - } + try { + fIndex.acquireReadLock(); + } catch (InterruptedException e) { + fIndex = null; } - int flags = ITranslationUnit.AST_SKIP_ALL_HEADERS | ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT; - if (fIndex == null) { - flags = 0; - } + boolean parseNonIndexed= CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.PREF_USE_STRUCTURAL_PARSE_MODE); + int flags = parseNonIndexed ? ITranslationUnit.AST_SKIP_INDEXED_HEADERS : ITranslationUnit.AST_SKIP_ALL_HEADERS; + flags |= ITranslationUnit.AST_CONFIGURE_USING_SOURCE_CONTEXT; fCN = fTU.getCompletionNode(fIndex, flags, offset); } catch (CoreException e) { + CUIPlugin.getDefault().log(e); } return fCN;