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

Scalability mode (bug 226955)

This commit is contained in:
Vivian Kong 2008-04-23 14:31:53 +00:00
parent 7364e1ddaf
commit eb2d63351a
13 changed files with 561 additions and 21 deletions

View file

@ -179,6 +179,7 @@ ColoringPreferencePage.name=Syntax Coloring
FoldingPreferencePage.name=Folding
HoverPreferencePage.name=Hovers
markOccurrencesPreferencePage.name= Mark Occurrences
ScalabilityPreferencePage.name=Scalability
DefaultBinaryFileEditor.name = Default Binary File Editor
AsmEditor.name = Assembly Editor

View file

@ -761,6 +761,11 @@
category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.MarkOccurrencesPreferencePage"
id="org.eclipse.cdt.ui.preferences.MarkOccurrencesPreferencePage"/>
<page
name="%ScalabilityPreferencePage.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
class="org.eclipse.cdt.internal.ui.preferences.ScalabilityPreferencePage"
id="org.eclipse.cdt.ui.preferneces.CScalabilityPreferernces"/>
<!--page
name="%WorkInProgress.name"
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"

View file

@ -171,4 +171,6 @@ public interface ICHelpContextIds {
public static final String PATHENTRY_VARIABLES_PREFERENCE_PAGE= PREFIX + "pathentry_variables_preference_page_context"; //$NON-NLS-1$
public static final String SCALABILITY_PREFERENCE_PAGE = PREFIX + "scalability_preference_page_context"; //$NON-NLS-1$
}

View file

@ -43,6 +43,9 @@ import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.MessageDialogWithToggle;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
@ -92,6 +95,7 @@ import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.ISourceViewerExtension2;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
import org.eclipse.jface.text.source.projection.ProjectionSupport;
@ -116,6 +120,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorActionBarContributor;
@ -203,6 +208,7 @@ import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
import org.eclipse.cdt.internal.ui.text.CPairMatcher;
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
import org.eclipse.cdt.internal.ui.text.CSourceViewerScalableConfiguration;
import org.eclipse.cdt.internal.ui.text.CTextTools;
import org.eclipse.cdt.internal.ui.text.CWordFinder;
import org.eclipse.cdt.internal.ui.text.CWordIterator;
@ -1232,6 +1238,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
* @since 4.0
*/
private TextViewerDragAdapter fTextViewerDragAdapter;
/**
* True if editor is opening a large file.
* @since 5.0
*/
private boolean fEnableScalablilityMode = false;
private static final Set<String> angularIntroducers = new HashSet<String>();
static {
@ -1325,6 +1337,33 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
} else {
fBracketMatcher.configure(null);
}
int lines = getDocumentProvider().getDocument(input).getNumberOfLines();
if (lines > getPreferenceStore().getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)) {
//Detecting if scalability mode should be turned on
fEnableScalablilityMode = true;
//Alert users that scalability mode should be turned on
if (getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_ALERT)) {
MessageDialogWithToggle dialog = new MessageDialogWithToggle(
Display.getCurrent().getActiveShell(),
CEditorMessages.getString("Scalability.info"), //$NON-NLS-1$
null,
CEditorMessages.getString("Scalability.message"), //$NON-NLS-1$
MessageDialog.INFORMATION,
new String[] {IDialogConstants.OK_LABEL}, 0,
CEditorMessages.getString("Scalability.reappear"), //$NON-NLS-1$
false) {
@Override
protected void buttonPressed(int buttonId) {
PreferenceConstants.getPreferenceStore().setValue(PreferenceConstants.SCALABILITY_ALERT, !getToggleState());
super.buttonPressed(buttonId);
}
};
dialog.setBlockOnOpen(false);
dialog.open();
}
}
}
/*
@ -1337,7 +1376,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
SourceViewerConfiguration sourceViewerConfiguration= getSourceViewerConfiguration();
if (!(sourceViewerConfiguration instanceof CSourceViewerConfiguration)) {
CTextTools textTools= CUIPlugin.getDefault().getTextTools();
setSourceViewerConfiguration(new CSourceViewerConfiguration(textTools.getColorManager(), store, this, ICPartitions.C_PARTITIONING));
setSourceViewerConfiguration(new CSourceViewerScalableConfiguration(textTools.getColorManager(), store, this, ICPartitions.C_PARTITIONING));
}
if (getSourceViewer() instanceof CSourceViewer)
@ -1377,6 +1416,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
* @return Outline page.
*/
public CContentOutlinePage getOutlinePage() {
if (isEnableScalablilityMode() && getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_RECONCILER))
return null;
if (fOutlinePage == null) {
fOutlinePage = new CContentOutlinePage(this);
fOutlinePage.addSelectionChangedListener(this);
@ -1557,6 +1598,17 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
if (c instanceof ContentAssistant) {
ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
}
//For Scalability
if (PreferenceConstants.SCALABILITY_RECONCILER.equals(property)) {
((SourceViewer)getSourceViewer()).unconfigure();
getSourceViewer().configure(getSourceViewerConfiguration());
}
if (PreferenceConstants.SCALABILITY_SYNTAX_COLOR.equals(property)) {
((SourceViewer)getSourceViewer()).unconfigure();
getSourceViewer().configure(getSourceViewerConfiguration());
}
}
} finally {
super.handlePreferenceStoreChanged(event);
@ -3251,4 +3303,22 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
return new ChainedPreferenceStore(stores.toArray(new IPreferenceStore[stores.size()]));
}
/**
* @return <code>true</code> if parser based Content Assist proposals are disabled.
*
* @since 5.0
*/
public boolean isParserBasedContentAssistDisabled() {
return getPreferenceStore().getBoolean(PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST);
}
/**
* @return <code>true</code> if the number of lines in the file exceed
* the line number for scalability mode in the preference.
*
* @since 5.0
*/
public boolean isEnableScalablilityMode() {
return fEnableScalablilityMode;
}
}

View file

@ -20,6 +20,9 @@ AddIncludeOnSelection.label=Add Include
AddIncludeOnSelection.tooltip=Add Include Statement on Selection
AddIncludesOperation.description=Adding include statement
Scalability.message=You are opening a large file. Turning on scalability mode might help improve editor's performance. Please see the Scalability preference page under Preferences -> C/C++.
Scalability.info=Editor Scalability
Scalability.reappear=Do not show this message again.
ShowInCView.description=Show the current resource in the C/C++ Projects view
ShowInCView.label=Show in C/C++ Projects
ShowInCView.tooltip=Show current resource in C/C++ Projects view

View file

@ -32,6 +32,7 @@ import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.internal.ui.text.CPresentationReconciler;
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
import org.eclipse.cdt.internal.ui.text.CSourceViewerScalableConfiguration;
import org.eclipse.cdt.internal.ui.text.IColorManager;
import org.eclipse.cdt.internal.ui.text.IColorManagerExtension;
@ -300,7 +301,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
fColorManager= colorManager;
fPreferenceStore= preferenceStore;
if (fEditor != null) {
fConfiguration= new CSourceViewerConfiguration(colorManager, preferenceStore, editor, ICPartitions.C_PARTITIONING);
fConfiguration= new CSourceViewerScalableConfiguration(colorManager, preferenceStore, editor, ICPartitions.C_PARTITIONING);
fPresentationReconciler= (CPresentationReconciler) fConfiguration.getPresentationReconciler(sourceViewer);
} else {
fConfiguration= null;

View file

@ -367,6 +367,20 @@ public final class PreferencesMessages extends NLS {
public static String MarkOccurrencesConfigurationBlock_link_tooltip;
public static String MarkOccurrencesConfigurationBlock_markOccurrences;
public static String MarkOccurrencesConfigurationBlock_stickyOccurrences;
public static String ScalabilityPreferencePage_description;
public static String ScalabilityPreferencePage_detection_label;
public static String ScalabilityPreferencePage_detection_group_label;
public static String ScalabilityPreferencePage_trigger_lines_label;
public static String ScalabilityPreferencePage_error;
public static String ScalabilityPreferencePage_scalabilityMode_group_label;
public static String ScalabilityPreferencePage_scalabilityMode_label;
public static String ScalabilityPreferencePage_reconciler_label;
public static String ScalabilityPreferencePage_syntaxColor_label;
public static String ScalabilityPreferencePage_contentAssist_label;
public static String ScalabilityPreferencePage_note;
public static String ScalabilityPreferencePage_preferenceOnlyForNewViews;
static {
NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class);

View file

@ -424,3 +424,19 @@ MarkOccurrencesConfigurationBlock_link= The appearance can be configured on the
MarkOccurrencesConfigurationBlock_link_tooltip=Show the annotations preferences
MarkOccurrencesConfigurationBlock_markOccurrences= Mark &occurrences of the selected element in the current file.
MarkOccurrencesConfigurationBlock_stickyOccurrences= &Keep marks when the selection changes
#Scalability Preferences
ScalabilityPreferencePage_description= Settings for editor scalability
ScalabilityPreferencePage_detection_group_label= Scalability mode detection
ScalabilityPreferencePage_detection_label= Alert me when scalability mode should be turned on
ScalabilityPreferencePage_trigger_lines_label= Enable scalability mode options when the number of lines in the file is more than:
ScalabilityPreferencePage_error=Value must be an integer between {0} and {1}.
ScalabilityPreferencePage_scalabilityMode_group_label= Scalability mode settings
ScalabilityPreferencePage_scalabilityMode_label= Enable all scalability mode options
ScalabilityPreferencePage_reconciler_label= Disable editor reconciling (Outline view, semantic highlighting and editor folding will also be disabled)
ScalabilityPreferencePage_syntaxColor_label= Disable syntax coloring in editor
ScalabilityPreferencePage_contentAssist_label= Disable parsing-based content assist proposals
ScalabilityPreferencePage_note=Note:
ScalabilityPreferencePage_preferenceOnlyForNewViews=Some options do not affect opened views
ScalabilityPreferencePage_error=Value must be an integer between {0} and {1}.

View file

@ -0,0 +1,298 @@
/*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.preferences;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.Separator;
public class ScalabilityPreferencePage extends PreferencePage implements
IWorkbenchPreferencePage {
// Files with this number of lines will trigger scalability mode
private IntegerFieldEditor fLinesToTrigger;
private Button fAlertMe;
private Button fEnableAll;
private Button fReconciler;
private Button fSyntaxColor;
private Button fContentAssist;
private Map<Object, String> fCheckBoxes= new HashMap<Object, String>();
/**
* List of master/slave listeners when there's a dependency.
*
* @see #createDependency(Button, String, Control)
*/
private ArrayList<Object> fMasterSlaveListeners= new ArrayList<Object>();
public ScalabilityPreferencePage() {
setPreferenceStore(PreferenceConstants.getPreferenceStore());
setDescription(PreferencesMessages.ScalabilityPreferencePage_description);
}
/**
* Creates a button with the given label and sets the default configuration data.
*/
private Button createCheckButton( Composite parent, String label, String key ) {
Button button = new Button( parent, SWT.CHECK | SWT.LEFT );
button.setText( label );
// FieldEditor GridData
GridData data = new GridData();
button.setLayoutData( data );
fCheckBoxes.put(button, key);
return button;
}
private void initFields() {
IPreferenceStore prefs=getPreferenceStore();
Iterator<Object> iter= fCheckBoxes.keySet().iterator();
while (iter.hasNext()) {
Button b= (Button) iter.next();
String key= fCheckBoxes.get(b);
b.setSelection(prefs.getBoolean(key));
}
// Update slaves
iter= fMasterSlaveListeners.iterator();
while (iter.hasNext()) {
SelectionListener listener= (SelectionListener)iter.next();
listener.widgetSelected(null);
}
fLinesToTrigger.setStringValue(Integer.toString(prefs.getInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
}
/*
* @see PreferencePage#createControl(Composite)
*/
@Override
public void createControl(Composite parent) {
super.createControl(parent);
PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.SCALABILITY_PREFERENCE_PAGE);
}
/*
* @see PreferencePage#createContents(Composite)
*/
@Override
protected Control createContents(Composite parent) {
initializeDialogUnits(parent);
int nColumns= 1;
Composite composite= new Composite(parent, SWT.NONE);
GridLayout layout= new GridLayout();
layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth= 0;
layout.numColumns= nColumns;
composite.setLayout(layout);
GridData data = new GridData();
data.verticalAlignment = GridData.FILL;
data.horizontalAlignment = GridData.FILL;
composite.setLayoutData( data );
createDetectionSettings(composite);
new Separator().doFillIntoGrid(composite, nColumns);
createScalabilityModeSettings(composite);
new Separator().doFillIntoGrid(composite, nColumns);
String noteTitle= PreferencesMessages.ScalabilityPreferencePage_note;
String noteMessage= PreferencesMessages.ScalabilityPreferencePage_preferenceOnlyForNewViews;
Composite noteControl= createNoteComposite(JFaceResources.getDialogFont(), composite, noteTitle, noteMessage);
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= 2;
noteControl.setLayoutData(gd);
initFields();
Dialog.applyDialogFont(composite);
return composite;
}
/**
* Creates composite group and sets the default layout data.
*
* @param parent
* the parent of the new composite
* @param numColumns
* the number of columns for the new composite
* @param labelText
* the text label of the new composite
* @return the newly-created composite
*/
private Composite createGroupComposite( Composite parent, int numColumns, String labelText ) {
return ControlFactory.createGroup( parent, labelText, numColumns );
}
/**
* Create the view setting preferences composite widget
*/
private void createDetectionSettings( Composite parent ) {
Composite group = createGroupComposite( parent, 1, PreferencesMessages.ScalabilityPreferencePage_detection_group_label );
fAlertMe = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_detection_label,PreferenceConstants.SCALABILITY_ALERT);
}
/**
* Create the view setting preferences composite widget
*/
private void createScalabilityModeSettings( Composite parent ) {
Composite group = createGroupComposite( parent, 1, PreferencesMessages.ScalabilityPreferencePage_scalabilityMode_group_label );
Composite comp = ControlFactory.createComposite( group, 2 );
fLinesToTrigger = new IntegerFieldEditor( PreferenceConstants.SCALABILITY_NUMBER_OF_LINES, PreferencesMessages.ScalabilityPreferencePage_trigger_lines_label, comp);
GridData data = (GridData)fLinesToTrigger.getTextControl( comp ).getLayoutData();
data.horizontalAlignment = GridData.BEGINNING;
data.widthHint = convertWidthInCharsToPixels( 11 );
fLinesToTrigger.setPage( this );
fLinesToTrigger.setValidateStrategy( StringFieldEditor.VALIDATE_ON_KEY_STROKE );
fLinesToTrigger.setValidRange( 1, Integer.MAX_VALUE );
String minValue = Integer.toString( 1 );
String maxValue = Integer.toString( Integer.MAX_VALUE );
fLinesToTrigger.setErrorMessage( MessageFormat.format(PreferencesMessages.ScalabilityPreferencePage_error, new String[]{ minValue, maxValue } ) );
fLinesToTrigger.load();
fLinesToTrigger.setPropertyChangeListener( new IPropertyChangeListener() {
public void propertyChange( PropertyChangeEvent event ) {
if ( event.getProperty().equals( FieldEditor.IS_VALID ) )
setValid( fLinesToTrigger.isValid() );
}
} );
new Separator().doFillIntoGrid(group, 1);
fEnableAll = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_scalabilityMode_label, PreferenceConstants.SCALABILITY_ENABLE_ALL);
fReconciler = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_reconciler_label, PreferenceConstants.SCALABILITY_RECONCILER);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fReconciler);
fContentAssist = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_contentAssist_label, PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fContentAssist);
fSyntaxColor = createCheckButton(group, PreferencesMessages.ScalabilityPreferencePage_syntaxColor_label, PreferenceConstants.SCALABILITY_SYNTAX_COLOR);
createDependency(fEnableAll, PreferenceConstants.SCALABILITY_ENABLE_ALL, fSyntaxColor);
}
private static void indent(Control control) {
GridData gridData= new GridData();
gridData.horizontalIndent= 20;
control.setLayoutData(gridData);
}
private void createDependency(final Button master, String masterKey, final Control slave) {
indent(slave);
boolean masterState= getPreferenceStore().getBoolean(masterKey);
slave.setEnabled(!masterState);
if (masterState) {
((Button)slave).setSelection(masterState);
}
SelectionListener listener= new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
slave.setEnabled(!master.getSelection());
if (master.getSelection()) {
((Button)slave).setSelection(master.getSelection());
}
}
public void widgetDefaultSelected(SelectionEvent e) {}
};
master.addSelectionListener(listener);
fMasterSlaveListeners.add(listener);
}
/*
* @see IWorkbenchPreferencePage#init(IWorkbench)
*/
public void init(IWorkbench workbench) {
}
/*
* @see IPreferencePage#performOk()
*/
@Override
public boolean performOk() {
IPreferenceStore prefs= getPreferenceStore();
Iterator<Object> iter= fCheckBoxes.keySet().iterator();
while (iter.hasNext()) {
Button b= (Button) iter.next();
String key= fCheckBoxes.get(b);
prefs.setValue(key, b.getSelection());
}
prefs.setValue(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES, fLinesToTrigger.getIntValue());
CUIPlugin.getDefault().savePluginPreferences();
return super.performOk();
}
/*
* @see PreferencePage#performDefaults()
*/
@Override
protected void performDefaults() {
IPreferenceStore prefs= getPreferenceStore();
Iterator<Object> iter= fCheckBoxes.keySet().iterator();
while (iter.hasNext()) {
Button b= (Button) iter.next();
String key= fCheckBoxes.get(b);
b.setSelection(prefs.getDefaultBoolean(key));
}
// Update slaves
iter= fMasterSlaveListeners.iterator();
while (iter.hasNext()) {
SelectionListener listener= (SelectionListener)iter.next();
listener.widgetSelected(null);
}
fLinesToTrigger.setStringValue(Integer.toString(prefs.getDefaultInt(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES)));
}
}

