1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-29 03:45:35 +02:00

Patch for Bogdan

This commit is contained in:
Hoda Amer 2003-11-11 18:25:56 +00:00
parent d655eed877
commit 757922dcc2
4 changed files with 114 additions and 61 deletions

View file

@ -1,3 +1,7 @@
2003-11-10 Bogdan Gheorghe
- Added a null resource check in UpdateDependency to fix up
a potential NPE in the test suite
2003-10-23 Bogdan Gheorghe
- Added UpdateDependency job

View file

@ -59,6 +59,8 @@ public class UpdateDependency implements IJob {
* @see org.eclipse.cdt.internal.core.search.processing.IJob#execute(org.eclipse.core.runtime.IProgressMonitor)
*/
public boolean execute(IProgressMonitor progress) {
if (resource == null) return false;
PathCollector pathCollector = new PathCollector();
//SubProgressMonitor subMonitor = (progressMonitor == null ) ? null : new SubProgressMonitor( progressMonitor, 5 );
ICSearchScope scope = SearchEngine.createWorkspaceScope();

View file

@ -1,3 +1,6 @@
2003-11-10 Bogdan Gheorghe
fix bug 45688: must highlight keyword to use "Open Declarations" or "Add Include"
2003-11-05 John Camelon
Updated parser clients to use new ParserFactory (stand-alone parser work item).

View file

@ -27,12 +27,14 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.texteditor.IDocumentProvider;
/**
* This action opens a java CEditor on the element represented by text selection of
@ -105,6 +107,15 @@ public class OpenDeclarationsAction extends Action {
try {
ArrayList elementsFound = new ArrayList();
String sel = selection.getText();
if (sel.equals(""))
{
int selStart = selection.getOffset();
IDocumentProvider prov = fEditor.getDocumentProvider();
IDocument doc = prov.getDocument(fEditor.getEditorInput());
sel = getSelection(doc, selStart);
}
IFile file = fEditor.getInputFile();
if(file == null)
return;
@ -203,5 +214,38 @@ public class OpenDeclarationsAction extends Action {
}
return null;
}
public String getSelection(IDocument doc, int fPos){
int pos= fPos;
char c;
int fStartPos =0, fEndPos=0;
String selectedWord=null;
try{
while (pos >= 0) {
c= doc.getChar(pos);
if (!Character.isJavaIdentifierPart(c))
break;
--pos;
}
fStartPos= pos + 1;
pos= fPos;
int length= doc.getLength();
while (pos < length) {
c= doc.getChar(pos);
if (!Character.isJavaIdentifierPart(c))
break;
++pos;
}
fEndPos= pos;
selectedWord = doc.get(fStartPos, (fEndPos - fStartPos));
}
catch(BadLocationException e){
}
return selectedWord;
}
}