1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-14 11:45:38 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-06-05 20:49:21 -07:00
parent ce9b270a38
commit cf4556f05f
33 changed files with 323 additions and 420 deletions

View file

@ -56,7 +56,7 @@ public class MoveRenameTest extends ChangeGeneratorTest {
IASTDeclaration[] members = classSpecifier.getMembers(); IASTDeclaration[] members = classSpecifier.getMembers();
ASTModification swap1 = new ASTModification(ASTModification.ModificationKind.REPLACE, members[1], members[2], null); ASTModification swap1 = new ASTModification(ASTModification.ModificationKind.REPLACE, members[1], members[2], null);
ASTModification swap2 = new ASTModification(ASTModification.ModificationKind.REPLACE, members[2], members[1], null); ASTModification swap2 = new ASTModification(ASTModification.ModificationKind.REPLACE, members[2], members[1], null);
IASTName name =((CPPASTSimpleDeclaration)members[2]).getDeclarators()[0].getName(); IASTName name =((CPPASTSimpleDeclaration) members[2]).getDeclarators()[0].getName();
modStore.storeModification(null, swap1); modStore.storeModification(null, swap1);
modStore.storeModification(null, swap2); modStore.storeModification(null, swap2);
modStore.storeModification(swap1, new ASTModification(ASTModification.ModificationKind.REPLACE, name, new CPPASTName("d".toCharArray()), null)); //$NON-NLS-1$ modStore.storeModification(swap1, new ASTModification(ASTModification.ModificationKind.REPLACE, name, new CPPASTName("d".toCharArray()), null)); //$NON-NLS-1$

View file

@ -12,6 +12,9 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.model; package org.eclipse.cdt.core.model;
import java.net.URI;
import java.util.List;
import org.eclipse.cdt.core.CCProjectNature; import org.eclipse.cdt.core.CCProjectNature;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CProjectNature; import org.eclipse.cdt.core.CProjectNature;
@ -59,9 +62,6 @@ import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.ISchedulingRule;
import java.net.URI;
import java.util.List;
/** /**
* @noextend This class is not intended to be subclassed by clients. * @noextend This class is not intended to be subclassed by clients.
* @noinstantiate This class is not intended to be instantiated by clients. * @noinstantiate This class is not intended to be instantiated by clients.
@ -260,9 +260,8 @@ public class CoreModel {
IContentType contentType = CCorePlugin.getContentType(project, name); IContentType contentType = CCorePlugin.getContentType(project, name);
if (contentType != null) { if (contentType != null) {
String id = contentType.getId(); String id = contentType.getId();
if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id)) { if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id) ||
return true; CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) {
} else if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) {
return true; return true;
} }
} }
@ -567,16 +566,12 @@ public class CoreModel {
* folders are located with that project. That is, a source entry * folders are located with that project. That is, a source entry
* specifying the path {@code /P1/src} is only usable for project * specifying the path {@code /P1/src} is only usable for project
* {@code P1}. * {@code P1}.
* </p>
* </p>
* <p> * <p>
* Note that all sources/binaries inside a project are contributed as a * Note that all sources/binaries inside a project are contributed as a
* whole through a project entry (see {@code newProjectEntry}). * whole through a project entry (see {@code newProjectEntry}).
* Particular source entries cannot be selectively exported. * Particular source entries cannot be selectively exported.
* </p>
* *
* @param sourcePath * @param sourcePath the project-relative path of a source folder
* the project-relative path of a source folder
* @return a new source entry with not exclusion patterns * @return a new source entry with not exclusion patterns
* *
*/ */
@ -596,7 +591,6 @@ public class CoreModel {
* folders are located with that project. That is, a source entry * folders are located with that project. That is, a source entry
* specifying the path {@code /P1/src} is only usable for project * specifying the path {@code /P1/src} is only usable for project
* {@code P1}. * {@code P1}.
* </p>
* *
* @param sourcePath * @param sourcePath
* the absolute project-relative path of a source folder * the absolute project-relative path of a source folder
@ -945,7 +939,6 @@ public class CoreModel {
* If the project's raw entries are later modified they can become out of * If the project's raw entries are later modified they can become out of
* date. Because of this, hanging on resolved pathentries is not * date. Because of this, hanging on resolved pathentries is not
* recommended. * recommended.
* </p>
* *
* @return the resolved entries for the project * @return the resolved entries for the project
* @exception CModelException * @exception CModelException
@ -963,7 +956,6 @@ public class CoreModel {
* If the project's raw entries are later modified they can become out of * If the project's raw entries are later modified they can become out of
* date. Because of this, hanging on resolved pathentries is not * date. Because of this, hanging on resolved pathentries is not
* recommended. * recommended.
* </p>
* *
* @return the include entries for the translation unit * @return the include entries for the translation unit
* @exception CModelException * @exception CModelException
@ -981,7 +973,6 @@ public class CoreModel {
* If the project's raw entries are later modified they can become out of * If the project's raw entries are later modified they can become out of
* date. Because of this, hanging on resolved pathentries is not * date. Because of this, hanging on resolved pathentries is not
* recommended. * recommended.
* </p>
* *
* @return the include file entries for the translation unit * @return the include file entries for the translation unit
* @exception CModelException * @exception CModelException
@ -999,7 +990,6 @@ public class CoreModel {
* If the project's raw entries are later modified they can become out of * If the project's raw entries are later modified they can become out of
* date. Because of this, hanging on resolved pathentries is not * date. Because of this, hanging on resolved pathentries is not
* recommended. * recommended.
* </p>
* *
* @return the resolved entries for the project * @return the resolved entries for the project
* @exception CModelException * @exception CModelException
@ -1017,7 +1007,6 @@ public class CoreModel {
* If the project's raw entries are later modified they can become out of * If the project's raw entries are later modified they can become out of
* date. Because of this, hanging on resolved pathentries is not * date. Because of this, hanging on resolved pathentries is not
* recommended. * recommended.
* </p>
* *
* @return the macro file entries for the translation unit * @return the macro file entries for the translation unit
* @exception CModelException * @exception CModelException
@ -1162,7 +1151,6 @@ public class CoreModel {
private CoreModel() { private CoreModel() {
} }
/** /**
* Runs the given action as an atomic C model operation. * Runs the given action as an atomic C model operation.
* <p> * <p>
@ -1173,13 +1161,11 @@ public class CoreModel {
* methods that modify C elements and only have element * methods that modify C elements and only have element
* changed event notifications reported at the end of the entire * changed event notifications reported at the end of the entire
* batch. * batch.
* </p>
* <p> * <p>
* If this method is called outside the dynamic scope of another such * If this method is called outside the dynamic scope of another such
* call, this method runs the action and then reports a single * call, this method runs the action and then reports a single
* element changed event describing the net effect of all changes * element changed event describing the net effect of all changes
* done to C elements by the action. * done to C elements by the action.
* </p>
* <p> * <p>
* If this method is called in the dynamic scope of another such * If this method is called in the dynamic scope of another such
* call, this method simply runs the action. * call, this method simply runs the action.
@ -1187,7 +1173,7 @@ public class CoreModel {
* *
* @param action the action to perform * @param action the action to perform
* @param monitor a progress monitor, or {@code null} if progress * @param monitor a progress monitor, or {@code null} if progress
* reporting and cancellation are not desired * reporting and cancellation are not desired
* @exception CoreException if the operation failed. * @exception CoreException if the operation failed.
* @since 2.1 * @since 2.1
*/ */
@ -1204,28 +1190,24 @@ public class CoreModel {
* methods that modify C elements and only have element * methods that modify C elements and only have element
* changed event notifications reported at the end of the entire * changed event notifications reported at the end of the entire
* batch. * batch.
* </p>
* <p> * <p>
* If this method is called outside the dynamic scope of another such * If this method is called outside the dynamic scope of another such
* call, this method runs the action and then reports a single * call, this method runs the action and then reports a single
* element changed event describing the net effect of all changes * element changed event describing the net effect of all changes
* done to C elements by the action. * done to C elements by the action.
* </p>
* <p> * <p>
* If this method is called in the dynamic scope of another such * If this method is called in the dynamic scope of another such
* call, this method simply runs the action. * call, this method simply runs the action.
* </p>
* <p> * <p>
* The supplied scheduling rule is used to determine whether this operation can be * The supplied scheduling rule is used to determine whether this operation can be
* run simultaneously with workspace changes in other threads. See * run simultaneously with workspace changes in other threads. See
* {@code IWorkspace.run(...)} for more details. * {@link IWorkspace#run} for more details.
* </p>
* *
* @param action the action to perform * @param action the action to perform
* @param rule the scheduling rule to use when running this operation, or * @param rule the scheduling rule to use when running this operation, or
* {@code null} if there are no scheduling restrictions for this operation. * {@code null} if there are no scheduling restrictions for this operation.
* @param monitor a progress monitor, or {@code null} if progress * @param monitor a progress monitor, or {@code null} if progress
* reporting and cancellation are not desired * reporting and cancellation are not desired
* @exception CoreException if the operation failed. * @exception CoreException if the operation failed.
* @since 3.0 * @since 3.0
*/ */
@ -1234,7 +1216,7 @@ public class CoreModel {
if (workspace.isTreeLocked()) { if (workspace.isTreeLocked()) {
new BatchOperation(action).run(monitor); new BatchOperation(action).run(monitor);
} else { } else {
// use IWorkspace.run(...) to ensure that a build will be done in autobuild mode // Use IWorkspace.run(...) to ensure that a build will be done in autobuild mode.
workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE, monitor); workspace.run(new BatchOperation(action), rule, IWorkspace.AVOID_UPDATE, monitor);
} }
} }

View file

@ -6,11 +6,10 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Rational Software - Initial API and implementation * Rational Software - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.model; package org.eclipse.cdt.core.model;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
@ -18,7 +17,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
* A buffer contains the text contents of a resource. It is not language-specific. * A buffer contains the text contents of a resource. It is not language-specific.
* The contents may be in the process of being edited, differing from the actual contents of the * The contents may be in the process of being edited, differing from the actual contents of the
* underlying resource. A buffer has an owner, which is an * underlying resource. A buffer has an owner, which is an
* <code>IOpenable</code>. If a buffer does not have an underlying resource, * {@code IOpenable}. If a buffer does not have an underlying resource,
* saving the buffer has no effect. Buffers can be read-only. * saving the buffer has no effect. Buffers can be read-only.
* <p> * <p>
* This interface is similar to the JDT IBuffer interface. * This interface is similar to the JDT IBuffer interface.
@ -26,15 +25,14 @@ import org.eclipse.core.runtime.IProgressMonitor;
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
*/ */
public interface IBuffer { public interface IBuffer {
/** /**
* Adds the given listener for changes to this buffer. * Adds the given listener for changes to this buffer.
* Has no effect if an identical listener is already registered or if the buffer * Has no effect if an identical listener is already registered or if the buffer is closed.
* is closed.
* *
* @param listener the listener of buffer changes * @param listener the listener of buffer changes
*/ */
public void addBufferChangedListener(IBufferChangedListener listener); public void addBufferChangedListener(IBufferChangedListener listener);
/** /**
* Appends the given character array to the contents of the buffer. * Appends the given character array to the contents of the buffer.
* This buffer will now have unsaved changes. * This buffer will now have unsaved changes.
@ -43,11 +41,12 @@ public interface IBuffer {
* <p> * <p>
* Has no effect if this buffer is read-only. * Has no effect if this buffer is read-only.
* <p> * <p>
* A <code>RuntimeException</code> might be thrown if the buffer is closed. * A {@code RuntimeException} might be thrown if the buffer is closed.
* *
* @param text the given character array to append to contents of the buffer * @param text the given character array to append to contents of the buffer
*/ */
public void append(char[] text); public void append(char[] text);
/** /**
* Appends the given string to the contents of the buffer. * Appends the given string to the contents of the buffer.
* This buffer will now have unsaved changes. * This buffer will now have unsaved changes.
@ -56,11 +55,12 @@ public interface IBuffer {
* <p> * <p>
* Has no effect if this buffer is read-only. * Has no effect if this buffer is read-only.
* <p> * <p>
* A <code>RuntimeException</code> might be thrown if the buffer is closed. * A {@code RuntimeException} might be thrown if the buffer is closed.
* *
* @param text the <code>String</code> to append to the contents of the buffer * @param text the {@code String} to append to the contents of the buffer
*/ */
public void append(String text); public void append(String text);
/** /**
* Closes the buffer. Any unsaved changes are lost. Reports a buffer changed event * Closes the buffer. Any unsaved changes are lost. Reports a buffer changed event
* with a 0 offset and a 0 length. When this event is fired, the buffer should already * with a 0 offset and a 0 length. When this event is fired, the buffer should already
@ -70,17 +70,19 @@ public interface IBuffer {
* attempt is made to close an already closed buffer, the second attempt has no effect. * attempt is made to close an already closed buffer, the second attempt has no effect.
*/ */
public void close(); public void close();
/** /**
* Returns the character at the given position in this buffer. * Returns the character at the given position in this buffer.
* <p> * <p>
* A <code>RuntimeException</code> might be thrown if the buffer is closed. * A {@code RuntimeException} might be thrown if the buffer is closed.
* *
* @param position a zero-based source offset in this buffer * @param position a zero-based source offset in this buffer
* @return the character at the given position in this buffer * @return the character at the given position in this buffer
*/ */
public char getChar(int position); public char getChar(int position);
/** /**
* Returns the contents of this buffer as a character array, or <code>null</code> if * Returns the contents of this buffer as a character array, or {@code null} if
* the buffer has not been initialized. * the buffer has not been initialized.
* <p> * <p>
* Callers should make no assumption about whether the returned character array * Callers should make no assumption about whether the returned character array
@ -88,77 +90,85 @@ public interface IBuffer {
* wishes to change this array, they should make a copy. Likewise, if the * wishes to change this array, they should make a copy. Likewise, if the
* client wishes to hang on to the array in its current state, they should * client wishes to hang on to the array in its current state, they should
* make a copy. * make a copy.
* </p>
* <p> * <p>
* A <code>RuntimeException</code> might be thrown if the buffer is closed. * A {@code RuntimeException} might be thrown if the buffer is closed.
* *
* @return the characters contained in this buffer * @return the characters contained in this buffer
*/ */
public char[] getCharacters(); public char[] getCharacters();
/** /**
* Returns the contents of this buffer as a <code>String</code>. Like all strings, * Returns the contents of this buffer as a {@code String}. Like all strings,
* the result is an immutable value object., It can also answer <code>null</code> if * the result is an immutable value object., It can also answer {@code null} if
* the buffer has not been initialized. * the buffer has not been initialized.
* <p> * <p>
* A <code>RuntimeException</code> might be thrown if the buffer is closed. * A {@code RuntimeException} might be thrown if the buffer is closed.
* *
* @return the contents of this buffer as a <code>String</code> * @return the contents of this buffer as a {@code String}
*/ */
public String getContents(); public String getContents();
/** /**
* Returns number of characters stored in this buffer. * Returns number of characters stored in this buffer.
* <p> * <p>
* A <code>RuntimeException</code> might be thrown if the buffer is closed. * A {@code RuntimeException} might be thrown if the buffer is closed.
* *
* @return the number of characters in this buffer * @return the number of characters in this buffer
*/ */
public int getLength(); public int getLength();
/** /**
* Returns the resource element owning of this buffer. * Returns the resource element owning of this buffer.
* *
* @return the resource element owning this buffer * @return the resource element owning this buffer
*/ */
public IOpenable getOwner(); public IOpenable getOwner();
/** /**
* Returns the given range of text in this buffer. * Returns the given range of text in this buffer.
* <p> * <p>
* A <code>RuntimeException</code> might be thrown if the buffer is closed. * A {@code RuntimeException} might be thrown if the buffer is closed.
* *
* @param offset the zero-based starting offset * @param offset the zero-based starting offset
* @param length the number of characters to retrieve * @param length the number of characters to retrieve
* @return the given range of text in this buffer * @return the given range of text in this buffer
*/ */
public String getText(int offset, int length); public String getText(int offset, int length);
/** /**
* Returns the underlying resource for which this buffer was opened, * Returns the underlying resource for which this buffer was opened,
* or <code>null</code> if this buffer was not opened on a resource. * or {@code null} if this buffer was not opened on a resource.
* *
* @return the underlying resource for this buffer, or <code>null</code> * @return the underlying resource for this buffer, or {@code null}
* if none. * if none.
*/ */
public IResource getUnderlyingResource(); public IResource getUnderlyingResource();
/** /**
* Returns whether this buffer has been modified since it * Returns whether this buffer has been modified since it
* was opened or since it was last saved. * was opened or since it was last saved.
* If a buffer does not have an underlying resource, this method always * If a buffer does not have an underlying resource, this method always
* returns <code>true</code>. * returns {@code true}.
* *
* @return a <code>boolean</code> indicating presence of unsaved changes (in * @return a {@code boolean} indicating presence of unsaved changes (in
* the absence of any underlying resource, it will always return <code>true</code>). * the absence of any underlying resource, it will always return {@code true}).
*/ */
public boolean hasUnsavedChanges(); public boolean hasUnsavedChanges();
/** /**
* Returns whether this buffer has been closed. * Returns whether this buffer has been closed.
* *
* @return a <code>boolean</code> indicating whether this buffer is closed. * @return a {@code boolean} indicating whether this buffer is closed.
*/ */
public boolean isClosed(); public boolean isClosed();
/** /**
* Returns whether this buffer is read-only. * Returns whether this buffer is read-only.
* *
* @return a <code>boolean</code> indicating whether this buffer is read-only * @return a {@code boolean} indicating whether this buffer is read-only
*/ */
public boolean isReadOnly(); public boolean isReadOnly();
/** /**
* Removes the given listener from this buffer. * Removes the given listener from this buffer.
* Has no affect if an identical listener is not registered or if the buffer is closed. * Has no affect if an identical listener is not registered or if the buffer is closed.
@ -166,30 +176,33 @@ public interface IBuffer {
* @param listener the listener * @param listener the listener
*/ */
public void removeBufferChangedListener(IBufferChangedListener listener); public void removeBufferChangedListener(IBufferChangedListener listener);
/** /**
* Replaces the given range of characters in this buffer with the given text. * Replaces the given range of characters in this buffer with the given text.
* <code>position</code> and <code>position + length</code> must be in the range [0, getLength()]. * {@code position} and {@code position + length} must be in the range [0, getLength()].
* <code>length</code> must not be negative. * {@code length} must not be negative.
* <p> * <p>
* A <code>RuntimeException</code> might be thrown if the buffer is closed. * A {@code RuntimeException} might be thrown if the buffer is closed.
* *
* @param position the zero-based starting position of the affected text range in this buffer * @param position the zero-based starting position of the affected text range in this buffer
* @param length the length of the affected text range in this buffer * @param length the length of the affected text range in this buffer
* @param text the replacing text as a character array * @param text the replacing text as a character array
*/ */
public void replace(int position, int length, char[] text); public void replace(int position, int length, char[] text);
/** /**
* Replaces the given range of characters in this buffer with the given text. * Replaces the given range of characters in this buffer with the given text.
* <code>position</code> and <code>position + length</code> must be in the range [0, getLength()]. * {@code position} and {@code position + length} must be in the range [0, getLength()].
* <code>length</code> must not be negative. * {@code length} must not be negative.
* <p> * <p>
* A <code>RuntimeException</code> might be thrown if the buffer is closed. * A {@code RuntimeException} might be thrown if the buffer is closed.
* *
* @param position the zero-based starting position of the affected text range in this buffer * @param position the zero-based starting position of the affected text range in this buffer
* @param length the length of the affected text range in this buffer * @param length the length of the affected text range in this buffer
* @param text the replacing text as a <code>String</code> * @param text the replacing text as a {@code String}
*/ */
public void replace(int position, int length, String text); public void replace(int position, int length, String text);
/** /**
* Saves the contents of this buffer to its underlying resource. If * Saves the contents of this buffer to its underlying resource. If
* successful, this buffer will have no unsaved changes. * successful, this buffer will have no unsaved changes.
@ -198,61 +211,60 @@ public interface IBuffer {
* If the buffer does not have an underlying resource or is read-only, this * If the buffer does not have an underlying resource or is read-only, this
* has no effect. * has no effect.
* <p> * <p>
* The <code>force</code> parameter controls how this method deals with * The {@code force} parameter controls how this method deals with
* cases where the workbench is not completely in sync with the local file system. * cases where the workbench is not completely in sync with the local file system.
* If <code>false</code> is specified, this method will only attempt * If {@code false} is specified, this method will only attempt
* to overwrite a corresponding file in the local file system provided * to overwrite a corresponding file in the local file system provided
* it is in sync with the workbench. This option ensures there is no * it is in sync with the workbench. This option ensures there is no
* unintended data loss; it is the recommended setting. * unintended data loss; it is the recommended setting.
* However, if <code>true</code> is specified, an attempt will be made * However, if {@code true} is specified, an attempt will be made
* to write a corresponding file in the local file system, * to write a corresponding file in the local file system,
* overwriting any existing one if need be. * overwriting any existing one if need be.
* In either case, if this method succeeds, the resource will be marked * In either case, if this method succeeds, the resource will be marked
* as being local (even if it wasn't before). * as being local (even if it wasn't before).
* <p> * <p>
* A <code>RuntimeException</code> might be thrown if the buffer is closed. * A {@code RuntimeException} might be thrown if the buffer is closed.
* *
* @param progress the progress monitor to notify * @param progress the progress monitor to notify
* @param force a <code> boolean </code> flag indicating how to deal with resource * @param force a {@code boolean} flag indicating how to deal with resource
* inconsistencies. * inconsistencies.
* *
* @exception CModelException if an error occurs writing the buffer to * @exception CModelException if an error occurs writing the buffer to
* the underlying resource * the underlying resource
* *
* @see org.eclipse.core.resources.IFile#setContents(java.io.InputStream, boolean, boolean, org.eclipse.core.runtime.IProgressMonitor) * @see org.eclipse.core.resources.IFile#setContents(java.io.InputStream, boolean, boolean, IProgressMonitor)
*/ */
public void save(IProgressMonitor progress, boolean force) throws CModelException; public void save(IProgressMonitor progress, boolean force) throws CModelException;
/** /**
* Sets the contents of this buffer to the given character array. * Sets the contents of this buffer to the given character array.
* This buffer will now have unsaved changes. * This buffer will now have unsaved changes.
* Any client can set the contents of the buffer, not just the owner of the buffer. * Any client can set the contents of the buffer, not just the owner of the buffer.
* Reports a buffer changed event. * Reports a buffer changed event.
* <p> * <p>
* Equivalent to <code>replace(0,getLength(),contents)</code>. * Equivalent to {@code replace(0, getLength(), contents)}.
* </p>
* <p> * <p>
* Has no effect if this buffer is read-only. * Has no effect if this buffer is read-only.
* <p> * <p>
* A <code>RuntimeException</code> might be thrown if the buffer is closed. * A {@code RuntimeException} might be thrown if the buffer is closed.
* *
* @param contents the new contents of this buffer as a character array * @param contents the new contents of this buffer as a character array
*/ */
public void setContents(char[] contents); public void setContents(char[] contents);
/** /**
* Sets the contents of this buffer to the given <code>String</code>. * Sets the contents of this buffer to the given {@code String}.
* This buffer will now have unsaved changes. * This buffer will now have unsaved changes.
* Any client can set the contents of the buffer, not just the owner of the buffer. * Any client can set the contents of the buffer, not just the owner of the buffer.
* Reports a buffer changed event. * Reports a buffer changed event.
* <p> * <p>
* Equivalent to <code>replace(0,getLength(),contents)</code>. * Equivalent to {@code replace(0, getLength(), contents)}.
* </p>
* <p> * <p>
* Has no effect if this buffer is read-only. * Has no effect if this buffer is read-only.
* <p> * <p>
* A <code>RuntimeException</code> might be thrown if the buffer is closed. * A {@code RuntimeException} might be thrown if the buffer is closed.
* *
* @param contents the new contents of this buffer as a <code>String</code> * @param contents the new contents of this buffer as a {@code String}
*/ */
public void setContents(String contents); public void setContents(String contents);
} }

View file

@ -373,18 +373,16 @@ public interface ICElement extends IAdaptable {
URI getLocationURI(); URI getLocationURI();
/** /**
* Returns the underlying resource that contains * Returns the underlying resource that contains this element, or {@code null} if this element
* this element, or {@code null} if this element is not contained * is not contained in a resource.
* in a resource.
* *
* @return the underlying resource, or {@code null} if none * @return the underlying resource, or {@code null} if none
*/ */
IResource getUnderlyingResource(); IResource getUnderlyingResource();
/** /**
* Returns the Corresponding resource for * Returns the corresponding resource for this element, or {@code null} if this element
* this element, or {@code null} if this element does not have * does not have a corresponding resource.
* a corresponding resource.
* *
* @return the corresponding resource, or {@code null} if none * @return the corresponding resource, or {@code null} if none
*/ */

View file

@ -48,7 +48,6 @@ import org.eclipse.core.resources.IResourceDelta;
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICElementDelta { public interface ICElementDelta {
/** /**
* Status constant indicating that the element has been added. * Status constant indicating that the element has been added.
*/ */

View file

@ -12,9 +12,7 @@ package org.eclipse.cdt.core.model;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
public interface IPathEntry { public interface IPathEntry {
/** /**
* Entry kind constant describing a path entry identifying a * Entry kind constant describing a path entry identifying a
* library. A library is an archive containing * library. A library is an archive containing
@ -104,5 +102,4 @@ public interface IPathEntry {
* @return IPath * @return IPath
*/ */
IPath getPath(); IPath getPath();
} }

View file

@ -8,7 +8,6 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.model; package org.eclipse.cdt.core.model;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
@ -25,5 +24,4 @@ public interface ISourceRoot extends ICContainer {
boolean isOnSourceEntry(IPath path); boolean isOnSourceEntry(IPath path);
boolean isOnSourceEntry(ICElement element); boolean isOnSourceEntry(ICElement element);
} }

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.settings.model; package org.eclipse.cdt.core.settings.model;
@ -16,25 +16,26 @@ import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICExclusionPatternPathEntry { public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICExclusionPatternPathEntry {
private final IPath[] exclusionPatterns;
private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$ private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$
/** calculated value, does not have to be final */
private final IPath[] exclusionPatterns;
/** Calculated value, does not have to be final */
char[][] fullCharExclusionPatterns = UNINIT_PATTERNS; char[][] fullCharExclusionPatterns = UNINIT_PATTERNS;
ACExclusionFilterEntry(IPath path, IPath exclusionPatterns[] , int flags) { ACExclusionFilterEntry(IPath path, IPath exclusionPatterns[] , int flags) {
super(path, flags); super(path, flags);
this.exclusionPatterns = exclusionPatterns != null ? (IPath[])exclusionPatterns.clone() : new IPath[0]; this.exclusionPatterns = exclusionPatterns != null ? (IPath[]) exclusionPatterns.clone() : new IPath[0];
} }
ACExclusionFilterEntry(IFolder rc, IPath exclusionPatterns[], int flags) { ACExclusionFilterEntry(IFolder rc, IPath exclusionPatterns[], int flags) {
super(rc, flags); super(rc, flags);
this.exclusionPatterns = exclusionPatterns != null ? (IPath[])exclusionPatterns.clone() : new IPath[0]; this.exclusionPatterns = exclusionPatterns != null ? (IPath[]) exclusionPatterns.clone() : new IPath[0];
} }
ACExclusionFilterEntry(String value, IPath exclusionPatterns[], int flags) { ACExclusionFilterEntry(String value, IPath exclusionPatterns[], int flags) {
super(value, flags); super(value, flags);
this.exclusionPatterns = exclusionPatterns != null ? (IPath[])exclusionPatterns.clone() : new IPath[0]; this.exclusionPatterns = exclusionPatterns != null ? (IPath[]) exclusionPatterns.clone() : new IPath[0];
} }
/** /**
@ -51,7 +52,7 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
*/ */
@Override @Override
public IPath[] getExclusionPatterns() { public IPath[] getExclusionPatterns() {
return exclusionPatterns.length != 0 ? (IPath[])exclusionPatterns.clone() : exclusionPatterns; return exclusionPatterns.length != 0 ? (IPath[]) exclusionPatterns.clone() : exclusionPatterns;
} }
/** /**
@ -63,7 +64,7 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
int length = this.exclusionPatterns.length; int length = this.exclusionPatterns.length;
this.fullCharExclusionPatterns = new char[length][]; this.fullCharExclusionPatterns = new char[length][];
IPath path = getFullPath(); IPath path = getFullPath();
if(path == null) if (path == null)
path = getLocation(); path = getLocation();
IPath prefixPath = path.removeTrailingSeparator(); IPath prefixPath = path.removeTrailingSeparator();
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
@ -98,7 +99,7 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
@Override @Override
public boolean equalsByContents(ICSettingEntry entry) { public boolean equalsByContents(ICSettingEntry entry) {
if(!super.equalsByContents(entry)) if (!super.equalsByContents(entry))
return false; return false;
ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)entry; ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)entry;
@ -108,12 +109,12 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
@Override @Override
protected String contentsToString() { protected String contentsToString() {
String result = super.contentsToString(); String result = super.contentsToString();
if(exclusionPatterns.length != 0){ if (exclusionPatterns.length != 0) {
StringBuffer buf = new StringBuffer(); StringBuilder buf = new StringBuilder();
buf.append(result); buf.append(result);
buf.append(" ; exclude: "); //$NON-NLS-1$ buf.append(" ; exclude: "); //$NON-NLS-1$
for(int i = 0; i < exclusionPatterns.length; i++){ for (int i = 0; i < exclusionPatterns.length; i++) {
if(i != 0) if (i != 0)
buf.append(", "); //$NON-NLS-1$ buf.append(", "); //$NON-NLS-1$
buf.append(exclusionPatterns[i].toString()); buf.append(exclusionPatterns[i].toString());
} }

View file

@ -12,6 +12,12 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementVisitor; import org.eclipse.cdt.core.model.ICElementVisitor;
@ -33,12 +39,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject; import org.eclipse.core.runtime.PlatformObject;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
public abstract class CElement extends PlatformObject implements ICElement { public abstract class CElement extends PlatformObject implements ICElement {
public static final char CEM_ESCAPE = '\\'; public static final char CEM_ESCAPE = '\\';
public static final char CEM_CPROJECT = '='; public static final char CEM_CPROJECT = '=';
@ -214,7 +214,8 @@ public abstract class CElement extends PlatformObject implements ICElement {
public ICModel getCModel () { public ICModel getCModel () {
ICElement current = this; ICElement current = this;
do { do {
if (current instanceof ICModel) return (ICModel) current; if (current instanceof ICModel)
return (ICModel) current;
} while ((current = current.getParent()) != null); } while ((current = current.getParent()) != null);
return null; return null;
} }
@ -234,14 +235,13 @@ public abstract class CElement extends PlatformObject implements ICElement {
@Override @Override
public IResource getUnderlyingResource() { public IResource getUnderlyingResource() {
IResource res = getResource(); ICElement current = this;
if (res == null) { do {
ICElement p = getParent(); IResource res = getResource();
if (p != null) { if (res != null)
res = p.getUnderlyingResource(); return res;
} } while ((current = current.getParent()) != null);
} return null;
return res;
} }
@Override @Override

View file

@ -20,8 +20,6 @@ import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICModel; import org.eclipse.cdt.core.model.ICModel;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.internal.core.util.MementoTokenizer; import org.eclipse.cdt.internal.core.util.MementoTokenizer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
@ -32,7 +30,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
public class CModel extends Openable implements ICModel { public class CModel extends Openable implements ICModel {
public CModel () { public CModel() {
this(ResourcesPlugin.getWorkspace().getRoot()); this(ResourcesPlugin.getWorkspace().getRoot());
} }
@ -56,9 +54,6 @@ public class CModel extends Openable implements ICModel {
return array; return array;
} }
/**
* ICModel#getCProject(String)
*/
@Override @Override
public ICProject getCProject(String name) { public ICProject getCProject(String name) {
IProject project = ((IWorkspaceRoot) getResource()).getProject(name); IProject project = ((IWorkspaceRoot) getResource()).getProject(name);
@ -66,24 +61,17 @@ public class CModel extends Openable implements ICModel {
} }
/** /**
* Returns the active C project associated with the specified * Returns the active C project associated with the specified resource,
* resource, or <code>null</code> if no C project yet exists * or {@code null} if no C project yet exists for the resource.
* for the resource.
* *
* @exception IllegalArgumentException if the given resource * @exception IllegalArgumentException if the given resource is not one of
* is not one of an IProject, IFolder, or IFile. * an IProject, IFolder, or IFile.
*/ */
public ICProject getCProject(IResource resource) { public ICProject getCProject(IResource resource) {
switch (resource.getType()) { IProject project = resource.getProject();
case IResource.FOLDER: if (project == null)
return new CProject(this, ((IFolder) resource).getProject());
case IResource.FILE:
return new CProject(this, ((IFile) resource).getProject());
case IResource.PROJECT:
return new CProject(this, (IProject) resource);
default:
throw new IllegalArgumentException("element.invalidResourceForProject"); //$NON-NLS-1$ throw new IllegalArgumentException("element.invalidResourceForProject"); //$NON-NLS-1$
} return new CProject(this, project);
} }
/** /**
@ -99,7 +87,7 @@ public class CModel extends Openable implements ICModel {
} }
} }
} catch (CModelException e) { } catch (CModelException e) {
// c model doesn't exist: cannot find any project // C model doesn't exist: cannot find any project.
} }
return null; return null;
} }
@ -111,7 +99,7 @@ public class CModel extends Openable implements ICModel {
@Override @Override
public void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings, public void copy(ICElement[] elements, ICElement[] containers, ICElement[] siblings,
String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException { String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException {
if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) { if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) {
runOperation(new CopyResourceElementsOperation(elements, containers, replace), elements, runOperation(new CopyResourceElementsOperation(elements, containers, replace), elements,
siblings, renamings, monitor); siblings, renamings, monitor);
@ -123,7 +111,7 @@ public class CModel extends Openable implements ICModel {
@Override @Override
public void delete(ICElement[] elements, boolean force, IProgressMonitor monitor) public void delete(ICElement[] elements, boolean force, IProgressMonitor monitor)
throws CModelException { throws CModelException {
CModelOperation op; CModelOperation op;
if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) { if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) {
op = new DeleteResourceElementsOperation(elements, force); op = new DeleteResourceElementsOperation(elements, force);
@ -135,7 +123,7 @@ public class CModel extends Openable implements ICModel {
@Override @Override
public void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings, public void move(ICElement[] elements, ICElement[] containers, ICElement[] siblings,
String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException { String[] renamings, boolean replace, IProgressMonitor monitor) throws CModelException {
if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) { if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) {
runOperation(new MoveResourceElementsOperation(elements, containers, replace), elements, runOperation(new MoveResourceElementsOperation(elements, containers, replace), elements,
siblings, renamings, monitor); siblings, renamings, monitor);
@ -147,7 +135,7 @@ public class CModel extends Openable implements ICModel {
@Override @Override
public void rename(ICElement[] elements, ICElement[] destinations, String[] renamings, public void rename(ICElement[] elements, ICElement[] destinations, String[] renamings,
boolean force, IProgressMonitor monitor) throws CModelException { boolean force, IProgressMonitor monitor) throws CModelException {
CModelOperation op; CModelOperation op;
if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) { if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) {
op = new RenameResourceElementsOperation(elements, destinations, renamings, force); op = new RenameResourceElementsOperation(elements, destinations, renamings, force);
@ -158,7 +146,7 @@ public class CModel extends Openable implements ICModel {
} }
/** /**
* Configures and runs the <code>MultiOperation</code>. * Configures and runs the {@link MultiOperation}.
*/ */
protected void runOperation(MultiOperation op, ICElement[] elements, ICElement[] siblings, protected void runOperation(MultiOperation op, ICElement[] elements, ICElement[] siblings,
String[] renamings, IProgressMonitor monitor) throws CModelException { String[] renamings, IProgressMonitor monitor) throws CModelException {
@ -216,7 +204,7 @@ public class CModel extends Openable implements ICModel {
} }
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException { protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
// determine my children // Determine my children.
IWorkspaceRoot root = (IWorkspaceRoot) getResource(); IWorkspaceRoot root = (IWorkspaceRoot) getResource();
IProject[] projects = root.getProjects(); IProject[] projects = root.getProjects();
for (IProject project : projects) { for (IProject project : projects) {
@ -233,12 +221,12 @@ public class CModel extends Openable implements ICModel {
public ICElement getHandleFromMemento(String token, MementoTokenizer memento) { public ICElement getHandleFromMemento(String token, MementoTokenizer memento) {
switch (token.charAt(0)) { switch (token.charAt(0)) {
case CEM_CPROJECT: case CEM_CPROJECT:
if (!memento.hasMoreTokens()) return this; if (!memento.hasMoreTokens())
return this;
String projectName = memento.nextToken(); String projectName = memento.nextToken();
CElement project = (CElement) getCProject(projectName); CElement project = (CElement) getCProject(projectName);
if (project != null) { if (project != null)
return project.getHandleFromMemento(memento); return project.getHandleFromMemento(memento);
}
} }
return null; return null;
} }

View file

@ -103,7 +103,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
*/ */
final CModel cModel = new CModel(); final CModel cModel = new CModel();
public static HashSet<String> OptionNames = new HashSet<String>(20); public static HashSet<String> OptionNames = new HashSet<>(20);
public static final int DEFAULT_CHANGE_EVENT = 0; // must not collide with ElementChangedEvent event masks public static final int DEFAULT_CHANGE_EVENT = 0; // must not collide with ElementChangedEvent event masks
@ -122,7 +122,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
* Queue of reconcile deltas on working copies that have yet to be fired. * Queue of reconcile deltas on working copies that have yet to be fired.
* This is a table form IWorkingCopy to ICElementDelta * This is a table form IWorkingCopy to ICElementDelta
*/ */
HashMap<IWorkingCopy, ICElementDelta> reconcileDeltas = new HashMap<IWorkingCopy, ICElementDelta>(); HashMap<IWorkingCopy, ICElementDelta> reconcileDeltas = new HashMap<>();
/** /**
* Turns delta firing on/off. By default it is on. * Turns delta firing on/off. By default it is on.
@ -137,16 +137,16 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
/** /**
* A map from ITranslationUnit to IWorkingCopy of the shared working copies. * A map from ITranslationUnit to IWorkingCopy of the shared working copies.
*/ */
private Map<IBufferFactory, Map<ITranslationUnit, WorkingCopy>> sharedWorkingCopies = new HashMap<IBufferFactory, Map<ITranslationUnit, WorkingCopy>>(); private Map<IBufferFactory, Map<ITranslationUnit, WorkingCopy>> sharedWorkingCopies = new HashMap<>();
/** /**
* Set of elements which are out of sync with their buffers. * Set of elements which are out of sync with their buffers.
*/ */
protected Map<ICElement, ICElement> elementsOutOfSynchWithBuffers = new HashMap<ICElement, ICElement>(11); protected Map<ICElement, ICElement> elementsOutOfSynchWithBuffers = new HashMap<>(11);
/* /*
* Temporary cache of newly opened elements * Temporary cache of newly opened elements
*/ */
private ThreadLocal<Map<ICElement, CElementInfo>> temporaryCache = new ThreadLocal<Map<ICElement, CElementInfo>>(); private ThreadLocal<Map<ICElement, CElementInfo>> temporaryCache = new ThreadLocal<>();
/** /**
* Infos cache. * Infos cache.
@ -161,7 +161,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
/** /**
* The list of started BinaryRunners on projects. * The list of started BinaryRunners on projects.
*/ */
private final Map<IProject, BinaryRunner> binaryRunners = new HashMap<IProject, BinaryRunner>(); private final Map<IProject, BinaryRunner> binaryRunners = new HashMap<>();
/** /**
* Map of the binary parser for each project. * Map of the binary parser for each project.
@ -172,7 +172,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
/** /**
* The list of the SourceMappers on projects. * The list of the SourceMappers on projects.
*/ */
private HashMap<ICProject, SourceMapper> sourceMappers = new HashMap<ICProject, SourceMapper>(); private HashMap<ICProject, SourceMapper> sourceMappers = new HashMap<>();
public static final IWorkingCopy[] NoWorkingCopy = {}; public static final IWorkingCopy[] NoWorkingCopy = {};
@ -244,8 +244,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
} }
} }
// In case this is an external resource see if we can find // In case this is an external resource see if we can find a file for it.
// a file for it.
if (res == null) { if (res == null) {
res= ResourceLookup.selectFileForLocation(path, null); res= ResourceLookup.selectFileForLocation(path, null);
} }
@ -261,13 +260,13 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
int type = resource.getType(); int type = resource.getType();
switch (type) { switch (type) {
case IResource.PROJECT: case IResource.PROJECT:
return create((IProject)resource); return create((IProject) resource);
case IResource.FILE: case IResource.FILE:
return create((IFile)resource, cproject); return create((IFile) resource, cproject);
case IResource.FOLDER: case IResource.FOLDER:
return create((IFolder)resource, cproject); return create((IFolder) resource, cproject);
case IResource.ROOT: case IResource.ROOT:
return getCModel((IWorkspaceRoot)resource); return getCModel((IWorkspaceRoot) resource);
default: default:
return null; return null;
} }
@ -291,9 +290,9 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
ICElement[] children = cproject.getChildren(); ICElement[] children = cproject.getChildren();
for (int i = 0; i < children.length; ++i) { for (int i = 0; i < children.length; ++i) {
if (children[i] instanceof ISourceRoot) { if (children[i] instanceof ISourceRoot) {
ISourceRoot root = (ISourceRoot)children[i]; ISourceRoot root = (ISourceRoot) children[i];
if (root.isOnSourceEntry(folder)) { if (root.isOnSourceEntry(folder)) {
// Get the container // Get the container.
IPath path = folder.getFullPath(); IPath path = folder.getFullPath();
path = path.removeFirstSegments(root.getPath().segmentCount()); path = path.removeFirstSegments(root.getPath().segmentCount());
String[] segments = path.segments(); String[] segments = path.segments();
@ -304,7 +303,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
return cfolder; return cfolder;
} }
} else if (children[i] instanceof ICContainer) { } else if (children[i] instanceof ICContainer) {
ICContainer root = (ICContainer)children[i]; ICContainer root = (ICContainer) children[i];
IPath rootPath = root.getPath(); IPath rootPath = root.getPath();
IPath path = folder.getFullPath(); IPath path = folder.getFullPath();
if (rootPath.isPrefixOf(path) && cproject.isOnOutputEntry(folder)) { if (rootPath.isPrefixOf(path) && cproject.isOnOutputEntry(folder)) {
@ -389,11 +388,11 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
cfolder = sourceRoot; cfolder = sourceRoot;
if (bin.getType() == IBinaryFile.ARCHIVE) { if (bin.getType() == IBinaryFile.ARCHIVE) {
ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer(); ArchiveContainer vlib = (ArchiveContainer) cproject.getArchiveContainer();
celement = new Archive(cfolder, file, (IBinaryArchive) bin); celement = new Archive(cfolder, file, (IBinaryArchive) bin);
vlib.addChild(celement); vlib.addChild(celement);
} else { } else {
BinaryContainer vbin = (BinaryContainer)cproject.getBinaryContainer(); BinaryContainer vbin = (BinaryContainer) cproject.getBinaryContainer();
celement = new Binary(cfolder, file, (IBinaryObject) bin); celement = new Binary(cfolder, file, (IBinaryObject) bin);
vbin.addChild(celement); vbin.addChild(celement);
} }
@ -473,7 +472,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
return null; return null;
} }
if(!locationURI.isAbsolute()) { if (!locationURI.isAbsolute()) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
@ -531,7 +530,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
// Remove from the containers. // Remove from the containers.
if (celement instanceof IParent) { if (celement instanceof IParent) {
CElementInfo info = (CElementInfo)peekAtInfo(celement); CElementInfo info = (CElementInfo) peekAtInfo(celement);
if (info != null) { if (info != null) {
ICElement[] children = info.getChildren(); ICElement[] children = info.getChildren();
for (ICElement element : children) { for (ICElement element : children) {
@ -543,7 +542,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
// For example the CProject needs to destroy the BinaryContainer and ArchiveContainer // For example the CProject needs to destroy the BinaryContainer and ArchiveContainer
if (celement instanceof CElement) { if (celement instanceof CElement) {
try { try {
((CElement)celement).closing(info); ((CElement) celement).closing(info);
} catch (CModelException e) { } catch (CModelException e) {
// //
} }
@ -553,8 +552,8 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
// BinaryContainer/ArchiveContainer also. // BinaryContainer/ArchiveContainer also.
if (celement.getElementType() == ICElement.C_CCONTAINER) { if (celement.getElementType() == ICElement.C_CCONTAINER) {
ICProject cproject = celement.getCProject(); ICProject cproject = celement.getCProject();
CProjectInfo pinfo = (CProjectInfo)peekAtInfo(cproject); CProjectInfo pinfo = (CProjectInfo) peekAtInfo(cproject);
ArrayList<ICElement> list = new ArrayList<ICElement>(5); ArrayList<ICElement> list = new ArrayList<>(5);
if (pinfo != null && pinfo.vBin != null) { if (pinfo != null && pinfo.vBin != null) {
if (peekAtInfo(pinfo.vBin) != null) { if (peekAtInfo(pinfo.vBin) != null) {
try { try {
@ -594,7 +593,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
} }
// Remove the child from the parent list. // Remove the child from the parent list.
//Parent parent = (Parent)celement.getParent(); //Parent parent = (Parent) celement.getParent();
//if (parent != null && peekAtInfo(parent) != null) { //if (parent != null && peekAtInfo(parent) != null) {
// parent.removeChild(celement); // parent.removeChild(celement);
//} //}
@ -611,7 +610,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
if (cfgDesc != null) { if (cfgDesc != null) {
ICConfigExtensionReference[] refs = cfgDesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID); ICConfigExtensionReference[] refs = cfgDesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
if (refs.length > 0) { if (refs.length > 0) {
ArrayList<BinaryParserConfig> list = new ArrayList<BinaryParserConfig>(refs.length); ArrayList<BinaryParserConfig> list = new ArrayList<>(refs.length);
for (ICConfigExtensionReference ref : refs) { for (ICConfigExtensionReference ref : refs) {
BinaryParserConfig config = new BinaryParserConfig(ref); BinaryParserConfig config = new BinaryParserConfig(ref);
list.add(config); list.add(config);
@ -685,7 +684,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
// PR:xxx the EFS does not seem to work for newly created file // PR:xxx the EFS does not seem to work for newly created file
// so before bailing out give another try? // so before bailing out give another try?
// Avoid name special devices, empty files and the like // Avoid name special devices, empty files and the like
if("file".equals(fileUri.getScheme())) { //$NON-NLS-1$ if ("file".equals(fileUri.getScheme())) { //$NON-NLS-1$
File f = new File(fileUri); File f = new File(fileUri);
if (f.length() == 0) { if (f.length() == 0) {
return null; return null;
@ -724,9 +723,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
System.arraycopy(bytes, 0, array, 0, count); System.arraycopy(bytes, 0, array, 0, count);
bytes = array; bytes = array;
} }
} catch (CoreException e) { } catch (CoreException | IOException e) {
return null;
} catch (IOException e) {
return null; return null;
} finally { } finally {
if (is != null) { if (is != null) {
@ -750,8 +747,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
return binFile; return binFile;
} }
} }
} catch (IOException e) { } catch (IOException | CoreException e) {
} catch (CoreException e) {
} }
} }
return null; return null;
@ -880,8 +876,8 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
case IResourceChangeEvent.PRE_DELETE: case IResourceChangeEvent.PRE_DELETE:
try { try {
if (resource.getType() == IResource.PROJECT && if (resource.getType() == IResource.PROJECT &&
( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) || (((IProject) resource).hasNature(CProjectNature.C_NATURE_ID) ||
((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){ ((IProject) resource).hasNature(CCProjectNature.CC_NATURE_ID))) {
this.preDeleteProject((IProject) resource);} this.preDeleteProject((IProject) resource);}
} catch (CoreException e) { } catch (CoreException e) {
} }
@ -890,8 +886,8 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
case IResourceChangeEvent.PRE_CLOSE: case IResourceChangeEvent.PRE_CLOSE:
try { try {
if (resource.getType() == IResource.PROJECT && if (resource.getType() == IResource.PROJECT &&
( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) || (((IProject) resource).hasNature(CProjectNature.C_NATURE_ID) ||
((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){ ((IProject) resource).hasNature(CCProjectNature.CC_NATURE_ID))) {
this.preCloseProject((IProject) resource);} this.preCloseProject((IProject) resource);}
} catch (CoreException e) { } catch (CoreException e) {
} }
@ -902,7 +898,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
if (delta != null) { if (delta != null) {
checkForProjectRename(delta); checkForProjectRename(delta);
ICElementDelta[] translatedDeltas = fDeltaProcessor.processResourceDelta(delta); ICElementDelta[] translatedDeltas = fDeltaProcessor.processResourceDelta(delta);
if (translatedDeltas.length > 0) { if (translatedDeltas.length != 0) {
for (ICElementDelta translatedDelta : translatedDeltas) { for (ICElementDelta translatedDelta : translatedDeltas) {
registerCModelDelta(translatedDelta); registerCModelDelta(translatedDelta);
} }
@ -919,18 +915,18 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
@Override @Override
public void handleEvent(CProjectDescriptionEvent event) { public void handleEvent(CProjectDescriptionEvent event) {
switch(event.getEventType()) { switch (event.getEventType()) {
case CProjectDescriptionEvent.APPLIED: case CProjectDescriptionEvent.APPLIED:
CProjectDescription newDes = (CProjectDescription)event.getNewCProjectDescription(); CProjectDescription newDes = (CProjectDescription) event.getNewCProjectDescription();
CProjectDescription oldDes = (CProjectDescription)event.getOldCProjectDescription(); CProjectDescription oldDes = (CProjectDescription) event.getOldCProjectDescription();
if(oldDes != null && newDes != null) { if (oldDes != null && newDes != null) {
ICConfigurationDescription newCfg = newDes.getDefaultSettingConfiguration(); ICConfigurationDescription newCfg = newDes.getDefaultSettingConfiguration();
ICConfigurationDescription oldCfg = oldDes.getDefaultSettingConfiguration(); ICConfigurationDescription oldCfg = oldDes.getDefaultSettingConfiguration();
int flags = 0; int flags = 0;
if(oldCfg != null && newCfg != null){ if (oldCfg != null && newCfg != null) {
if(newCfg.getId().equals(oldCfg.getId())){ if (newCfg.getId().equals(oldCfg.getId())) {
ICDescriptionDelta cfgDelta = findCfgDelta(event.getProjectDelta(), newCfg.getId()); ICDescriptionDelta cfgDelta = findCfgDelta(event.getProjectDelta(), newCfg.getId());
if(cfgDelta != null){ if (cfgDelta != null) {
flags = cfgDelta.getChangeFlags() & (ICDescriptionDelta.EXT_REF | ICDescriptionDelta.OWNER); flags = cfgDelta.getChangeFlags() & (ICDescriptionDelta.EXT_REF | ICDescriptionDelta.OWNER);
} }
} else { } else {
@ -965,13 +961,13 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
} }
} }
private ICDescriptionDelta findCfgDelta(ICDescriptionDelta delta, String id){ private ICDescriptionDelta findCfgDelta(ICDescriptionDelta delta, String id) {
if(delta == null) if (delta == null)
return null; return null;
ICDescriptionDelta children[] = delta.getChildren(); ICDescriptionDelta children[] = delta.getChildren();
for(int i = 0; i < children.length; i++){ for (int i = 0; i < children.length; i++) {
ICSettingObject s = children[i].getNewSetting(); ICSettingObject s = children[i].getNewSetting();
if(s != null && id.equals(s.getId())) if (s != null && id.equals(s.getId()))
return children[i]; return children[i];
} }
return null; return null;
@ -979,7 +975,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
@Override @Override
public void contentTypeChanged(ContentTypeChangeEvent event) { public void contentTypeChanged(ContentTypeChangeEvent event) {
ContentTypeProcessor.processContentTypeChanges(new ContentTypeChangeEvent[]{ event }); ContentTypeProcessor.processContentTypeChanges(new ContentTypeChangeEvent[] { event });
} }
public void contentTypeChanged(ContentTypeChangeEvent[] events) { public void contentTypeChanged(ContentTypeChangeEvent[] events) {
@ -1020,7 +1016,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
protected IStatus run(IProgressMonitor monitor) { protected IStatus run(IProgressMonitor monitor) {
try { try {
fire(delta, ElementChangedEvent.POST_CHANGE); fire(delta, ElementChangedEvent.POST_CHANGE);
} catch (Exception e){ } catch (Exception e) {
CCorePlugin.log(e); CCorePlugin.log(e);
} }
return Status.OK_STATUS; return Status.OK_STATUS;
@ -1123,7 +1119,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
} }
if (deltaToNotify != null) { if (deltaToNotify != null) {
// Flush now so as to keep listener reactions to post their own deltas for subsequent iteration // Flush now so as to keep listener reactions to post their own deltas for subsequent iteration
this.reconcileDeltas = new HashMap<IWorkingCopy, ICElementDelta>(); this.reconcileDeltas = new HashMap<>();
notifyListeners(deltaToNotify, ElementChangedEvent.POST_RECONCILE, listeners, listenerMask, listenerCount); notifyListeners(deltaToNotify, ElementChangedEvent.POST_RECONCILE, listeners, listenerMask, listenerCount);
} }
} }
@ -1197,7 +1193,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
ICElement element = delta.getElement(); ICElement element = delta.getElement();
if (cRoot.equals(element)) { if (cRoot.equals(element)) {
for (ICElementDelta child : delta.getAffectedChildren()) { for (ICElementDelta child : delta.getAffectedChildren()) {
CElementDelta projectDelta = (CElementDelta)child; CElementDelta projectDelta = (CElementDelta) child;
rootDelta.insertDeltaTree(projectDelta.getElement(), projectDelta); rootDelta.insertDeltaTree(projectDelta.getElement(), projectDelta);
insertedTree = true; insertedTree = true;
} }
@ -1209,7 +1205,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
} }
} }
} else { } else {
rootDelta.insertDeltaTree(element, (CElementDelta)delta); rootDelta.insertDeltaTree(element, (CElementDelta) delta);
insertedTree = true; insertedTree = true;
} }
} }
@ -1263,12 +1259,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
* its ancestors). So returns without updating the cache. * its ancestors). So returns without updating the cache.
*/ */
protected synchronized void putInfos(ICElement openedElement, Map<ICElement, CElementInfo> newElements) { protected synchronized void putInfos(ICElement openedElement, Map<ICElement, CElementInfo> newElements) {
// remove children // Remove children.
Object existingInfo = this.cache.peekAtInfo(openedElement); Object existingInfo = this.cache.peekAtInfo(openedElement);
if (openedElement instanceof IParent && existingInfo instanceof CElementInfo) { if (openedElement instanceof IParent && existingInfo instanceof CElementInfo) {
ICElement[] children = ((CElementInfo)existingInfo).getChildren(); ICElement[] children = ((CElementInfo) existingInfo).getChildren();
for (int i = 0, size = children.length; i < size; ++i) { for (int i = 0, size = children.length; i < size; ++i) {
CElement child = (CElement)children[i]; CElement child = (CElement) children[i];
try { try {
child.close(); child.close();
} catch (CModelException e) { } catch (CModelException e) {
@ -1287,7 +1283,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
* but does not close this element. * but does not close this element.
*/ */
protected synchronized void removeChildrenInfo(ICElement openedElement) { protected synchronized void removeChildrenInfo(ICElement openedElement) {
// remove children // Remove children.
Object existingInfo = this.cache.peekAtInfo(openedElement); Object existingInfo = this.cache.peekAtInfo(openedElement);
if (openedElement instanceof IParent && existingInfo instanceof CElementInfo) { if (openedElement instanceof IParent && existingInfo instanceof CElementInfo) {
ICElement[] children = ((CElementInfo) existingInfo).getChildren(); ICElement[] children = ((CElementInfo) existingInfo).getChildren();
@ -1316,7 +1312,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
public Map<ICElement, CElementInfo> getTemporaryCache() { public Map<ICElement, CElementInfo> getTemporaryCache() {
Map<ICElement, CElementInfo> result = this.temporaryCache.get(); Map<ICElement, CElementInfo> result = this.temporaryCache.get();
if (result == null) { if (result == null) {
result = new HashMap<ICElement, CElementInfo>(); result = new HashMap<>();
this.temporaryCache.set(result); this.temporaryCache.set(result);
} }
return result; return result;
@ -1382,25 +1378,25 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
} }
private void preDeleteProject(IProject project) { private void preDeleteProject(IProject project) {
// remove binary parsers // Remove binary parsers
binaryParsersMap.remove(project); binaryParsersMap.remove(project);
// stop the binary runner for this project // Stop the binary runner for this project
removeBinaryRunner(project); removeBinaryRunner(project);
// stop indexing jobs for this project // Stop indexing jobs for this project
CCoreInternals.getPDOMManager().preDeleteProject(create(project)); CCoreInternals.getPDOMManager().preDeleteProject(create(project));
} }
private void preCloseProject(IProject project) { private void preCloseProject(IProject project) {
// remove binary parsers // Remove binary parsers
binaryParsersMap.remove(project); binaryParsersMap.remove(project);
// stop the binary runner for this project // Stop the binary runner for this project
removeBinaryRunner(project); removeBinaryRunner(project);
// stop indexing jobs for this project // Stop indexing jobs for this project
CCoreInternals.getPDOMManager().preCloseProject(create(project)); CCoreInternals.getPDOMManager().preCloseProject(create(project));
} }
public IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) { public IWorkingCopy[] getSharedWorkingCopies(IBufferFactory factory) {
// if factory is null, default factory must be used // If factory is null, default factory must be used.
if (factory == null) if (factory == null)
factory = BufferManager.getDefaultBufferManager().getDefaultBufferFactory(); factory = BufferManager.getDefaultBufferManager().getDefaultBufferFactory();
@ -1431,7 +1427,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
Map<ITranslationUnit, WorkingCopy> perFactoryWorkingCopies = sharedWorkingCopies.get(factory); Map<ITranslationUnit, WorkingCopy> perFactoryWorkingCopies = sharedWorkingCopies.get(factory);
if (perFactoryWorkingCopies == null) { if (perFactoryWorkingCopies == null) {
perFactoryWorkingCopies = new HashMap<ITranslationUnit, WorkingCopy>(); perFactoryWorkingCopies = new HashMap<>();
sharedWorkingCopies.put(factory, perFactoryWorkingCopies); sharedWorkingCopies.put(factory, perFactoryWorkingCopies);
} }
WorkingCopy workingCopy = perFactoryWorkingCopies.get(tu); WorkingCopy workingCopy = perFactoryWorkingCopies.get(tu);
@ -1439,8 +1435,8 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
workingCopy.useCount++; workingCopy.useCount++;
return workingCopy; return workingCopy;
} }
CreateWorkingCopyOperation op = new CreateWorkingCopyOperation(tu, perFactoryWorkingCopies, CreateWorkingCopyOperation op =
factory, requestor); new CreateWorkingCopyOperation(tu, perFactoryWorkingCopies, factory, requestor);
op.runOperation(monitor); op.runOperation(monitor);
return (IWorkingCopy) op.getResultElements()[0]; return (IWorkingCopy) op.getResultElements()[0];
} }

View file

@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.model;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -160,21 +161,21 @@ public class CProject extends Openable implements ICProject {
@Override @Override
public IIncludeReference[] getIncludeReferences() throws CModelException { public IIncludeReference[] getIncludeReferences() throws CModelException {
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this); CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this);
IIncludeReference[] incRefs = null; IIncludeReference[] incRefs = null;
if (pinfo != null) { if (pinfo != null) {
incRefs = pinfo.incReferences; incRefs = pinfo.incReferences;
} }
if (incRefs == null) { if (incRefs == null) {
IPathEntry[] entries = getResolvedPathEntries(); IPathEntry[] entries = getResolvedPathEntries();
ArrayList<IncludeReference> list = new ArrayList<IncludeReference>(entries.length); ArrayList<IncludeReference> list = new ArrayList<>(entries.length);
for (IPathEntry entrie : entries) { for (IPathEntry entrie : entries) {
if (entrie.getEntryKind() == IPathEntry.CDT_INCLUDE) { if (entrie.getEntryKind() == IPathEntry.CDT_INCLUDE) {
IIncludeEntry entry = (IIncludeEntry) entrie; IIncludeEntry entry = (IIncludeEntry) entrie;
list.add(new IncludeReference(this, entry)); list.add(new IncludeReference(this, entry));
} }
} }
incRefs = list.toArray(new IIncludeReference[0]); incRefs = list.toArray(new IIncludeReference[list.size()]);
if (pinfo != null) { if (pinfo != null) {
pinfo.incReferences = incRefs; pinfo.incReferences = incRefs;
} }
@ -184,7 +185,7 @@ public class CProject extends Openable implements ICProject {
@Override @Override
public ILibraryReference[] getLibraryReferences() throws CModelException { public ILibraryReference[] getLibraryReferences() throws CModelException {
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this); CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this);
ILibraryReference[] libRefs = null; ILibraryReference[] libRefs = null;
if (pinfo != null) { if (pinfo != null) {
libRefs = pinfo.libReferences; libRefs = pinfo.libReferences;
@ -193,7 +194,7 @@ public class CProject extends Openable implements ICProject {
if (libRefs == null) { if (libRefs == null) {
BinaryParserConfig[] binConfigs = CModelManager.getDefault().getBinaryParser(getProject()); BinaryParserConfig[] binConfigs = CModelManager.getDefault().getBinaryParser(getProject());
IPathEntry[] entries = getResolvedPathEntries(); IPathEntry[] entries = getResolvedPathEntries();
ArrayList<ILibraryReference> list = new ArrayList<ILibraryReference>(entries.length); ArrayList<ILibraryReference> list = new ArrayList<>(entries.length);
for (IPathEntry entrie : entries) { for (IPathEntry entrie : entries) {
if (entrie.getEntryKind() == IPathEntry.CDT_LIBRARY) { if (entrie.getEntryKind() == IPathEntry.CDT_LIBRARY) {
ILibraryEntry entry = (ILibraryEntry) entrie; ILibraryEntry entry = (ILibraryEntry) entrie;
@ -203,7 +204,7 @@ public class CProject extends Openable implements ICProject {
} }
} }
} }
libRefs = list.toArray(new ILibraryReference[0]); libRefs = list.toArray(new ILibraryReference[list.size()]);
if (pinfo != null) { if (pinfo != null) {
pinfo.libReferences = libRefs; pinfo.libReferences = libRefs;
} }
@ -224,14 +225,13 @@ public class CProject extends Openable implements ICProject {
bin = parser.getBinary(entry.getFullLibraryPath()); bin = parser.getBinary(entry.getFullLibraryPath());
if (bin != null) { if (bin != null) {
if (bin.getType() == IBinaryFile.ARCHIVE) { if (bin.getType() == IBinaryFile.ARCHIVE) {
lib = new LibraryReferenceArchive(cproject, entry, (IBinaryArchive)bin); lib = new LibraryReferenceArchive(cproject, entry, (IBinaryArchive) bin);
} else if (bin instanceof IBinaryObject){ } else if (bin instanceof IBinaryObject) {
lib = new LibraryReferenceShared(cproject, entry, (IBinaryObject)bin); lib = new LibraryReferenceShared(cproject, entry, (IBinaryObject) bin);
} }
break; break;
} }
} catch (IOException e) { } catch (IOException | CoreException e) {
} catch (CoreException e) {
} }
} }
} }
@ -289,7 +289,7 @@ public class CProject extends Openable implements ICProject {
String[] propertyNames= preferences.keys(); String[] propertyNames= preferences.keys();
for (String propertyName : propertyNames) { for (String propertyName : propertyNames) {
String value= preferences.get(propertyName, null); String value= preferences.get(propertyName, null);
if (value != null && optionNames.contains(propertyName)){ if (value != null && optionNames.contains(propertyName)) {
options.put(propertyName, value.trim()); options.put(propertyName, value.trim());
} }
} }
@ -466,7 +466,7 @@ public class CProject extends Openable implements ICProject {
@Override @Override
public ISourceRoot[] getSourceRoots() throws CModelException { public ISourceRoot[] getSourceRoots() throws CModelException {
Object[] children = getChildren(); Object[] children = getChildren();
ArrayList<ISourceRoot> result = new ArrayList<ISourceRoot>(children.length); ArrayList<ISourceRoot> result = new ArrayList<>(children.length);
for (Object element : children) { for (Object element : children) {
if (element instanceof ISourceRoot) { if (element instanceof ISourceRoot) {
result.add((ISourceRoot) element); result.add((ISourceRoot) element);
@ -483,7 +483,7 @@ public class CProject extends Openable implements ICProject {
*/ */
@Override @Override
public ISourceRoot[] getAllSourceRoots() throws CModelException { public ISourceRoot[] getAllSourceRoots() throws CModelException {
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this); CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this);
ISourceRoot[] roots = null; ISourceRoot[] roots = null;
if (pinfo != null) { if (pinfo != null) {
if (pinfo.sourceRoots != null) { if (pinfo.sourceRoots != null) {
@ -518,7 +518,7 @@ public class CProject extends Openable implements ICProject {
} }
public IOutputEntry[] getOutputEntries(IPathEntry[] entries) throws CModelException { public IOutputEntry[] getOutputEntries(IPathEntry[] entries) throws CModelException {
ArrayList<IPathEntry> list = new ArrayList<IPathEntry>(entries.length); ArrayList<IPathEntry> list = new ArrayList<>(entries.length);
for (IPathEntry entrie : entries) { for (IPathEntry entrie : entries) {
if (entrie.getEntryKind() == IPathEntry .CDT_OUTPUT) { if (entrie.getEntryKind() == IPathEntry .CDT_OUTPUT) {
list.add(entrie); list.add(entrie);
@ -583,14 +583,14 @@ public class CProject extends Openable implements ICProject {
//IPathEntry[] entries = getResolvedPathEntries(); //IPathEntry[] entries = getResolvedPathEntries();
ICSourceEntry[] entries = null; ICSourceEntry[] entries = null;
ICProjectDescription des = CProjectDescriptionManager.getInstance().getProjectDescription(getProject(), false); ICProjectDescription des = CProjectDescriptionManager.getInstance().getProjectDescription(getProject(), false);
if(des != null){ if (des != null) {
ICConfigurationDescription cfg = des.getDefaultSettingConfiguration(); ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
if(cfg != null) if (cfg != null)
entries = cfg.getResolvedSourceEntries(); entries = cfg.getResolvedSourceEntries();
} }
if(entries != null){ if (entries != null) {
ArrayList<ISourceRoot> list = new ArrayList<ISourceRoot>(entries.length); ArrayList<ISourceRoot> list = new ArrayList<>(entries.length);
for (ICSourceEntry sourceEntry : entries) { for (ICSourceEntry sourceEntry : entries) {
ISourceRoot root = getSourceRoot(sourceEntry); ISourceRoot root = getSourceRoot(sourceEntry);
if (root != null) { if (root != null) {
@ -599,7 +599,7 @@ public class CProject extends Openable implements ICProject {
} }
return list; return list;
} }
return new ArrayList<ISourceRoot>(0); return Collections.emptyList();
} }
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException { protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
@ -712,7 +712,7 @@ public class CProject extends Openable implements ICProject {
*/ */
public void resetCaches() { public void resetCaches() {
CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this); CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this);
if (pinfo != null){ if (pinfo != null) {
pinfo.resetCaches(); pinfo.resetCaches();
} }
} }
@ -736,7 +736,7 @@ public class CProject extends Openable implements ICProject {
if (!rootPath.isAbsolute()) { if (!rootPath.isAbsolute()) {
rootPath= getProject().getFullPath().append(rootPath); rootPath= getProject().getFullPath().append(rootPath);
} }
CElement root = (CElement)findSourceRoot(rootPath); CElement root = (CElement) findSourceRoot(rootPath);
if (root != null) { if (root != null) {
if (token != null) { if (token != null) {
return root.getHandleFromMemento(token, memento); return root.getHandleFromMemento(token, memento);

View file

@ -38,7 +38,6 @@ import org.eclipse.core.runtime.IPath;
* (e.g. closing them or updating binary containers). * (e.g. closing them or updating binary containers).
*/ */
final class DeltaProcessor { final class DeltaProcessor {
/** /**
* The <code>CElementDelta</code> corresponding to the <code>IResourceDelta</code> being translated. * The <code>CElementDelta</code> corresponding to the <code>IResourceDelta</code> being translated.
*/ */
@ -47,7 +46,7 @@ final class DeltaProcessor {
static final ICElementDelta[] NO_DELTA = new ICElementDelta[0]; static final ICElementDelta[] NO_DELTA = new ICElementDelta[0];
// Hold on the element being renamed. // Hold on the element being renamed.
private ICElement movedFromElement = null; private ICElement movedFromElement;
/** /**
* Creates the create corresponding to this resource. * Creates the create corresponding to this resource.
@ -148,7 +147,7 @@ final class DeltaProcessor {
Openable parent = (Openable) child.getParent(); Openable parent = (Openable) child.getParent();
if (parent != null && parent.isOpen()) { if (parent != null && parent.isOpen()) {
CElementInfo info = parent.getElementInfo(); CElementInfo info = parent.getElementInfo();
// Check if the element exits // Check if the element exists.
if (!info.includesChild(child)) { if (!info.includesChild(child)) {
info.addChild(child); info.addChild(child);
} }
@ -166,7 +165,7 @@ final class DeltaProcessor {
// Remove the child from the parent list. // Remove the child from the parent list.
ICElement parent = child.getParent(); ICElement parent = child.getParent();
if (parent != null && parent instanceof Parent && factory.peekAtInfo(parent) != null) { if (parent != null && parent instanceof Parent && factory.peekAtInfo(parent) != null) {
((Parent)parent).removeChild(child); ((Parent) parent).removeChild(child);
} }
} }
@ -457,7 +456,7 @@ final class DeltaProcessor {
if (parent != null) if (parent != null)
nonCResourcesChanged(parent, delta); nonCResourcesChanged(parent, delta);
} else if (current instanceof ICProject) { } else if (current instanceof ICProject) {
ICProject cprj = (ICProject)current; ICProject cprj = (ICProject) current;
CModel cModel = CModelManager.getDefault().getCModel(); CModel cModel = CModelManager.getDefault().getCModel();
if (!cprj.getProject().isOpen() || cModel.findCProject(cprj.getProject()) == null) { if (!cprj.getProject().isOpen() || cModel.findCProject(cprj.getProject()) == null) {
nonCResourcesChanged(parent, delta); nonCResourcesChanged(parent, delta);

View file

@ -31,25 +31,23 @@ public class DestroyWorkingCopyOperation extends CModelOperation {
*/ */
@Override @Override
protected void executeOperation() throws CModelException { protected void executeOperation() throws CModelException {
WorkingCopy workingCopy = getWorkingCopy(); WorkingCopy workingCopy = getWorkingCopy();
workingCopy.close(); workingCopy.close();
// if original element is not on classpath flush it from the cache // If original element is not on classpath flush it from the cache.
ITranslationUnit originalElement = workingCopy.getOriginalElement(); ITranslationUnit originalElement = workingCopy.getOriginalElement();
if (!workingCopy.getParent().exists()) { if (!workingCopy.getParent().exists()) {
originalElement.close(); originalElement.close();
} }
// remove working copy from the cache if it is shared // Remove working copy from the cache if it is shared.
IWorkingCopy wc = CModelManager.getDefault().removeSharedWorkingCopy(workingCopy.bufferFactory, originalElement); IWorkingCopy wc = CModelManager.getDefault().removeSharedWorkingCopy(workingCopy.bufferFactory, originalElement);
if (wc != null) { if (wc != null) {
//System.out.println("Destroying shared working copy " + workingCopy.toStringWithAncestors());//$NON-NLS-1$ //System.out.println("Destroying shared working copy " + workingCopy.toStringWithAncestors());//$NON-NLS-1$
//CModelManager.getDefault().fire(delta, ElementChangedEvent.POST_RECONCILE); //CModelManager.getDefault().fire(delta, ElementChangedEvent.POST_RECONCILE);
} }
// Report C deltas
// report C deltas
CElementDelta delta = new CElementDelta(this.getCModel()); CElementDelta delta = new CElementDelta(this.getCModel());
delta.removed(workingCopy); delta.removed(workingCopy);
addDelta(delta); addDelta(delta);

View file

@ -1320,7 +1320,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
try { try {
IMarker[] markers = project.findMarkers(ICModelMarker.PATHENTRY_PROBLEM_MARKER, false, IResource.DEPTH_ZERO); IMarker[] markers = project.findMarkers(ICModelMarker.PATHENTRY_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
if (markers != null && markers.length > 0) { if (markers != null && markers.length > 0) {
ArrayList<ICModelStatus> problemList = new ArrayList<ICModelStatus>(); ArrayList<ICModelStatus> problemList = new ArrayList<>();
for (IPathEntry entry : entries) { for (IPathEntry entry : entries) {
ICModelStatus status = PathEntryUtil.validatePathEntry(project2, entry, true, false); ICModelStatus status = PathEntryUtil.validatePathEntry(project2, entry, true, false);
if (!status.isOK()) { if (!status.isOK()) {
@ -1349,7 +1349,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
int type = element.getElementType(); int type = element.getElementType();
// Handle open, closing and removing of projects // Handle open, closing and removing of projects
if ( type == ICElement.C_PROJECT) { if (type == ICElement.C_PROJECT) {
ICProject cproject = (ICProject)element; ICProject cproject = (ICProject)element;
if ((kind == ICElementDelta.REMOVED || kind == ICElementDelta.ADDED)) { if ((kind == ICElementDelta.REMOVED || kind == ICElementDelta.ADDED)) {
if (kind == ICElementDelta.REMOVED) { if (kind == ICElementDelta.REMOVED) {

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Intel Corporation - Initial API and implementation * Intel Corporation - Initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
@ -31,26 +31,21 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
private List<IPathEntryStoreListener> fListeners; private List<IPathEntryStoreListener> fListeners;
private IPathEntryStore fStore; private IPathEntryStore fStore;
public PathEntryStoreProxy(IProject project){ public PathEntryStoreProxy(IProject project) {
super(project, PathEntryManager.PATHENTRY_STORE_UNIQ_ID); super(project, PathEntryManager.PATHENTRY_STORE_UNIQ_ID);
fListeners = Collections.synchronizedList(new ArrayList<IPathEntryStoreListener>()); fListeners = Collections.synchronizedList(new ArrayList<IPathEntryStoreListener>());
} }
public IPathEntryStore getStore(){ public IPathEntryStore getStore() {
providerRequested(); providerRequested();
return fStore; return fStore;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.resources.IPathEntryStore#addPathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
*/
@Override @Override
public void addPathEntryStoreListener(IPathEntryStoreListener listener) { public void addPathEntryStoreListener(IPathEntryStoreListener listener) {
fListeners.add(listener); fListeners.add(listener);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
*/
@Override @Override
public void removePathEntryStoreListener(IPathEntryStoreListener listener) { public void removePathEntryStoreListener(IPathEntryStoreListener listener) {
fListeners.remove(listener); fListeners.remove(listener);
@ -61,7 +56,7 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
notifyListeners(evt); notifyListeners(evt);
} }
private void notifyListeners(PathEntryStoreChangedEvent evt){ private void notifyListeners(PathEntryStoreChangedEvent evt) {
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()]; IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()];
fListeners.toArray(observers); fListeners.toArray(observers);
for (int i = 0; i < observers.length; i++) { for (int i = 0; i < observers.length; i++) {
@ -69,9 +64,6 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.resources.IPathEntryStore#fireClosedChangedEvent(IProject)
*/
@Override @Override
public void close() { public void close() {
super.close(); super.close();
@ -89,8 +81,8 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
} }
@Override @Override
@Deprecated
public ICExtensionReference getExtensionReference() { public ICExtensionReference getExtensionReference() {
//TODO: calculate
return null; return null;
} }
@ -109,7 +101,6 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
public void setRawPathEntries(IPathEntry[] entries) throws CoreException { public void setRawPathEntries(IPathEntry[] entries) throws CoreException {
providerRequested(); providerRequested();
fStore.setRawPathEntries(entries); fStore.setRawPathEntries(entries);
} }
@Override @Override
@ -118,9 +109,8 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
} }
@Override @Override
protected Object createDefaultProvider(ICConfigurationDescription cfgDes, protected Object createDefaultProvider(ICConfigurationDescription cfgDes, boolean newStile) {
boolean newStile) { if (newStile) {
if(newStile){
return new ConfigBasedPathEntryStore(getProject()); return new ConfigBasedPathEntryStore(getProject());
} }
return new DefaultPathEntryStore(getProject()); return new DefaultPathEntryStore(getProject());
@ -146,9 +136,8 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
} }
@Override @Override
protected void postProcessProviderChange(Object newProvider, protected void postProcessProviderChange(Object newProvider, Object oldProvider) {
Object oldProvider) { // if (oldProvider != null)
// if(oldProvider != null)
fireContentChangedEvent(getProject()); fireContentChangedEvent(getProject());
} }
@ -156,10 +145,9 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
protected boolean doHandleEvent(CProjectDescriptionEvent event) { protected boolean doHandleEvent(CProjectDescriptionEvent event) {
IPathEntryStore oldStore = fStore; IPathEntryStore oldStore = fStore;
boolean result = super.doHandleEvent(event); boolean result = super.doHandleEvent(event);
if(!result) if (!result)
postProcessProviderChange(fStore, oldStore); postProcessProviderChange(fStore, oldStore);
return result; return result;
} }
} }

View file

@ -38,7 +38,6 @@ import org.eclipse.cdt.core.model.IPathEntryContainer;
import org.eclipse.cdt.core.model.IProjectEntry; import org.eclipse.cdt.core.model.IProjectEntry;
import org.eclipse.cdt.core.model.ISourceEntry; import org.eclipse.cdt.core.model.ISourceEntry;
import org.eclipse.cdt.core.resources.IPathEntryVariableManager; import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
import org.eclipse.cdt.utils.UNCPathConverter;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;

View file

@ -37,13 +37,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
*/ */
public class SourceManipulation extends Parent implements ISourceManipulation, ISourceReference { public class SourceManipulation extends Parent implements ISourceManipulation, ISourceReference {
/** /**
* An empty list of Strings * An empty array of Strings
*/ */
protected static final String[] fgEmptyStrings = {}; protected static final String[] fgEmptyStrings = {};
private boolean fIsActive= true; private boolean fIsActive= true;
private short fIndex= 0; private short fIndex;
public SourceManipulation(ICElement parent, String name, int type) { public SourceManipulation(ICElement parent, String name, int type) {
super(parent, name, type); super(parent, name, type);
@ -54,7 +53,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
*/ */
@Override @Override
public void copy(ICElement container, ICElement sibling, String rename, boolean force, public void copy(ICElement container, ICElement sibling, String rename, boolean force,
IProgressMonitor monitor) throws CModelException { IProgressMonitor monitor) throws CModelException {
if (container == null) { if (container == null) {
throw new IllegalArgumentException(CoreModelMessages.getString("operation.nullContainer")); //$NON-NLS-1$ throw new IllegalArgumentException(CoreModelMessages.getString("operation.nullContainer")); //$NON-NLS-1$
} }
@ -189,15 +188,15 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
} }
protected SourceManipulationInfo getSourceManipulationInfo() throws CModelException { protected SourceManipulationInfo getSourceManipulationInfo() throws CModelException {
return (SourceManipulationInfo)getElementInfo(); return (SourceManipulationInfo) getElementInfo();
} }
public boolean isIdentical(SourceManipulation other) throws CModelException{ public boolean isIdentical(SourceManipulation other) throws CModelException{
return (this.equals(other) return this.equals(other)
&& (this.getSourceManipulationInfo().hasSameContentsAs(other.getSourceManipulationInfo()))); && (this.getSourceManipulationInfo().hasSameContentsAs(other.getSourceManipulationInfo()));
} }
/* /**
* @see CElement#generateInfos * @see CElement#generateInfos
*/ */
@Override @Override
@ -239,7 +238,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
} }
} }
/* /**
* @see CElement * @see CElement
*/ */
@Override @Override

View file

@ -9,10 +9,8 @@
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import org.eclipse.cdt.core.model.CoreModelUtil; import org.eclipse.cdt.core.model.CoreModelUtil;
import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ISourceRoot; import org.eclipse.cdt.core.model.ISourceRoot;
@ -25,7 +23,6 @@ import org.eclipse.core.runtime.Path;
* SourceRoot * SourceRoot
*/ */
public class SourceRoot extends CContainer implements ISourceRoot { public class SourceRoot extends CContainer implements ISourceRoot {
ICSourceEntry sourceEntry; ICSourceEntry sourceEntry;
/** /**
@ -47,18 +44,12 @@ public class SourceRoot extends CContainer implements ISourceRoot {
return sourceEntry; return sourceEntry;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceRoot#isOnclasspath(org.eclipse.cdt.core.model.ICElement)
*/
@Override @Override
public boolean isOnSourceEntry(ICElement element) { public boolean isOnSourceEntry(ICElement element) {
IPath path = element.getPath(); IPath path = element.getPath();
return this.isOnSourceEntry(path); return this.isOnSourceEntry(path);
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.model.ISourceRoot#isOnSourceEntry(org.eclipse.core.resources.IResource)
*/
@Override @Override
public boolean isOnSourceEntry(IResource res) { public boolean isOnSourceEntry(IResource res) {
IPath path = res.getFullPath(); IPath path = res.getFullPath();

View file

@ -78,27 +78,24 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
op.runOperation(monitor); op.runOperation(monitor);
} else { } else {
String contents = this.getSource(); String contents = this.getSource();
if (contents == null) return; if (contents == null)
return;
try { try {
IFile originalRes = (IFile)original.getResource(); IFile originalRes = (IFile) original.getResource();
String encoding = null; String encoding = null;
try { try {
encoding = originalRes.getCharset(); encoding = originalRes.getCharset();
} catch (CoreException e) { } catch (CoreException e) {
// use no encoding // Use no encoding.
} }
byte[] bytes = encoding == null ? contents.getBytes() : contents.getBytes(encoding); byte[] bytes = encoding == null ? contents.getBytes() : contents.getBytes(encoding);
ByteArrayInputStream stream = new ByteArrayInputStream(bytes); ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
if (originalRes.exists()) { if (originalRes.exists()) {
originalRes.setContents( int updateFlags = force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY;
stream, originalRes.setContents(stream, updateFlags, monitor);
force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
null);
} else { } else {
originalRes.create( originalRes.create(stream, force, monitor);
stream,
force,
monitor);
} }
} catch (IOException e) { } catch (IOException e) {
throw new CModelException(e, ICModelStatusConstants.IO_EXCEPTION); throw new CModelException(e, ICModelStatusConstants.IO_EXCEPTION);
@ -118,13 +115,13 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
DestroyWorkingCopyOperation op = new DestroyWorkingCopyOperation(this); DestroyWorkingCopyOperation op = new DestroyWorkingCopyOperation(this);
op.runOperation(null); op.runOperation(null);
} catch (CModelException e) { } catch (CModelException e) {
// do nothing // Do nothing.
} }
} }
@Override @Override
public boolean exists() { public boolean exists() {
// working copy always exists in the model until it is destroyed // Working copy always exists in the model until it is destroyed.
return this.useCount != 0; return this.useCount != 0;
} }
@ -132,7 +129,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
* Returns custom buffer factory * Returns custom buffer factory
*/ */
@Override @Override
public IBufferFactory getBufferFactory(){ public IBufferFactory getBufferFactory() {
return this.bufferFactory; return this.bufferFactory;
} }
@ -170,7 +167,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
return null; // oops !! return null; // oops !!
} }
// look for it. // Look for it.
ICElement element = workingCopyElement; ICElement element = workingCopyElement;
ArrayList<ICElement> children = new ArrayList<ICElement>(); ArrayList<ICElement> children = new ArrayList<ICElement>();
while (element != null && element.getElementType() != ICElement.C_UNIT) { while (element != null && element.getElementType() != ICElement.C_UNIT) {
@ -221,7 +218,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
} }
@Override @Override
public IWorkingCopy getWorkingCopy(IProgressMonitor monitor){ public IWorkingCopy getWorkingCopy(IProgressMonitor monitor) {
return this; return this;
} }
@ -262,7 +259,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
} }
super.open(monitor); super.open(monitor);
//if (monitor != null && monitor.isCanceled()) return; //if (monitor != null && monitor.isCanceled()) return;
//if (this.problemRequestor != null && this.problemRequestor.isActive()){ //if (this.problemRequestor != null && this.problemRequestor.isActive()) {
// this.problemRequestor.beginReporting(); // this.problemRequestor.beginReporting();
// TranslationUnitProblemFinder.process(this, this.problemRequestor, monitor); // TranslationUnitProblemFinder.process(this, this.problemRequestor, monitor);
// this.problemRequestor.endReporting(); // this.problemRequestor.endReporting();
@ -280,7 +277,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
return null; return null;
// Set the buffer source if needed // Set the buffer source if needed
if (buffer.getContents() == null){ if (buffer.getContents() == null) {
ITranslationUnit original= this.getOriginalElement(); ITranslationUnit original= this.getOriginalElement();
IBuffer originalBuffer = null; IBuffer originalBuffer = null;
try { try {

View file

@ -14,6 +14,8 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.index; package org.eclipse.cdt.core.index;
import java.util.regex.Pattern;
import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IScope;
@ -21,8 +23,6 @@ import org.eclipse.cdt.core.parser.ISignificantMacros;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import java.util.regex.Pattern;
/** /**
* Interface for accessing the index for one or more projects. * Interface for accessing the index for one or more projects.
* *

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
@ -45,9 +45,6 @@ public class CPPASTLambdaExpression extends ASTNode implements ICPPASTLambdaExpr
fCaptureDefault= CaptureDefault.UNSPECIFIED; fCaptureDefault= CaptureDefault.UNSPECIFIED;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTExpression#copy()
*/
@Override @Override
public CPPASTLambdaExpression copy() { public CPPASTLambdaExpression copy() {
return copy(CopyStyle.withoutLocations); return copy(CopyStyle.withoutLocations);

View file

@ -12,6 +12,13 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.index.provider; package org.eclipse.cdt.internal.core.index.provider;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.index.IIndexManager; import org.eclipse.cdt.core.index.IIndexManager;
import org.eclipse.cdt.core.index.provider.IIndexProvider; import org.eclipse.cdt.core.index.provider.IIndexProvider;
@ -38,13 +45,6 @@ import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.osgi.util.NLS; import org.eclipse.osgi.util.NLS;
import org.osgi.framework.Version; import org.osgi.framework.Version;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/** /**
* The IndexProviderManager is responsible for maintaining the set of index * The IndexProviderManager is responsible for maintaining the set of index
* fragments contributed via the CIndex extension point. * fragments contributed via the CIndex extension point.
@ -431,14 +431,15 @@ public final class IndexProviderManager implements IElementChangedListener {
case ICElement.C_MODEL: case ICElement.C_MODEL:
// Loop through the children // Loop through the children
ICElementDelta[] children = delta.getAffectedChildren(); ICElementDelta[] children = delta.getAffectedChildren();
for (int i = 0; i < children.length; ++i) for (int i = 0; i < children.length; ++i) {
processDelta(children[i]); processDelta(children[i]);
}
break; break;
case ICElement.C_PROJECT: case ICElement.C_PROJECT:
final ICProject cproject = (ICProject) delta.getElement(); final ICProject cproject = (ICProject) delta.getElement();
switch (delta.getKind()) { switch (delta.getKind()) {
case ICElementDelta.REMOVED: case ICElementDelta.REMOVED:
List<ProvisionMapKey> toRemove = new ArrayList<ProvisionMapKey>(); List<ProvisionMapKey> toRemove = new ArrayList<>();
for (ProvisionMapKey key : provisionMap.keySet()) { for (ProvisionMapKey key : provisionMap.keySet()) {
if (key.getProject().equals(cproject.getProject())) { if (key.getProject().equals(cproject.getProject())) {
toRemove.add(key); toRemove.add(key);

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom; package org.eclipse.cdt.internal.core.pdom;
@ -57,7 +57,7 @@ public class CModelListener implements IElementChangedListener, IResourceChangeL
return; return;
// Walk the delta collecting tu's per project // Walk the delta collecting tu's per project
HashMap<ICProject, DeltaAnalyzer> changeMap= new HashMap<ICProject, DeltaAnalyzer>(); HashMap<ICProject, DeltaAnalyzer> changeMap= new HashMap<>();
processDelta(event.getDelta(), changeMap); processDelta(event.getDelta(), changeMap);
// bug 171834 update last recently changed sources // bug 171834 update last recently changed sources
@ -84,7 +84,7 @@ public class CModelListener implements IElementChangedListener, IResourceChangeL
break; break;
case ICElement.C_PROJECT: case ICElement.C_PROJECT:
// Find the appropriate indexer and pass the delta on // Find the appropriate indexer and pass the delta on
final ICProject project = (ICProject)delta.getElement(); final ICProject project = (ICProject) delta.getElement();
switch (delta.getKind()) { switch (delta.getKind()) {
case ICElementDelta.ADDED: case ICElementDelta.ADDED:
fManager.addProject(project); fManager.addProject(project);

View file

@ -53,7 +53,7 @@ public class DeltaAnalyzer {
final ICElement element = delta.getElement(); final ICElement element = delta.getElement();
switch (element.getElementType()) { switch (element.getElementType()) {
case ICElement.C_UNIT: case ICElement.C_UNIT:
ITranslationUnit tu = (ITranslationUnit)element; ITranslationUnit tu = (ITranslationUnit) element;
if (!tu.isWorkingCopy()) { if (!tu.isWorkingCopy()) {
handled.add(element.getResource()); handled.add(element.getResource());
switch (delta.getKind()) { switch (delta.getKind()) {

View file

@ -14,17 +14,20 @@ import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
/** /**
* This represents an executable extension in the cmodel hierarchy * Represents an executable extension in the C model hierarchy.
*
* @noextend This interface is not intended to be extended by clients. * @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients. * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICExtension { public interface ICExtension {
public IProject getProject(); public IProject getProject();
/** /**
* @deprecated Use {@link #getConfigExtensionReference()} instead. * @deprecated Use {@link #getConfigExtensionReference()} instead.
*/ */
@Deprecated @Deprecated
public ICExtensionReference getExtensionReference(); public ICExtensionReference getExtensionReference();
/** /**
* @since 5.2 * @since 5.2
*/ */

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core; package org.eclipse.cdt.internal.core;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
@ -60,8 +59,7 @@ public class CContentTypes {
// fallback to workspace wide definitions. // fallback to workspace wide definitions.
matcher= Platform.getContentTypeManager(); matcher= Platform.getContentTypeManager();
} }
} } else {
else {
matcher= Platform.getContentTypeManager(); matcher= Platform.getContentTypeManager();
} }
@ -95,8 +93,7 @@ public class CContentTypes {
if (isPreferredContentType(candidate, preferCpp)) { if (isPreferredContentType(candidate, preferCpp)) {
priority+= 1; priority+= 1;
} }
} } catch (CoreException e) {
catch (CoreException e) {
// skip it // skip it
} }
if (priority > bestPriority) { if (priority > bestPriority) {

View file

@ -1,4 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others * Rapperswil, University of applied sciences 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
@ -34,7 +35,7 @@ public class ExtractFunctionRefactoringTest extends RefactoringTestBase {
private String extractedFunctionName = "extracted"; private String extractedFunctionName = "extracted";
private String returnValue; private String returnValue;
// Map from old names to new ones. // Map from old names to new ones.
private Map<String, String> parameterRename = new HashMap<String, String>(); private Map<String, String> parameterRename = new HashMap<>();
// New positions of parameters, or null. // New positions of parameters, or null.
private int[] parameterOrder; private int[] parameterOrder;
private VisibilityEnum visibility = VisibilityEnum.v_private; private VisibilityEnum visibility = VisibilityEnum.v_private;

View file

@ -26,8 +26,8 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
public class CRefactoringMatchStore { public class CRefactoringMatchStore {
private Map<IFile, IPath> fFileToPathMap= new HashMap<IFile, IPath>(); private Map<IFile, IPath> fFileToPathMap= new HashMap<>();
private Map<IPath, SortedMap<CRefactoringMatch, CRefactoringMatch>> fPathToMatches= new HashMap<IPath, SortedMap<CRefactoringMatch, CRefactoringMatch>>(); private Map<IPath, SortedMap<CRefactoringMatch, CRefactoringMatch>> fPathToMatches= new HashMap<>();
private Comparator<CRefactoringMatch> fOffsetComparator; private Comparator<CRefactoringMatch> fOffsetComparator;
public CRefactoringMatchStore() { public CRefactoringMatchStore() {
@ -50,7 +50,7 @@ public class CRefactoringMatchStore {
private Map<CRefactoringMatch, CRefactoringMatch> getMapForPath(IPath path, boolean create) { private Map<CRefactoringMatch, CRefactoringMatch> getMapForPath(IPath path, boolean create) {
SortedMap<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path); SortedMap<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path);
if (map == null && create) { if (map == null && create) {
map= new TreeMap<CRefactoringMatch, CRefactoringMatch>(fOffsetComparator); map= new TreeMap<>(fOffsetComparator);
fPathToMatches.put(path, map); fPathToMatches.put(path, map);
} }
return map; return map;
@ -73,7 +73,7 @@ public class CRefactoringMatchStore {
} }
public List<IFile> getFileList() { public List<IFile> getFileList() {
return new ArrayList<IFile>(fFileToPathMap.keySet()); return new ArrayList<>(fFileToPathMap.keySet());
} }
public boolean contains(IResource file) { public boolean contains(IResource file) {

View file

@ -83,9 +83,9 @@ public class RenameCSourceFolderChange extends Change {
return new RenameCSourceFolderChange(newName, oldName, project, folder2); return new RenameCSourceFolderChange(newName, oldName, project, folder2);
} }
private void changeEntryInAllCfgs(ICProjectDescription des) throws WriteAccessException, CoreException{ private void changeEntryInAllCfgs(ICProjectDescription des) throws WriteAccessException, CoreException {
ICConfigurationDescription cfgs[] = des.getConfigurations(); ICConfigurationDescription cfgs[] = des.getConfigurations();
for (ICConfigurationDescription cfg : cfgs){ for (ICConfigurationDescription cfg : cfgs) {
ICSourceEntry[] entries = cfg.getSourceEntries(); ICSourceEntry[] entries = cfg.getSourceEntries();
entries = renameEntry(entries); entries = renameEntry(entries);
cfg.setSourceEntries(entries); cfg.setSourceEntries(entries);
@ -93,25 +93,24 @@ public class RenameCSourceFolderChange extends Change {
CCorePlugin.getDefault().setProjectDescription(project, des, false, new NullProgressMonitor()); CCorePlugin.getDefault().setProjectDescription(project, des, false, new NullProgressMonitor());
} }
private ICSourceEntry[] renameEntry(ICSourceEntry[] entries){ private ICSourceEntry[] renameEntry(ICSourceEntry[] entries) {
Set<ICSourceEntry> set = new HashSet<>(); Set<ICSourceEntry> set = new HashSet<>();
for (ICSourceEntry se : entries){ for (ICSourceEntry entry : entries) {
String seLocation = se.getName(); String entryPath = entry.getName();
if (seLocation.equals(oldName.toPortableString())) { if (entryPath.equals(oldName.toString())) {
ICSourceEntry newSE = new CSourceEntry(newName, se.getExclusionPatterns(), se.getFlags()); set.add(new CSourceEntry(newName, entry.getExclusionPatterns(), entry.getFlags()));
set.add(newSE);
} else { } else {
Set<IPath> exPatters = new HashSet<>(); IPath oldSegments = oldName.removeFirstSegments(oldName.segmentCount() - 1);
for (IPath filter : se.getExclusionPatterns()) { Set<IPath> exclusionPatterns = new HashSet<>();
IPath oldSegments = oldName.removeFirstSegments(oldName.segmentCount() -1); for (IPath pattern : entry.getExclusionPatterns()) {
if (filter.equals(oldSegments)) { if (pattern.equals(oldSegments)) {
exPatters.add(newName.removeFirstSegments(newName.segmentCount() - 1)); exclusionPatterns.add(newName.removeFirstSegments(newName.segmentCount() - 1));
} else { } else {
exPatters.add(filter); exclusionPatterns.add(pattern);
} }
} }
set.add(new CSourceEntry(se.getValue(), exPatters.toArray(new IPath[exPatters.size()]), se.getFlags())); set.add(new CSourceEntry(entry.getValue(), exclusionPatterns.toArray(new IPath[exclusionPatterns.size()]), entry.getFlags()));
} }
} }
return set.toArray(new ICSourceEntry[set.size()]); return set.toArray(new ICSourceEntry[set.size()]);

View file

@ -9,7 +9,6 @@
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.ui.text.correction.proposals; package org.eclipse.cdt.internal.ui.text.correction.proposals;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -89,7 +88,6 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
throw new IllegalArgumentException("Translation unit must not be null"); //$NON-NLS-1$ throw new IllegalArgumentException("Translation unit must not be null"); //$NON-NLS-1$
} }
fTranslationUnit= tu; fTranslationUnit= tu;
fLinkedProposalModel= null;
} }
/** /**
@ -135,12 +133,9 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
fLinkedProposalModel= model; fLinkedProposalModel= model;
} }
/*
* @see ICompletionProposal#getAdditionalProposalInfo()
*/
@Override @Override
public String getAdditionalProposalInfo() { public String getAdditionalProposalInfo() {
final StringBuffer buf= new StringBuffer(); final StringBuilder buf= new StringBuilder();
try { try {
final TextChange change= getTextChange(); final TextChange change= getTextChange();
@ -218,13 +213,13 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
private final int surroundLines= 1; private final int surroundLines= 1;
private void appendContent(IDocument text, int startOffset, int endOffset, StringBuffer buf, boolean surroundLinesOnly) { private void appendContent(IDocument text, int startOffset, int endOffset, StringBuilder buf, boolean surroundLinesOnly) {
try { try {
int startLine= text.getLineOfOffset(startOffset); int startLine= text.getLineOfOffset(startOffset);
int endLine= text.getLineOfOffset(endOffset); int endLine= text.getLineOfOffset(endOffset);
boolean dotsAdded= false; boolean dotsAdded= false;
if (surroundLinesOnly && startOffset == 0) { // no surround lines for the top no-change range if (surroundLinesOnly && startOffset == 0) { // No surround lines for the top no-change range
startLine= Math.max(endLine - surroundLines, 0); startLine= Math.max(endLine - surroundLines, 0);
buf.append("...<br>"); //$NON-NLS-1$ buf.append("...<br>"); //$NON-NLS-1$
dotsAdded= true; dotsAdded= true;
@ -237,7 +232,7 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
buf.append("...<br>"); //$NON-NLS-1$ buf.append("...<br>"); //$NON-NLS-1$
dotsAdded= true; dotsAdded= true;
} else if (endOffset == text.getLength()) { } else if (endOffset == text.getLength()) {
return; // no surround lines for the bottom no-change range return; // No surround lines for the bottom no-change range
} }
continue; continue;
} }
@ -250,8 +245,8 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
int from= Math.max(start, startOffset); int from= Math.max(start, startOffset);
int to= Math.min(end, endOffset); int to= Math.min(end, endOffset);
String content= text.get(from, to - from); String content= text.get(from, to - from);
if (surroundLinesOnly && (from == start) && Strings.containsOnlyWhitespaces(content)) { if (surroundLinesOnly && from == start && Strings.containsOnlyWhitespaces(content)) {
continue; // ignore empty lines except when range started in the middle of a line continue; // Ignore empty lines except when range started in the middle of a line
} }
for (int k= 0; k < content.length(); k++) { for (int k= 0; k < content.length(); k++) {
char ch= content.charAt(k); char ch= content.charAt(k);
@ -263,18 +258,15 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
buf.append(ch); buf.append(ch);
} }
} }
if (to == end && to != endOffset) { // new line when at the end of the line, and not end of range if (to == end && to != endOffset) { // New line when at the end of the line, and not end of range
buf.append("<br>"); //$NON-NLS-1$ buf.append("<br>"); //$NON-NLS-1$
} }
} }
} catch (BadLocationException e) { } catch (BadLocationException e) {
// ignore // Ignore.
} }
} }
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
*/
@Override @Override
public void apply(IDocument document) { public void apply(IDocument document) {
try { try {
@ -318,9 +310,6 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
return true; return true;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.text.correction.ChangeCorrectionProposal#performChange(org.eclipse.jface.text.IDocument, org.eclipse.ui.IEditorPart)
*/
@Override @Override
protected void performChange(IEditorPart part, IDocument document) throws CoreException { protected void performChange(IEditorPart part, IDocument document) throws CoreException {
try { try {
@ -366,7 +355,7 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
source= tu.getSource(); source= tu.getSource();
} catch (CModelException e) { } catch (CModelException e) {
CUIPlugin.log(e); CUIPlugin.log(e);
source= new String(); // empty source= ""; //$NON-NLS-1$
} }
Document document= new Document(source); Document document= new Document(source);
document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(tu)); document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(tu));
@ -379,15 +368,12 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
TextEdit rootEdit= new MultiTextEdit(); TextEdit rootEdit= new MultiTextEdit();
change.setEdit(rootEdit); change.setEdit(rootEdit);
// initialize text change // Initialize text change.
IDocument document= change.getCurrentDocument(new NullProgressMonitor()); IDocument document= change.getCurrentDocument(new NullProgressMonitor());
addEdits(document, rootEdit); addEdits(document, rootEdit);
return change; return change;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.ui.text.correction.ChangeCorrectionProposal#createChange()
*/
@Override @Override
protected final Change createChange() throws CoreException { protected final Change createChange() throws CoreException {
return createTextChange(); // make sure that only text changes are allowed here return createTextChange(); // make sure that only text changes are allowed here
@ -422,9 +408,6 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
return getTextChange().getPreviewContent(new NullProgressMonitor()); return getTextChange().getPreviewContent(new NullProgressMonitor());
} }
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override @Override
public String toString() { public String toString() {
try { try {

View file

@ -42,7 +42,7 @@ public class CTextFileChange extends TextFileChange {
private static final String TEXT_TYPE = "c2"; //$NON-NLS-1$ private static final String TEXT_TYPE = "c2"; //$NON-NLS-1$
private ITranslationUnit fTranslationUnit; private ITranslationUnit fTranslationUnit;
private IWorkingCopy fWorkingCopy; private IWorkingCopy fWorkingCopy;
private int fAquireCount; private int fAcquireCount;
public CTextFileChange(String name, IFile file) { public CTextFileChange(String name, IFile file) {
super(name, file); super(name, file);
@ -65,7 +65,7 @@ public class CTextFileChange extends TextFileChange {
@Override @Override
protected IDocument acquireDocument(IProgressMonitor pm) throws CoreException { protected IDocument acquireDocument(IProgressMonitor pm) throws CoreException {
IDocument doc= super.acquireDocument(pm); IDocument doc= super.acquireDocument(pm);
if (++fAquireCount == 1) { if (++fAcquireCount == 1) {
if (fTranslationUnit instanceof TranslationUnit && fWorkingCopy == null) { if (fTranslationUnit instanceof TranslationUnit && fWorkingCopy == null) {
fWorkingCopy= ((TranslationUnit) fTranslationUnit).getWorkingCopy(null, DocumentAdapter.FACTORY); fWorkingCopy= ((TranslationUnit) fTranslationUnit).getWorkingCopy(null, DocumentAdapter.FACTORY);
if (!fTranslationUnit.isOpen()) { if (!fTranslationUnit.isOpen()) {
@ -88,7 +88,7 @@ public class CTextFileChange extends TextFileChange {
@Override @Override
protected void releaseDocument(IDocument document, IProgressMonitor pm) throws CoreException { protected void releaseDocument(IDocument document, IProgressMonitor pm) throws CoreException {
super.releaseDocument(document, pm); super.releaseDocument(document, pm);
if (--fAquireCount == 0) { if (--fAcquireCount == 0) {
if (fWorkingCopy != null) { if (fWorkingCopy != null) {
fWorkingCopy.destroy(); fWorkingCopy.destroy();
fWorkingCopy= null; fWorkingCopy= null;

View file

@ -6,9 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation9 * QNX Software Systems - Initial API and implementation9
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.launch.internal.refactoring; package org.eclipse.cdt.launch.internal.refactoring;
import java.util.Collection; import java.util.Collection;
@ -42,16 +41,10 @@ import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
* *
* @since 6.0 * @since 6.0
*/ */
public class ResourceRenameParticipant extends RenameParticipant implements public class ResourceRenameParticipant extends RenameParticipant implements IExecutableExtension {
IExecutableExtension {
private String name; private String name;
private IResource resourceBeingRenamed; private IResource resourceBeingRenamed;
/**
* Initializes me.
*/
public ResourceRenameParticipant() { public ResourceRenameParticipant() {
super(); super();
} }
@ -66,17 +59,14 @@ public class ResourceRenameParticipant extends RenameParticipant implements
if (element instanceof IResource) { if (element instanceof IResource) {
resourceBeingRenamed = (IResource) element; resourceBeingRenamed = (IResource) element;
} else if (element instanceof IAdaptable) { } else if (element instanceof IAdaptable) {
resourceBeingRenamed = (IResource) ((IAdaptable) element) resourceBeingRenamed = (IResource) ((IAdaptable) element).getAdapter(IResource.class);
.getAdapter(IResource.class);
} }
return true; return true;
} }
@Override @Override
public Change createChange(IProgressMonitor pm) throws CoreException, public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
OperationCanceledException {
Change result = null; Change result = null;
if (resourceBeingRenamed instanceof IProject) { if (resourceBeingRenamed instanceof IProject) {
@ -85,22 +75,15 @@ public class ResourceRenameParticipant extends RenameParticipant implements
Collection<ILaunchConfigurationType> launchTypes = getCLaunchConfigTypes(); Collection<ILaunchConfigurationType> launchTypes = getCLaunchConfigTypes();
if (!launchTypes.isEmpty()) { if (!launchTypes.isEmpty()) {
ILaunchManager mgr = DebugPlugin.getDefault() ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager();
.getLaunchManager();
for (ILaunchConfigurationType type : launchTypes) { for (ILaunchConfigurationType type : launchTypes) {
ILaunchConfiguration[] launches = mgr ILaunchConfiguration[] launches = mgr.getLaunchConfigurations(type);
.getLaunchConfigurations(type);
for (ILaunchConfiguration next : launches) { for (ILaunchConfiguration next : launches) {
if (next if (next.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "").equals(oldName)) { //$NON-NLS-1$
.getAttribute( result = AbstractLaunchConfigChange.append(
ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, result, new ProjectRenameChange(next, oldName, newName));
"").equals(oldName)) { //$NON-NLS-1$
result = AbstractLaunchConfigChange.append(result,
new ProjectRenameChange(next, oldName,
newName));
} }
} }
} }
@ -111,10 +94,10 @@ public class ResourceRenameParticipant extends RenameParticipant implements
} }
static Collection<ILaunchConfigurationType> getCLaunchConfigTypes() { static Collection<ILaunchConfigurationType> getCLaunchConfigTypes() {
Set<ILaunchConfigurationType> result = new java.util.HashSet<ILaunchConfigurationType>(); Set<ILaunchConfigurationType> result = new HashSet<>();
// Get launch config types registered by CDT adopters // Get launch config types registered by CDT adopters
Set<String> thirdPartyConfgTypeIds = new HashSet<String>(5); Set<String> thirdPartyConfgTypeIds = new HashSet<>(5);
LaunchConfigAffinityExtensionPoint.getLaunchConfigTypeIds(thirdPartyConfgTypeIds); LaunchConfigAffinityExtensionPoint.getLaunchConfigTypeIds(thirdPartyConfgTypeIds);
ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager(); ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager();
@ -130,18 +113,15 @@ public class ResourceRenameParticipant extends RenameParticipant implements
} }
@Override @Override
public RefactoringStatus checkConditions(IProgressMonitor pm, public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
CheckConditionsContext context) throws OperationCanceledException { throws OperationCanceledException {
// I have no conditions to check. Updating the launches is trivial // I have no conditions to check. Updating the launches is trivial
return new RefactoringStatus(); return new RefactoringStatus();
} }
@Override @Override
public void setInitializationData(IConfigurationElement config, public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
String propertyName, Object data) throws CoreException { throws CoreException {
this.name = config.getAttribute("name"); //$NON-NLS-1$ this.name = config.getAttribute("name"); //$NON-NLS-1$
} }
} }