View file

@ -107,35 +107,35 @@ import org.eclipse.cdt.internal.ui.typehierarchy.THInformationProvider;
*/
public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
private ITextEditor fTextEditor;
protected ITextEditor fTextEditor;
/**
* The document partitioning.
*/
private String fDocumentPartitioning;
protected String fDocumentPartitioning;
/**
* The code scanner.
*/
private AbstractCScanner fCodeScanner;
protected AbstractCScanner fCodeScanner;
/**
* The C multi-line comment scanner.
*/
private ICTokenScanner fMultilineDocCommentScanner;
protected ICTokenScanner fMultilineDocCommentScanner;
/**
* The C single-line comment scanner.
*/
private ICTokenScanner fSinglelineDocCommentScanner;
protected ICTokenScanner fSinglelineDocCommentScanner;
/**
* The C string scanner.
*/
private AbstractCScanner fStringScanner;
protected AbstractCScanner fStringScanner;
/**
* The preprocessor scanner.
*/
private AbstractCScanner fPreprocessorScanner;
protected AbstractCScanner fPreprocessorScanner;
/**
* The color manager.
*/
private IColorManager fColorManager;
protected IColorManager fColorManager;
/**
* Creates a new C source viewer configuration for viewers in the given editor
@ -238,7 +238,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
/**
* Initializes the scanners.
*/
private void initializeScanners() {
protected void initializeScanners() {
fStringScanner= new SingleTokenCScanner(getTokenStoreFactory(), ICColorConstants.C_STRING);
}
@ -397,7 +397,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* @return the settings
* @since 4.0
*/
private IDialogSettings getSettings(String sectionName) {
protected IDialogSettings getSettings(String sectionName) {
IDialogSettings settings= CUIPlugin.getDefault().getDialogSettings().getSection(sectionName);
if (settings == null)
settings= CUIPlugin.getDefault().getDialogSettings().addNewSection(sectionName);
@ -529,7 +529,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* @return the indent prefixes
* @see #getIndentPrefixes(ISourceViewer, String)
*/
private String[] getIndentPrefixesForSpaces(int tabWidth) {
protected String[] getIndentPrefixesForSpaces(int tabWidth) {
String[] indentPrefixes= new String[tabWidth + 2];
indentPrefixes[0]= getStringWithSpaces(tabWidth);
@ -552,7 +552,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* @param count the space count
* @return the string with the spaces
*/
private static String getStringWithSpaces(int count) {
protected static String getStringWithSpaces(int count) {
char[] spaceChars= new char[count];
Arrays.fill(spaceChars, ' ');
return new String(spaceChars);
@ -563,7 +563,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* no ICProject could be determined
* @return
*/
private ICProject getCProject() {
protected ICProject getCProject() {
ITextEditor editor= getEditor();
if (editor == null)
return null;
@ -751,7 +751,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* @return an information control creator
* @since 5.0
*/
private IInformationControlCreator getInformationPresenterControlCreator(ISourceViewer sourceViewer) {
protected IInformationControlCreator getInformationPresenterControlCreator(ISourceViewer sourceViewer) {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, true);
@ -827,7 +827,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* Creates control for outline presentation in editor.
* @return Control.
*/
private IInformationControlCreator getOutlineControlCreator() {
protected IInformationControlCreator getOutlineControlCreator() {
final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
/**
* @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
@ -845,7 +845,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* Creates control for outline presentation in editor.
* @return Control.
*/
private IInformationControlCreator getHierarchyControlCreator() {
protected IInformationControlCreator getHierarchyControlCreator() {
final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
/**
* @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
@ -929,7 +929,7 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* Creates control for macro exploration in editor.
* @return Control.
*/
private IInformationControlCreator getMacroExplorationControlCreator() {
protected IInformationControlCreator getMacroExplorationControlCreator() {
final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
return new CMacroExpansionExplorationControl(parent);

View file

@ -0,0 +1,53 @@
/*******************************************************************************
* Copyright (c) 2008 IBM Corporation 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.reconciler.IReconciler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.internal.ui.editor.CEditor;
/**
* Configuration for an <code>SourceViewer</code> which shows C/C++ code.
* It turns off some editor features when scalability mode options are enabled.
*/
public class CSourceViewerScalableConfiguration extends
CSourceViewerConfiguration {
public CSourceViewerScalableConfiguration(
IColorManager colorManager, IPreferenceStore preferenceStore,
ITextEditor editor, String partitioning) {
super(colorManager, preferenceStore, editor, partitioning);
}
@Override
public IReconciler getReconciler(ISourceViewer sourceViewer) {
if (((CEditor)getEditor()).isEnableScalablilityMode() && fPreferenceStore.getBoolean(PreferenceConstants.SCALABILITY_RECONCILER))
return null;
return super.getReconciler(sourceViewer);
}
/**
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
*/
@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
if (((CEditor)getEditor()).isEnableScalablilityMode() && fPreferenceStore.getBoolean(PreferenceConstants.SCALABILITY_SYNTAX_COLOR))
return null;
return super.getPresentationReconciler(sourceViewer);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2007 IBM Corporation and others.
* Copyright (c) 2005, 2008 IBM Corporation 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
@ -28,6 +28,7 @@ import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
import org.eclipse.cdt.ui.text.contentassist.ICEditorContentAssistInvocationContext;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
import org.eclipse.cdt.internal.ui.text.Symbols;
@ -61,7 +62,7 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
* @param viewer the viewer used by the editor
* @param offset the invocation offset
* @param editor the editor that content assist is invoked in
* @param isAutoActivated inidicates whether content assist was auto-activated
* @param isAutoActivated indicates whether content assist was auto-activated
*/
public CContentAssistInvocationContext(ITextViewer viewer, int offset, IEditorPart editor, boolean isCompletion, boolean isAutoActivated) {
super(viewer, offset);
@ -111,6 +112,14 @@ public class CContentAssistInvocationContext extends ContentAssistInvocationCont
}
public IASTCompletionNode getCompletionNode() {
//for scalability
if (fEditor != null && fEditor instanceof CEditor) {
CEditor editor = (CEditor)fEditor;
if (editor.isEnableScalablilityMode() && editor.isParserBasedContentAssistDisabled())
return null;
}
if (fCNComputed) return fCN;
fCNComputed = true;

View file

@ -1300,6 +1300,66 @@ public class PreferenceConstants {
*/
public static final String EDITOR_STICKY_OCCURRENCES= "stickyOccurrences"; //$NON-NLS-1$
/**
* A named preference that controls whether all scalability mode options should be turned on.
* <p>
* Value is of type <code>Boolean</code>.
* </p>
*
* @since 5.0
*/
public static final String SCALABILITY_ENABLE_ALL = "enableScalabilityOptions"; //$NON-NLS-1$
/**
* A named preference that controls whether the editor's reconciler is disabled.
* <p>
* Value is of type <code>Boolean</code>.
* </p>
*
* @since 5.0
*/
public static final String SCALABILITY_RECONCILER = "reconciler"; //$NON-NLS-1$
/**
* A named preference that controls whether syntax coloring is disabled.
* <p>
* Value is of type <code>Boolean</code>.
* </p>
*
* @since 5.0
*/
public static final String SCALABILITY_SYNTAX_COLOR = "syntaxColor"; //$NON-NLS-1$
/**
* A named preference that controls whether parser-based content assist proposals are disabled.
* <p>
* Value is of type <code>Boolean</code>.
* </p>
*
* @since 5.0
*/
public static final String SCALABILITY_PARSER_BASED_CONTENT_ASSIST = "cdtContentAssist"; //$NON-NLS-1$
/**
* A named preference that controls whether users should be notified if scalability mode should be turned on.
* <p>
* Value is of type <code>Boolean</code>.
* </p>
*
* @since 5.0
*/
public static final String SCALABILITY_ALERT = "detectScalability"; //$NON-NLS-1$
/**
* The size of the file that will trigger scalability mode
* <p>
* Value is of type <code>int</code>.
* </p>
*
* @since 5.0
*/
public static final String SCALABILITY_NUMBER_OF_LINES = "numberOfLines"; //$NON-NLS-1$
/**
* Returns the CDT-UI preference store.
*
@ -1481,6 +1541,14 @@ public class PreferenceConstants {
// mark occurrences
store.setDefault(PreferenceConstants.EDITOR_MARK_OCCURRENCES, true);
store.setDefault(PreferenceConstants.EDITOR_STICKY_OCCURRENCES, true);
//Scalability
store.setDefault(PreferenceConstants.SCALABILITY_ALERT, true);
store.setDefault(PreferenceConstants.SCALABILITY_NUMBER_OF_LINES, 5000);
store.setDefault(PreferenceConstants.SCALABILITY_ENABLE_ALL, false);
store.setDefault(PreferenceConstants.SCALABILITY_RECONCILER, false);
store.setDefault(PreferenceConstants.SCALABILITY_SYNTAX_COLOR, false);
store.setDefault(PreferenceConstants.SCALABILITY_PARSER_BASED_CONTENT_ASSIST, false);
}