mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Reimplemented IndexUI.getTranslationUnit(IASTName) method.
Change-Id: Icb13f2d8d4370c670053a52aeb226d4853ce4b44
This commit is contained in:
parent
537178b4e4
commit
d4c3e42e7e
3 changed files with 14 additions and 5 deletions
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui
|
@ -57,6 +57,7 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
|
@ -416,8 +417,10 @@ public class SelectionToDeclarationJob extends Job implements ASTRunnable {
|
|||
IASTName astName = (IASTName) declName;
|
||||
IBinding binding = astName.resolveBinding();
|
||||
if (binding != null) {
|
||||
ITranslationUnit tu = IndexUI.getTranslationUnit(project, astName);
|
||||
ITranslationUnit tu = IndexUI.getTranslationUnit(astName);
|
||||
if (tu != null) {
|
||||
if (tu instanceof IWorkingCopy)
|
||||
tu = ((IWorkingCopy) tu).getOriginalElement();
|
||||
IASTFileLocation loc = astName.getFileLocation();
|
||||
IRegion region = new Region(loc.getNodeOffset(), loc.getNodeLength());
|
||||
return CElementHandleFactory.create(tu, binding, astName.isDefinition(), region, 0);
|
||||
|
|
|
@ -84,6 +84,7 @@ import org.eclipse.cdt.core.model.ISourceRange;
|
|||
import org.eclipse.cdt.core.model.ISourceReference;
|
||||
import org.eclipse.cdt.core.model.IStructureDeclaration;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
@ -501,8 +502,10 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
|
|||
IASTName astName = (IASTName) declName;
|
||||
IBinding binding= astName.resolveBinding();
|
||||
if (binding != null) {
|
||||
ITranslationUnit tu= IndexUI.getTranslationUnit(project, astName);
|
||||
ITranslationUnit tu= IndexUI.getTranslationUnit(astName);
|
||||
if (tu != null) {
|
||||
if (tu instanceof IWorkingCopy)
|
||||
tu = ((IWorkingCopy) tu).getOriginalElement();
|
||||
IASTFileLocation loc= astName.getFileLocation();
|
||||
IRegion region= new Region(loc.getNodeOffset(), loc.getNodeLength());
|
||||
return CElementHandleFactory.create(tu, binding, astName.isDefinition(), region, 0);
|
||||
|
|
|
@ -316,8 +316,10 @@ public class IndexUI {
|
|||
assert !declName.isReference();
|
||||
IBinding binding= declName.resolveBinding();
|
||||
if (binding != null) {
|
||||
ITranslationUnit tu= getTranslationUnit(preferProject, declName);
|
||||
ITranslationUnit tu= getTranslationUnit(declName);
|
||||
if (tu != null) {
|
||||
if (tu instanceof IWorkingCopy)
|
||||
tu = ((IWorkingCopy) tu).getOriginalElement();
|
||||
IFile file= (IFile) tu.getResource();
|
||||
long timestamp= file != null ? file.getLocalTimeStamp() : 0;
|
||||
IASTFileLocation loc= declName.getFileLocation();
|
||||
|
@ -332,8 +334,9 @@ public class IndexUI {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static ITranslationUnit getTranslationUnit(ICProject cproject, IASTName name) {
|
||||
return getTranslationUnit(cproject, name.getFileLocation());
|
||||
public static ITranslationUnit getTranslationUnit(IASTName name) {
|
||||
IASTTranslationUnit astTranslationUnit = name.getTranslationUnit();
|
||||
return astTranslationUnit == null ? null : astTranslationUnit.getOriginatingTranslationUnit();
|
||||
}
|
||||
|
||||
public static ITranslationUnit getTranslationUnit(ICProject cproject, IIndexName name) {
|
||||
|
|
Loading…
Add table
Reference in a new issue