mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Fixed deprecation warnings.
This commit is contained in:
parent
9804e683e6
commit
e7d8109e95
3 changed files with 29 additions and 48 deletions
|
@ -27,9 +27,8 @@ import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.ListenerList;
|
import org.eclipse.core.runtime.ListenerList;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubMonitor;
|
||||||
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
|
@ -664,10 +663,10 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
|
protected static class GlobalAnnotationModelListener implements IAnnotationModelListener, IAnnotationModelListenerExtension {
|
||||||
private ListenerList fListenerList;
|
private ListenerList<IAnnotationModelListener> fListenerList;
|
||||||
|
|
||||||
public GlobalAnnotationModelListener() {
|
public GlobalAnnotationModelListener() {
|
||||||
fListenerList= new ListenerList(ListenerList.IDENTITY);
|
fListenerList= new ListenerList<IAnnotationModelListener>(ListenerList.IDENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -872,27 +871,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
super.disposeFileInfo(element, info);
|
super.disposeFileInfo(element, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and returns a new sub-progress monitor for the
|
|
||||||
* given parent monitor.
|
|
||||||
*
|
|
||||||
* @param monitor the parent progress monitor
|
|
||||||
* @param ticks the number of work ticks allocated from the parent monitor
|
|
||||||
* @return the new sub-progress monitor
|
|
||||||
*/
|
|
||||||
private IProgressMonitor getSubProgressMonitor(IProgressMonitor monitor, int ticks) {
|
|
||||||
if (monitor != null)
|
|
||||||
return new SubProgressMonitor(monitor, ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
|
|
||||||
|
|
||||||
return new NullProgressMonitor();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void commitWorkingCopy(IProgressMonitor monitor, Object element, TranslationUnitInfo info,
|
protected void commitWorkingCopy(IProgressMonitor monitor, Object element, TranslationUnitInfo info,
|
||||||
boolean overwrite) throws CoreException {
|
boolean overwrite) throws CoreException {
|
||||||
if (monitor == null)
|
SubMonitor progress = SubMonitor.convert(monitor, 100);
|
||||||
monitor= new NullProgressMonitor();
|
|
||||||
|
|
||||||
monitor.beginTask("", 100); //$NON-NLS-1$
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IDocument document= info.fTextFileBuffer.getDocument();
|
IDocument document= info.fTextFileBuffer.getDocument();
|
||||||
|
@ -900,7 +881,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
|
|
||||||
if (resource instanceof IFile && !resource.exists()) {
|
if (resource instanceof IFile && !resource.exists()) {
|
||||||
// The underlying resource has been deleted, just recreate the file, ignore the rest
|
// The underlying resource has been deleted, just recreate the file, ignore the rest
|
||||||
createFileFromDocument(getSubProgressMonitor(monitor, 20), (IFile) resource, document);
|
createFileFromDocument(progress.split(20), (IFile) resource, document);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -912,12 +893,12 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
cproject = CoreModel.getDefault().create(resource.getProject());
|
cproject = CoreModel.getDefault().create(resource.getProject());
|
||||||
}
|
}
|
||||||
performSaveActions(cproject, info.fTextFileBuffer, getSubProgressMonitor(monitor, 20));
|
performSaveActions(cproject, info.fTextFileBuffer, progress.split(20));
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
saveActionException = e;
|
saveActionException = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
commitFileBuffer(getSubProgressMonitor(monitor, 20), info, overwrite);
|
commitFileBuffer(progress.split(20), info, overwrite);
|
||||||
|
|
||||||
if (saveActionException != null) {
|
if (saveActionException != null) {
|
||||||
CUIPlugin.log(saveActionException);
|
CUIPlugin.log(saveActionException);
|
||||||
|
@ -1003,10 +984,11 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
||||||
* if the last line of the file was changed.
|
* if the last line of the file was changed.
|
||||||
* @throws BadLocationException
|
* @throws BadLocationException
|
||||||
*/
|
*/
|
||||||
private void performSaveActions(ICProject project, ITextFileBuffer buffer, IProgressMonitor monitor) throws CoreException {
|
private void performSaveActions(ICProject project, ITextFileBuffer buffer, IProgressMonitor monitor)
|
||||||
|
throws CoreException {
|
||||||
if (shouldRemoveTrailingWhitespace() || shouldAddNewlineAtEof() || shouldStyleFormatCode()) {
|
if (shouldRemoveTrailingWhitespace() || shouldAddNewlineAtEof() || shouldStyleFormatCode()) {
|
||||||
IRegion[] changedRegions= needsChangedRegions() ?
|
IRegion[] changedRegions= needsChangedRegions() ?
|
||||||
EditorUtility.calculateChangedLineRegions(buffer, getSubProgressMonitor(monitor, 20)) :
|
EditorUtility.calculateChangedLineRegions(buffer, monitor) :
|
||||||
null;
|
null;
|
||||||
IDocument document = buffer.getDocument();
|
IDocument document = buffer.getDocument();
|
||||||
formatCode(project, document);
|
formatCode(project, document);
|
||||||
|
|
|
@ -1319,7 +1319,8 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
* AST reconciling listeners.
|
* AST reconciling listeners.
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
private final ListenerList fReconcilingListeners= new ListenerList(ListenerList.IDENTITY);
|
private final ListenerList<ICReconcilingListener> fReconcilingListeners=
|
||||||
|
new ListenerList<ICReconcilingListener>(ListenerList.IDENTITY);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Semantic highlighting manager
|
* Semantic highlighting manager
|
||||||
|
@ -1342,7 +1343,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
|
|
||||||
private final IndexUpdateRequestor fIndexUpdateRequestor = new IndexUpdateRequestor();
|
private final IndexUpdateRequestor fIndexUpdateRequestor = new IndexUpdateRequestor();
|
||||||
|
|
||||||
private final ListenerList fPostSaveListeners;
|
private final ListenerList<IPostSaveListener> fPostSaveListeners;
|
||||||
|
|
||||||
private static final Set<String> angularIntroducers = new HashSet<>();
|
private static final Set<String> angularIntroducers = new HashSet<>();
|
||||||
static {
|
static {
|
||||||
|
@ -1379,7 +1380,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
setOutlinerContextMenuId("#CEditorOutlinerContext"); //$NON-NLS-1$
|
setOutlinerContextMenuId("#CEditorOutlinerContext"); //$NON-NLS-1$
|
||||||
|
|
||||||
fCEditorErrorTickUpdater = new CEditorErrorTickUpdater(this);
|
fCEditorErrorTickUpdater = new CEditorErrorTickUpdater(this);
|
||||||
fPostSaveListeners = new ListenerList();
|
fPostSaveListeners = new ListenerList<IPostSaveListener>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1545,12 +1546,12 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings("unchecked")
|
||||||
public Object getAdapter(Class adapterClass) {
|
public <T> T getAdapter(Class<T> adapterClass) {
|
||||||
if (adapterClass.isAssignableFrom(IContentOutlinePage.class)) {
|
if (adapterClass.isAssignableFrom(IContentOutlinePage.class)) {
|
||||||
return getOutlinePage();
|
return (T) getOutlinePage();
|
||||||
} else if (adapterClass.isAssignableFrom(IShowInTargetList.class)) {
|
} else if (adapterClass.isAssignableFrom(IShowInTargetList.class)) {
|
||||||
return new IShowInTargetList() {
|
return (T) new IShowInTargetList() {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public String[] getShowInTargetIds() {
|
public String[] getShowInTargetIds() {
|
||||||
|
@ -1563,7 +1564,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
ce = null;
|
ce = null;
|
||||||
}
|
}
|
||||||
final ISelection selection= ce != null ? new StructuredSelection(ce) : null;
|
final ISelection selection= ce != null ? new StructuredSelection(ce) : null;
|
||||||
return new IShowInSource() {
|
return (T) new IShowInSource() {
|
||||||
@Override
|
@Override
|
||||||
public ShowInContext getShowInContext() {
|
public ShowInContext getShowInContext() {
|
||||||
return new ShowInContext(getEditorInput(), selection);
|
return new ShowInContext(getEditorInput(), selection);
|
||||||
|
@ -1571,21 +1572,21 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
};
|
};
|
||||||
} else if (adapterClass.isAssignableFrom(ProjectionAnnotationModel.class)) {
|
} else if (adapterClass.isAssignableFrom(ProjectionAnnotationModel.class)) {
|
||||||
if (fProjectionSupport != null) {
|
if (fProjectionSupport != null) {
|
||||||
Object adapter = fProjectionSupport.getAdapter(getSourceViewer(), adapterClass);
|
T adapter = fProjectionSupport.getAdapter(getSourceViewer(), adapterClass);
|
||||||
if (adapter != null)
|
if (adapter != null)
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
} else if (adapterClass.isAssignableFrom(IContextProvider.class)) {
|
} else if (adapterClass.isAssignableFrom(IContextProvider.class)) {
|
||||||
return new CUIHelp.CUIHelpContextProvider(this);
|
return (T) new CUIHelp.CUIHelpContextProvider(this);
|
||||||
} else if (adapterClass.isAssignableFrom(IGotoMarker.class)) {
|
} else if (adapterClass.isAssignableFrom(IGotoMarker.class)) {
|
||||||
return new GotoMarkerAdapter();
|
return (T) new GotoMarkerAdapter();
|
||||||
} else if (adapterClass.isAssignableFrom(ITemplatesPage.class)) {
|
} else if (adapterClass.isAssignableFrom(ITemplatesPage.class)) {
|
||||||
if (fTemplatesPage == null) {
|
if (fTemplatesPage == null) {
|
||||||
fTemplatesPage = new CTemplatesPage(this);
|
fTemplatesPage = new CTemplatesPage(this);
|
||||||
}
|
}
|
||||||
return fTemplatesPage;
|
return (T) fTemplatesPage;
|
||||||
} else if (adapterClass.isAssignableFrom(ITranslationUnitHolder.class))
|
} else if (adapterClass.isAssignableFrom(ITranslationUnitHolder.class))
|
||||||
return this;
|
return (T) this;
|
||||||
return super.getAdapter(adapterClass);
|
return super.getAdapter(adapterClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2485,7 +2486,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
parent.addHelpListener(new HelpListener() {
|
parent.addHelpListener(new HelpListener() {
|
||||||
@Override
|
@Override
|
||||||
public void helpRequested(HelpEvent e) {
|
public void helpRequested(HelpEvent e) {
|
||||||
IContextProvider provider = (IContextProvider) CEditor.this.getAdapter(IContextProvider.class);
|
IContextProvider provider = CEditor.this.getAdapter(IContextProvider.class);
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
IContext context = provider.getContext(CEditor.this);
|
IContext context = provider.getContext(CEditor.this);
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
|
@ -2657,15 +2658,13 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
|
||||||
if (model == null)
|
if (model == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
Iterator<Annotation> parent;
|
||||||
Iterator parent;
|
|
||||||
if (model instanceof IAnnotationModelExtension2) {
|
if (model instanceof IAnnotationModelExtension2) {
|
||||||
parent= ((IAnnotationModelExtension2) model).getAnnotationIterator(offset, length, true, true);
|
parent= ((IAnnotationModelExtension2) model).getAnnotationIterator(offset, length, true, true);
|
||||||
} else {
|
} else {
|
||||||
parent= model.getAnnotationIterator();
|
parent= model.getAnnotationIterator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Iterator<Annotation> e= new CAnnotationIterator(parent, false);
|
Iterator<Annotation> e= new CAnnotationIterator(parent, false);
|
||||||
Annotation annotation = null;
|
Annotation annotation = null;
|
||||||
while (e.hasNext()) {
|
while (e.hasNext()) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ class EclipsePreferencesAdapter implements IPreferenceStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Listeners on on this adapter */
|
/** Listeners on on this adapter */
|
||||||
private ListenerList fListeners= new ListenerList(ListenerList.IDENTITY);
|
private ListenerList<IPropertyChangeListener> fListeners= new ListenerList<IPropertyChangeListener>(ListenerList.IDENTITY);
|
||||||
|
|
||||||
/** Listener on the node */
|
/** Listener on the node */
|
||||||
private IEclipsePreferences.IPreferenceChangeListener fListener= new PreferenceChangeListener();
|
private IEclipsePreferences.IPreferenceChangeListener fListener= new PreferenceChangeListener();
|
||||||
|
@ -83,7 +83,7 @@ class EclipsePreferencesAdapter implements IPreferenceStore {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addPropertyChangeListener(IPropertyChangeListener listener) {
|
public void addPropertyChangeListener(IPropertyChangeListener listener) {
|
||||||
if (fListeners.size() == 0)
|
if (fListeners.isEmpty())
|
||||||
getNode().addPreferenceChangeListener(fListener);
|
getNode().addPreferenceChangeListener(fListener);
|
||||||
fListeners.add(listener);
|
fListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ class EclipsePreferencesAdapter implements IPreferenceStore {
|
||||||
@Override
|
@Override
|
||||||
public void removePropertyChangeListener(IPropertyChangeListener listener) {
|
public void removePropertyChangeListener(IPropertyChangeListener listener) {
|
||||||
fListeners.remove(listener);
|
fListeners.remove(listener);
|
||||||
if (fListeners.size() == 0) {
|
if (fListeners.isEmpty()) {
|
||||||
getNode().removePreferenceChangeListener(fListener);
|
getNode().removePreferenceChangeListener(fListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue