1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

Bug 371144 - There seems to be no easy way to add custom marker annotations to non-workspace file

This commit is contained in:
Anton Leherbauer 2012-02-16 12:33:08 +01:00
parent d4f69c801e
commit 1bc41d348f

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2008 IBM Corporation and others.
* Copyright (c) 2002, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -44,13 +44,20 @@ public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
@Override
protected FileInfo createFileInfo(Object element) throws CoreException {
final FileInfo info= super.createFileInfo(element);
if (info != null && info.fModel == null) {
info.fModel= createAnnotationModel(element);
if (info.fModel != null) {
IAnnotationModel fileBufferAnnotationModel= info.fTextFileBuffer.getAnnotationModel();
if (fileBufferAnnotationModel != null) {
((AnnotationModel)info.fModel).addAnnotationModel("fileBufferModel", fileBufferAnnotationModel); //$NON-NLS-1$
if (info != null) {
IAnnotationModel originalModel = info.fModel;
IAnnotationModel externalSearchModel = createAnnotationModel(element);
if (externalSearchModel != null) {
info.fModel= externalSearchModel;
IAnnotationModel fileBufferModel= info.fTextFileBuffer.getAnnotationModel();
if (fileBufferModel != null) {
((AnnotationModel) externalSearchModel).addAnnotationModel("fileBufferModel", fileBufferModel); //$NON-NLS-1$
}
if (originalModel != null && originalModel != fileBufferModel) {
((AnnotationModel) externalSearchModel).addAnnotationModel("originalModel", originalModel); //$NON-NLS-1$
}
}
if (info.fModel != null) {
setUpSynchronization(info);
}
}
@ -104,8 +111,7 @@ public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
private IAnnotationModel createExternalSearchAnnotationModel(ExternalEditorInput externalInput) {
IPath location = externalInput.getPath();
if (location != null) {
IResource markerResource = externalInput.getMarkerResource();
return createExternalSearchAnnotationModel(location, markerResource);
return createExternalSearchAnnotationModel(location, null);
}
return null;
}