1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-09 17:25:38 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-05-15 12:23:48 -07:00
parent a7b73d776c
commit 62776c27d6
5 changed files with 46 additions and 73 deletions

View file

@ -67,14 +67,11 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
public PDOMCFunction(PDOMLinkage linkage, PDOMNode parent, IFunction function) throws CoreException { public PDOMCFunction(PDOMLinkage linkage, PDOMNode parent, IFunction function) throws CoreException {
super(linkage, parent, function.getNameCharArray()); super(linkage, parent, function.getNameCharArray());
IFunctionType type; IFunctionType type = function.getType();
IParameter[] parameters;
byte annotations;
type = function.getType();
parameters = function.getParameters();
annotations = PDOMCAnnotation.encodeAnnotation(function);
setType(getLinkage(), type); setType(getLinkage(), type);
IParameter[] parameters = function.getParameters();
setParameters(parameters); setParameters(parameters);
byte annotations = PDOMCAnnotation.encodeAnnotation(function);
getDB().putByte(record + ANNOTATIONS, annotations); getDB().putByte(record + ANNOTATIONS, annotations);
} }
@ -84,19 +81,16 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
return; return;
IFunction func= (IFunction) newBinding; IFunction func= (IFunction) newBinding;
IFunctionType newType; IFunctionType newType = func.getType();
IParameter[] newParams;
byte newAnnotation;
newType= func.getType();
newParams = func.getParameters();
newAnnotation = PDOMCAnnotation.encodeAnnotation(func);
setType(linkage, newType); setType(linkage, newType);
PDOMCParameter oldParams= getFirstParameter(null); PDOMCParameter oldParams= getFirstParameter(null);
IParameter[] newParams = func.getParameters();
setParameters(newParams); setParameters(newParams);
if (oldParams != null) { if (oldParams != null) {
oldParams.delete(linkage); oldParams.delete(linkage);
} }
byte newAnnotation = PDOMCAnnotation.encodeAnnotation(func);
getDB().putByte(record + ANNOTATIONS, newAnnotation); getDB().putByte(record + ANNOTATIONS, newAnnotation);
} }

View file

