mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-07 17:15:25 +02:00
159812: Mark Occurrences
This commit is contained in:
parent
aa03923d5f
commit
1ba6e6237a
47 changed files with 2369 additions and 482 deletions
core
org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser
org.eclipse.cdt.ui.tests
resources/ceditor
ui/org/eclipse/cdt/ui/tests/text
org.eclipse.cdt.ui
icons
plugin.propertiesplugin.xmlsrc/org/eclipse/cdt
internal/ui
ICHelpContextIds.java
editor
CEditor.javaCEditorActionContributor.javaCEditorMessages.propertiesEditorHighlightingSynchronizer.javaICEditorActionDefinitionIds.javaToggleMarkOccurrencesAction.java
preferences
MarkOccurrencesConfigurationBlock.javaMarkOccurrencesPreferencePage.javaPreferencesMessages.javaPreferencesMessages.properties
formatter
search
CSearchMessages.javaCSearchMessages.propertiesCountLabelProvider.javaIOccurrencesFinder.javaOccurrencesFinder.javaPDOMSearchListLabelProvider.javaPDOMSearchPage.javaPDOMSearchPatternQuery.javaPDOMSearchQuery.javaPDOMSearchTreeLabelProvider.java
actions
text
ui
|
@ -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
|
* 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
|
||||||
|
@ -423,17 +423,26 @@ public class CVisitor {
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( CharArrayUtils.equals(name.toCharArray(), binding.getNameCharArray()) &&
|
if( CharArrayUtils.equals(name.toCharArray(), binding.getNameCharArray()) )
|
||||||
name.resolveBinding() == binding ){
|
if (sameBinding(name.resolveBinding(), binding)){
|
||||||
if( refs.length == idx ){
|
if( refs.length == idx ){
|
||||||
IASTName [] temp = new IASTName[ refs.length * 2 ];
|
IASTName [] temp = new IASTName[ refs.length * 2 ];
|
||||||
System.arraycopy( refs, 0, temp, 0, refs.length );
|
System.arraycopy( refs, 0, temp, 0, refs.length );
|
||||||
refs = temp;
|
refs = temp;
|
||||||
|
}
|
||||||
|
refs[idx++] = name;
|
||||||
}
|
}
|
||||||
refs[idx++] = name;
|
|
||||||
}
|
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean sameBinding(IBinding binding1, IBinding binding2) {
|
||||||
|
if (binding1 == binding2)
|
||||||
|
return true;
|
||||||
|
if (binding1.equals(binding2))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public IASTName[] getReferences(){
|
public IASTName[] getReferences(){
|
||||||
if( idx < refs.length ){
|
if( idx < refs.length ){
|
||||||
IASTName [] temp = new IASTName[ idx ];
|
IASTName [] temp = new IASTName[ idx ];
|
||||||
|
@ -2024,7 +2033,7 @@ public class CVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
//label names
|
//label names
|
||||||
List b3 = new ArrayList();
|
List<ILabel> b3 = new ArrayList<ILabel>();
|
||||||
do{
|
do{
|
||||||
char [] n = name.toCharArray();
|
char [] n = name.toCharArray();
|
||||||
if( scope instanceof ICFunctionScope ){
|
if( scope instanceof ICFunctionScope ){
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation 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
|
||||||
|
@ -1338,6 +1338,7 @@ public class CPPVisitor {
|
||||||
prop == ICPPASTTypenameExpression.TYPENAME ||
|
prop == ICPPASTTypenameExpression.TYPENAME ||
|
||||||
prop == ICPPASTUsingDeclaration.NAME ||
|
prop == ICPPASTUsingDeclaration.NAME ||
|
||||||
prop == ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.NAME ||
|
prop == ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier.NAME ||
|
||||||
|
prop == ICPPASTTemplateId.TEMPLATE_NAME ||
|
||||||
p2 == ICPPASTQualifiedName.SEGMENT_NAME )
|
p2 == ICPPASTQualifiedName.SEGMENT_NAME )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -1374,7 +1375,7 @@ public class CPPVisitor {
|
||||||
p2 == ICPPASTQualifiedName.SEGMENT_NAME )
|
p2 == ICPPASTQualifiedName.SEGMENT_NAME )
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
109
core/org.eclipse.cdt.ui.tests/resources/ceditor/occurrences.cpp
Normal file
109
core/org.eclipse.cdt.ui.tests/resources/ceditor/occurrences.cpp
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
#define INT int
|
||||||
|
#define FUNCTION_MACRO(arg) globalFunc(arg)
|
||||||
|
|
||||||
|
enum Enumeration {
|
||||||
|
ONE, TWO, THREE
|
||||||
|
};
|
||||||
|
|
||||||
|
const int globalConstant = 0;
|
||||||
|
int globalVariable = 0;
|
||||||
|
static int globalStaticVariable = 0;
|
||||||
|
|
||||||
|
void globalFunc(int a);
|
||||||
|
static void globalStaticFunc() {
|
||||||
|
globalVariable = 1;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
class Base1 {
|
||||||
|
};
|
||||||
|
class Base2 {
|
||||||
|
};
|
||||||
|
|
||||||
|
class ClassContainer : Base1, Base2 {
|
||||||
|
public:
|
||||||
|
static int staticPubField;
|
||||||
|
const int constPubField;
|
||||||
|
const static int constStaticPubField;
|
||||||
|
int pubField;
|
||||||
|
|
||||||
|
static INT staticPubMethod(int arg) {
|
||||||
|
FUNCTION_MACRO(arg);
|
||||||
|
globalFunc(arg);
|
||||||
|
return globalStaticVariable;
|
||||||
|
}
|
||||||
|
int pubMethod();
|
||||||
|
|
||||||
|
typedef float pubTypedef;
|
||||||
|
pubTypedef tdField;
|
||||||
|
private:
|
||||||
|
static INT staticPrivMethod();
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T1, class T2> class TemplateClass {
|
||||||
|
T1 tArg1;
|
||||||
|
T2 tArg2;
|
||||||
|
TemplateClass(T1 arg1, T2 arg2) {
|
||||||
|
tArg1 = arg1;
|
||||||
|
tArg2 = arg2;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T1> class PartialInstantiatedClass : TemplateClass<T1, Base1> {
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CppStruct {
|
||||||
|
CppStruct() {}
|
||||||
|
int structField;
|
||||||
|
};
|
||||||
|
|
||||||
|
union CppUnion {
|
||||||
|
int unionField;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef CppUnion TUnion;
|
||||||
|
|
||||||
|
namespace ns {
|
||||||
|
int namespaceVar = 0;
|
||||||
|
int namespaceFunc() {
|
||||||
|
globalStaticFunc();
|
||||||
|
TUnion tu;
|
||||||
|
Enumeration e= TWO;
|
||||||
|
switch (e) {
|
||||||
|
case ONE: case THREE:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return namespaceVar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
INT ClassContainer::pubMethod() {
|
||||||
|
int localVar = 0;
|
||||||
|
ns::namespaceVar= 1;
|
||||||
|
return pubField + localVar;
|
||||||
|
}
|
||||||
|
|
||||||
|
INT ClassContainer::staticPrivMethod() {
|
||||||
|
CppStruct* st= new CppStruct();
|
||||||
|
st->structField= 1;
|
||||||
|
CppUnion un;
|
||||||
|
un.unionField= 2;
|
||||||
|
staticPubMethod(staticPubField);
|
||||||
|
label:
|
||||||
|
FUNCTION_MACRO(0);
|
||||||
|
if (un.unionField < st->structField)
|
||||||
|
goto label;
|
||||||
|
return globalConstant;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<int X>
|
||||||
|
class ConstantTemplate {
|
||||||
|
public:
|
||||||
|
int foo(int y) {
|
||||||
|
return X;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ConstantTemplate<5> c5;
|
||||||
|
ConstantTemplate<5> c52;
|
||||||
|
ConstantTemplate<4> c4;
|
|
@ -175,7 +175,7 @@ public class AbstractSemanticHighlightingTest extends TestCase {
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
disableAllSemanticHighlightings();
|
disableAllSemanticHighlightings();
|
||||||
EditorTestHelper.runEventQueue(1000);
|
EditorTestHelper.runEventQueue(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertEqualPositions(Position[] expected, Position[] actual) {
|
protected void assertEqualPositions(Position[] expected, Position[] actual) {
|
||||||
|
|
|
@ -0,0 +1,401 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.ui.tests.text;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import junit.extensions.TestSetup;
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import org.eclipse.core.resources.IFile;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
import org.eclipse.jface.preference.PreferenceConverter;
|
||||||
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
|
import org.eclipse.jface.text.FindReplaceDocumentAdapter;
|
||||||
|
import org.eclipse.jface.text.IDocument;
|
||||||
|
import org.eclipse.jface.text.IRegion;
|
||||||
|
import org.eclipse.jface.text.ITextSelection;
|
||||||
|
import org.eclipse.jface.text.Position;
|
||||||
|
import org.eclipse.jface.text.Region;
|
||||||
|
import org.eclipse.jface.text.source.Annotation;
|
||||||
|
import org.eclipse.jface.text.source.IAnnotationModel;
|
||||||
|
import org.eclipse.swt.custom.StyleRange;
|
||||||
|
import org.eclipse.swt.custom.StyledText;
|
||||||
|
import org.eclipse.swt.graphics.RGB;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
import org.eclipse.ui.PartInitException;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
import org.eclipse.ui.editors.text.EditorsUI;
|
||||||
|
import org.eclipse.ui.internal.editors.text.EditorsPlugin;
|
||||||
|
import org.eclipse.ui.texteditor.AnnotationPreference;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.ISelectionListenerWithAST;
|
||||||
|
import org.eclipse.cdt.internal.ui.viewsupport.SelectionListenerWithASTManager;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the C/C++ Editor's occurrence marking feature.
|
||||||
|
*
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public class MarkOccurrenceTest extends TestCase {
|
||||||
|
|
||||||
|
private static final String PROJECT = "MarkOccurrenceTest";
|
||||||
|
|
||||||
|
private static final String OCCURRENCE_ANNOTATION= "org.eclipse.cdt.ui.occurrences";
|
||||||
|
private static final RGB fgHighlightRGB= getHighlightRGB();
|
||||||
|
|
||||||
|
private CEditor fEditor;
|
||||||
|
private IDocument fDocument;
|
||||||
|
private FindReplaceDocumentAdapter fFindReplaceDocumentAdapter;
|
||||||
|
private int fOccurrences;
|
||||||
|
private IAnnotationModel fAnnotationModel;
|
||||||
|
private ISelectionListenerWithAST fSelWASTListener;
|
||||||
|
private IRegion fMatch;
|
||||||
|
private StyledText fTextWidget;
|
||||||
|
|
||||||
|
private MarkOccurrenceTestSetup fProjectSetup;
|
||||||
|
|
||||||
|
protected static class MarkOccurrenceTestSetup extends TestSetup {
|
||||||
|
private ICProject fCProject;
|
||||||
|
|
||||||
|
public MarkOccurrenceTestSetup(Test test) {
|
||||||
|
super(test);
|
||||||
|
}
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
fCProject= EditorTestHelper.createCProject(PROJECT, "resources/ceditor");
|
||||||
|
}
|
||||||
|
protected void tearDown () throws Exception {
|
||||||
|
if (fCProject != null)
|
||||||
|
CProjectHelper.delete(fCProject);
|
||||||
|
|
||||||
|
super.tearDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test setUpTest(Test someTest) {
|
||||||
|
return new MarkOccurrenceTestSetup(someTest);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
return setUpTest(new TestSuite(MarkOccurrenceTest.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setUp() throws Exception {
|
||||||
|
if (!ResourcesPlugin.getWorkspace().getRoot().exists(new Path(PROJECT))) {
|
||||||
|
fProjectSetup= new MarkOccurrenceTestSetup(this);
|
||||||
|
fProjectSetup.setUp();
|
||||||
|
}
|
||||||
|
assertNotNull(fgHighlightRGB);
|
||||||
|
CUIPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, true);
|
||||||
|
fEditor= openCEditor(new Path("/" + PROJECT + "/src/occurrences.cpp"));
|
||||||
|
assertNotNull(fEditor);
|
||||||
|
fTextWidget= fEditor.getViewer().getTextWidget();
|
||||||
|
assertNotNull(fTextWidget);
|
||||||
|
fDocument= fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
|
||||||
|
assertNotNull(fDocument);
|
||||||
|
fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(fDocument);
|
||||||
|
fAnnotationModel= fEditor.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput());
|
||||||
|
|
||||||
|
fMatch= null;
|
||||||
|
fSelWASTListener= new ISelectionListenerWithAST() {
|
||||||
|
public void selectionChanged(IEditorPart part, ITextSelection selection, IASTTranslationUnit astRoot) {
|
||||||
|
if (fMatch != null && selection != null && selection.getOffset() == fMatch.getOffset() && selection.getLength() == fMatch.getLength()) {
|
||||||
|
countOccurrences();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void countOccurrences() {
|
||||||
|
fOccurrences= 0;
|
||||||
|
Iterator iter= fAnnotationModel.getAnnotationIterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
Annotation annotation= (Annotation)iter.next();
|
||||||
|
if (OCCURRENCE_ANNOTATION.equals(annotation.getType()))
|
||||||
|
fOccurrences++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
SelectionListenerWithASTManager.getDefault().addListener(fEditor, fSelWASTListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see junit.framework.TestCase#tearDown()
|
||||||
|
*/
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
SelectionListenerWithASTManager.getDefault().removeListener(fEditor, fSelWASTListener);
|
||||||
|
EditorTestHelper.closeAllEditors();
|
||||||
|
if (fProjectSetup != null) {
|
||||||
|
fProjectSetup.tearDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CEditor openCEditor(IPath path) {
|
||||||
|
IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(path);
|
||||||
|
assertTrue(file != null && file.exists());
|
||||||
|
try {
|
||||||
|
return (CEditor)EditorTestHelper.openInEditor(file, true);
|
||||||
|
} catch (PartInitException e) {
|
||||||
|
fail();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMarkTypeOccurrences() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "ClassContainer", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(3);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMarkTypeOccurrences2() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "Base1", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(3);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMarkClassTemplateOccurrences() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "TemplateClass", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(2);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMarkTemplateParameterOccurrences() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "T1", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(3);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMarkTemplateIdOccurrences() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "ConstantTemplate", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(4);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMarkOccurrencesAfterEditorReuse() {
|
||||||
|
IPreferenceStore store= PlatformUI.getWorkbench().getPreferenceStore();
|
||||||
|
store.setValue("REUSE_OPEN_EDITORS_BOOLEAN", true);
|
||||||
|
|
||||||
|
int reuseOpenEditors= store.getInt("REUSE_OPEN_EDITORS");
|
||||||
|
store.setValue("REUSE_OPEN_EDITORS", 1);
|
||||||
|
|
||||||
|
SelectionListenerWithASTManager.getDefault().removeListener(fEditor, fSelWASTListener);
|
||||||
|
fEditor= openCEditor(new Path("/" + PROJECT + "/src/main.cpp"));
|
||||||
|
SelectionListenerWithASTManager.getDefault().addListener(fEditor, fSelWASTListener);
|
||||||
|
fDocument= fEditor.getDocumentProvider().getDocument(fEditor.getEditorInput());
|
||||||
|
assertNotNull(fDocument);
|
||||||
|
fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(fDocument);
|
||||||
|
fAnnotationModel= fEditor.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput());
|
||||||
|
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "main", true, true, false, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
fMatch= new Region(fMatch.getOffset(), 4);
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(1);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
|
||||||
|
store.setValue("REUSE_OPEN_EDITORS_BOOLEAN", false);
|
||||||
|
store.setValue("REUSE_OPEN_EDITORS", reuseOpenEditors);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMarkMethodOccurrences() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "pubMethod", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(2);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
public void testMarkFieldOccurrences() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "pubField", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(2);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMarkLocalOccurrences() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "localVar", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(2);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMarkMacroOccurrences() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "INT", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(5);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMarkEnumeratorOccurrences() {
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "ONE", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(2);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNoOccurrencesIfDisabled() {
|
||||||
|
CUIPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, false);
|
||||||
|
fOccurrences= Integer.MAX_VALUE;
|
||||||
|
try {
|
||||||
|
fMatch= fFindReplaceDocumentAdapter.find(0, "Base1", true, true, true, false);
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
|
assertOccurrences(0);
|
||||||
|
assertOccurrencesInWidget();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertOccurrencesInWidget() {
|
||||||
|
EditorTestHelper.runEventQueue(500);
|
||||||
|
|
||||||
|
Iterator iter= fAnnotationModel.getAnnotationIterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
Annotation annotation= (Annotation)iter.next();
|
||||||
|
if (OCCURRENCE_ANNOTATION.equals(annotation.getType()))
|
||||||
|
assertOccurrenceInWidget(fAnnotationModel.getPosition(annotation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertOccurrenceInWidget(Position position) {
|
||||||
|
StyleRange[] styleRanges= fTextWidget.getStyleRanges(position.offset, position.length);
|
||||||
|
for (int i= 0; i < styleRanges.length; i++) {
|
||||||
|
if (styleRanges[i].background != null) {
|
||||||
|
RGB rgb= styleRanges[i].background.getRGB();
|
||||||
|
if (fgHighlightRGB.equals(rgb))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fail();
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns the occurrence annotation color.
|
||||||
|
*
|
||||||
|
* @return the occurrence annotation color
|
||||||
|
*/
|
||||||
|
private static RGB getHighlightRGB() {
|
||||||
|
AnnotationPreference annotationPref= EditorsPlugin.getDefault().getAnnotationPreferenceLookup().getAnnotationPreference(OCCURRENCE_ANNOTATION);
|
||||||
|
IPreferenceStore store= EditorsUI.getPreferenceStore();
|
||||||
|
if (store != null)
|
||||||
|
return PreferenceConverter.getColor(store, annotationPref.getColorPreferenceKey());
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void assertOccurrences(final int expected) {
|
||||||
|
DisplayHelper helper= new DisplayHelper() {
|
||||||
|
protected boolean condition() {
|
||||||
|
return fOccurrences == expected;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (!helper.waitForCondition(EditorTestHelper.getActiveDisplay(), 10000)) {
|
||||||
|
assertEquals(expected, fOccurrences);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2008 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
|
||||||
|
@ -46,6 +46,7 @@ public class TextTestSuite extends TestSuite {
|
||||||
addTest(CHeaderRuleTest.suite());
|
addTest(CHeaderRuleTest.suite());
|
||||||
addTest(NumberRuleTest.suite());
|
addTest(NumberRuleTest.suite());
|
||||||
addTest(PairMatcherTest.suite());
|
addTest(PairMatcherTest.suite());
|
||||||
|
addTest(MarkOccurrenceTest.suite());
|
||||||
|
|
||||||
// folding tests
|
// folding tests
|
||||||
addTest(FoldingTest.suite());
|
addTest(FoldingTest.suite());
|
||||||
|
|
BIN
core/org.eclipse.cdt.ui/icons/dtool16/mark_occurrences.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/dtool16/mark_occurrences.gif
Normal file
Binary file not shown.
After ![]() (image error) Size: 208 B |
BIN
core/org.eclipse.cdt.ui/icons/etool16/mark_occurrences.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/etool16/mark_occurrences.gif
Normal file
Binary file not shown.
After ![]() (image error) Size: 321 B |
BIN
core/org.eclipse.cdt.ui/icons/obj16/searchm_obj.gif
Normal file
BIN
core/org.eclipse.cdt.ui/icons/obj16/searchm_obj.gif
Normal file
Binary file not shown.
After ![]() (image error) Size: 200 B |
|
@ -133,13 +133,14 @@ CPluginTemplatePreferencePage.name=Templates
|
||||||
CPluginBuildConsolePreferencePage.name=Build Console
|
CPluginBuildConsolePreferencePage.name=Build Console
|
||||||
CPluginFileTypesPreferencePage.name=File Types
|
CPluginFileTypesPreferencePage.name=File Types
|
||||||
CodeFormatterPreferencePage.name=Code Style
|
CodeFormatterPreferencePage.name=Code Style
|
||||||
codeTemplatePreferencePageName=Code Templates
|
codeTemplatePreferencePage.name=Code Templates
|
||||||
CodeAssistPreferencePage.name=Content Assist
|
CodeAssistPreferencePage.name=Content Assist
|
||||||
CodeAssistAdvancedPreferencePage.name=Advanced
|
CodeAssistAdvancedPreferencePage.name=Advanced
|
||||||
SmartTypingPreferencePage.name=Typing
|
SmartTypingPreferencePage.name=Typing
|
||||||
ColoringPreferencePage.name=Syntax Coloring
|
ColoringPreferencePage.name=Syntax Coloring
|
||||||
FoldingPreferencePage.name=Folding
|
FoldingPreferencePage.name=Folding
|
||||||
HoverPreferencePage.name=Hovers
|
HoverPreferencePage.name=Hovers
|
||||||
|
markOccurrencesPreferencePage.name= Mark Occurrences
|
||||||
|
|
||||||
DefaultBinaryFileEditor.name = Default Binary File Editor
|
DefaultBinaryFileEditor.name = Default Binary File Editor
|
||||||
AsmEditor.name = Assembly Editor
|
AsmEditor.name = Assembly Editor
|
||||||
|
@ -436,3 +437,10 @@ HelpInfo=Allows contributing the map files to the map-file-based CDT CHelpProvid
|
||||||
# Macro Expansion Hover key binding context
|
# Macro Expansion Hover key binding context
|
||||||
macroExpansionHoverScope.name= In Macro Expansion Hover
|
macroExpansionHoverScope.name= In Macro Expansion Hover
|
||||||
macroExpansionHoverScope.description= In Macro Expansion Hover
|
macroExpansionHoverScope.description= In Macro Expansion Hover
|
||||||
|
|
||||||
|
# Mark occurrences
|
||||||
|
toggleMarkOccurrences.label= Toggle Mark Occurrences
|
||||||
|
toggleMarkOccurrences.tooltip= Toggle Mark Occurrences
|
||||||
|
toggleMarkOccurrences.description= Toggles mark occurrences in C/C++ editors
|
||||||
|
|
||||||
|
OccurrenceAnnotation.label= C/C++ Occurrences
|
||||||
|
|
|
@ -750,10 +750,15 @@
|
||||||
id="org.eclipse.cdt.ui.preferences.TodoTaskPreferencePage"
|
id="org.eclipse.cdt.ui.preferences.TodoTaskPreferencePage"
|
||||||
name="%todoTaskPrefName"/>
|
name="%todoTaskPrefName"/>
|
||||||
<page
|
<page
|
||||||
name="%codeTemplatePreferencePageName"
|
name="%codeTemplatePreferencePage.name"
|
||||||
category="org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"
|
category="org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"
|
||||||
class="org.eclipse.cdt.internal.ui.preferences.CodeTemplatePreferencePage"
|
class="org.eclipse.cdt.internal.ui.preferences.CodeTemplatePreferencePage"
|
||||||
id="org.eclipse.cdt.ui.preferences.CodeTemplatePreferencePage"/>
|
id="org.eclipse.cdt.ui.preferences.CodeTemplatePreferencePage"/>
|
||||||
|
<page
|
||||||
|
name="%markOccurrencesPreferencePage.name"
|
||||||
|
category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
|
||||||
|
class="org.eclipse.cdt.internal.ui.preferences.MarkOccurrencesPreferencePage"
|
||||||
|
id="org.eclipse.cdt.ui.preferences.MarkOccurrencesPreferencePage"/>
|
||||||
<!--page
|
<!--page
|
||||||
name="%WorkInProgress.name"
|
name="%WorkInProgress.name"
|
||||||
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
|
category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
|
||||||
|
@ -1256,6 +1261,24 @@
|
||||||
tooltip="%NewProjectDropDownAction.tooltip">
|
tooltip="%NewProjectDropDownAction.tooltip">
|
||||||
</action>
|
</action>
|
||||||
</actionSet>
|
</actionSet>
|
||||||
|
<actionSet
|
||||||
|
label="%CEditorPresentationActionSet.label"
|
||||||
|
visible="false"
|
||||||
|
id="org.eclipse.cdt.ui.text.c.actionSet.presentation">
|
||||||
|
<action
|
||||||
|
allowLabelUpdate="true"
|
||||||
|
style="toggle"
|
||||||
|
toolbarPath="org.eclipse.ui.edit.text.actionSet.presentation/Presentation"
|
||||||
|
id="org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"
|
||||||
|
definitionId="org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"
|
||||||
|
disabledIcon="$nl$/icons/dtool16/mark_occurrences.gif"
|
||||||
|
icon="$nl$/icons/etool16/mark_occurrences.gif"
|
||||||
|
helpContextId="toggle_mark_occurrences_action"
|
||||||
|
label="%toggleMarkOccurrences.label"
|
||||||
|
retarget="true"
|
||||||
|
tooltip="%toggleMarkOccurrences.tooltip">
|
||||||
|
</action>
|
||||||
|
</actionSet>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.ide.projectNatureImages">
|
point="org.eclipse.ui.ide.projectNatureImages">
|
||||||
|
@ -1452,6 +1475,11 @@
|
||||||
contextId="org.eclipse.cdt.ui.macroExpansionHoverScope"
|
contextId="org.eclipse.cdt.ui.macroExpansionHoverScope"
|
||||||
commandId="org.eclipse.cdt.ui.hover.forwardMacroExpansion"
|
commandId="org.eclipse.cdt.ui.hover.forwardMacroExpansion"
|
||||||
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
|
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
|
||||||
|
<key
|
||||||
|
sequence="M2+M3+O"
|
||||||
|
contextId="org.eclipse.cdt.ui.cEditorScope"
|
||||||
|
commandId="org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"
|
||||||
|
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.commands">
|
point="org.eclipse.ui.commands">
|
||||||
|
@ -1605,6 +1633,11 @@
|
||||||
description="%ActionDefinition.forwardMacroExpansion.description"
|
description="%ActionDefinition.forwardMacroExpansion.description"
|
||||||
categoryId="org.eclipse.cdt.ui.category.source"
|
categoryId="org.eclipse.cdt.ui.category.source"
|
||||||
id="org.eclipse.cdt.ui.hover.forwardMacroExpansion"/>
|
id="org.eclipse.cdt.ui.hover.forwardMacroExpansion"/>
|
||||||
|
<command
|
||||||
|
name="%toggleMarkOccurrences.label"
|
||||||
|
description="%toggleMarkOccurrences.description"
|
||||||
|
categoryId="org.eclipse.cdt.ui.category.source"
|
||||||
|
id="org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"/>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
id="pdomSearchPage"
|
id="pdomSearchPage"
|
||||||
|
@ -1641,6 +1674,12 @@
|
||||||
id="org.eclipse.cdt.ui.editor.CEditor">
|
id="org.eclipse.cdt.ui.editor.CEditor">
|
||||||
</part>
|
</part>
|
||||||
</actionSetPartAssociation>
|
</actionSetPartAssociation>
|
||||||
|
<actionSetPartAssociation
|
||||||
|
targetID="org.eclipse.cdt.ui.text.c.actionSet.presentation">
|
||||||
|
<part
|
||||||
|
id="org.eclipse.cdt.ui.editor.CEditor">
|
||||||
|
</part>
|
||||||
|
</actionSetPartAssociation>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.cdt.ui.BinaryParserPage">
|
point="org.eclipse.cdt.ui.BinaryParserPage">
|
||||||
|
@ -1681,6 +1720,7 @@
|
||||||
</workingSet>
|
</workingSet>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
|
id="org.eclipse.cdt.ui.annotations"
|
||||||
point="org.eclipse.ui.editors.markerAnnotationSpecification">
|
point="org.eclipse.ui.editors.markerAnnotationSpecification">
|
||||||
<specification
|
<specification
|
||||||
colorPreferenceValue="254,155,0"
|
colorPreferenceValue="254,155,0"
|
||||||
|
@ -1705,6 +1745,31 @@
|
||||||
isGoToPreviousNavigationTargetKey="isIndexResultGoToPreviousNavigationTarget"
|
isGoToPreviousNavigationTargetKey="isIndexResultGoToPreviousNavigationTarget"
|
||||||
isGoToPreviousNavigationTarget="false">
|
isGoToPreviousNavigationTarget="false">
|
||||||
</specification>
|
</specification>
|
||||||
|
<specification
|
||||||
|
annotationType="org.eclipse.cdt.ui.occurrences"
|
||||||
|
label="%OccurrenceAnnotation.label"
|
||||||
|
icon="$nl$/icons/obj16/searchm_obj.gif"
|
||||||
|
textPreferenceKey="org.eclipse.cdt.ui.occurrenceIndication"
|
||||||
|
textPreferenceValue="false"
|
||||||
|
highlightPreferenceKey="org.eclipse.cdt.ui.occurrenceHighlighting"
|
||||||
|
highlightPreferenceValue="true"
|
||||||
|
contributesToHeader="false"
|
||||||
|
overviewRulerPreferenceKey="org.eclipse.cdt.ui.occurrenceIndicationInOverviewRuler"
|
||||||
|
overviewRulerPreferenceValue="true"
|
||||||
|
verticalRulerPreferenceKey="org.eclipse.cdt.ui.occurrenceIndicationInVerticalRuler"
|
||||||
|
verticalRulerPreferenceValue="false"
|
||||||
|
colorPreferenceKey="org.eclipse.cdt.ui.occurrenceIndicationColor"
|
||||||
|
colorPreferenceValue="212,212,212"
|
||||||
|
presentationLayer="4"
|
||||||
|
showInNextPrevDropdownToolbarActionKey="org.eclipse.cdt.ui.showOccurrenceInNextPrevDropdownToolbarAction"
|
||||||
|
showInNextPrevDropdownToolbarAction="true"
|
||||||
|
isGoToNextNavigationTargetKey="org.eclipse.cdt.ui.isOccurrenceGoToNextNavigationTarget"
|
||||||
|
isGoToNextNavigationTarget="false"
|
||||||
|
isGoToPreviousNavigationTargetKey="org.eclipse.cdt.ui.isOccurrenceGoToPreviousNavigationTarget"
|
||||||
|
isGoToPreviousNavigationTarget="false"
|
||||||
|
textStylePreferenceKey="org.eclipse.cdt.ui.occurrenceTextStyle"
|
||||||
|
textStylePreferenceValue="NONE">
|
||||||
|
</specification>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.search.searchResultViewPages">
|
point="org.eclipse.search.searchResultViewPages">
|
||||||
|
@ -1829,6 +1894,9 @@
|
||||||
markerType="org.eclipse.cdt.core.indexermarker"
|
markerType="org.eclipse.cdt.core.indexermarker"
|
||||||
name="org.eclipse.cdt.ui.indexmarker">
|
name="org.eclipse.cdt.ui.indexmarker">
|
||||||
</type>
|
</type>
|
||||||
|
<type
|
||||||
|
name="org.eclipse.cdt.ui.occurrences">
|
||||||
|
</type>
|
||||||
</extension>
|
</extension>
|
||||||
<extension point="org.eclipse.ui.workbench.texteditor.spellingEngine">
|
<extension point="org.eclipse.ui.workbench.texteditor.spellingEngine">
|
||||||
<engine
|
<engine
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2007 IBM Corporation and others.
|
* Copyright (c) 2006, 2008 IBM Corporation 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
|
||||||
|
@ -46,6 +46,7 @@ public interface ICHelpContextIds {
|
||||||
public static final String PREVIOUS_PROBLEM_ACTION= PREFIX + "previous_problem_action"; //$NON-NLS-1$
|
public static final String PREVIOUS_PROBLEM_ACTION= PREFIX + "previous_problem_action"; //$NON-NLS-1$
|
||||||
public static final String GOTO_NEXT_ERROR_ACTION= PREFIX + "goto_next_error_action"; //$NON-NLS-1$
|
public static final String GOTO_NEXT_ERROR_ACTION= PREFIX + "goto_next_error_action"; //$NON-NLS-1$
|
||||||
public static final String GOTO_PREVIOUS_ERROR_ACTION= PREFIX + "goto_previous_error_action"; //$NON-NLS-1$
|
public static final String GOTO_PREVIOUS_ERROR_ACTION= PREFIX + "goto_previous_error_action"; //$NON-NLS-1$
|
||||||
|
public static final String TOGGLE_MARK_OCCURRENCES_ACTION= PREFIX + "toggle_mark_occurrences_action"; //$NON-NLS-1$
|
||||||
|
|
||||||
// Preference/property pages
|
// Preference/property pages
|
||||||
public static final String C_PREF_PAGE = PREFIX + "c_pref"; //$NON-NLS-1$
|
public static final String C_PREF_PAGE = PREFIX + "c_pref"; //$NON-NLS-1$
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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
|
* 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,6 +50,7 @@ public class CEditorActionContributor extends TextEditorActionContributor {
|
||||||
private RetargetTextEditorAction fToggleInsertModeAction;
|
private RetargetTextEditorAction fToggleInsertModeAction;
|
||||||
private RetargetTextEditorAction fShowOutline;
|
private RetargetTextEditorAction fShowOutline;
|
||||||
private RetargetTextEditorAction fToggleSourceHeader;
|
private RetargetTextEditorAction fToggleSourceHeader;
|
||||||
|
private ToggleMarkOccurrencesAction fToggleMarkOccurrencesAction;
|
||||||
|
|
||||||
public CEditorActionContributor() {
|
public CEditorActionContributor() {
|
||||||
super();
|
super();
|
||||||
|
@ -81,8 +82,9 @@ public class CEditorActionContributor extends TextEditorActionContributor {
|
||||||
|
|
||||||
// actions that are "contributed" to editors, they are considered belonging to the active editor
|
// actions that are "contributed" to editors, they are considered belonging to the active editor
|
||||||
fTogglePresentation= new TogglePresentationAction();
|
fTogglePresentation= new TogglePresentationAction();
|
||||||
fTogglePresentation.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY);
|
|
||||||
|
fToggleMarkOccurrencesAction= new ToggleMarkOccurrencesAction();
|
||||||
|
|
||||||
fPreviousAnnotation= new GotoAnnotationAction("PreviousAnnotation.", false); //$NON-NLS-1$
|
fPreviousAnnotation= new GotoAnnotationAction("PreviousAnnotation.", false); //$NON-NLS-1$
|
||||||
fNextAnnotation= new GotoAnnotationAction("NextAnnotation.", true); //$NON-NLS-1$
|
fNextAnnotation= new GotoAnnotationAction("NextAnnotation.", true); //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -102,7 +104,8 @@ public class CEditorActionContributor extends TextEditorActionContributor {
|
||||||
|
|
||||||
fToggleSourceHeader= new RetargetTextEditorAction(bundle, "ToggleSourceHeader."); //$NON-NLS-1$
|
fToggleSourceHeader= new RetargetTextEditorAction(bundle, "ToggleSourceHeader."); //$NON-NLS-1$
|
||||||
fToggleSourceHeader.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_SOURCE_HEADER);
|
fToggleSourceHeader.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_SOURCE_HEADER);
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.ui.texteditor.BasicTextEditorActionContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
|
* @see org.eclipse.ui.texteditor.BasicTextEditorActionContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager)
|
||||||
|
@ -156,6 +159,7 @@ public class CEditorActionContributor extends TextEditorActionContributor {
|
||||||
bars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, fNextAnnotation);
|
bars.setGlobalActionHandler(ITextEditorActionConstants.NEXT, fNextAnnotation);
|
||||||
bars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, fPreviousAnnotation);
|
bars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, fPreviousAnnotation);
|
||||||
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
|
bars.setGlobalActionHandler(ITextEditorActionDefinitionIds.TOGGLE_SHOW_SELECTED_ELEMENT_ONLY, fTogglePresentation);
|
||||||
|
bars.setGlobalActionHandler(ICEditorActionDefinitionIds.TOGGLE_MARK_OCCURRENCES, fToggleMarkOccurrencesAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -173,6 +177,7 @@ public class CEditorActionContributor extends TextEditorActionContributor {
|
||||||
fShiftLeft.setAction(getAction(textEditor, ITextEditorActionConstants.SHIFT_LEFT));
|
fShiftLeft.setAction(getAction(textEditor, ITextEditorActionConstants.SHIFT_LEFT));
|
||||||
|
|
||||||
fTogglePresentation.setEditor(textEditor);
|
fTogglePresentation.setEditor(textEditor);
|
||||||
|
fToggleMarkOccurrencesAction.setEditor(textEditor);
|
||||||
fPreviousAnnotation.setEditor(textEditor);
|
fPreviousAnnotation.setEditor(textEditor);
|
||||||
fNextAnnotation.setEditor(textEditor);
|
fNextAnnotation.setEditor(textEditor);
|
||||||
|
|
||||||
|
@ -204,4 +209,4 @@ public class CEditorActionContributor extends TextEditorActionContributor {
|
||||||
setActiveEditor(null);
|
setActiveEditor(null);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,3 +179,8 @@ ToggleSourceHeader.label= To&ggle Source/Header
|
||||||
ToggleSourceHeader.tooltip= Toggle Source and Header File
|
ToggleSourceHeader.tooltip= Toggle Source and Header File
|
||||||
ToggleInsertMode.image=
|
ToggleInsertMode.image=
|
||||||
ToggleSourceHeader.description= Toggles between corresponding source and header file
|
ToggleSourceHeader.description= Toggles between corresponding source and header file
|
||||||
|
|
||||||
|
ToggleMarkOccurrencesAction.label= Toggle Mark Occurrences
|
||||||
|
ToggleMarkOccurrencesAction.tooltip= Toggle Mark Occurrences
|
||||||
|
|
||||||
|
CEditor_markOccurrences_job_name= Occurrences Marker
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.editor;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
|
||||||
|
import org.eclipse.jface.text.link.ILinkedModeListener;
|
||||||
|
import org.eclipse.jface.text.link.LinkedModeModel;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns off occurrences highlighting on a C editor until linked mode is
|
||||||
|
* left.
|
||||||
|
*
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public class EditorHighlightingSynchronizer implements ILinkedModeListener {
|
||||||
|
|
||||||
|
private final CEditor fEditor;
|
||||||
|
private final boolean fWasOccurrencesOn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new synchronizer.
|
||||||
|
*
|
||||||
|
* @param editor the editor the occurrences markers of which will be
|
||||||
|
* synchronized with the linked mode
|
||||||
|
*/
|
||||||
|
public EditorHighlightingSynchronizer(CEditor editor) {
|
||||||
|
Assert.isLegal(editor != null);
|
||||||
|
fEditor= editor;
|
||||||
|
fWasOccurrencesOn= fEditor.isMarkingOccurrences();
|
||||||
|
|
||||||
|
if (fWasOccurrencesOn && !isEditorDisposed())
|
||||||
|
fEditor.uninstallOccurrencesFinder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.jface.text.link.ILinkedModeListener#left(org.eclipse.jface.text.link.LinkedModeModel, int)
|
||||||
|
*/
|
||||||
|
public void left(LinkedModeModel environment, int flags) {
|
||||||
|
if (fWasOccurrencesOn && !isEditorDisposed())
|
||||||
|
fEditor.installOccurrencesFinder(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isEditorDisposed() {
|
||||||
|
return fEditor == null || fEditor.getSelectionProvider() == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.jface.text.link.ILinkedModeListener#suspend(org.eclipse.jface.text.link.LinkedModeModel)
|
||||||
|
*/
|
||||||
|
public void suspend(LinkedModeModel environment) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.jface.text.link.ILinkedModeListener#resume(org.eclipse.jface.text.link.LinkedModeModel, int)
|
||||||
|
*/
|
||||||
|
public void resume(LinkedModeModel environment, int flags) {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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
|
* 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
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.editor;
|
package org.eclipse.cdt.internal.ui.editor;
|
||||||
|
@ -185,4 +186,11 @@ public interface ICEditorActionDefinitionIds extends ITextEditorActionDefinition
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public static final String TOGGLE_SOURCE_HEADER = "org.eclipse.cdt.ui.edit.text.c.toggle.source.header"; //$NON-NLS-1$
|
public static final String TOGGLE_SOURCE_HEADER = "org.eclipse.cdt.ui.edit.text.c.toggle.source.header"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action definition id of toggle mark occurrences action
|
||||||
|
* (value: <code>"org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"</code>).
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public static final String TOGGLE_MARK_OCCURRENCES= "org.eclipse.cdt.ui.edit.text.c.toggleMarkOccurrences"; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.editor;
|
||||||
|
|
||||||
|
|
||||||
|
import org.eclipse.jface.action.IAction;
|
||||||
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
import org.eclipse.ui.texteditor.TextEditorAction;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.CPluginImages;
|
||||||
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A toolbar action which toggles the {@linkplain org.eclipse.cdt.ui.PreferenceConstants#EDITOR_MARK_OCCURRENCES mark occurrences preference}.
|
||||||
|
*
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public class ToggleMarkOccurrencesAction extends TextEditorAction implements IPropertyChangeListener {
|
||||||
|
|
||||||
|
private IPreferenceStore fStore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs and updates the action.
|
||||||
|
*/
|
||||||
|
public ToggleMarkOccurrencesAction() {
|
||||||
|
super(CEditorMessages.getResourceBundle(), "ToggleMarkOccurrencesAction.", null, IAction.AS_CHECK_BOX); //$NON-NLS-1$
|
||||||
|
CPluginImages.setToolImageDescriptors(this, "mark_occurrences.gif"); //$NON-NLS-1$
|
||||||
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.TOGGLE_MARK_OCCURRENCES_ACTION);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see IAction#actionPerformed
|
||||||
|
*/
|
||||||
|
public void run() {
|
||||||
|
fStore.setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see TextEditorAction#update
|
||||||
|
*/
|
||||||
|
public void update() {
|
||||||
|
ITextEditor editor= getTextEditor();
|
||||||
|
|
||||||
|
boolean checked= false;
|
||||||
|
if (editor instanceof CEditor)
|
||||||
|
checked= ((CEditor)editor).isMarkingOccurrences();
|
||||||
|
|
||||||
|
setChecked(checked);
|
||||||
|
setEnabled(editor != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see TextEditorAction#setEditor(ITextEditor)
|
||||||
|
*/
|
||||||
|
public void setEditor(ITextEditor editor) {
|
||||||
|
|
||||||
|
super.setEditor(editor);
|
||||||
|
|
||||||
|
if (editor != null) {
|
||||||
|
|
||||||
|
if (fStore == null) {
|
||||||
|
fStore= CUIPlugin.getDefault().getPreferenceStore();
|
||||||
|
fStore.addPropertyChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (fStore != null) {
|
||||||
|
fStore.removePropertyChangeListener(this);
|
||||||
|
fStore= null;
|
||||||
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
|
||||||
|
*/
|
||||||
|
public void propertyChange(PropertyChangeEvent event) {
|
||||||
|
if (event.getProperty().equals(PreferenceConstants.EDITOR_MARK_OCCURRENCES))
|
||||||
|
setChecked(Boolean.valueOf(event.getNewValue().toString()).booleanValue());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,221 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
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.swt.widgets.Label;
|
||||||
|
import org.eclipse.swt.widgets.Link;
|
||||||
|
import org.eclipse.ui.dialogs.PreferencesUtil;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
|
||||||
|
import org.eclipse.cdt.internal.ui.util.PixelConverter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures C/C++ Editor mark occurrences preferences.
|
||||||
|
*
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock {
|
||||||
|
|
||||||
|
private OverlayPreferenceStore fStore;
|
||||||
|
|
||||||
|
|
||||||
|
private Map fCheckBoxes= new HashMap();
|
||||||
|
private SelectionListener fCheckBoxListener= new SelectionListener() {
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {
|
||||||
|
}
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
Button button= (Button) e.widget;
|
||||||
|
fStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of master/slave listeners when there's a dependency.
|
||||||
|
*
|
||||||
|
* @see #createDependency(Button, String, Control)
|
||||||
|
*/
|
||||||
|
private ArrayList fMasterSlaveListeners= new ArrayList();
|
||||||
|
|
||||||
|
private StatusInfo fStatus;
|
||||||
|
|
||||||
|
public MarkOccurrencesConfigurationBlock(OverlayPreferenceStore store) {
|
||||||
|
Assert.isNotNull(store);
|
||||||
|
fStore= store;
|
||||||
|
|
||||||
|
fStore.addKeys(createOverlayStoreKeys());
|
||||||
|
}
|
||||||
|
|
||||||
|
private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
|
||||||
|
|
||||||
|
ArrayList overlayKeys= new ArrayList();
|
||||||
|
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OCCURRENCES));
|
||||||
|
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
|
||||||
|
|
||||||
|
OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
|
||||||
|
overlayKeys.toArray(keys);
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates page for mark occurrences preferences.
|
||||||
|
*
|
||||||
|
* @param parent the parent composite
|
||||||
|
* @return the control for the preference page
|
||||||
|
*/
|
||||||
|
public Control createControl(final Composite parent) {
|
||||||
|
|
||||||
|
Composite composite= new Composite(parent, SWT.NONE);
|
||||||
|
GridLayout layout= new GridLayout();
|
||||||
|
layout.numColumns= 1;
|
||||||
|
layout.marginHeight= 0;
|
||||||
|
layout.marginWidth= 0;
|
||||||
|
composite.setLayout(layout);
|
||||||
|
|
||||||
|
Link link= new Link(composite, SWT.NONE);
|
||||||
|
link.setText(PreferencesMessages.MarkOccurrencesConfigurationBlock_link);
|
||||||
|
link.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// TODO replace by link-specific tooltips when
|
||||||
|
// bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed
|
||||||
|
link.setToolTipText(PreferencesMessages.MarkOccurrencesConfigurationBlock_link_tooltip);
|
||||||
|
|
||||||
|
addFiller(composite);
|
||||||
|
|
||||||
|
String label;
|
||||||
|
|
||||||
|
label= PreferencesMessages.MarkOccurrencesConfigurationBlock_markOccurrences;
|
||||||
|
Button master= addCheckBox(composite, label, PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0);
|
||||||
|
|
||||||
|
addFiller(composite);
|
||||||
|
|
||||||
|
label= PreferencesMessages.MarkOccurrencesConfigurationBlock_stickyOccurrences;
|
||||||
|
Button slave = addCheckBox(composite, label, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0);
|
||||||
|
createDependency(master, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, slave);
|
||||||
|
|
||||||
|
return composite;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addFiller(Composite composite) {
|
||||||
|
PixelConverter pixelConverter= new PixelConverter(composite);
|
||||||
|
|
||||||
|
Label filler= new Label(composite, SWT.LEFT );
|
||||||
|
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
|
||||||
|
gd.horizontalSpan= 2;
|
||||||
|
gd.heightHint= pixelConverter.convertHeightInCharsToPixels(1) / 2;
|
||||||
|
filler.setLayoutData(gd);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Button addCheckBox(Composite parent, String label, String key, int indentation) {
|
||||||
|
Button checkBox= new Button(parent, SWT.CHECK);
|
||||||
|
checkBox.setText(label);
|
||||||
|
|
||||||
|
GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
|
||||||
|
gd.horizontalIndent= indentation;
|
||||||
|
gd.horizontalSpan= 2;
|
||||||
|
checkBox.setLayoutData(gd);
|
||||||
|
checkBox.addSelectionListener(fCheckBoxListener);
|
||||||
|
|
||||||
|
fCheckBoxes.put(checkBox, key);
|
||||||
|
|
||||||
|
return checkBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createDependency(final Button master, String masterKey, final Control slave) {
|
||||||
|
indent(slave);
|
||||||
|
boolean masterState= fStore.getBoolean(masterKey);
|
||||||
|
slave.setEnabled(masterState);
|
||||||
|
SelectionListener listener= new SelectionListener() {
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
slave.setEnabled(master.getSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void widgetDefaultSelected(SelectionEvent e) {}
|
||||||
|
};
|
||||||
|
master.addSelectionListener(listener);
|
||||||
|
fMasterSlaveListeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void indent(Control control) {
|
||||||
|
GridData gridData= new GridData();
|
||||||
|
gridData.horizontalIndent= 10;
|
||||||
|
control.setLayoutData(gridData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initialize() {
|
||||||
|
initializeFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
void initializeFields() {
|
||||||
|
|
||||||
|
Iterator iter= fCheckBoxes.keySet().iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
Button b= (Button) iter.next();
|
||||||
|
String key= (String) fCheckBoxes.get(b);
|
||||||
|
b.setSelection(fStore.getBoolean(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update slaves
|
||||||
|
iter= fMasterSlaveListeners.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
SelectionListener listener= (SelectionListener)iter.next();
|
||||||
|
listener.widgetSelected(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void performOk() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void performDefaults() {
|
||||||
|
restoreFromPreferences();
|
||||||
|
initializeFields();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restoreFromPreferences() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IStatus getStatus() {
|
||||||
|
if (fStatus == null)
|
||||||
|
fStatus= new StatusInfo();
|
||||||
|
return fStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.jdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
|
||||||
|
*/
|
||||||
|
public void dispose() {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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 org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The page for setting the editor options.
|
||||||
|
*/
|
||||||
|
public final class MarkOccurrencesPreferencePage extends AbstractConfigurationBlockPreferencePage {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
|
||||||
|
*/
|
||||||
|
protected String getHelpId() {
|
||||||
|
return ICHelpContextIds.C_EDITOR_PREF_PAGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
|
||||||
|
*/
|
||||||
|
protected void setDescription() {
|
||||||
|
String description= PreferencesMessages.MarkOccurrencesConfigurationBlock_title;
|
||||||
|
setDescription(description);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
|
||||||
|
*/
|
||||||
|
protected void setPreferenceStore() {
|
||||||
|
setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected Label createDescriptionLabel(Composite parent) {
|
||||||
|
return null; // no description for new look.
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
|
||||||
|
*/
|
||||||
|
protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
|
||||||
|
return new MarkOccurrencesConfigurationBlock(overlayPreferenceStore);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2007 IBM Corporation and others.
|
* Copyright (c) 2000, 2008 IBM Corporation 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
|
||||||
|
@ -361,6 +361,12 @@ public final class PreferencesMessages extends NLS {
|
||||||
public static String EditTemplateDialog_content_assist;
|
public static String EditTemplateDialog_content_assist;
|
||||||
public static String EditTemplateDialog_autoinsert;
|
public static String EditTemplateDialog_autoinsert;
|
||||||
|
|
||||||
|
public static String MarkOccurrencesConfigurationBlock_title;
|
||||||
|
public static String MarkOccurrencesConfigurationBlock_link;
|
||||||
|
public static String MarkOccurrencesConfigurationBlock_link_tooltip;
|
||||||
|
public static String MarkOccurrencesConfigurationBlock_markOccurrences;
|
||||||
|
public static String MarkOccurrencesConfigurationBlock_stickyOccurrences;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class);
|
NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2000, 2007 IBM Corporation and others.
|
# Copyright (c) 2000, 2008 IBM Corporation 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
|
||||||
|
@ -415,3 +415,13 @@ EditTemplateDialog_paste=&Paste
|
||||||
EditTemplateDialog_select_all=Select &All
|
EditTemplateDialog_select_all=Select &All
|
||||||
EditTemplateDialog_autoinsert=Auto&matically insert
|
EditTemplateDialog_autoinsert=Auto&matically insert
|
||||||
EditTemplateDialog_content_assist=Insert &Variable...
|
EditTemplateDialog_content_assist=Insert &Variable...
|
||||||
|
|
||||||
|
# Mark Occurrences preference page
|
||||||
|
MarkOccurrencesConfigurationBlock_title= &Mark Occurrences
|
||||||
|
|
||||||
|
# DO NOT TRANSLATE "org.eclipse.ui.editors.preferencePages.Annotations"
|
||||||
|
MarkOccurrencesConfigurationBlock_link= The appearance can be configured on the <a href=\"org.eclipse.ui.editors.preferencePages.Annotations\">Annotations</a> preference page.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2006 IBM Corporation and others.
|
* Copyright (c) 2000, 2008 IBM Corporation 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
|
||||||
|
@ -12,88 +12,49 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.preferences.formatter;
|
package org.eclipse.cdt.internal.ui.preferences.formatter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||||
import org.osgi.service.prefs.BackingStoreException;
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
|
|
||||||
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
|
|
||||||
|
|
||||||
|
|
||||||
public class FormatterProfileStore extends ProfileStore {
|
public class FormatterProfileStore extends ProfileStore {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preference key where all profiles are stored
|
* Preference key where all profiles are stored
|
||||||
*/
|
*/
|
||||||
private static final String PREF_FORMATTER_PROFILES= "org.eclipse.jdt.ui.formatterprofiles"; //$NON-NLS-1$
|
private static final String PREF_FORMATTER_PROFILES= "org.eclipse.cdt.ui.formatterprofiles"; //$NON-NLS-1$
|
||||||
|
private static final String PREF_FORMATTER_PROFILES_OLD= "org.eclipse.jdt.ui.formatterprofiles"; //$NON-NLS-1$
|
||||||
|
|
||||||
// private final IProfileVersioner fProfileVersioner;
|
|
||||||
|
|
||||||
public FormatterProfileStore(IProfileVersioner profileVersioner) {
|
public FormatterProfileStore(IProfileVersioner profileVersioner) {
|
||||||
super(PREF_FORMATTER_PROFILES, profileVersioner);
|
super(PREF_FORMATTER_PROFILES, profileVersioner);
|
||||||
// fProfileVersioner= profileVersioner;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public List readProfiles(IScopeContext scope) throws CoreException {
|
public List readProfiles(IScopeContext scope) throws CoreException {
|
||||||
List profiles= super.readProfiles(scope);
|
final IEclipsePreferences node= scope.getNode(CUIPlugin.PLUGIN_ID);
|
||||||
return profiles;
|
final String profilesValue= node.get(PREF_FORMATTER_PROFILES_OLD, null);
|
||||||
|
if (profilesValue != null) {
|
||||||
|
// migrate to new preference key
|
||||||
|
final String versionKeyOld = PREF_FORMATTER_PROFILES_OLD + VERSION_KEY_SUFFIX;
|
||||||
|
String version= node.get(versionKeyOld, null);
|
||||||
|
node.put(PREF_FORMATTER_PROFILES, profilesValue);
|
||||||
|
node.put(PREF_FORMATTER_PROFILES + VERSION_KEY_SUFFIX, version);
|
||||||
|
node.remove(PREF_FORMATTER_PROFILES_OLD);
|
||||||
|
node.remove(versionKeyOld);
|
||||||
|
try {
|
||||||
|
node.flush();
|
||||||
|
} catch (BackingStoreException exc) {
|
||||||
|
return readProfilesFromString(profilesValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.readProfiles(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkCurrentOptionsVersion() {
|
|
||||||
PreferencesAccess access= PreferencesAccess.getOriginalPreferences();
|
|
||||||
ProfileVersioner profileVersioner= new ProfileVersioner();
|
|
||||||
|
|
||||||
IScopeContext instanceScope= access.getInstanceScope();
|
|
||||||
IEclipsePreferences uiPreferences= instanceScope.getNode(CUIPlugin.PLUGIN_ID);
|
|
||||||
int version= uiPreferences.getInt(PREF_FORMATTER_PROFILES + VERSION_KEY_SUFFIX, 0);
|
|
||||||
if (version >= profileVersioner.getCurrentVersion()) {
|
|
||||||
return; // is up to date
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
List profiles= (new FormatterProfileStore(profileVersioner)).readProfiles(instanceScope);
|
|
||||||
if (profiles == null) {
|
|
||||||
profiles= new ArrayList();
|
|
||||||
}
|
|
||||||
ProfileManager manager= new FormatterProfileManager(profiles, instanceScope, access, profileVersioner);
|
|
||||||
if (manager.getSelected() instanceof CustomProfile) {
|
|
||||||
manager.commitChanges(instanceScope); // updates core options
|
|
||||||
}
|
|
||||||
uiPreferences.putInt(PREF_FORMATTER_PROFILES + VERSION_KEY_SUFFIX, profileVersioner.getCurrentVersion());
|
|
||||||
savePreferences(instanceScope);
|
|
||||||
|
|
||||||
IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
|
|
||||||
for (int i= 0; i < projects.length; i++) {
|
|
||||||
IScopeContext scope= access.getProjectScope(projects[i]);
|
|
||||||
if (manager.hasProjectSpecificSettings(scope)) {
|
|
||||||
manager= new FormatterProfileManager(profiles, scope, access, profileVersioner);
|
|
||||||
manager.commitChanges(scope); // updates JavaCore project options
|
|
||||||
savePreferences(scope);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CUIPlugin.getDefault().log(e);
|
|
||||||
} catch (BackingStoreException e) {
|
|
||||||
CUIPlugin.getDefault().log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void savePreferences(final IScopeContext context) throws BackingStoreException {
|
|
||||||
try {
|
|
||||||
context.getNode(CUIPlugin.PLUGIN_ID).flush();
|
|
||||||
} finally {
|
|
||||||
context.getNode(CCorePlugin.PLUGIN_ID).flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2003, 2006 IBM Corporation and others.
|
* Copyright (c) 2003, 2008 IBM Corporation 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
|
||||||
|
@ -7,75 +7,85 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corp. - Rational Software - initial implementation
|
* IBM Corp. - Rational Software - initial implementation
|
||||||
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created on Jun 11, 2003
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.internal.ui.search;
|
package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import org.eclipse.osgi.util.NLS;
|
||||||
import java.util.MissingResourceException;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
/**
|
public final class CSearchMessages extends NLS {
|
||||||
* @author aniefer
|
|
||||||
*
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.search.CSearchMessages";//$NON-NLS-1$
|
||||||
* To change the template for this generated type comment go to
|
|
||||||
* Window>Preferences>Java>Code Generation>Code and Comments
|
|
||||||
*/
|
|
||||||
public class CSearchMessages {
|
|
||||||
private static final String RESOURCE_BUNDLE= CSearchMessages.class.getName();
|
|
||||||
|
|
||||||
private static ResourceBundle fgResourceBundle;
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
|
|
||||||
} catch (MissingResourceException x) {
|
|
||||||
fgResourceBundle = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private CSearchMessages() {
|
private CSearchMessages() {
|
||||||
|
// Do not instantiate
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getString(String key) {
|
public static String group_declarations;
|
||||||
try {
|
public static String group_references;
|
||||||
return fgResourceBundle.getString(key);
|
public static String CSearchResultCollector_matches;
|
||||||
} catch (MissingResourceException e) {
|
public static String CSearchPage_searchFor_label;
|
||||||
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
public static String CSearchPage_searchFor_type;
|
||||||
} catch (NullPointerException e) {
|
public static String CSearchPage_searchFor_namespace;
|
||||||
return "#" + key + "#"; //$NON-NLS-1$ //$NON-NLS-2$
|
public static String CSearchPage_searchFor_method;
|
||||||
}
|
public static String CSearchPage_searchFor_function;
|
||||||
}
|
public static String CSearchPage_searchFor_field;
|
||||||
/**
|
public static String CSearchPage_searchFor_variable;
|
||||||
* Gets a string from the resource bundle and formats it with the argument
|
public static String CSearchPage_searchFor_class;
|
||||||
*
|
public static String CSearchPage_searchFor_struct;
|
||||||
* @param key the string used to get the bundle value, must not be null
|
public static String CSearchPage_searchFor_union;
|
||||||
*/
|
public static String CSearchPage_searchFor_enum;
|
||||||
public static String getFormattedString(String key, Object[] args) {
|
public static String CSearchPage_searchFor_enumr;
|
||||||
String format= null;
|
public static String CSearchPage_searchFor_derived;
|
||||||
try {
|
public static String CSearchPage_searchFor_friend;
|
||||||
format= fgResourceBundle.getString(key);
|
public static String CSearchPage_searchFor_typedef;
|
||||||
} catch (MissingResourceException e) {
|
public static String CSearchPage_searchFor_macro;
|
||||||
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
public static String CSearchPage_searchFor_any;
|
||||||
}
|
public static String CSearchPage_searchFor_classStruct;
|
||||||
return MessageFormat.format(format, args);
|
public static String CSearchPage_limitTo_label;
|
||||||
}
|
public static String CSearchPage_limitTo_declarations;
|
||||||
|
public static String CSearchPage_limitTo_definitions;
|
||||||
|
public static String CSearchPage_limitTo_references;
|
||||||
|
public static String CSearchPage_limitTo_allOccurrences;
|
||||||
|
public static String CSearchPage_expression_label;
|
||||||
|
public static String CSearchPage_expression_caseSensitive;
|
||||||
|
public static String CSearch_FindDeclarationAction_label;
|
||||||
|
public static String CSearch_FindDeclarationAction_tooltip;
|
||||||
|
public static String CSearch_FindDeclarationsProjectAction_label;
|
||||||
|
public static String CSearch_FindDeclarationsProjectAction_tooltip;
|
||||||
|
public static String CSearch_FindDeclarationsInWorkingSetAction_label;
|
||||||
|
public static String CSearch_FindDeclarationsInWorkingSetAction_tooltip;
|
||||||
|
public static String CSearch_FindReferencesAction_label;
|
||||||
|
public static String CSearch_FindReferencesAction_tooltip;
|
||||||
|
public static String CSearch_FindReferencesProjectAction_label;
|
||||||
|
public static String CSearch_FindReferencesProjectAction_tooltip;
|
||||||
|
public static String CSearch_FindReferencesInWorkingSetAction_label;
|
||||||
|
public static String CSearch_FindReferencesInWorkingSetAction_tooltip;
|
||||||
|
public static String CSearchOperation_operationUnavailable_message;
|
||||||
|
public static String WorkspaceScope;
|
||||||
|
public static String WorkingSetScope;
|
||||||
|
public static String SelectionScope;
|
||||||
|
public static String HierarchyScope;
|
||||||
|
public static String ProjectScope;
|
||||||
|
public static String PDOMSearch_query_refs_label;
|
||||||
|
public static String PDOMSearch_query_defs_label;
|
||||||
|
public static String PDOMSearch_query_decls_label;
|
||||||
|
public static String PDOMSearchPatternQuery_PatternQuery_labelPatternInScope;
|
||||||
|
public static String PDOMSearch_query_pattern_error;
|
||||||
|
public static String SelectionParseAction_FileOpenFailure_format;
|
||||||
|
public static String SelectionParseAction_SelectedTextNotSymbol_message;
|
||||||
|
public static String SelectionParseAction_SymbolNotFoundInIndex_format;
|
||||||
|
public static String SelectionParseAction_IncludeNotFound_format;
|
||||||
|
|
||||||
/**
|
public static String OccurrencesFinder_no_element;
|
||||||
* Gets a string from the resource bundle and formats it with the argument
|
public static String OccurrencesFinder_no_binding;
|
||||||
*
|
public static String OccurrencesFinder_searchfor;
|
||||||
* @param key the string used to get the bundle value, must not be null
|
public static String OccurrencesFinder_label_singular;
|
||||||
*/
|
public static String OccurrencesFinder_label_plural;
|
||||||
public static String getFormattedString(String key, Object arg) {
|
public static String OccurrencesFinder_occurrence_description;
|
||||||
String format= null;
|
public static String OccurrencesFinder_occurrence_write_description;
|
||||||
try {
|
|
||||||
format= fgResourceBundle.getString(key);
|
static {
|
||||||
} catch (MissingResourceException e) {
|
NLS.initializeMessages(BUNDLE_NAME, CSearchMessages.class);
|
||||||
return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
if (arg == null)
|
|
||||||
arg= ""; //$NON-NLS-1$
|
|
||||||
return MessageFormat.format(format, new Object[] { arg });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2000, 2007 IBM Corporation and others.
|
# Copyright (c) 2000, 2008 IBM Corporation 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
|
||||||
|
@ -9,97 +9,61 @@
|
||||||
# IBM Corporation - initial API and implementation
|
# IBM Corporation - initial API and implementation
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
group.search=S&earch For
|
group_declarations=Dec&larations
|
||||||
group.declarations=Dec&larations
|
group_references=Re&ferences
|
||||||
group.references=Re&ferences
|
|
||||||
|
|
||||||
|
|
||||||
Search.Error.search.title=Search Error
|
# Examples of the display for the following value are
|
||||||
Search.Error.search.message=An error occurred during the search operation
|
|
||||||
|
|
||||||
# Examples of the display for the following value are
|
|
||||||
# "(1 match)", where {0} is 1 and "(5 matches)", where {0} is 2 or more.
|
# "(1 match)", where {0} is 1 and "(5 matches)", where {0} is 2 or more.
|
||||||
CSearchResultCollector.matches= ({0} {0, choice, 1\#match|2\#matches})
|
CSearchResultCollector_matches= ({0} {0, choice, 1\#match|2\#matches})
|
||||||
CSearchResultCollector.done= Search done: {0}.
|
|
||||||
CSearchResultCollector.searching= Searching...
|
|
||||||
|
|
||||||
Search.potentialMatchDialog.title.foundPotentialMatch= Search: Found 1 Inexact Match
|
CSearchPage_searchFor_label= Search For
|
||||||
Search.potentialMatchDialog.title.foundPotentialMatches= Search: Found {0} Inexact Matches
|
CSearchPage_searchFor_type= &Type
|
||||||
Search.potentialMatchDialog.message= Inexact matches were found and will be displayed with a different\nforeground color. This can be configured on the Search preference page.
|
CSearchPage_searchFor_namespace= Names&pace
|
||||||
|
CSearchPage_searchFor_method= &Method
|
||||||
|
CSearchPage_searchFor_function= F&unction
|
||||||
|
CSearchPage_searchFor_field= &Field
|
||||||
|
CSearchPage_searchFor_variable= &Variable
|
||||||
|
CSearchPage_searchFor_class= &Class
|
||||||
|
CSearchPage_searchFor_struct= &Struct
|
||||||
|
CSearchPage_searchFor_union= U&nion
|
||||||
|
CSearchPage_searchFor_enum= &Enumeration
|
||||||
|
CSearchPage_searchFor_enumr = Enume&rator
|
||||||
|
CSearchPage_searchFor_derived = &Derived
|
||||||
|
CSearchPage_searchFor_friend = &Friend
|
||||||
|
CSearchPage_searchFor_typedef = Type&def
|
||||||
|
CSearchPage_searchFor_macro = &Macro
|
||||||
|
CSearchPage_searchFor_any= An&y Element
|
||||||
|
CSearchPage_searchFor_classStruct= Cl&ass / Struct
|
||||||
|
|
||||||
CSearchPage.searchFor.label= Search For
|
CSearchPage_limitTo_label= Limit To
|
||||||
CSearchPage.searchFor.type= &Type
|
CSearchPage_limitTo_declarations= Dec&larations
|
||||||
CSearchPage.searchFor.namespace= Names&pace
|
CSearchPage_limitTo_definitions= Defini&tions
|
||||||
CSearchPage.searchFor.method= &Method
|
CSearchPage_limitTo_references= Referen&ces
|
||||||
CSearchPage.searchFor.function= F&unction
|
CSearchPage_limitTo_allOccurrences= All &Occurrences
|
||||||
CSearchPage.searchFor.field= &Field
|
|
||||||
CSearchPage.searchFor.variable= &Variable
|
|
||||||
CSearchPage.searchFor.class= &Class
|
|
||||||
CSearchPage.searchFor.struct= &Struct
|
|
||||||
CSearchPage.searchFor.union= U&nion
|
|
||||||
CSearchPage.searchFor.enum= &Enumeration
|
|
||||||
CSearchPage.searchFor.enumr = Enume&rator
|
|
||||||
CSearchPage.searchFor.derived = &Derived
|
|
||||||
CSearchPage.searchFor.friend = &Friend
|
|
||||||
CSearchPage.searchFor.typedef = Type&def
|
|
||||||
CSearchPage.searchFor.macro = &Macro
|
|
||||||
CSearchPage.searchFor.any= An&y Element
|
|
||||||
CSearchPage.searchFor.classStruct= Cl&ass / Struct
|
|
||||||
|
|
||||||
CSearchPage.limitTo.label= Limit To
|
CSearchPage_expression_label= Search strin&g (* = any string, ? = any character):
|
||||||
CSearchPage.limitTo.declarations= Dec&larations
|
CSearchPage_expression_caseSensitive= Case sens&itive
|
||||||
CSearchPage.limitTo.definitions= Defini&tions
|
|
||||||
CSearchPage.limitTo.references= Referen&ces
|
|
||||||
CSearchPage.limitTo.allOccurrences= All &Occurrences
|
|
||||||
|
|
||||||
CSearchPage.expression.label= Search strin&g (* = any string, ? = any character):
|
CSearch_FindDeclarationAction_label= &Workspace
|
||||||
CSearchPage.expression.caseSensitive= Case sens&itive
|
CSearch_FindDeclarationAction_tooltip= Search for Declarations of the Selected Element in the Workspace
|
||||||
|
|
||||||
# Concatenate two working set names e.g. "Source, Lib"
|
CSearch_FindDeclarationsProjectAction_label = &Project
|
||||||
SearchUtil.workingSetConcatenation= {0}, {1}
|
CSearch_FindDeclarationsProjectAction_tooltip = Search for Declarations of the Selected Element in the current project
|
||||||
|
|
||||||
CSearch.FindDeclarationAction.label= &Workspace
|
CSearch_FindDeclarationsInWorkingSetAction_label= Working &Set...
|
||||||
CSearch.FindDeclarationAction.tooltip= Search for Declarations of the Selected Element in the Workspace
|
CSearch_FindDeclarationsInWorkingSetAction_tooltip= Search for Declarations of the Selected Element in a Working Set
|
||||||
|
|
||||||
CSearch.FindDeclarationsProjectAction.label = &Project
|
CSearch_FindReferencesAction_label= &Workspace
|
||||||
CSearch.FindDeclarationsProjectAction.tooltip = Search for Declarations of the Selected Element in the current project
|
CSearch_FindReferencesAction_tooltip= Search for References to the Selected Element in the Workspace
|
||||||
|
|
||||||
CSearch.FindDeclarationsInWorkingSetAction.label= Working &Set...
|
CSearch_FindReferencesProjectAction_label= &Project
|
||||||
CSearch.FindDeclarationsInWorkingSetAction.tooltip= Search for Declarations of the Selected Element in a Working Set
|
CSearch_FindReferencesProjectAction_tooltip= Search for References to the Selected Element in the current project
|
||||||
|
|
||||||
CSearch.FindReferencesAction.label= &Workspace
|
CSearch_FindReferencesInWorkingSetAction_label= Working &Set...
|
||||||
CSearch.FindReferencesAction.tooltip= Search for References to the Selected Element in the Workspace
|
CSearch_FindReferencesInWorkingSetAction_tooltip= Search for References to the Selected Element in a Working Set
|
||||||
|
|
||||||
CSearch.FindReferencesProjectAction.label= &Project
|
|
||||||
CSearch.FindReferencesProjectAction.tooltip= Search for References to the Selected Element in the current project
|
|
||||||
|
|
||||||
CSearch.FindReferencesInWorkingSetAction.label= Working &Set...
|
|
||||||
CSearch.FindReferencesInWorkingSetAction.tooltip= Search for References to the Selected Element in a Working Set
|
|
||||||
|
|
||||||
# The first argument will be replaced by the pattern and the second by the scope
|
|
||||||
CSearchOperation.singularDeclarationsPostfix={0} - 1 Declaration in {1}
|
|
||||||
CSearchOperation.singularReferencesPostfix={0} - 1 Reference in {1}
|
|
||||||
CSearchOperation.singularReadReferencesPostfix={0} - 1 Read Reference in {1}
|
|
||||||
CSearchOperation.singularWriteReferencesPostfix={0} - 1 Write Reference in {1}
|
|
||||||
CSearchOperation.singularImplementorsPostfix={0} - 1 Implementor in {1}
|
|
||||||
CSearchOperation.singularOccurrencesPostfix={0} - 1 Occurrence in {1}
|
|
||||||
|
|
||||||
# The first argument will be replaced by the pattern, the second by the count and the last by the scope
|
|
||||||
CSearchOperation.pluralDeclarationsPostfix={0} - {1} Declarations in {2}
|
|
||||||
CSearchOperation.pluralReferencesPostfix={0} - {1} References in {2}
|
|
||||||
CSearchOperation.pluralReadReferencesPostfix={0} - {1} Read References in {2}
|
|
||||||
CSearchOperation.pluralWriteReferencesPostfix={0} - {1} Write References in {2}
|
|
||||||
CSearchOperation.pluralImplementorsPostfix={0} - {1} Implementors in {2}
|
|
||||||
CSearchOperation.pluralOccurrencesPostfix={0} - {1} Occurrences in {2}
|
|
||||||
|
|
||||||
CSearchResultLabelProvider.potentialMatch= \ (inexact)
|
|
||||||
|
|
||||||
CSearchOperation.operationUnavailable.title= Operation Unavailable
|
|
||||||
CSearchOperation.operationUnavailable.message= The operation is unavailable on the current selection.
|
|
||||||
CSearchOperation.noNamesSelected.message= The operation is unavailable on the current selection (no name selected).
|
|
||||||
CSearchOperation.noDefinitionFound.message= No definition was found.
|
|
||||||
CSearchOperation.noDeclarationFound.message= No declaration was found.
|
|
||||||
|
|
||||||
|
CSearchOperation_operationUnavailable_message= The operation is unavailable on the current selection.
|
||||||
|
|
||||||
WorkspaceScope= Workspace
|
WorkspaceScope= Workspace
|
||||||
WorkingSetScope= Working Set - {0}
|
WorkingSetScope= Working Set - {0}
|
||||||
|
@ -107,47 +71,23 @@ SelectionScope= Selection
|
||||||
HierarchyScope= Hierarchy - {0}
|
HierarchyScope= Hierarchy - {0}
|
||||||
ProjectScope = Project
|
ProjectScope = Project
|
||||||
|
|
||||||
CElementLabels.concat_string=\ -\
|
PDOMSearch_query_refs_label = Find references to
|
||||||
CElementLabels.comma_string=,\
|
PDOMSearch_query_defs_label = Find definitions of
|
||||||
CElementLabels.declseparator_string=\ :\
|
PDOMSearch_query_decls_label = Find declarations of
|
||||||
CSearchResultCollector.4=IMatchObject
|
PDOMSearchPatternQuery_PatternQuery_labelPatternInScope={0} {1} in {2}
|
||||||
|
PDOMSearch_query_pattern_error = Illegal Search String
|
||||||
|
SelectionParseAction_FileOpenFailure_format=Could not open file ''{0}'', verify index is up-to-date
|
||||||
|
SelectionParseAction_SelectedTextNotSymbol_message=Selected text cannot be mapped to a symbol name
|
||||||
|
SelectionParseAction_SymbolNotFoundInIndex_format=Could not find symbol ''{0}'' in index
|
||||||
|
SelectionParseAction_IncludeNotFound_format=Could not find include file ''{0}'' on include paths
|
||||||
|
|
||||||
CSearchQuery.searchfor_references=Search for References
|
# Occurrences
|
||||||
CSearchQuery.searchfor_declarations=Search for Declarations
|
OccurrencesFinder_no_element= Cannot search for the current selection. Please select a valid C/C++ element name.
|
||||||
CSearchQuery.searchfor_definitions=Search for Definitions
|
OccurrencesFinder_no_binding= Selected C/C++ element is unknown.
|
||||||
CSearchQuery.searchfor_all=Search for All Occurrences
|
OccurrencesFinder_searchfor=Search for Occurrences in File
|
||||||
CSearchQuery.search_label=Search
|
# The first argument will be replaced by the element name and the second one by the file name
|
||||||
|
OccurrencesFinder_label_singular=''{0}'' - 1 occurrence in ''{1}''
|
||||||
# CSearchResultPage Sort
|
# The first argument will be replaced by the element name, the second by the count and the last by the file name
|
||||||
CSearchResultPage.element_name= Name
|
OccurrencesFinder_label_plural=''{0}'' - {1} occurrences in ''{2}''
|
||||||
CSearchResultPage.parent_name= Parent Name
|
OccurrencesFinder_occurrence_description=Occurrence of ''{0}''
|
||||||
CSearchResultPage.path_name= Path
|
OccurrencesFinder_occurrence_write_description=Write occurrence of ''{0}''
|
||||||
CSearchResultPage.sort= Sort By
|
|
||||||
|
|
||||||
# Group
|
|
||||||
CSearchResultPage.groupby_project=Project
|
|
||||||
CSearchResultPage.groupby_project.tooltip=Group by Project
|
|
||||||
CSearchResultPage.groupby_file=File
|
|
||||||
CSearchResultPage.groupby_file.tooltip=Group by File
|
|
||||||
CSearchResultPage.groupby_folder=Folder
|
|
||||||
CSearchResultPage.groupby_folder.tooltip=Group by Folder
|
|
||||||
CSearchResultPage.groupby_class=Class
|
|
||||||
CSearchResultPage.groupby_class.tooltip=Group by Class
|
|
||||||
|
|
||||||
# Search Page Indexer warnings
|
|
||||||
CSearchPage.warning.indexernoprojects=Index not enabled on any projects
|
|
||||||
CSearchPage.warning.indexersomeprojects=Index not enabled on some projects
|
|
||||||
|
|
||||||
# Add To Index Action
|
|
||||||
ActionDefinition.addToIndex.name= Add To Index
|
|
||||||
ActionDefinition.addToIndex.description= Add file to index
|
|
||||||
|
|
||||||
PDOMSearch.query.refs.label = Find references to
|
|
||||||
PDOMSearch.query.defs.label = Find definitions of
|
|
||||||
PDOMSearch.query.decls.label = Find declarations of
|
|
||||||
PDOMSearchPatternQuery.PatternQuery_labelPatternInScope={0} {1} in {2}
|
|
||||||
PDOMSearch.query.pattern.error = Illegal Search String
|
|
||||||
SelectionParseAction.FileOpenFailure.format=Could not open file ''{0}'', verify index is up-to-date
|
|
||||||
SelectionParseAction.SelectedTextNotSymbol.message=Selected text cannot be mapped to a symbol name
|
|
||||||
SelectionParseAction.SymbolNotFoundInIndex.format=Could not find symbol ''{0}'' in index
|
|
||||||
SelectionParseAction.IncludeNotFound.format=Could not find include file ''{0}'' on include paths
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation 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
|
||||||
|
@ -21,6 +21,8 @@ import org.eclipse.jface.viewers.LabelProvider;
|
||||||
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
|
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author bgheorgh
|
* @author bgheorgh
|
||||||
*
|
*
|
||||||
|
@ -52,7 +54,7 @@ public class CountLabelProvider extends LabelProvider {
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
return text;
|
return text;
|
||||||
Integer matchCount= new Integer(c);
|
Integer matchCount= new Integer(c);
|
||||||
return fLabelProvider.getText(element) + " "+ CSearchMessages.getFormattedString("CSearchResultCollector.matches", matchCount); //$NON-NLS-1$ //$NON-NLS-2$
|
return fLabelProvider.getText(element) + " "+ Messages.format(CSearchMessages.CSearchResultCollector_matches, matchCount); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.search;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
|
||||||
|
public interface IOccurrencesFinder {
|
||||||
|
|
||||||
|
public static final int K_OCCURRENCE= 5;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Element representing a occurrence
|
||||||
|
*/
|
||||||
|
public static class OccurrenceLocation {
|
||||||
|
private final int fOffset;
|
||||||
|
private final int fLength;
|
||||||
|
private final int fFlags;
|
||||||
|
private final String fDescription;
|
||||||
|
|
||||||
|
public OccurrenceLocation(int offset, int length, int flags, String description) {
|
||||||
|
fOffset= offset;
|
||||||
|
fLength= length;
|
||||||
|
fFlags= flags;
|
||||||
|
fDescription= description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOffset() {
|
||||||
|
return fOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLength() {
|
||||||
|
return fLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFlags() {
|
||||||
|
return fFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return fDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return "[" + fOffset + " / " + fLength + "] " + fDescription; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String initialize(IASTTranslationUnit root, IASTNode node);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the plural label for this finder with 3 placeholders:
|
||||||
|
* <ul>
|
||||||
|
* <li>{0} for the {@link #getElementName() element name}</li>
|
||||||
|
* <li>{1} for the number of results found</li>
|
||||||
|
* <li>{2} for the scope (name of the compilation unit)</li>
|
||||||
|
* </ul>
|
||||||
|
* @return the unformatted label
|
||||||
|
*/
|
||||||
|
public String getUnformattedPluralLabel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the singular label for this finder with 2 placeholders:
|
||||||
|
* <ul>
|
||||||
|
* <li>{0} for the {@link #getElementName() element name}</li>
|
||||||
|
* <li>{1} for the scope (name of the compilation unit)</li>
|
||||||
|
* </ul>
|
||||||
|
* @return the unformatted label
|
||||||
|
*/
|
||||||
|
public String getUnformattedSingularLabel();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the element to look for or <code>null</code> if the finder hasn't
|
||||||
|
* been initialized yet.
|
||||||
|
* @return the name of the element
|
||||||
|
*/
|
||||||
|
public String getElementName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the AST root.
|
||||||
|
*
|
||||||
|
* @return the AST root
|
||||||
|
*/
|
||||||
|
public IASTTranslationUnit getASTRoot();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the occurrences
|
||||||
|
*
|
||||||
|
* @return the occurrences
|
||||||
|
*/
|
||||||
|
public OccurrenceLocation[] getOccurrences();
|
||||||
|
|
||||||
|
|
||||||
|
public int getSearchKind();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the id of this finder.
|
||||||
|
* @return returns the id of this finder.
|
||||||
|
*/
|
||||||
|
public String getID();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.search;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||||
|
|
||||||
|
public class OccurrencesFinder implements IOccurrencesFinder {
|
||||||
|
|
||||||
|
public static final String ID= "OccurrencesFinder"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
private IASTTranslationUnit fRoot;
|
||||||
|
private IASTName fSelectedNode;
|
||||||
|
private IBinding fTarget;
|
||||||
|
|
||||||
|
private List/*<OccurrenceLocation>*/fResult;
|
||||||
|
private String fDescription;
|
||||||
|
|
||||||
|
public OccurrencesFinder() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String initialize(IASTTranslationUnit root, IASTNode node) {
|
||||||
|
if (!(node instanceof IASTName))
|
||||||
|
return CSearchMessages.OccurrencesFinder_no_element;
|
||||||
|
fRoot= root;
|
||||||
|
fSelectedNode= (IASTName)node;
|
||||||
|
fTarget= fSelectedNode.resolveBinding();
|
||||||
|
if (fTarget == null)
|
||||||
|
return CSearchMessages.OccurrencesFinder_no_binding;
|
||||||
|
|
||||||
|
fDescription= Messages.format(CSearchMessages.OccurrencesFinder_occurrence_description, fTarget.getName());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performSearch() {
|
||||||
|
if (fResult == null) {
|
||||||
|
fResult= new ArrayList/*<OccurrenceLocation>*/();
|
||||||
|
IASTName[] names= fRoot.getDeclarationsInAST(fTarget);
|
||||||
|
for (int i= 0; i < names.length; i++) {
|
||||||
|
IASTName candidate= names[i];
|
||||||
|
if (candidate.isPartOfTranslationUnitFile()) {
|
||||||
|
addUsage(candidate, candidate.resolveBinding());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
names= fRoot.getReferences(fTarget);
|
||||||
|
for (int i= 0; i < names.length; i++) {
|
||||||
|
IASTName candidate= names[i];
|
||||||
|
if (candidate.isPartOfTranslationUnitFile()) {
|
||||||
|
addUsage(candidate, candidate.resolveBinding());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public OccurrenceLocation[] getOccurrences() {
|
||||||
|
performSearch();
|
||||||
|
if (fResult.isEmpty())
|
||||||
|
return null;
|
||||||
|
return (OccurrenceLocation[]) fResult.toArray(new OccurrenceLocation[fResult.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTTranslationUnit getASTRoot() {
|
||||||
|
return fRoot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.cdt.internal.ui.search.IOccurrencesFinder#getJobLabel()
|
||||||
|
*/
|
||||||
|
public String getJobLabel() {
|
||||||
|
return CSearchMessages.OccurrencesFinder_searchfor ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getElementName() {
|
||||||
|
if (fSelectedNode != null) {
|
||||||
|
return new String(fSelectedNode.toCharArray());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnformattedPluralLabel() {
|
||||||
|
return CSearchMessages.OccurrencesFinder_label_plural;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUnformattedSingularLabel() {
|
||||||
|
return CSearchMessages.OccurrencesFinder_label_singular;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean addUsage(IASTName node, IBinding binding) {
|
||||||
|
if (binding != null /* && Bindings.equals(binding, fTarget) */) {
|
||||||
|
int flag= 0;
|
||||||
|
String description= fDescription;
|
||||||
|
IASTNodeLocation nodeLocation= node.getImageLocation();
|
||||||
|
if (nodeLocation == null) {
|
||||||
|
nodeLocation= node.getFileLocation();
|
||||||
|
}
|
||||||
|
if (nodeLocation != null) {
|
||||||
|
final int offset= nodeLocation.getNodeOffset();
|
||||||
|
final int length= nodeLocation.getNodeLength();
|
||||||
|
if (offset >= 0 && length > 0) {
|
||||||
|
fResult.add(new OccurrenceLocation(offset, length, flag, description));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSearchKind() {
|
||||||
|
return K_OCCURRENCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getID() {
|
||||||
|
return ID;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2007 QNX Software Systems and others.
|
* Copyright (c) 2006, 2008 QNX Software Systems 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
|
||||||
|
@ -18,6 +18,8 @@ import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*
|
*
|
||||||
|
@ -36,7 +38,7 @@ public class PDOMSearchListLabelProvider extends PDOMSearchLabelProvider {
|
||||||
final int count= getMatchCount(element);
|
final int count= getMatchCount(element);
|
||||||
final String filename = " - " + IndexLocationFactory.getPath(searchElement.getLocation()); //$NON-NLS-1$
|
final String filename = " - " + IndexLocationFactory.getPath(searchElement.getLocation()); //$NON-NLS-1$
|
||||||
return text + filename + " " //$NON-NLS-1$
|
return text + filename + " " //$NON-NLS-1$
|
||||||
+ CSearchMessages.getFormattedString("CSearchResultCollector.matches", new Integer(count)); //$NON-NLS-1$
|
+ Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element instanceof IIndexFileLocation) {
|
if (element instanceof IIndexFileLocation) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2007 QNX Software Systems and others.
|
* Copyright (c) 2006, 2008 QNX Software Systems 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
|
||||||
|
@ -16,12 +16,6 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
|
||||||
import org.eclipse.cdt.internal.ui.util.RowLayouter;
|
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.jface.action.IStatusLineManager;
|
import org.eclipse.jface.action.IStatusLineManager;
|
||||||
|
@ -55,6 +49,15 @@ import org.eclipse.ui.IWorkbenchWindow;
|
||||||
import org.eclipse.ui.IWorkingSet;
|
import org.eclipse.ui.IWorkingSet;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
|
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||||
|
import org.eclipse.cdt.internal.ui.util.RowLayouter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*
|
*
|
||||||
|
@ -75,18 +78,18 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
||||||
public final static String EXTERNALMATCH_VISIBLE = "externMatchVisible"; //$NON-NLS-1$
|
public final static String EXTERNALMATCH_VISIBLE = "externMatchVisible"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String[] searchForText= {
|
private static final String[] searchForText= {
|
||||||
CSearchMessages.getString("CSearchPage.searchFor.classStruct"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_searchFor_classStruct,
|
||||||
CSearchMessages.getString("CSearchPage.searchFor.function"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_searchFor_function,
|
||||||
CSearchMessages.getString("CSearchPage.searchFor.variable"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_searchFor_variable,
|
||||||
CSearchMessages.getString("CSearchPage.searchFor.union"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_searchFor_union,
|
||||||
CSearchMessages.getString("CSearchPage.searchFor.method"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_searchFor_method,
|
||||||
CSearchMessages.getString("CSearchPage.searchFor.field"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_searchFor_field,
|
||||||
CSearchMessages.getString("CSearchPage.searchFor.enum"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_searchFor_enum,
|
||||||
CSearchMessages.getString("CSearchPage.searchFor.enumr"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_searchFor_enumr,
|
||||||
CSearchMessages.getString("CSearchPage.searchFor.namespace"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_searchFor_namespace,
|
||||||
CSearchMessages.getString("CSearchPage.searchFor.typedef"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_searchFor_typedef,
|
||||||
CSearchMessages.getString("CSearchPage.searchFor.macro"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_searchFor_macro,
|
||||||
CSearchMessages.getString("CSearchPage.searchFor.any") //$NON-NLS-1$
|
CSearchMessages.CSearchPage_searchFor_any
|
||||||
};
|
};
|
||||||
|
|
||||||
// These must be in the same order as the Text
|
// These must be in the same order as the Text
|
||||||
|
@ -109,10 +112,10 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
||||||
private static final int searchAllButtonIndex = searchForData.length - 1;
|
private static final int searchAllButtonIndex = searchForData.length - 1;
|
||||||
|
|
||||||
private static String[] limitToText = {
|
private static String[] limitToText = {
|
||||||
CSearchMessages.getString("CSearchPage.limitTo.declarations"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_limitTo_declarations,
|
||||||
CSearchMessages.getString("CSearchPage.limitTo.definitions"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_limitTo_definitions,
|
||||||
CSearchMessages.getString("CSearchPage.limitTo.references"), //$NON-NLS-1$
|
CSearchMessages.CSearchPage_limitTo_references,
|
||||||
CSearchMessages.getString("CSearchPage.limitTo.allOccurrences") //$NON-NLS-1$
|
CSearchMessages.CSearchPage_limitTo_allOccurrences
|
||||||
};
|
};
|
||||||
|
|
||||||
// Must be in the same order as the text
|
// Must be in the same order as the text
|
||||||
|
@ -180,7 +183,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
||||||
switch (getContainer().getSelectedScope()) {
|
switch (getContainer().getSelectedScope()) {
|
||||||
case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
|
case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
|
||||||
if (structuredSelection != null) {
|
if (structuredSelection != null) {
|
||||||
scopeDescription = CSearchMessages.getString("ProjectScope"); //$NON-NLS-1$
|
scopeDescription = CSearchMessages.ProjectScope;
|
||||||
for (Iterator i = structuredSelection.iterator(); i.hasNext();) {
|
for (Iterator i = structuredSelection.iterator(); i.hasNext();) {
|
||||||
ICProject project = getProject(i.next());
|
ICProject project = getProject(i.next());
|
||||||
if (project != null)
|
if (project != null)
|
||||||
|
@ -190,7 +193,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
||||||
break;
|
break;
|
||||||
case ISearchPageContainer.SELECTION_SCOPE:
|
case ISearchPageContainer.SELECTION_SCOPE:
|
||||||
if( structuredSelection != null) {
|
if( structuredSelection != null) {
|
||||||
scopeDescription = CSearchMessages.getString("SelectionScope"); //$NON-NLS-1$
|
scopeDescription = CSearchMessages.SelectionScope;
|
||||||
for (Iterator i = structuredSelection.iterator(); i.hasNext();) {
|
for (Iterator i = structuredSelection.iterator(); i.hasNext();) {
|
||||||
Object obj = i.next();
|
Object obj = i.next();
|
||||||
if (obj instanceof IResource)
|
if (obj instanceof IResource)
|
||||||
|
@ -202,12 +205,12 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ISearchPageContainer.WORKSPACE_SCOPE:
|
case ISearchPageContainer.WORKSPACE_SCOPE:
|
||||||
scopeDescription = CSearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$
|
scopeDescription = CSearchMessages.WorkspaceScope;
|
||||||
// Don't add anything
|
// Don't add anything
|
||||||
break;
|
break;
|
||||||
case ISearchPageContainer.WORKING_SET_SCOPE:
|
case ISearchPageContainer.WORKING_SET_SCOPE:
|
||||||
IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets();
|
IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets();
|
||||||
scopeDescription = CSearchMessages.getFormattedString("WorkingSetScope", CSearchUtil.toString(workingSets)); //$NON-NLS-1$
|
scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, CSearchUtil.toString(workingSets));
|
||||||
for (int i = 0; i < workingSets.length; ++i) {
|
for (int i = 0; i < workingSets.length; ++i) {
|
||||||
IAdaptable[] wsElements = workingSets[i].getElements();
|
IAdaptable[] wsElements = workingSets[i].getElements();
|
||||||
for (int j = 0; j < wsElements.length; ++j) {
|
for (int j = 0; j < wsElements.length; ++j) {
|
||||||
|
@ -232,7 +235,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
||||||
|
|
||||||
NewSearchUI.runQueryInBackground(job);
|
NewSearchUI.runQueryInBackground(job);
|
||||||
} catch (PatternSyntaxException e) {
|
} catch (PatternSyntaxException e) {
|
||||||
fLineManager.setErrorMessage(CSearchMessages.getString("PDOMSearch.query.pattern.error")); //$NON-NLS-1$
|
fLineManager.setErrorMessage(CSearchMessages.PDOMSearch_query_pattern_error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,7 +330,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
||||||
|
|
||||||
// Pattern text + info
|
// Pattern text + info
|
||||||
Label label = new Label( result, SWT.LEFT );
|
Label label = new Label( result, SWT.LEFT );
|
||||||
label.setText( CSearchMessages.getString( "CSearchPage.expression.label" ) ); //$NON-NLS-1$
|
label.setText( CSearchMessages.CSearchPage_expression_label );
|
||||||
gd = new GridData( GridData.BEGINNING );
|
gd = new GridData( GridData.BEGINNING );
|
||||||
gd.horizontalSpan = 2;
|
gd.horizontalSpan = 2;
|
||||||
label.setLayoutData( gd );
|
label.setLayoutData( gd );
|
||||||
|
@ -353,7 +356,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
||||||
|
|
||||||
// Ignore case checkbox
|
// Ignore case checkbox
|
||||||
caseSensitiveButton= new Button(result, SWT.CHECK);
|
caseSensitiveButton= new Button(result, SWT.CHECK);
|
||||||
caseSensitiveButton.setText(CSearchMessages.getString("CSearchPage.expression.caseSensitive")); //$NON-NLS-1$
|
caseSensitiveButton.setText(CSearchMessages.CSearchPage_expression_caseSensitive);
|
||||||
gd= new GridData();
|
gd= new GridData();
|
||||||
caseSensitiveButton.setLayoutData(gd);
|
caseSensitiveButton.setLayoutData(gd);
|
||||||
caseSensitiveButton.addSelectionListener( new SelectionAdapter() {
|
caseSensitiveButton.addSelectionListener( new SelectionAdapter() {
|
||||||
|
@ -368,7 +371,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
||||||
|
|
||||||
private Control createLimitTo( Composite parent ) {
|
private Control createLimitTo( Composite parent ) {
|
||||||
Group result = new Group(parent, SWT.NONE);
|
Group result = new Group(parent, SWT.NONE);
|
||||||
result.setText( CSearchMessages.getString("CSearchPage.limitTo.label") ); //$NON-NLS-1$
|
result.setText( CSearchMessages.CSearchPage_limitTo_label );
|
||||||
GridLayout layout = new GridLayout();
|
GridLayout layout = new GridLayout();
|
||||||
layout.numColumns = 2;
|
layout.numColumns = 2;
|
||||||
result.setLayout( layout );
|
result.setLayout( layout );
|
||||||
|
@ -386,7 +389,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
||||||
|
|
||||||
private Control createSearchFor(Composite parent) {
|
private Control createSearchFor(Composite parent) {
|
||||||
Group result= new Group(parent, SWT.NONE);
|
Group result= new Group(parent, SWT.NONE);
|
||||||
result.setText(CSearchMessages.getString("CSearchPage.searchFor.label")); //$NON-NLS-1$
|
result.setText(CSearchMessages.CSearchPage_searchFor_label);
|
||||||
GridLayout layout= new GridLayout();
|
GridLayout layout= new GridLayout();
|
||||||
layout.numColumns= 3;
|
layout.numColumns= 3;
|
||||||
result.setLayout(layout);
|
result.setLayout(layout);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2007 QNX Software Systems and others.
|
* Copyright (c) 2006, 2008 QNX Software Systems 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
|
||||||
|
@ -188,7 +188,7 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return Messages.format(CSearchMessages.getString("PDOMSearchPatternQuery.PatternQuery_labelPatternInScope"), super.getLabel(), patternStr, scopeDesc); //$NON-NLS-1$
|
return Messages.format(CSearchMessages.PDOMSearchPatternQuery_PatternQuery_labelPatternInScope, super.getLabel(), patternStr, scopeDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 QNX Software Systems and others.
|
* Copyright (c) 2006, 2008 QNX Software Systems 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
|
||||||
|
@ -79,11 +79,11 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
String type;
|
String type;
|
||||||
if ((flags & FIND_REFERENCES) != 0)
|
if ((flags & FIND_REFERENCES) != 0)
|
||||||
type = CSearchMessages.getString("PDOMSearch.query.refs.label"); //$NON-NLS-1$
|
type = CSearchMessages.PDOMSearch_query_refs_label;
|
||||||
else if ((flags & FIND_DECLARATIONS) != 0)
|
else if ((flags & FIND_DECLARATIONS) != 0)
|
||||||
type = CSearchMessages.getString("PDOMSearch.query.decls.label"); //$NON-NLS-1$
|
type = CSearchMessages.PDOMSearch_query_decls_label;
|
||||||
else
|
else
|
||||||
type = CSearchMessages.getString("PDOMSearch.query.defs.label"); //$NON-NLS-1$
|
type = CSearchMessages.PDOMSearch_query_defs_label;
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2007 QNX Software Systems and others.
|
* Copyright (c) 2006, 2008 QNX Software Systems 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
|
||||||
|
@ -14,6 +14,8 @@ package org.eclipse.cdt.internal.ui.search;
|
||||||
|
|
||||||
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
|
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*
|
*
|
||||||
|
@ -31,7 +33,7 @@ public class PDOMSearchTreeLabelProvider extends PDOMSearchLabelProvider {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
return text + " " //$NON-NLS-1$
|
return text + " " //$NON-NLS-1$
|
||||||
+ CSearchMessages.getFormattedString("CSearchResultCollector.matches", new Integer(count)); //$NON-NLS-1$
|
+ Messages.format(CSearchMessages.CSearchResultCollector_matches, new Integer(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class DeclarationsSearchGroup extends ActionGroup {
|
||||||
|
|
||||||
IMenuManager incomingMenu = menu;
|
IMenuManager incomingMenu = menu;
|
||||||
|
|
||||||
IMenuManager declarationsMenu = new MenuManager(CSearchMessages.getString("group.declarations"), IContextMenuConstants.GROUP_SEARCH); //$NON-NLS-1$
|
IMenuManager declarationsMenu = new MenuManager(CSearchMessages.group_declarations, IContextMenuConstants.GROUP_SEARCH);
|
||||||
|
|
||||||
if (fEditor != null){
|
if (fEditor != null){
|
||||||
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);
|
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, declarationsMenu);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation 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
|
||||||
|
@ -58,7 +58,7 @@ public abstract class FindAction extends SelectionParseAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchJob == null) {
|
if (searchJob == null) {
|
||||||
showStatusLineMessage(CSearchMessages.getString(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE));
|
showStatusLineMessage(CSearchMessages.CSearchOperation_operationUnavailable_message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation 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
|
||||||
|
@ -28,14 +28,14 @@ public class FindDeclarationsAction extends FindAction {
|
||||||
|
|
||||||
public FindDeclarationsAction(CEditor editor){
|
public FindDeclarationsAction(CEditor editor){
|
||||||
this(editor,
|
this(editor,
|
||||||
CSearchMessages.getString("CSearch.FindDeclarationAction.label"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindDeclarationAction_label,
|
||||||
CSearchMessages.getString("CSearch.FindDeclarationAction.tooltip")); //$NON-NLS-1$
|
CSearchMessages.CSearch_FindDeclarationAction_tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindDeclarationsAction(IWorkbenchSite site){
|
public FindDeclarationsAction(IWorkbenchSite site){
|
||||||
this(site,
|
this(site,
|
||||||
CSearchMessages.getString("CSearch.FindDeclarationAction.label"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindDeclarationAction_label,
|
||||||
CSearchMessages.getString("CSearch.FindDeclarationAction.tooltip")); //$NON-NLS-1$
|
CSearchMessages.CSearch_FindDeclarationAction_tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindDeclarationsAction(IWorkbenchSite site, String label, String tooltip) {
|
public FindDeclarationsAction(IWorkbenchSite site, String label, String tooltip) {
|
||||||
|
@ -49,7 +49,7 @@ public class FindDeclarationsAction extends FindAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getScopeDescription() {
|
protected String getScopeDescription() {
|
||||||
return CSearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$
|
return CSearchMessages.WorkspaceScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getLimitTo() {
|
protected int getLimitTo() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation 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
|
||||||
|
@ -22,15 +22,15 @@ public class FindDeclarationsInWorkingSetAction extends FindInWorkingSetAction {
|
||||||
|
|
||||||
public FindDeclarationsInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets) {
|
public FindDeclarationsInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets) {
|
||||||
super(site,
|
super(site,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesInWorkingSetAction.label"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesInWorkingSetAction.tooltip"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip,
|
||||||
workingSets);
|
workingSets);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindDeclarationsInWorkingSetAction(CEditor editor, IWorkingSet[] workingSets) {
|
public FindDeclarationsInWorkingSetAction(CEditor editor, IWorkingSet[] workingSets) {
|
||||||
super(editor,
|
super(editor,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesInWorkingSetAction.label"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesInWorkingSetAction.tooltip"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip,
|
||||||
workingSets);
|
workingSets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2006 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation 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
|
||||||
|
@ -31,14 +31,14 @@ public class FindDeclarationsProjectAction extends FindAction {
|
||||||
|
|
||||||
public FindDeclarationsProjectAction(CEditor editor){
|
public FindDeclarationsProjectAction(CEditor editor){
|
||||||
this(editor,
|
this(editor,
|
||||||
CSearchMessages.getString("CSearch.FindDeclarationsProjectAction.label"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindDeclarationsProjectAction_label,
|
||||||
CSearchMessages.getString("CSearch.FindDeclarationsProjectAction.tooltip")); //$NON-NLS-1$
|
CSearchMessages.CSearch_FindDeclarationsProjectAction_tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindDeclarationsProjectAction(IWorkbenchSite site){
|
public FindDeclarationsProjectAction(IWorkbenchSite site){
|
||||||
this(site,
|
this(site,
|
||||||
CSearchMessages.getString("CSearch.FindDeclarationsProjectAction.label"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindDeclarationsProjectAction_label,
|
||||||
CSearchMessages.getString("CSearch.FindDeclarationsProjectAction.tooltip")); //$NON-NLS-1$
|
CSearchMessages.CSearch_FindDeclarationsProjectAction_tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindDeclarationsProjectAction(IWorkbenchSite site, String label, String tooltip) {
|
public FindDeclarationsProjectAction(IWorkbenchSite site, String label, String tooltip) {
|
||||||
|
@ -66,7 +66,7 @@ public class FindDeclarationsProjectAction extends FindAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getScopeDescription() {
|
protected String getScopeDescription() {
|
||||||
return CSearchMessages.getString("ProjectScope"); //$NON-NLS-1$
|
return CSearchMessages.ProjectScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getLimitTo() {
|
protected int getLimitTo() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Wind River Systems, Inc. and others.
|
* Copyright (c) 2007, 2008 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
|
||||||
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
|
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
|
||||||
import org.eclipse.cdt.internal.ui.search.CSearchUtil;
|
import org.eclipse.cdt.internal.ui.search.CSearchUtil;
|
||||||
|
import org.eclipse.cdt.internal.ui.util.Messages;
|
||||||
|
|
||||||
public abstract class FindInWorkingSetAction extends FindAction {
|
public abstract class FindInWorkingSetAction extends FindAction {
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ public abstract class FindInWorkingSetAction extends FindAction {
|
||||||
fWorkingSets= askForWorkingSets();
|
fWorkingSets= askForWorkingSets();
|
||||||
}
|
}
|
||||||
if (fWorkingSets != null) {
|
if (fWorkingSets != null) {
|
||||||
scopeDescription = CSearchMessages.getFormattedString("WorkingSetScope", new String[] {CSearchUtil.toString(fWorkingSets)}); //$NON-NLS-1$
|
scopeDescription = Messages.format(CSearchMessages.WorkingSetScope, new String[] {CSearchUtil.toString(fWorkingSets)});
|
||||||
super.run();
|
super.run();
|
||||||
}
|
}
|
||||||
fWorkingSets= initial;
|
fWorkingSets= initial;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation 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
|
||||||
|
@ -20,14 +20,14 @@ public class FindRefsAction extends FindAction {
|
||||||
|
|
||||||
public FindRefsAction(CEditor editor) {
|
public FindRefsAction(CEditor editor) {
|
||||||
this(editor,
|
this(editor,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesAction.label"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesAction_label,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesAction.tooltip")); //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesAction_tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindRefsAction(IWorkbenchSite site){
|
public FindRefsAction(IWorkbenchSite site){
|
||||||
this(site,
|
this(site,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesAction.label"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesAction_label,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesAction.tooltip")); //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesAction_tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindRefsAction(CEditor editor, String label, String tooltip) {
|
public FindRefsAction(CEditor editor, String label, String tooltip) {
|
||||||
|
@ -43,7 +43,7 @@ public class FindRefsAction extends FindAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getScopeDescription() {
|
protected String getScopeDescription() {
|
||||||
return CSearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$
|
return CSearchMessages.WorkspaceScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ICElement[] getScope() {
|
protected ICElement[] getScope() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation 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
|
||||||
|
@ -22,15 +22,15 @@ public class FindRefsInWorkingSetAction extends FindInWorkingSetAction {
|
||||||
|
|
||||||
public FindRefsInWorkingSetAction(CEditor editor, IWorkingSet[] workingSets) {
|
public FindRefsInWorkingSetAction(CEditor editor, IWorkingSet[] workingSets) {
|
||||||
super(editor,
|
super(editor,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesInWorkingSetAction.label"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesInWorkingSetAction.tooltip"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip,
|
||||||
workingSets);
|
workingSets);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindRefsInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets){
|
public FindRefsInWorkingSetAction(IWorkbenchSite site, IWorkingSet[] workingSets){
|
||||||
super (site,
|
super (site,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesInWorkingSetAction.label"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesInWorkingSetAction_label,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesInWorkingSetAction.tooltip"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesInWorkingSetAction_tooltip,
|
||||||
workingSets);
|
workingSets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2006 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation 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
|
||||||
|
@ -31,14 +31,14 @@ public class FindRefsProjectAction extends FindAction {
|
||||||
|
|
||||||
public FindRefsProjectAction(CEditor editor){
|
public FindRefsProjectAction(CEditor editor){
|
||||||
this(editor,
|
this(editor,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesProjectAction.label"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesProjectAction_label,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesProjectAction.tooltip")); //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesProjectAction_tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindRefsProjectAction(IWorkbenchSite site){
|
public FindRefsProjectAction(IWorkbenchSite site){
|
||||||
this(site,
|
this(site,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesProjectAction.label"), //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesProjectAction_label,
|
||||||
CSearchMessages.getString("CSearch.FindReferencesProjectAction.tooltip")); //$NON-NLS-1$
|
CSearchMessages.CSearch_FindReferencesProjectAction_tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FindRefsProjectAction(IWorkbenchSite site, String label, String tooltip) {
|
public FindRefsProjectAction(IWorkbenchSite site, String label, String tooltip) {
|
||||||
|
@ -66,7 +66,7 @@ public class FindRefsProjectAction extends FindAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getScopeDescription() {
|
protected String getScopeDescription() {
|
||||||
return CSearchMessages.getString("ProjectScope"); //$NON-NLS-1$
|
return CSearchMessages.ProjectScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getLimitTo() {
|
protected int getLimitTo() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2006 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation 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
|
||||||
|
@ -66,7 +66,7 @@ public class ReferencesSearchGroup extends ActionGroup {
|
||||||
|
|
||||||
IMenuManager incomingMenu = menu;
|
IMenuManager incomingMenu = menu;
|
||||||
|
|
||||||
IMenuManager refsMenu = new MenuManager(CSearchMessages.getString("group.references"), IContextMenuConstants.GROUP_SEARCH); //$NON-NLS-1$
|
IMenuManager refsMenu = new MenuManager(CSearchMessages.group_references, IContextMenuConstants.GROUP_SEARCH);
|
||||||
|
|
||||||
if (fEditor != null){
|
if (fEditor != null){
|
||||||
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu);
|
menu.appendToGroup(ITextEditorActionConstants.GROUP_FIND, refsMenu);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2007 IBM Corporation and others.
|
* Copyright (c) 2004, 2008 IBM Corporation 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
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
* IBM Corp. - Rational Software - initial implementation
|
* IBM Corp. - Rational Software - initial implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.search.actions;
|
package org.eclipse.cdt.internal.ui.search.actions;
|
||||||
|
@ -43,10 +44,6 @@ import org.eclipse.cdt.internal.ui.util.StatusLineHandler;
|
||||||
* Created on Jun 2, 2004
|
* Created on Jun 2, 2004
|
||||||
*/
|
*/
|
||||||
public class SelectionParseAction extends Action {
|
public class SelectionParseAction extends Action {
|
||||||
protected static final String CSEARCH_OPERATION_NO_NAMES_SELECTED_MESSAGE = "CSearchOperation.noNamesSelected.message"; //$NON-NLS-1$
|
|
||||||
protected static final String CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE = "CSearchOperation.operationUnavailable.message"; //$NON-NLS-1$
|
|
||||||
protected static final String CSEARCH_OPERATION_NO_DEFINITION_MESSAGE = "CSearchOperation.noDefinitionFound.message"; //$NON-NLS-1$
|
|
||||||
protected static final String CSEARCH_OPERATION_NO_DECLARATION_MESSAGE = "CSearchOperation.noDeclarationFound.message"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
protected IWorkbenchSite fSite;
|
protected IWorkbenchSite fSite;
|
||||||
protected CEditor fEditor;
|
protected CEditor fEditor;
|
||||||
|
@ -230,23 +227,23 @@ public class SelectionParseAction extends Action {
|
||||||
|
|
||||||
protected void reportSourceFileOpenFailure(IPath path) {
|
protected void reportSourceFileOpenFailure(IPath path) {
|
||||||
showStatusLineMessage(MessageFormat.format(
|
showStatusLineMessage(MessageFormat.format(
|
||||||
CSearchMessages.getString("SelectionParseAction.FileOpenFailure.format"), //$NON-NLS-1$
|
CSearchMessages.SelectionParseAction_FileOpenFailure_format,
|
||||||
new String[] { path.toOSString() }));
|
new String[] { path.toOSString() }));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void reportSelectionMatchFailure() {
|
protected void reportSelectionMatchFailure() {
|
||||||
showStatusLineMessage(CSearchMessages.getString("SelectionParseAction.SelectedTextNotSymbol.message")); //$NON-NLS-1$
|
showStatusLineMessage(CSearchMessages.SelectionParseAction_SelectedTextNotSymbol_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void reportSymbolLookupFailure(String symbol) {
|
protected void reportSymbolLookupFailure(String symbol) {
|
||||||
showStatusLineMessage(MessageFormat.format(
|
showStatusLineMessage(MessageFormat.format(
|
||||||
CSearchMessages.getString("SelectionParseAction.SymbolNotFoundInIndex.format"), //$NON-NLS-1$
|
CSearchMessages.SelectionParseAction_SymbolNotFoundInIndex_format,
|
||||||
new String[] { symbol }));
|
new String[] { symbol }));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void reportIncludeLookupFailure(String filename) {
|
protected void reportIncludeLookupFailure(String filename) {
|
||||||
showStatusLineMessage(MessageFormat.format(
|
showStatusLineMessage(MessageFormat.format(
|
||||||
CSearchMessages.getString("SelectionParseAction.IncludeNotFound.format"), //$NON-NLS-1$
|
CSearchMessages.SelectionParseAction_IncludeNotFound_format,
|
||||||
new String[] { filename }));
|
new String[] { filename }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
* 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
|
||||||
|
@ -84,6 +84,7 @@ import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
|
||||||
import org.eclipse.cdt.internal.ui.editor.CElementHyperlinkDetector;
|
import org.eclipse.cdt.internal.ui.editor.CElementHyperlinkDetector;
|
||||||
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
|
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
|
||||||
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverProxy;
|
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverProxy;
|
||||||
|
import org.eclipse.cdt.internal.ui.text.c.hover.CInformationProvider;
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistProcessor;
|
import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistProcessor;
|
||||||
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
|
||||||
import org.eclipse.cdt.internal.ui.text.correction.CCorrectionAssistant;
|
import org.eclipse.cdt.internal.ui.text.correction.CCorrectionAssistant;
|
||||||
|
@ -649,12 +650,41 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the information presenter control creator. The creator is a factory creating the
|
||||||
|
* presenter controls for the given source viewer. This implementation always returns a creator
|
||||||
|
* for <code>DefaultInformationControl</code> instances.
|
||||||
|
*
|
||||||
|
* @param sourceViewer the source viewer to be configured by this configuration
|
||||||
|
* @return an information control creator
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
private IInformationControlCreator getInformationPresenterControlCreator(ISourceViewer sourceViewer) {
|
||||||
|
return new IInformationControlCreator() {
|
||||||
|
public IInformationControl createInformationControl(Shell parent) {
|
||||||
|
int shellStyle= SWT.RESIZE | SWT.TOOL;
|
||||||
|
int style= SWT.V_SCROLL | SWT.H_SCROLL;
|
||||||
|
return new DefaultInformationControl(parent, shellStyle, style, new HTMLTextPresenter(false));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
|
* @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
|
public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
|
||||||
return super.getInformationPresenter(sourceViewer);
|
InformationPresenter presenter= new InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
|
||||||
|
presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
|
||||||
|
|
||||||
|
// Register information provider
|
||||||
|
IInformationProvider provider= new CInformationProvider(getEditor());
|
||||||
|
String[] contentTypes= getConfiguredContentTypes(sourceViewer);
|
||||||
|
for (int i= 0; i < contentTypes.length; i++)
|
||||||
|
presenter.setInformationProvider(provider, contentTypes[i]);
|
||||||
|
|
||||||
|
presenter.setSizeConstraints(60, 10, true, true);
|
||||||
|
return presenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,134 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* 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.text.c.hover;
|
||||||
|
|
||||||
|
|
||||||
|
import org.eclipse.jface.text.AbstractReusableInformationControlCreator;
|
||||||
|
import org.eclipse.jface.text.DefaultInformationControl;
|
||||||
|
import org.eclipse.jface.text.IInformationControl;
|
||||||
|
import org.eclipse.jface.text.IInformationControlCreator;
|
||||||
|
import org.eclipse.jface.text.IRegion;
|
||||||
|
import org.eclipse.jface.text.ITextViewer;
|
||||||
|
import org.eclipse.jface.text.information.IInformationProvider;
|
||||||
|
import org.eclipse.jface.text.information.IInformationProviderExtension2;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
import org.eclipse.ui.IPartListener;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.ui.text.HTMLTextPresenter;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides information for the current word under the cursor based on available hovers.
|
||||||
|
*
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public class CInformationProvider implements IInformationProvider, IInformationProviderExtension2 {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default control creator.
|
||||||
|
*/
|
||||||
|
private static final class ControlCreator extends AbstractReusableInformationControlCreator {
|
||||||
|
public IInformationControl doCreateInformationControl(Shell parent) {
|
||||||
|
int shellStyle= SWT.RESIZE | SWT.TOOL;
|
||||||
|
int style= SWT.V_SCROLL | SWT.H_SCROLL;
|
||||||
|
return new DefaultInformationControl(parent, shellStyle, style, new HTMLTextPresenter(false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Part listener handling editor close.
|
||||||
|
*/
|
||||||
|
class EditorWatcher implements IPartListener {
|
||||||
|
public void partOpened(IWorkbenchPart part) {
|
||||||
|
}
|
||||||
|
public void partDeactivated(IWorkbenchPart part) {
|
||||||
|
}
|
||||||
|
public void partClosed(IWorkbenchPart part) {
|
||||||
|
if (part == fEditor) {
|
||||||
|
fEditor.getSite().getWorkbenchWindow().getPartService().removePartListener(fPartListener);
|
||||||
|
fPartListener= null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void partActivated(IWorkbenchPart part) {
|
||||||
|
}
|
||||||
|
public void partBroughtToTop(IWorkbenchPart part) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected IEditorPart fEditor;
|
||||||
|
protected IPartListener fPartListener;
|
||||||
|
|
||||||
|
protected ICEditorTextHover fImplementation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default presentation control creator.
|
||||||
|
*/
|
||||||
|
private IInformationControlCreator fPresenterControlCreator;
|
||||||
|
|
||||||
|
|
||||||
|
public CInformationProvider(IEditorPart editor) {
|
||||||
|
|
||||||
|
fEditor= editor;
|
||||||
|
|
||||||
|
if (fEditor != null) {
|
||||||
|
fPartListener= new EditorWatcher();
|
||||||
|
IWorkbenchWindow window= fEditor.getSite().getWorkbenchWindow();
|
||||||
|
window.getPartService().addPartListener(fPartListener);
|
||||||
|
fImplementation= new BestMatchHover();
|
||||||
|
fImplementation.setEditor(fEditor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see IInformationProvider#getSubject(ITextViewer, int)
|
||||||
|
*/
|
||||||
|
public IRegion getSubject(ITextViewer textViewer, int offset) {
|
||||||
|
if (textViewer != null && fImplementation != null) {
|
||||||
|
return fImplementation.getHoverRegion(textViewer, offset);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see IInformationProvider#getInformation(ITextViewer, IRegion)
|
||||||
|
*/
|
||||||
|
public String getInformation(ITextViewer textViewer, IRegion subject) {
|
||||||
|
if (fImplementation != null) {
|
||||||
|
String s= fImplementation.getHoverInfo(textViewer, subject);
|
||||||
|
if (s != null && s.trim().length() > 0) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see IInformationProviderExtension2#getInformationPresenterControlCreator()
|
||||||
|
*/
|
||||||
|
public IInformationControlCreator getInformationPresenterControlCreator() {
|
||||||
|
if (fImplementation instanceof IInformationProviderExtension2) {
|
||||||
|
IInformationProviderExtension2 ext2= (IInformationProviderExtension2) fImplementation;
|
||||||
|
return ext2.getInformationPresenterControlCreator();
|
||||||
|
}
|
||||||
|
if (fPresenterControlCreator == null)
|
||||||
|
fPresenterControlCreator= new ControlCreator();
|
||||||
|
return fPresenterControlCreator;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
* 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
|
||||||
|
@ -30,6 +30,7 @@ import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.ICThemeConstants;
|
import org.eclipse.cdt.internal.ui.ICThemeConstants;
|
||||||
|
import org.eclipse.cdt.internal.ui.preferences.formatter.FormatterProfileManager;
|
||||||
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
|
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
|
||||||
import org.eclipse.cdt.internal.ui.text.spelling.SpellCheckEngine;
|
import org.eclipse.cdt.internal.ui.text.spelling.SpellCheckEngine;
|
||||||
|
|
||||||
|
@ -1240,6 +1241,27 @@ public class PreferenceConstants {
|
||||||
*/
|
*/
|
||||||
public final static String EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT= "sourceHoverBackgroundColor.SystemDefault"; //$NON-NLS-1$
|
public final static String EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT= "sourceHoverBackgroundColor.SystemDefault"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A named preference that controls whether occurrences are marked in the editor.
|
||||||
|
* <p>
|
||||||
|
* Value is of type <code>Boolean</code>.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public static final String EDITOR_MARK_OCCURRENCES= "markOccurrences"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A named preference that controls whether occurrences are sticky in the editor.
|
||||||
|
* <p>
|
||||||
|
* Value is of type <code>Boolean</code>.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @since 5.0
|
||||||
|
*/
|
||||||
|
public static final String EDITOR_STICKY_OCCURRENCES= "stickyOccurrences"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the CDT-UI preference store.
|
* Returns the CDT-UI preference store.
|
||||||
*
|
*
|
||||||
|
@ -1357,6 +1379,9 @@ public class PreferenceConstants {
|
||||||
|
|
||||||
store.setDefault(PreferenceConstants.ENSURE_NEWLINE_AT_EOF, false);
|
store.setDefault(PreferenceConstants.ENSURE_NEWLINE_AT_EOF, false);
|
||||||
|
|
||||||
|
// formatter profile
|
||||||
|
store.setDefault(PreferenceConstants.FORMATTER_PROFILE, FormatterProfileManager.DEFAULT_PROFILE);
|
||||||
|
|
||||||
// content assist
|
// content assist
|
||||||
store.setDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES, "org.eclipse.cdt.ui.textProposalCategory\0"); //$NON-NLS-1$
|
store.setDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES, "org.eclipse.cdt.ui.textProposalCategory\0"); //$NON-NLS-1$
|
||||||
store.setDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER, "org.eclipse.cdt.ui.parserProposalCategory:65539\0org.eclipse.cdt.ui.textProposalCategory:65541\0org.eclipse.cdt.ui.templateProposalCategory:2\0"); //$NON-NLS-1$
|
store.setDefault(PreferenceConstants.CODEASSIST_CATEGORY_ORDER, "org.eclipse.cdt.ui.parserProposalCategory:65539\0org.eclipse.cdt.ui.textProposalCategory:65541\0org.eclipse.cdt.ui.templateProposalCategory:2\0"); //$NON-NLS-1$
|
||||||
|
@ -1411,6 +1436,10 @@ public class PreferenceConstants {
|
||||||
|
|
||||||
// codegen
|
// codegen
|
||||||
store.setDefault(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
|
store.setDefault(PreferenceConstants.CODEGEN_ADD_COMMENTS, false);
|
||||||
|
|
||||||
|
// mark occurrences
|
||||||
|
store.setDefault(PreferenceConstants.EDITOR_MARK_OCCURRENCES, true);
|
||||||
|
store.setDefault(PreferenceConstants.EDITOR_STICKY_OCCURRENCES, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue