1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

Fix for 227463: Syntax coloring error on insertion/deletion

This commit is contained in:
Anton Leherbauer 2008-04-21 13:33:01 +00:00
parent 390aa48830
commit 835e96be68
5 changed files with 105 additions and 59 deletions

View file

@ -72,6 +72,7 @@ import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.internal.core.model.IBufferFactory; import org.eclipse.cdt.internal.core.model.IBufferFactory;
import org.eclipse.cdt.internal.core.model.TranslationUnit;
import org.eclipse.cdt.internal.ui.text.IProblemRequestorExtension; import org.eclipse.cdt.internal.ui.text.IProblemRequestorExtension;
import org.eclipse.cdt.internal.ui.text.spelling.CoreSpellingProblem; import org.eclipse.cdt.internal.ui.text.spelling.CoreSpellingProblem;
@ -111,7 +112,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
SpellingAnnotation.TYPE : INDEXER_ANNOTATION_TYPE); SpellingAnnotation.TYPE : INDEXER_ANNOTATION_TYPE);
if (problem instanceof IPersistableProblem) if (problem instanceof IPersistableProblem)
fMarkerType= ((IPersistableProblem) problem).getMarkerType(); fMarkerType= ((IPersistableProblem) problem).getMarkerType();
else else
fMarkerType= null; fMarkerType= null;
} }
@ -195,7 +196,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
/** /**
* Internal structure for mapping positions to some value. * Internal structure for mapping positions to some value.
* The reason for this specific structure is that positions can * The reason for this specific structure is that positions can
* change over time. Thus a lookup is based on value and not * change over time. Thus a lookup is based on value and not
* on hash value. * on hash value.
@ -336,7 +337,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
private boolean fIsActive= false; private boolean fIsActive= false;
private ReverseMap fReverseMap= new ReverseMap(); private ReverseMap fReverseMap= new ReverseMap();
private List<CMarkerAnnotation> fPreviouslyOverlaid= null; private List<CMarkerAnnotation> fPreviouslyOverlaid= null;
private List<CMarkerAnnotation> fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>(); private List<CMarkerAnnotation> fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>();
@ -422,7 +423,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
public void beginReporting() { public void beginReporting() {
ProblemRequestorState state= fProblemRequestorState.get(); ProblemRequestorState state= fProblemRequestorState.get();
if (state == null) if (state == null)
internalBeginReporting(false); internalBeginReporting(false);
} }
/* /*
@ -509,7 +510,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>(); fCurrentlyOverlaid= new ArrayList<CMarkerAnnotation>();
if (fGeneratedAnnotations.size() > 0) { if (fGeneratedAnnotations.size() > 0) {
temporaryProblemsChanged= true; temporaryProblemsChanged= true;
removeAnnotations(fGeneratedAnnotations, false, true); removeAnnotations(fGeneratedAnnotations, false, true);
fGeneratedAnnotations.clear(); fGeneratedAnnotations.clear();
} }
@ -529,7 +530,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
try { try {
ProblemAnnotation annotation= new ProblemAnnotation(problem, fTranslationUnit); ProblemAnnotation annotation= new ProblemAnnotation(problem, fTranslationUnit);
overlayMarkers(position, annotation); overlayMarkers(position, annotation);
addAnnotation(annotation, position, false); addAnnotation(annotation, position, false);
fGeneratedAnnotations.add(annotation); fGeneratedAnnotations.add(annotation);
@ -558,7 +559,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
CMarkerAnnotation annotation= e.next(); CMarkerAnnotation annotation= e.next();
annotation.setOverlay(null); annotation.setOverlay(null);
} }
} }
} }
/** /**
@ -592,7 +593,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<ProblemAnnotation>(); fGeneratedAnnotations= new ArrayList<ProblemAnnotation>();
} }
/** /**
@ -642,7 +643,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
*/ */
@Override @Override
@SuppressWarnings("unchecked") @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);
synchronized (getLockObject()) { synchronized (getLockObject()) {
@ -731,8 +732,8 @@ public class CDocumentProvider extends TextFileDocumentProvider {
public void removeListener(IAnnotationModelListener listener) { public void removeListener(IAnnotationModelListener listener) {
fListenerList.remove(listener); fListenerList.remove(listener);
} }
} }
/** Preference key for temporary problems */ /** Preference key for temporary problems */
private final static String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS; private final static String HANDLE_TEMPORARY_PROBLEMS= PreferenceConstants.EDITOR_EVALUATE_TEMPORARY_PROBLEMS;
@ -740,10 +741,10 @@ public class CDocumentProvider extends TextFileDocumentProvider {
/** Internal property changed listener */ /** Internal property changed listener */
private IPropertyChangeListener fPropertyListener; private IPropertyChangeListener fPropertyListener;
/** Annotation model listener added to all created CU annotation models */ /** Annotation model listener added to all created CU annotation models */
private GlobalAnnotationModelListener fGlobalAnnotationModelListener; private GlobalAnnotationModelListener fGlobalAnnotationModelListener;
/** /**
* *
*/ */
public CDocumentProvider() { public CDocumentProvider() {
super(); super();
@ -787,12 +788,10 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
if (element == null) { if (element == null) {
// not in a source folder? // not in a source folder?
final IPath location= file.getLocation(); ICProject cproject= CoreModel.getDefault().create(file.getProject());
if (location != null) { if (cproject != null) {
ICProject cproject= CoreModel.getDefault().create(file.getProject()); String contentTypeId= CoreModel.getRegistedContentTypeId(file.getProject(), file.getName());
if (cproject != null) { return new TranslationUnit(cproject, file, contentTypeId);
return CoreModel.getDefault().createTranslationUnitFrom(cproject, location);
}
} }
} }
return null; return null;
@ -937,7 +936,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
//for people who do not want auto-modification of their files, //for people who do not want auto-modification of their files,
//this flag will prevent addition of a newline unless the user //this flag will prevent addition of a newline unless the user
//explicitly sets the preference thru Window -> Preferences -> C/C++ -> Editor //explicitly sets the preference thru Window -> Preferences -> C/C++ -> Editor
// -> Appearance Tab -> Ensure newline end of file when saving // -> Appearance Tab -> Ensure newline end of file when saving
if (PreferenceConstants.getPreferenceStore().getBoolean( if (PreferenceConstants.getPreferenceStore().getBoolean(
PreferenceConstants.ENSURE_NEWLINE_AT_EOF)) { PreferenceConstants.ENSURE_NEWLINE_AT_EOF)) {
@ -948,8 +947,8 @@ public class CDocumentProvider extends TextFileDocumentProvider {
try { try {
// we have to ensure that the length of the last line is 0. // we have to ensure that the length of the last line is 0.
// this will also take care of empty files. empty files have // this will also take care of empty files. empty files have
// only one line in them and the length of this one and only // only one line in them and the length of this one and only
// line is 0. // line is 0.
// Thus we do not need to append an extra line separator to // Thus we do not need to append an extra line separator to
// empty files. // empty files.
int lastLineLength = document.getLineLength(lastLineIndex); int lastLineLength = document.getLineLength(lastLineIndex);
@ -959,10 +958,10 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
} catch (BadLocationException e) { } catch (BadLocationException e) {
} }
} }
// Remove trailing whitespace when saving. Triggered by the flag // Remove trailing whitespace when saving. Triggered by the flag
// in Preferences -> C/C++ -> Editor // in Preferences -> C/C++ -> Editor
if (PreferenceConstants.getPreferenceStore().getBoolean( if (PreferenceConstants.getPreferenceStore().getBoolean(
PreferenceConstants.REMOVE_TRAILING_WHITESPACE)) { PreferenceConstants.REMOVE_TRAILING_WHITESPACE)) {
try { try {
@ -989,7 +988,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
} }
} catch (BadLocationException e) { } catch (BadLocationException e) {
} }
} }
final FileInfo info= getFileInfo(element); final FileInfo info= getFileInfo(element);
if (info instanceof TranslationUnitInfo) { if (info instanceof TranslationUnitInfo) {
@ -1026,7 +1025,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
protected boolean isHandlingTemporaryProblems() { protected boolean isHandlingTemporaryProblems() {
IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore();
return store.getBoolean(HANDLE_TEMPORARY_PROBLEMS); return store.getBoolean(HANDLE_TEMPORARY_PROBLEMS);
} }
/** /**
* Switches the state of problem acceptance according to the value in the preference store. * Switches the state of problem acceptance according to the value in the preference store.

View file

@ -195,7 +195,6 @@ import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
import org.eclipse.cdt.internal.ui.actions.GotoNextBookmarkAction; import org.eclipse.cdt.internal.ui.actions.GotoNextBookmarkAction;
import org.eclipse.cdt.internal.ui.actions.IndentAction; import org.eclipse.cdt.internal.ui.actions.IndentAction;
import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction; import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction;
import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
import org.eclipse.cdt.internal.ui.dnd.TextEditorDropAdapter; import org.eclipse.cdt.internal.ui.dnd.TextEditorDropAdapter;
import org.eclipse.cdt.internal.ui.dnd.TextViewerDragAdapter; import org.eclipse.cdt.internal.ui.dnd.TextViewerDragAdapter;
import org.eclipse.cdt.internal.ui.search.OccurrencesFinder; import org.eclipse.cdt.internal.ui.search.OccurrencesFinder;
@ -1405,12 +1404,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
} }
else if (required == IShowInSource.class) { else if (required == IShowInSource.class) {
ICElement ce= null; ICElement ce= null;
try { ce= getElementAt(getSourceViewer().getSelectedRange().x, false);
ce= SelectionConverter.getElementAtOffset(this); if (ce instanceof ITranslationUnit) {
if (ce instanceof ITranslationUnit) { ce = null;
ce = null;
}
} catch (CModelException ex) {
} }
final ISelection selection= ce != null ? new StructuredSelection(ce) : null; final ISelection selection= ce != null ? new StructuredSelection(ce) : null;
return new IShowInSource() { return new IShowInSource() {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2007 QNX Software Systems and others. * Copyright (c) 2002, 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
@ -12,14 +12,18 @@
package org.eclipse.cdt.internal.ui.editor; package org.eclipse.cdt.internal.ui.editor;
import java.net.URI;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.cdt.core.model.IBuffer; import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.IOpenable; import org.eclipse.cdt.core.model.IOpenable;
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;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.core.model.IBufferFactory; import org.eclipse.cdt.internal.core.model.IBufferFactory;
@ -54,7 +58,17 @@ public class CustomBufferFactory implements IBufferFactory {
if (location != null) { if (location != null) {
return new DocumentAdapter(owner, location); return new DocumentAdapter(owner, location);
} }
// URI
URI locationUri= original.getLocationURI();
if (locationUri != null) {
try {
return new DocumentAdapter(owner, locationUri);
} catch (CoreException exc) {
CUIPlugin.log(exc);
}
}
} }
return DocumentAdapter.NULL; return DocumentAdapter.NULL;
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2007 IBM Corporation and others. * Copyright (c) 2002, 2008 IBM Corporation 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
@ -12,25 +12,23 @@
package org.eclipse.cdt.internal.ui.editor; package org.eclipse.cdt.internal.ui.editor;
import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.eclipse.cdt.core.model.BufferChangedEvent;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.IBufferChangedListener;
import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.filebuffers.FileBuffers; import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer; import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.filebuffers.ITextFileBufferManager; import org.eclipse.core.filebuffers.ITextFileBufferManager;
import org.eclipse.core.filebuffers.LocationKind; import org.eclipse.core.filebuffers.LocationKind;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourceAttributes; import org.eclipse.core.resources.ResourceAttributes;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
@ -42,13 +40,19 @@ import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentListener; import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.ISynchronizable; import org.eclipse.jface.text.ISynchronizable;
import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
import org.eclipse.cdt.core.model.BufferChangedEvent;
import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.IBuffer;
import org.eclipse.cdt.core.model.IBufferChangedListener;
import org.eclipse.cdt.core.model.IOpenable;
import org.eclipse.cdt.ui.CUIPlugin;
/** /**
* Adapts <code>IDocument</code> to <code>IBuffer</code>. Uses the * Adapts <code>IDocument</code> to <code>IBuffer</code>. Uses the
* same algorithm as the text widget to determine the buffer's line delimiter. * same algorithm as the text widget to determine the buffer's line delimiter.
* All text inserted into the buffer is converted to this line delimiter. * All text inserted into the buffer is converted to this line delimiter.
* This class is <code>public</code> for test purposes only. * This class is <code>public</code> for test purposes only.
* *
@ -186,6 +190,8 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
final private IPath fLocation; final private IPath fLocation;
final private LocationKind fLocationKind; final private LocationKind fLocationKind;
private IFileStore fFileStore;
public DocumentAdapter(IOpenable owner, IFile file) { public DocumentAdapter(IOpenable owner, IFile file) {
fOwner= owner; fOwner= owner;
@ -193,7 +199,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
fLocation= file.getFullPath(); fLocation= file.getFullPath();
fLocationKind= LocationKind.IFILE; fLocationKind= LocationKind.IFILE;
initialize(); initialize();
} }
public DocumentAdapter(IOpenable owner, IPath location) { public DocumentAdapter(IOpenable owner, IPath location) {
@ -201,20 +207,38 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
fLocation= location; fLocation= location;
fLocationKind= LocationKind.LOCATION; fLocationKind= LocationKind.LOCATION;
initialize(); initialize();
}
public DocumentAdapter(IOpenable owner, URI locationUri) throws CoreException {
fOwner= owner;
fFileStore= EFS.getStore(locationUri);
fLocation= null;
fLocationKind= null;
initialize();
} }
private void initialize() { private void initialize() {
ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager(); ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
try { try {
manager.connect(fLocation, fLocationKind, new NullProgressMonitor()); if (fLocation != null) {
fTextFileBuffer= manager.getTextFileBuffer(fLocation, fLocationKind); manager.connect(fLocation, fLocationKind, new NullProgressMonitor());
fTextFileBuffer= manager.getTextFileBuffer(fLocation, fLocationKind);
} else {
manager.connectFileStore(fFileStore, new NullProgressMonitor());
fTextFileBuffer= manager.getFileStoreTextFileBuffer(fFileStore);
}
fDocument= fTextFileBuffer.getDocument(); fDocument= fTextFileBuffer.getDocument();
} catch (CoreException x) { } catch (CoreException x) {
fStatus= x.getStatus(); fStatus= x.getStatus();
fDocument= manager.createEmptyDocument(fLocation, fLocationKind); if (fLocation != null) {
if (fDocument instanceof ISynchronizable) fDocument= manager.createEmptyDocument(fLocation, fLocationKind);
}
if (fDocument instanceof ISynchronizable) {
((ISynchronizable)fDocument).setLockObject(new Object()); ((ISynchronizable)fDocument).setLockObject(new Object());
}
} }
fDocument.addPrenotifiedDocumentListener(this); fDocument.addPrenotifiedDocumentListener(this);
} }
@ -261,7 +285,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
* @see org.eclipse.cdt.core.model.IBuffer#append(char[]) * @see org.eclipse.cdt.core.model.IBuffer#append(char[])
*/ */
public void append(char[] text) { public void append(char[] text) {
append(new String(text)); append(new String(text));
} }
/** /**
@ -271,7 +295,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
if (DEBUG_LINE_DELIMITERS) { if (DEBUG_LINE_DELIMITERS) {
validateLineDelimiters(text); validateLineDelimiters(text);
} }
fReplaceCmd.replace(fDocument.getLength(), 0, text); fReplaceCmd.replace(fDocument.getLength(), 0, text);
} }
@ -290,7 +314,11 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
if (fTextFileBuffer != null) { if (fTextFileBuffer != null) {
ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager(); ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
try { try {
manager.disconnect(fLocation, fLocationKind, new NullProgressMonitor()); if (fLocation != null) {
manager.disconnect(fLocation, fLocationKind, new NullProgressMonitor());
} else {
manager.disconnectFileStore(fFileStore, new NullProgressMonitor());
}
} catch (CoreException x) { } catch (CoreException x) {
// ignore // ignore
} }
@ -384,14 +412,14 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
return attributes.isReadOnly(); return attributes.isReadOnly();
} }
} }
return false; return false;
} }
/** /**
* @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[]) * @see org.eclipse.cdt.core.model.IBuffer#replace(int, int, char[])
*/ */
public void replace(int position, int length, char[] text) { public void replace(int position, int length, char[] text) {
replace(position, length, new String(text)); replace(position, length, new String(text));
} }
/** /**
@ -420,7 +448,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
* @see org.eclipse.cdt.core.model.IBuffer#setContents(char[]) * @see org.eclipse.cdt.core.model.IBuffer#setContents(char[])
*/ */
public void setContents(char[] contents) { public void setContents(char[] contents) {
setContents(new String(contents)); setContents(new String(contents));
} }
/** /**

View file

@ -57,14 +57,23 @@ public class CNavigatorLinkHelper implements ILinkHelper {
*/ */
public IStructuredSelection findSelection(IEditorInput input) { public IStructuredSelection findSelection(IEditorInput input) {
IWorkingCopyManager mgr= CUIPlugin.getDefault().getWorkingCopyManager(); IWorkingCopyManager mgr= CUIPlugin.getDefault().getWorkingCopyManager();
ICElement element= mgr.getWorkingCopy(input); Object element= mgr.getWorkingCopy(input);
if (element == null) { if (element == null) {
IFile file = ResourceUtil.getFile(input); IFile file = ResourceUtil.getFile(input);
if (file != null && CoreModel.hasCNature(file.getProject())) { if (file != null && CoreModel.hasCNature(file.getProject())) {
element= CoreModel.getDefault().create(file); element= CoreModel.getDefault().create(file);
} }
} else { } else {
element= ((IWorkingCopy) element).getOriginalElement(); ITranslationUnit tUnit= ((IWorkingCopy) element).getOriginalElement();
IFile file= (IFile) tUnit.getResource();
if (file != null) {
element= CoreModel.getDefault().create(file);
if (element == null) {
element= file;
}
} else {
element= tUnit;
}
} }
return (element != null) ? new StructuredSelection(element) : StructuredSelection.EMPTY; return (element != null) ? new StructuredSelection(element) : StructuredSelection.EMPTY;
} }