diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java index 20a4094fc6b..bdf49ba46e3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java @@ -67,14 +67,11 @@ class PDOMCFunction extends PDOMBinding implements IFunction { public PDOMCFunction(PDOMLinkage linkage, PDOMNode parent, IFunction function) throws CoreException { super(linkage, parent, function.getNameCharArray()); - IFunctionType type; - IParameter[] parameters; - byte annotations; - type = function.getType(); - parameters = function.getParameters(); - annotations = PDOMCAnnotation.encodeAnnotation(function); + IFunctionType type = function.getType(); setType(getLinkage(), type); + IParameter[] parameters = function.getParameters(); setParameters(parameters); + byte annotations = PDOMCAnnotation.encodeAnnotation(function); getDB().putByte(record + ANNOTATIONS, annotations); } @@ -84,19 +81,16 @@ class PDOMCFunction extends PDOMBinding implements IFunction { return; IFunction func= (IFunction) newBinding; - IFunctionType newType; - IParameter[] newParams; - byte newAnnotation; - newType= func.getType(); - newParams = func.getParameters(); - newAnnotation = PDOMCAnnotation.encodeAnnotation(func); - + IFunctionType newType = func.getType(); setType(linkage, newType); + PDOMCParameter oldParams= getFirstParameter(null); + IParameter[] newParams = func.getParameters(); setParameters(newParams); if (oldParams != null) { oldParams.delete(linkage); } + byte newAnnotation = PDOMCAnnotation.encodeAnnotation(func); getDB().putByte(record + ANNOTATIONS, newAnnotation); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index 1d0357e2683..1d538ab38e3 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2014 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 @@ -18,7 +18,9 @@ package org.eclipse.cdt.internal.ui.editor; import java.text.CharacterIterator; +import java.util.ArrayDeque; import java.util.ArrayList; +import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -26,7 +28,6 @@ import java.util.List; import java.util.Map; import java.util.ResourceBundle; import java.util.Set; -import java.util.Stack; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; @@ -399,10 +400,10 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi private class ExitPolicy implements IExitPolicy { final char fExitCharacter; final char fEscapeCharacter; - final Stack fStack; + final Deque fStack; final int fSize; - public ExitPolicy(char exitCharacter, char escapeCharacter, Stack stack) { + public ExitPolicy(char exitCharacter, char escapeCharacter, Deque stack) { fExitCharacter = exitCharacter; fEscapeCharacter = escapeCharacter; fStack = stack; @@ -536,7 +537,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi private boolean fCloseAngularBrackets = true; private final String CATEGORY = toString(); private IPositionUpdater fUpdater = new ExclusivePositionUpdater(CATEGORY); - private Stack fBracketLevelStack = new Stack(); + private Deque fBracketLevelStack = new ArrayDeque<>(); public void setCloseBracketsEnabled(boolean enabled) { fCloseBrackets = enabled; @@ -1243,7 +1244,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi private final ListenerList fPostSaveListeners; - private static final Set angularIntroducers = new HashSet(); + private static final Set angularIntroducers = new HashSet<>(); static { angularIntroducers.add("template"); //$NON-NLS-1$ angularIntroducers.add("vector"); //$NON-NLS-1$ @@ -3100,7 +3101,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi // Add occurrence annotations int length= fLocations.length; - Map annotationMap= new HashMap(length); + Map annotationMap= new HashMap<>(length); for (int i= 0; i < length; i++) { if (isCanceled(progressMonitor)) return Status.CANCEL_STATUS; @@ -3367,7 +3368,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi * @return the preference store for this editor */ private IPreferenceStore createCombinedPreferenceStore(IEditorInput input) { - List stores= new ArrayList(3); + List stores= new ArrayList<>(3); ICProject project= EditorUtility.getCProject(input); if (project != null) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java index 95d6236c1dd..0222248ad66 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/WorkingCopyManager.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.editor; - import java.util.HashMap; import java.util.Map; @@ -29,13 +28,11 @@ import org.eclipse.cdt.ui.IWorkingCopyManagerExtension; import org.eclipse.cdt.internal.core.model.CModelManager; import org.eclipse.cdt.internal.core.model.IBufferFactory; - /** * This working copy manager works together with a given compilation unit document provider and * additionally offers to "overwrite" the working copy provided by this document provider. */ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyManagerExtension { - private CDocumentProvider fDocumentProvider; private Map fMap; private boolean fIsShuttingDown; @@ -52,25 +49,16 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana fDocumentProvider= provider; } - /* - * @see org.eclipse.cdt.ui.IWorkingCopyManager#connect(org.eclipse.ui.IEditorInput) - */ @Override public void connect(IEditorInput input) throws CoreException { fDocumentProvider.connect(input); } - /* - * @see org.eclipse.cdt.ui.IWorkingCopyManager#disconnect(org.eclipse.ui.IEditorInput) - */ @Override public void disconnect(IEditorInput input) { fDocumentProvider.disconnect(input); } - /* - * @see org.eclipse.cdt.ui.IWorkingCopyManager#shutdown() - */ @Override public void shutdown() { if (!fIsShuttingDown) { @@ -87,30 +75,21 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana } } - /* - * @see org.eclipse.cdt.ui.IWorkingCopyManager#getWorkingCopy(org.eclipse.ui.IEditorInput) - */ @Override public IWorkingCopy getWorkingCopy(IEditorInput input) { IWorkingCopy unit= fMap == null ? null : fMap.get(input); return unit != null ? unit : fDocumentProvider.getWorkingCopy(input); } - /* - * @see org.eclipse.cdt.internal.ui.editor.IWorkingCopyManagerExtension#setWorkingCopy(org.eclipse.ui.IEditorInput, org.eclipse.cdt.core.model.ITranslationUnit) - */ @Override public void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy) { if (fDocumentProvider.getDocument(input) != null) { if (fMap == null) - fMap= new HashMap(); + fMap= new HashMap<>(); fMap.put(input, workingCopy); } } - /* - * @see org.eclipse.cdt.internal.ui.editor.IWorkingCopyManagerExtension#removeWorkingCopy(org.eclipse.ui.IEditorInput) - */ @Override public void removeWorkingCopy(IEditorInput input) { fMap.remove(input); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java index 95a3f7452a4..091d0e0fb5c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManager.java @@ -20,26 +20,23 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.IWorkingCopy; /** - * Interface for accessing working copies of ITranslationUnit + * Interface for accessing working copies of {@code ITranslationUnit} * objects. The original translation unit is only given indirectly by means - * of an IEditorInput. The life cycle is as follows: + * of an {@code IEditorInput}. The life cycle is as follows: *
    - *
  • connect creates and remembers a working copy of the - * translation unit which is encoded in the given editor input
  • - *
  • getWorkingCopy returns the working copy remembered on - * connect
  • - *
  • disconnect destroys the working copy remembered on - * connect
  • + *
  • {@code connect} creates and remembers a working copy of the + * translation unit which is encoded in the given editor input
  • + *
  • {@code getWorkingCopy} returns the working copy remembered on + * {@code connect}
  • + *
  • {@code disconnect} destroys the working copy remembered on + * {@code connect}
  • *
- *

- * This interface is not intended to be implemented by clients. *

* @noimplement This interface is not intended to be implemented by clients. * * @see CDTUITools#getWorkingCopyManager */ public interface IWorkingCopyManager { - /** * Connects the given editor input to this manager. After calling * this method, a working copy will be available for the translation unit encoded @@ -47,7 +44,7 @@ public interface IWorkingCopyManager { * * @param input the editor input * @exception CoreException if the working copy cannot be created for the - * translation unit + * translation unit */ void connect(IEditorInput input) throws CoreException; @@ -67,9 +64,9 @@ public interface IWorkingCopyManager { * the given editor input. * * @param input the editor input - * @return the working copy of the translation unit, or null if the - * input does not encode an editor input, or if there is no remembered working - * copy for this translation unit + * @return the working copy of the translation unit, or {@code null} if the + * input does not encode an editor input, or if there is no remembered working + * copy for this translation unit */ IWorkingCopy getWorkingCopy(IEditorInput input); @@ -82,12 +79,14 @@ public interface IWorkingCopyManager { /** * Returns a shared working copy for the given translation unit. If necessary, a new * working copy will be created. + * * @param tu a translation unit - * @param requestor call back interface for reporting problems, may be null. + * @param requestor call back interface for reporting problems, may be {@code null}. * @param monitor a monitor to report progress * @since 5.2 */ - IWorkingCopy getSharedWorkingCopy(ITranslationUnit tu, IProblemRequestor requestor, IProgressMonitor monitor) throws CModelException; + IWorkingCopy getSharedWorkingCopy(ITranslationUnit tu, IProblemRequestor requestor, + IProgressMonitor monitor) throws CModelException; /** * Returns all shared working copies, currently available. @@ -96,9 +95,9 @@ public interface IWorkingCopyManager { IWorkingCopy[] getSharedWorkingCopies(); /** - * Returns the shared working copy for the given translation unit, if it exists, or null, otherwise. + * Returns the shared working copy for the given translation unit, if it exists, + * or {@code null}, otherwise. * @since 5.2 */ IWorkingCopy findSharedWorkingCopy(ITranslationUnit tu); - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManagerExtension.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManagerExtension.java index 9a9946e4160..3712f6a938e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManagerExtension.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/IWorkingCopyManagerExtension.java @@ -1,29 +1,29 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 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 - * http://www.eclipse.org/legal/epl-v10.html + * Copyright (c) 2000, 2008 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 + * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: + * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.ui; -import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.ui.IEditorInput; +import org.eclipse.cdt.core.model.IWorkingCopy; + /** - * Extension interface for IWorkingCopyManager. + * Extension interface for {@code IWorkingCopyManager}. * @noimplement This interface is not intended to be implemented by clients. * @since 2.1 */ public interface IWorkingCopyManagerExtension { - /** * Sets the given working copy for the given editor input. If the given editor input - * is not connected to this working copy manager, this call has no effect.

+ * is not connected to this working copy manager, this call has no effect. + *

* This working copy manager does not assume the ownership of this working copy, i.e., * the given working copy is not automatically be freed when this manager is shut down. *