mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
2004-09-02 Alain Magloire
Fix to TranslationUnit.getElement(String). * model/org/eclipse/cdt/internal/core/model/TranslationUnit.java * model/org/eclipse/cdt/internal/core/model/WorkingCopy.java
This commit is contained in:
parent
69ecf16572
commit
043f79d100
3 changed files with 42 additions and 23 deletions
|
@ -1,3 +1,9 @@
|
|||
2004-09-02 Alain Magloire
|
||||
|
||||
Fix to TranslationUnit.getElement(String).
|
||||
* model/org/eclipse/cdt/internal/core/model/TranslationUnit.java
|
||||
* model/org/eclipse/cdt/internal/core/model/WorkingCopy.java
|
||||
|
||||
2004-09-01 Alain Magloire
|
||||
|
||||
Provide IWorkingCopy.getOriginal(ICElement)
|
||||
|
|
|
@ -101,16 +101,30 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
}
|
||||
|
||||
public ICElement getElement(String name ) {
|
||||
try {
|
||||
ICElement[] celements = getChildren();
|
||||
for (int i = 0; i < celements.length; i++) {
|
||||
if (name.equals(celements[i].getElementName())) {
|
||||
return celements[i];
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
if (name == null || name.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
String[] names = name.split("::");
|
||||
ICElement current = this;
|
||||
for (int j = 0; j < names.length; ++j) {
|
||||
if (current instanceof IParent) {
|
||||
try {
|
||||
ICElement[] celements = ((IParent)current).getChildren();
|
||||
current = null;
|
||||
for (int i = 0; i < celements.length; i++) {
|
||||
if (names[j].equals(celements[i].getElementName())) {
|
||||
current = celements[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (CModelException e) {
|
||||
current = null;
|
||||
}
|
||||
} else {
|
||||
current = null;
|
||||
}
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
public IInclude getInclude(String name) {
|
||||
|
@ -377,12 +391,10 @@ public class TranslationUnit extends Openable implements ITranslationUnit {
|
|||
if (workingCopy != null) {
|
||||
workingCopy.useCount++;
|
||||
return workingCopy;
|
||||
|
||||
} else {
|
||||
CreateWorkingCopyOperation op = new CreateWorkingCopyOperation(this, perFactoryWorkingCopies, factory, requestor);
|
||||
runOperation(op, monitor);
|
||||
return (IWorkingCopy)op.getResultElements()[0];
|
||||
}
|
||||
CreateWorkingCopyOperation op = new CreateWorkingCopyOperation(this, perFactoryWorkingCopies, factory, requestor);
|
||||
runOperation(op, monitor);
|
||||
return (IWorkingCopy)op.getResultElements()[0];
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -212,6 +212,8 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
} catch (CModelException e) {
|
||||
current = null;
|
||||
}
|
||||
} else {
|
||||
current = null;
|
||||
}
|
||||
}
|
||||
return current;
|
||||
|
@ -282,15 +284,14 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
public void open(IProgressMonitor monitor) throws CModelException {
|
||||
if (this.useCount == 0) { // was destroyed
|
||||
throw newNotPresentException();
|
||||
} else {
|
||||
super.open(monitor);
|
||||
//if (monitor != null && monitor.isCanceled()) return;
|
||||
//if (this.problemRequestor != null && this.problemRequestor.isActive()){
|
||||
// this.problemRequestor.beginReporting();
|
||||
// TranslationUnitProblemFinder.process(this, this.problemRequestor, monitor);
|
||||
// this.problemRequestor.endReporting();
|
||||
//}
|
||||
}
|
||||
}
|
||||
super.open(monitor);
|
||||
//if (monitor != null && monitor.isCanceled()) return;
|
||||
//if (this.problemRequestor != null && this.problemRequestor.isActive()){
|
||||
// this.problemRequestor.beginReporting();
|
||||
// TranslationUnitProblemFinder.process(this, this.problemRequestor, monitor);
|
||||
// this.problemRequestor.endReporting();
|
||||
//}
|
||||
}
|
||||
/**
|
||||
* @see org.eclipse.cdt.internal.core.model.CFile#openBuffer(IProgressMonitor)
|
||||
|
|
Loading…
Add table
Reference in a new issue