mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Make use of position tracker in include browser.
This commit is contained in:
parent
7aef1d752c
commit
a4e5148925
6 changed files with 21 additions and 9 deletions
|
@ -26,5 +26,5 @@ public interface IPositionTrackerManager {
|
|||
* @param timestamp identifies the version of the file stored on disk.
|
||||
* @return the requested position adapter or <code>null</code>.
|
||||
*/
|
||||
IPositionConverter findPositionAdapter(IFile file, long timestamp);
|
||||
IPositionConverter findPositionConverter(IFile file, long timestamp);
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ public class PositionTrackerManager implements IPositionTrackerManager, IFileBuf
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized IPositionConverter findPositionAdapter(IFile file, long timestamp) {
|
||||
public synchronized IPositionConverter findPositionConverter(IFile file, long timestamp) {
|
||||
PositionTrackerChain chain= (PositionTrackerChain) fPositionTrackerMap.get(file.getFullPath());
|
||||
if (chain != null) {
|
||||
return chain.findTrackerAt(timestamp);
|
||||
|
|
|
@ -49,7 +49,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
|||
public Object[] syncronouslyComputeChildren(Object parentElement) {
|
||||
if (parentElement instanceof ITranslationUnit) {
|
||||
ITranslationUnit tu = (ITranslationUnit) parentElement;
|
||||
return new Object[] { new IBNode(null, new IBFile(tu), null, null, 0) };
|
||||
return new Object[] { new IBNode(null, new IBFile(tu), null, null, 0, 0) };
|
||||
}
|
||||
if (parentElement instanceof IBNode) {
|
||||
IBNode node = (IBNode) parentElement;
|
||||
|
@ -90,7 +90,7 @@ public class IBContentProvider extends AsyncTreeContentProvider {
|
|||
}
|
||||
|
||||
IBNode newnode= new IBNode(node, targetFile, directiveFile,
|
||||
include.getName(), include.getOffset());
|
||||
include.getName(), include.getOffset(), include.getTimestamp());
|
||||
newnode.setIsActiveCode(include.isActiveCode());
|
||||
newnode.setIsSystemInclude(include.isSystemInclude());
|
||||
result[i]= newnode;
|
||||
|
|
|
@ -35,12 +35,13 @@ public class IBNode implements IAdaptable {
|
|||
private boolean fIsSystemInclude= false;
|
||||
private boolean fIsActive= true;
|
||||
private boolean fIsRecursive;
|
||||
private long fTimestamp;
|
||||
|
||||
/**
|
||||
* Creates a new node for the include browser
|
||||
*/
|
||||
public IBNode(IBNode parent, IBFile represents, IBFile fileOfDirective, String nameOfDirective,
|
||||
int charOffset) {
|
||||
int charOffset, long timestamp) {
|
||||
fParent= parent;
|
||||
fRepresentedFile= represents;
|
||||
fDirectiveFile= fileOfDirective;
|
||||
|
@ -48,6 +49,7 @@ public class IBNode implements IAdaptable {
|
|||
fDirectiveCharacterOffset= charOffset;
|
||||
fIsRecursive= computeIsRecursive(fParent, represents.getLocation());
|
||||
fHashCode= computeHashCode();
|
||||
fTimestamp= timestamp;
|
||||
}
|
||||
|
||||
private int computeHashCode() {
|
||||
|
@ -183,4 +185,8 @@ public class IBNode implements IAdaptable {
|
|||
}
|
||||
return fRepresentedFile.getLocation();
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return fTimestamp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.jface.action.IMenuManager;
|
|||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.action.MenuManager;
|
||||
import org.eclipse.jface.action.Separator;
|
||||
import org.eclipse.jface.text.Position;
|
||||
import org.eclipse.jface.util.LocalSelectionTransfer;
|
||||
import org.eclipse.jface.viewers.IOpenListener;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
|
@ -72,6 +73,7 @@ import org.eclipse.ui.part.ViewPart;
|
|||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.IPositionConverter;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
@ -670,13 +672,14 @@ public class IBViewPart extends ViewPart
|
|||
IBFile ibf= node.getDirectiveFile();
|
||||
if (ibf != null) {
|
||||
IEditorPart editor= null;
|
||||
int offset= node.getDirectiveCharacterOffset();
|
||||
int length= node.getDirectiveName().length() + 2;
|
||||
Position pos= new Position(node.getDirectiveCharacterOffset(),
|
||||
node.getDirectiveName().length() + 2);
|
||||
|
||||
IFile f= ibf.getResource();
|
||||
if (f != null) {
|
||||
fLastNavigationNode= node;
|
||||
// mstodo position tracker
|
||||
IPositionConverter converter= CCorePlugin.getPositionTrackerManager().findPositionConverter(f, node.getTimestamp());
|
||||
pos= converter.historicToActual(pos);
|
||||
try {
|
||||
editor= IDE.openEditor(page, f, false);
|
||||
} catch (PartInitException e) {
|
||||
|
@ -698,7 +701,7 @@ public class IBViewPart extends ViewPart
|
|||
}
|
||||
if (editor instanceof ITextEditor) {
|
||||
ITextEditor te= (ITextEditor) editor;
|
||||
te.selectAndReveal(offset, length);
|
||||
te.selectAndReveal(pos.getOffset(), pos.getLength());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -53,6 +53,9 @@ public class CIndexQueries {
|
|||
public int getOffset() {
|
||||
return 9;
|
||||
}
|
||||
public long getTimestamp() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static final IPDOMInclude[] EMPTY_INCLUDES = new IPDOMInclude[0];
|
||||
|
|
Loading…
Add table
Reference in a new issue