@ -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 * 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
@ -18,7 +18,9 @@
package org.eclipse.cdt.internal.ui.editor; package org.eclipse.cdt.internal.ui.editor;
import java.text.CharacterIterator; import java.text.CharacterIterator;
import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -26,7 +28,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.Set; import java.util.Set;
import java.util.Stack;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
@ -399,10 +400,10 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private class ExitPolicy implements IExitPolicy { private class ExitPolicy implements IExitPolicy {
final char fExitCharacter; final char fExitCharacter;
final char fEscapeCharacter; final char fEscapeCharacter;
final Stack<BracketLevel> fStack; final Deque<BracketLevel> fStack;
final int fSize; final int fSize;
public ExitPolicy(char exitCharacter, char escapeCharacter, Stack<BracketLevel> stack) { public ExitPolicy(char exitCharacter, char escapeCharacter, Deque<BracketLevel> stack) {
fExitCharacter = exitCharacter; fExitCharacter = exitCharacter;
fEscapeCharacter = escapeCharacter; fEscapeCharacter = escapeCharacter;
fStack = stack; fStack = stack;
@ -536,7 +537,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private boolean fCloseAngularBrackets = true; private boolean fCloseAngularBrackets = true;
private final String CATEGORY = toString(); private final String CATEGORY = toString();
private IPositionUpdater fUpdater = new ExclusivePositionUpdater(CATEGORY); private IPositionUpdater fUpdater = new ExclusivePositionUpdater(CATEGORY);
private Stack<BracketLevel> fBracketLevelStack = new Stack<BracketLevel>(); private Deque<BracketLevel> fBracketLevelStack = new ArrayDeque<>();
public void setCloseBracketsEnabled(boolean enabled) { public void setCloseBracketsEnabled(boolean enabled) {
fCloseBrackets = enabled; fCloseBrackets = enabled;
@ -1243,7 +1244,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
private final ListenerList fPostSaveListeners; private final ListenerList fPostSaveListeners;
private static final Set<String> angularIntroducers = new HashSet<String>(); private static final Set<String> angularIntroducers = new HashSet<>();
static { static {
angularIntroducers.add("template"); //$NON-NLS-1$ angularIntroducers.add("template"); //$NON-NLS-1$
angularIntroducers.add("vector"); //$NON-NLS-1$ angularIntroducers.add("vector"); //$NON-NLS-1$
@ -3100,7 +3101,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
// Add occurrence annotations // Add occurrence annotations
int length= fLocations.length; int length= fLocations.length;
Map<Annotation, Position> annotationMap= new HashMap<Annotation, Position>(length); Map<Annotation, Position> annotationMap= new HashMap<>(length);
for (int i= 0; i < length; i++) { for (int i= 0; i < length; i++) {
if (isCanceled(progressMonitor)) if (isCanceled(progressMonitor))
return Status.CANCEL_STATUS; return Status.CANCEL_STATUS;
@ -3367,7 +3368,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
* @return the preference store for this editor * @return the preference store for this editor
*/ */
private IPreferenceStore createCombinedPreferenceStore(IEditorInput input) { private IPreferenceStore createCombinedPreferenceStore(IEditorInput input) {
List<IPreferenceStore> stores= new ArrayList<IPreferenceStore>(3); List<IPreferenceStore> stores= new ArrayList<>(3);
ICProject project= EditorUtility.getCProject(input); ICProject project= EditorUtility.getCProject(input);
if (project != null) { if (project != null) {

View file

@ -10,7 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.editor; package org.eclipse.cdt.internal.ui.editor;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; 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.CModelManager;
import org.eclipse.cdt.internal.core.model.IBufferFactory; import org.eclipse.cdt.internal.core.model.IBufferFactory;
/** /**
* This working copy manager works together with a given compilation unit document provider and * 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. * additionally offers to "overwrite" the working copy provided by this document provider.
*/ */
public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyManagerExtension { public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyManagerExtension {
private CDocumentProvider fDocumentProvider; private CDocumentProvider fDocumentProvider;
private Map<IEditorInput, IWorkingCopy> fMap; private Map<IEditorInput, IWorkingCopy> fMap;
private boolean fIsShuttingDown; private boolean fIsShuttingDown;
@ -52,25 +49,16 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
fDocumentProvider= provider; fDocumentProvider= provider;
} }
/*
* @see org.eclipse.cdt.ui.IWorkingCopyManager#connect(org.eclipse.ui.IEditorInput)
*/
@Override @Override
public void connect(IEditorInput input) throws CoreException { public void connect(IEditorInput input) throws CoreException {
fDocumentProvider.connect(input); fDocumentProvider.connect(input);
} }
/*
* @see org.eclipse.cdt.ui.IWorkingCopyManager#disconnect(org.eclipse.ui.IEditorInput)
*/
@Override @Override
public void disconnect(IEditorInput input) { public void disconnect(IEditorInput input) {
fDocumentProvider.disconnect(input); fDocumentProvider.disconnect(input);
} }
/*
* @see org.eclipse.cdt.ui.IWorkingCopyManager#shutdown()
*/
@Override @Override
public void shutdown() { public void shutdown() {
if (!fIsShuttingDown) { if (!fIsShuttingDown) {
@ -87,30 +75,21 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
} }
} }
/*
* @see org.eclipse.cdt.ui.IWorkingCopyManager#getWorkingCopy(org.eclipse.ui.IEditorInput)
*/
@Override @Override
public IWorkingCopy getWorkingCopy(IEditorInput input) { public IWorkingCopy getWorkingCopy(IEditorInput input) {
IWorkingCopy unit= fMap == null ? null : fMap.get(input); IWorkingCopy unit= fMap == null ? null : fMap.get(input);
return unit != null ? unit : fDocumentProvider.getWorkingCopy(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 @Override
public void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy) { public void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy) {
if (fDocumentProvider.getDocument(input) != null) { if (fDocumentProvider.getDocument(input) != null) {
if (fMap == null) if (fMap == null)
fMap= new HashMap<IEditorInput, IWorkingCopy>(); fMap= new HashMap<>();
fMap.put(input, workingCopy); fMap.put(input, workingCopy);
} }
} }
/*
* @see org.eclipse.cdt.internal.ui.editor.IWorkingCopyManagerExtension#removeWorkingCopy(org.eclipse.ui.IEditorInput)
*/
@Override @Override
public void removeWorkingCopy(IEditorInput input) { public void removeWorkingCopy(IEditorInput input) {
fMap.remove(input); fMap.remove(input);

View file

@ -20,26 +20,23 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.model.IWorkingCopy;
/** /**
* Interface for accessing working copies of <code>ITranslationUnit</code> * Interface for accessing working copies of {@code ITranslationUnit}
* objects. The original translation unit is only given indirectly by means * objects. The original translation unit is only given indirectly by means
* of an <code>IEditorInput</code>. The life cycle is as follows: * of an {@code IEditorInput}. The life cycle is as follows:
* <ul> * <ul>
* <li> <code>connect</code> creates and remembers a working copy of the * <li> {@code connect} creates and remembers a working copy of the
* translation unit which is encoded in the given editor input</li> * translation unit which is encoded in the given editor input</li>
* <li> <code>getWorkingCopy</code> returns the working copy remembered on * <li> {@code getWorkingCopy} returns the working copy remembered on
* <code>connect</code></li> * {@code connect}</li>
* <li> <code>disconnect</code> destroys the working copy remembered on * <li> {@code disconnect} destroys the working copy remembered on
* <code>connect</code></li> * {@code connect}</li>
* </ul> * </ul>
* <p>
* This interface is not intended to be implemented by clients.
* </p> * </p>
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
* *
* @see CDTUITools#getWorkingCopyManager * @see CDTUITools#getWorkingCopyManager
*/ */
public interface IWorkingCopyManager { public interface IWorkingCopyManager {
/** /**
* Connects the given editor input to this manager. After calling * Connects the given editor input to this manager. After calling
* this method, a working copy will be available for the translation unit encoded * 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 * @param input the editor input
* @exception CoreException if the working copy cannot be created for the * @exception CoreException if the working copy cannot be created for the
* translation unit * translation unit
*/ */
void connect(IEditorInput input) throws CoreException; void connect(IEditorInput input) throws CoreException;
@ -67,9 +64,9 @@ public interface IWorkingCopyManager {
* the given editor input. * the given editor input.
* *
* @param input the editor input * @param input the editor input
* @return the working copy of the translation unit, or <code>null</code> if the * @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 * input does not encode an editor input, or if there is no remembered working
* copy for this translation unit * copy for this translation unit
*/ */
IWorkingCopy getWorkingCopy(IEditorInput input); 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 * Returns a shared working copy for the given translation unit. If necessary, a new
* working copy will be created. * working copy will be created.
*
* @param tu a translation unit * @param tu a translation unit
* @param requestor call back interface for reporting problems, may be <code>null</code>. * @param requestor call back interface for reporting problems, may be {@code null}.
* @param monitor a monitor to report progress * @param monitor a monitor to report progress
* @since 5.2 * @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. * Returns all shared working copies, currently available.
@ -96,9 +95,9 @@ public interface IWorkingCopyManager {
IWorkingCopy[] getSharedWorkingCopies(); IWorkingCopy[] getSharedWorkingCopies();
/** /**
* Returns the shared working copy for the given translation unit, if it exists, or <code>null</code>, otherwise. * Returns the shared working copy for the given translation unit, if it exists,
* or {@code null}, otherwise.
* @since 5.2 * @since 5.2
*/ */
IWorkingCopy findSharedWorkingCopy(ITranslationUnit tu); IWorkingCopy findSharedWorkingCopy(ITranslationUnit tu);
} }

View file

@ -1,29 +1,29 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2008 IBM Corporation and others. * Copyright (c) 2000, 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
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.ui; package org.eclipse.cdt.ui;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorInput;
import org.eclipse.cdt.core.model.IWorkingCopy;
/** /**
* Extension interface for <code>IWorkingCopyManager</code>. * Extension interface for {@code IWorkingCopyManager}.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
* @since 2.1 * @since 2.1
*/ */
public interface IWorkingCopyManagerExtension { public interface IWorkingCopyManagerExtension {
/** /**
* Sets the given working copy for the given editor input. If the given editor input * 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. <p> * is not connected to this working copy manager, this call has no effect.
* <p>
* This working copy manager does not assume the ownership of this working copy, i.e., * 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. * the given working copy is not automatically be freed when this manager is shut down.
* *