mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 199369: [Outline View] empty for headers in project on include path outside of src folder
This commit is contained in:
parent
2f0d70899e
commit
c1570a8a01
2 changed files with 49 additions and 35 deletions
|
@ -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
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
* Ed Swartz (Nokia)
|
* Ed Swartz (Nokia)
|
||||||
|
* Anton Leherbauer (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
@ -92,7 +93,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
||||||
* @see org.eclipse.cdt.internal.core.model.CContainer#computeChildren(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.resources.IResource)
|
* @see org.eclipse.cdt.internal.core.model.CContainer#computeChildren(org.eclipse.cdt.internal.core.model.OpenableInfo, org.eclipse.core.resources.IResource)
|
||||||
*/
|
*/
|
||||||
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
|
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
|
||||||
ArrayList vChildren = new ArrayList();
|
ArrayList<ICElement> vChildren = new ArrayList<ICElement>();
|
||||||
File file = null;
|
File file = null;
|
||||||
if (fPath != null) {
|
if (fPath != null) {
|
||||||
file = fPath.toFile();
|
file = fPath.toFile();
|
||||||
|
@ -131,7 +132,7 @@ public class IncludeReference extends Openable implements IIncludeReference {
|
||||||
* @see org.eclipse.cdt.core.model.IIncludeReference#isOnIncludeEntry(org.eclipse.core.runtime.IPath)
|
* @see org.eclipse.cdt.core.model.IIncludeReference#isOnIncludeEntry(org.eclipse.core.runtime.IPath)
|
||||||
*/
|
*/
|
||||||
public boolean isOnIncludeEntry(IPath path) {
|
public boolean isOnIncludeEntry(IPath path) {
|
||||||
if (fIncludeEntry.getIncludePath().isPrefixOf(path)
|
if (fIncludeEntry.getFullIncludePath().isPrefixOf(path)
|
||||||
&& !CoreModelUtil.isExcluded(path, fIncludeEntry.fullExclusionPatternChars())) {
|
&& !CoreModelUtil.isExcluded(path, fIncludeEntry.fullExclusionPatternChars())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,7 @@ import org.eclipse.ui.texteditor.spelling.SpellingAnnotation;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IProblemRequestor;
|
import org.eclipse.cdt.core.model.IProblemRequestor;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
|
@ -97,7 +98,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
private final boolean fIsProblem;
|
private final boolean fIsProblem;
|
||||||
private final String[] fArguments;
|
private final String[] fArguments;
|
||||||
private final String fMarkerType;
|
private final String fMarkerType;
|
||||||
private List fOverlaids;
|
private List<ICAnnotation> fOverlaids;
|
||||||
|
|
||||||
public ProblemAnnotation(IProblem problem, ITranslationUnit tu) {
|
public ProblemAnnotation(IProblem problem, ITranslationUnit tu) {
|
||||||
fTranslationUnit= tu;
|
fTranslationUnit= tu;
|
||||||
|
@ -153,7 +154,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
*/
|
*/
|
||||||
public void addOverlaid(ICAnnotation annotation) {
|
public void addOverlaid(ICAnnotation annotation) {
|
||||||
if (fOverlaids == null)
|
if (fOverlaids == null)
|
||||||
fOverlaids= new ArrayList(1);
|
fOverlaids= new ArrayList<ICAnnotation>(1);
|
||||||
fOverlaids.add(annotation);
|
fOverlaids.add(annotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +172,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
/*
|
/*
|
||||||
* @see ICAnnotation#getOverlaidIterator()
|
* @see ICAnnotation#getOverlaidIterator()
|
||||||
*/
|
*/
|
||||||
public Iterator getOverlaidIterator() {
|
public Iterator<ICAnnotation> getOverlaidIterator() {
|
||||||
if (fOverlaids != null)
|
if (fOverlaids != null)
|
||||||
return fOverlaids.iterator();
|
return fOverlaids.iterator();
|
||||||
return null;
|
return null;
|
||||||
|
@ -205,7 +206,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
Object fValue;
|
Object fValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List fList= new ArrayList(2);
|
private List<Entry> fList= new ArrayList<Entry>(2);
|
||||||
private int fAnchor= 0;
|
private int fAnchor= 0;
|
||||||
|
|
||||||
public ReverseMap() {
|
public ReverseMap() {
|
||||||
|
@ -218,7 +219,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
// behind anchor
|
// behind anchor
|
||||||
int length= fList.size();
|
int length= fList.size();
|
||||||
for (int i= fAnchor; i < length; i++) {
|
for (int i= fAnchor; i < length; i++) {
|
||||||
entry= (Entry) fList.get(i);
|
entry= fList.get(i);
|
||||||
if (entry.fPosition.equals(position)) {
|
if (entry.fPosition.equals(position)) {
|
||||||
fAnchor= i;
|
fAnchor= i;
|
||||||
return entry.fValue;
|
return entry.fValue;
|
||||||
|
@ -227,7 +228,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
|
|
||||||
// before anchor
|
// before anchor
|
||||||
for (int i= 0; i < fAnchor; i++) {
|
for (int i= 0; i < fAnchor; i++) {
|
||||||
entry= (Entry) fList.get(i);
|
entry= fList.get(i);
|
||||||
if (entry.fPosition.equals(position)) {
|
if (entry.fPosition.equals(position)) {
|
||||||
fAnchor= i;
|
fAnchor= i;
|
||||||
return entry.fValue;
|
return entry.fValue;
|
||||||
|
@ -241,7 +242,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
Entry entry;
|
Entry entry;
|
||||||
int length= fList.size();
|
int length= fList.size();
|
||||||
for (int i= 0; i < length; i++) {
|
for (int i= 0; i < length; i++) {
|
||||||
entry= (Entry) fList.get(i);
|
entry= fList.get(i);
|
||||||
if (entry.fPosition.equals(position))
|
if (entry.fPosition.equals(position))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +257,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
entry.fValue= value;
|
entry.fValue= value;
|
||||||
fList.add(entry);
|
fList.add(entry);
|
||||||
} else {
|
} else {
|
||||||
Entry entry= (Entry) fList.get(index);
|
Entry entry= fList.get(index);
|
||||||
entry.fValue= value;
|
entry.fValue= value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,20 +323,20 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
|
|
||||||
private static class ProblemRequestorState {
|
private static class ProblemRequestorState {
|
||||||
boolean fInsideReportingSequence= false;
|
boolean fInsideReportingSequence= false;
|
||||||
List fReportedProblems;
|
List<IProblem> fReportedProblems;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ThreadLocal fProblemRequestorState= new ThreadLocal();
|
private ThreadLocal<ProblemRequestorState> fProblemRequestorState= new ThreadLocal<ProblemRequestorState>();
|
||||||
private int fStateCount= 0;
|
private int fStateCount= 0;
|
||||||
|
|
||||||
private ITranslationUnit fTranslationUnit;
|
private ITranslationUnit fTranslationUnit;
|
||||||
private List fGeneratedAnnotations;
|
private List<ProblemAnnotation> fGeneratedAnnotations;
|
||||||
private IProgressMonitor fProgressMonitor;
|
private IProgressMonitor fProgressMonitor;
|
||||||
private boolean fIsActive= false;
|
private boolean fIsActive= false;
|
||||||
|
|
||||||
private ReverseMap fReverseMap= new ReverseMap();
|
private ReverseMap fReverseMap= new ReverseMap();
|
||||||
private List fPreviouslyOverlaid= null;
|
private List<CMarkerAnnotation> fPreviouslyOverlaid= null;
|
||||||
private List fCurrentlyOverlaid= new ArrayList();
|
private List<CMarkerAnnotation> fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>();
|
||||||
|
|
||||||
|
|
||||||
public TranslationUnitAnnotationModel(IResource resource) {
|
public TranslationUnitAnnotationModel(IResource resource) {
|
||||||
|
@ -415,7 +416,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
* @see IProblemRequestor#beginReporting()
|
* @see IProblemRequestor#beginReporting()
|
||||||
*/
|
*/
|
||||||
public void beginReporting() {
|
public void beginReporting() {
|
||||||
ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
|
ProblemRequestorState state= fProblemRequestorState.get();
|
||||||
if (state == null)
|
if (state == null)
|
||||||
internalBeginReporting(false);
|
internalBeginReporting(false);
|
||||||
}
|
}
|
||||||
|
@ -424,7 +425,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
* @see org.eclipse.cdt.internal.ui.text.java.IProblemRequestorExtension#beginReportingSequence()
|
* @see org.eclipse.cdt.internal.ui.text.java.IProblemRequestorExtension#beginReportingSequence()
|
||||||
*/
|
*/
|
||||||
public void beginReportingSequence() {
|
public void beginReportingSequence() {
|
||||||
ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
|
ProblemRequestorState state= fProblemRequestorState.get();
|
||||||
if (state == null)
|
if (state == null)
|
||||||
internalBeginReporting(true);
|
internalBeginReporting(true);
|
||||||
}
|
}
|
||||||
|
@ -436,10 +437,10 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
* call is issued from inside a reporting sequence
|
* call is issued from inside a reporting sequence
|
||||||
*/
|
*/
|
||||||
private void internalBeginReporting(boolean insideReportingSequence) {
|
private void internalBeginReporting(boolean insideReportingSequence) {
|
||||||
if (fTranslationUnit != null && fTranslationUnit.getCProject().isOnSourceRoot(fTranslationUnit.getResource())) {
|
if (fTranslationUnit != null) {
|
||||||
ProblemRequestorState state= new ProblemRequestorState();
|
ProblemRequestorState state= new ProblemRequestorState();
|
||||||
state.fInsideReportingSequence= insideReportingSequence;
|
state.fInsideReportingSequence= insideReportingSequence;
|
||||||
state.fReportedProblems= new ArrayList();
|
state.fReportedProblems= new ArrayList<IProblem>();
|
||||||
synchronized (getLockObject()) {
|
synchronized (getLockObject()) {
|
||||||
fProblemRequestorState.set(state);
|
fProblemRequestorState.set(state);
|
||||||
++fStateCount;
|
++fStateCount;
|
||||||
|
@ -452,7 +453,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
*/
|
*/
|
||||||
public void acceptProblem(IProblem problem) {
|
public void acceptProblem(IProblem problem) {
|
||||||
if (isActive()) {
|
if (isActive()) {
|
||||||
ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
|
ProblemRequestorState state= fProblemRequestorState.get();
|
||||||
if (state != null)
|
if (state != null)
|
||||||
state.fReportedProblems.add(problem);
|
state.fReportedProblems.add(problem);
|
||||||
}
|
}
|
||||||
|
@ -462,7 +463,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
* @see IProblemRequestor#endReporting()
|
* @see IProblemRequestor#endReporting()
|
||||||
*/
|
*/
|
||||||
public void endReporting() {
|
public void endReporting() {
|
||||||
ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
|
ProblemRequestorState state= fProblemRequestorState.get();
|
||||||
if (state != null && !state.fInsideReportingSequence)
|
if (state != null && !state.fInsideReportingSequence)
|
||||||
internalEndReporting(state);
|
internalEndReporting(state);
|
||||||
}
|
}
|
||||||
|
@ -471,7 +472,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
* @see org.eclipse.cdt.internal.ui.text.java.IProblemRequestorExtension#endReportingSequence()
|
* @see org.eclipse.cdt.internal.ui.text.java.IProblemRequestorExtension#endReportingSequence()
|
||||||
*/
|
*/
|
||||||
public void endReportingSequence() {
|
public void endReportingSequence() {
|
||||||
ProblemRequestorState state= (ProblemRequestorState) fProblemRequestorState.get();
|
ProblemRequestorState state= fProblemRequestorState.get();
|
||||||
if (state != null && state.fInsideReportingSequence)
|
if (state != null && state.fInsideReportingSequence)
|
||||||
internalEndReporting(state);
|
internalEndReporting(state);
|
||||||
}
|
}
|
||||||
|
@ -491,7 +492,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
/**
|
/**
|
||||||
* Signals the end of problem reporting.
|
* Signals the end of problem reporting.
|
||||||
*/
|
*/
|
||||||
private void reportProblems(List reportedProblems) {
|
private void reportProblems(List<IProblem> reportedProblems) {
|
||||||
if (fProgressMonitor != null && fProgressMonitor.isCanceled())
|
if (fProgressMonitor != null && fProgressMonitor.isCanceled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -502,7 +503,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
boolean isCanceled= false;
|
boolean isCanceled= false;
|
||||||
|
|
||||||
fPreviouslyOverlaid= fCurrentlyOverlaid;
|
fPreviouslyOverlaid= fCurrentlyOverlaid;
|
||||||
fCurrentlyOverlaid= new ArrayList();
|
fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>();
|
||||||
|
|
||||||
if (fGeneratedAnnotations.size() > 0) {
|
if (fGeneratedAnnotations.size() > 0) {
|
||||||
temporaryProblemsChanged= true;
|
temporaryProblemsChanged= true;
|
||||||
|
@ -512,7 +513,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
|
|
||||||
if (reportedProblems != null && reportedProblems.size() > 0) {
|
if (reportedProblems != null && reportedProblems.size() > 0) {
|
||||||
|
|
||||||
Iterator e= reportedProblems.iterator();
|
Iterator<IProblem> e= reportedProblems.iterator();
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
|
|
||||||
if (fProgressMonitor != null && fProgressMonitor.isCanceled()) {
|
if (fProgressMonitor != null && fProgressMonitor.isCanceled()) {
|
||||||
|
@ -520,7 +521,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
IProblem problem= (IProblem) e.next();
|
IProblem problem= e.next();
|
||||||
Position position= createPositionFromProblem(problem);
|
Position position= createPositionFromProblem(problem);
|
||||||
if (position != null) {
|
if (position != null) {
|
||||||
|
|
||||||
|
@ -550,9 +551,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
if (isCanceled) {
|
if (isCanceled) {
|
||||||
fCurrentlyOverlaid.addAll(fPreviouslyOverlaid);
|
fCurrentlyOverlaid.addAll(fPreviouslyOverlaid);
|
||||||
} else if (fPreviouslyOverlaid != null) {
|
} else if (fPreviouslyOverlaid != null) {
|
||||||
Iterator e= fPreviouslyOverlaid.iterator();
|
Iterator<CMarkerAnnotation> e= fPreviouslyOverlaid.iterator();
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
CMarkerAnnotation annotation= (CMarkerAnnotation) e.next();
|
CMarkerAnnotation annotation= e.next();
|
||||||
annotation.setOverlay(null);
|
annotation.setOverlay(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -589,7 +590,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
* Tells this annotation model to collect temporary problems from now on.
|
* Tells this annotation model to collect temporary problems from now on.
|
||||||
*/
|
*/
|
||||||
private void startCollectingProblems() {
|
private void startCollectingProblems() {
|
||||||
fGeneratedAnnotations= new ArrayList();
|
fGeneratedAnnotations= new ArrayList<ProblemAnnotation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -637,6 +638,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
/*
|
/*
|
||||||
* @see AnnotationModel#addAnnotation(Annotation, Position, boolean)
|
* @see AnnotationModel#addAnnotation(Annotation, Position, boolean)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
|
protected void addAnnotation(Annotation annotation, Position position, boolean fireModelChanged) throws BadLocationException {
|
||||||
super.addAnnotation(annotation, position, fireModelChanged);
|
super.addAnnotation(annotation, position, fireModelChanged);
|
||||||
|
|
||||||
|
@ -645,10 +647,10 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
if (cached == null)
|
if (cached == null)
|
||||||
fReverseMap.put(position, annotation);
|
fReverseMap.put(position, annotation);
|
||||||
else if (cached instanceof List) {
|
else if (cached instanceof List) {
|
||||||
List list= (List) cached;
|
List<Annotation> list= (List<Annotation>) cached;
|
||||||
list.add(annotation);
|
list.add(annotation);
|
||||||
} else if (cached instanceof Annotation) {
|
} else if (cached instanceof Annotation) {
|
||||||
List list= new ArrayList(2);
|
List<Object> list= new ArrayList<Object>(2);
|
||||||
list.add(cached);
|
list.add(cached);
|
||||||
list.add(annotation);
|
list.add(annotation);
|
||||||
fReverseMap.put(position, list);
|
fReverseMap.put(position, list);
|
||||||
|
@ -778,6 +780,16 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
if (element instanceof ITranslationUnit) {
|
if (element instanceof ITranslationUnit) {
|
||||||
return (ITranslationUnit) element;
|
return (ITranslationUnit) element;
|
||||||
}
|
}
|
||||||
|
if (element == null) {
|
||||||
|
// not in a source folder?
|
||||||
|
final IPath location= file.getLocation();
|
||||||
|
if (location != null) {
|
||||||
|
ICProject cproject= CoreModel.getDefault().create(file.getProject());
|
||||||
|
if (cproject != null) {
|
||||||
|
return CoreModel.getDefault().createTranslationUnitFrom(cproject, location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -811,11 +823,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
ILocationProvider locationProvider= (ILocationProvider)adaptable.getAdapter(ILocationProvider.class);
|
ILocationProvider locationProvider= (ILocationProvider)adaptable.getAdapter(ILocationProvider.class);
|
||||||
if (locationProvider != null) {
|
if (locationProvider != null) {
|
||||||
IPath location= locationProvider.getPath(element);
|
IPath location= locationProvider.getPath(element);
|
||||||
if (location != null) {
|
|
||||||
original= createTranslationUnit(location);
|
original= createTranslationUnit(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (original == null) {
|
if (original == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -860,6 +870,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
* @return a translation unit or <code>null</code>
|
* @return a translation unit or <code>null</code>
|
||||||
*/
|
*/
|
||||||
private ITranslationUnit createTranslationUnit(IPath location) {
|
private ITranslationUnit createTranslationUnit(IPath location) {
|
||||||
|
if (location == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
IEditorInput input= EditorUtility.getEditorInputForLocation(location, null);
|
IEditorInput input= EditorUtility.getEditorInputForLocation(location, null);
|
||||||
if (input instanceof ITranslationUnitEditorInput) {
|
if (input instanceof ITranslationUnitEditorInput) {
|
||||||
return ((ITranslationUnitEditorInput)input).getTranslationUnit();
|
return ((ITranslationUnitEditorInput)input).getTranslationUnit();
|
||||||
|
|
Loading…
Add table
Reference in a new issue