mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-14 03:35:37 +02:00
Cosmetics.
This commit is contained in:
parent
ce9b270a38
commit
cf4556f05f
33 changed files with 323 additions and 420 deletions
|
@ -56,7 +56,7 @@ public class MoveRenameTest extends ChangeGeneratorTest {
|
|||
IASTDeclaration[] members = classSpecifier.getMembers();
|
||||
ASTModification swap1 = new ASTModification(ASTModification.ModificationKind.REPLACE, members[1], members[2], 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, swap2);
|
||||
modStore.storeModification(swap1, new ASTModification(ASTModification.ModificationKind.REPLACE, name, new CPPASTName("d".toCharArray()), null)); //$NON-NLS-1$
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
*******************************************************************************/
|
||||
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.CCorePlugin;
|
||||
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.jobs.ISchedulingRule;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @noextend This class is not intended to be subclassed 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);
|
||||
if (contentType != null) {
|
||||
String id = contentType.getId();
|
||||
if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id)) {
|
||||
return true;
|
||||
} else if (CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) {
|
||||
if (CCorePlugin.CONTENT_TYPE_CHEADER.equals(id) ||
|
||||
CCorePlugin.CONTENT_TYPE_CXXHEADER.equals(id)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -567,16 +566,12 @@ public class CoreModel {
|
|||
* folders are located with that project. That is, a source entry
|
||||
* specifying the path {@code /P1/src} is only usable for project
|
||||
* {@code P1}.
|
||||
* </p>
|
||||
* </p>
|
||||
* <p>
|
||||
* Note that all sources/binaries inside a project are contributed as a
|
||||
* whole through a project entry (see {@code newProjectEntry}).
|
||||
* Particular source entries cannot be selectively exported.
|
||||
* </p>
|
||||
*
|
||||
* @param sourcePath
|
||||
* the project-relative path of a source folder
|
||||
* @param sourcePath the project-relative path of a source folder
|
||||
* @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
|
||||
* specifying the path {@code /P1/src} is only usable for project
|
||||
* {@code P1}.
|
||||
* </p>
|
||||
*
|
||||
* @param sourcePath
|
||||
* 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
|
||||
* date. Because of this, hanging on resolved pathentries is not
|
||||
* recommended.
|
||||
* </p>
|
||||
*
|
||||
* @return the resolved entries for the project
|
||||
* @exception CModelException
|
||||
|
@ -963,7 +956,6 @@ public class CoreModel {
|
|||
* If the project's raw entries are later modified they can become out of
|
||||
* date. Because of this, hanging on resolved pathentries is not
|
||||
* recommended.
|
||||
* </p>
|
||||
*
|
||||
* @return the include entries for the translation unit
|
||||
* @exception CModelException
|
||||
|
@ -981,7 +973,6 @@ public class CoreModel {
|
|||
* If the project's raw entries are later modified they can become out of
|
||||
* date. Because of this, hanging on resolved pathentries is not
|
||||
* recommended.
|
||||
* </p>
|
||||
*
|
||||
* @return the include file entries for the translation unit
|
||||
* @exception CModelException
|
||||
|
@ -999,7 +990,6 @@ public class CoreModel {
|
|||
* If the project's raw entries are later modified they can become out of
|
||||
* date. Because of this, hanging on resolved pathentries is not
|
||||
* recommended.
|
||||
* </p>
|
||||
*
|
||||
* @return the resolved entries for the project
|
||||
* @exception CModelException
|
||||
|
@ -1017,7 +1007,6 @@ public class CoreModel {
|
|||
* If the project's raw entries are later modified they can become out of
|
||||
* date. Because of this, hanging on resolved pathentries is not
|
||||
* recommended.
|
||||
* </p>
|
||||
*
|
||||
* @return the macro file entries for the translation unit
|
||||
* @exception CModelException
|
||||
|
@ -1162,7 +1151,6 @@ public class CoreModel {
|
|||
private CoreModel() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs the given action as an atomic C model operation.
|
||||
* <p>
|
||||
|
@ -1173,13 +1161,11 @@ public class CoreModel {
|
|||
* methods that modify C elements and only have element
|
||||
* changed event notifications reported at the end of the entire
|
||||
* batch.
|
||||
* </p>
|
||||
* <p>
|
||||
* If this method is called outside the dynamic scope of another such
|
||||
* call, this method runs the action and then reports a single
|
||||
* element changed event describing the net effect of all changes
|
||||
* done to C elements by the action.
|
||||
* </p>
|
||||
* <p>
|
||||
* If this method is called in the dynamic scope of another such
|
||||
* call, this method simply runs the action.
|
||||
|
@ -1187,7 +1173,7 @@ public class CoreModel {
|
|||
*
|
||||
* @param action the action to perform
|
||||
* @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.
|
||||
* @since 2.1
|
||||
*/
|
||||
|
@ -1204,28 +1190,24 @@ public class CoreModel {
|
|||
* methods that modify C elements and only have element
|
||||
* changed event notifications reported at the end of the entire
|
||||
* batch.
|
||||
* </p>
|
||||
* <p>
|
||||
* If this method is called outside the dynamic scope of another such
|
||||
* call, this method runs the action and then reports a single
|
||||
* element changed event describing the net effect of all changes
|
||||
* done to C elements by the action.
|
||||
* </p>
|
||||
* <p>
|
||||
* If this method is called in the dynamic scope of another such
|
||||
* call, this method simply runs the action.
|
||||
* </p>
|
||||
* <p>
|
||||
* The supplied scheduling rule is used to determine whether this operation can be
|
||||
* run simultaneously with workspace changes in other threads. See
|
||||
* {@code IWorkspace.run(...)} for more details.
|
||||
* </p>
|
||||
* {@link IWorkspace#run} for more details.
|
||||
*
|
||||
* @param action the action to perform
|
||||
* @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
|
||||
* reporting and cancellation are not desired
|
||||
* reporting and cancellation are not desired
|
||||
* @exception CoreException if the operation failed.
|
||||
* @since 3.0
|
||||
*/
|
||||
|
@ -1234,7 +1216,7 @@ public class CoreModel {
|
|||
if (workspace.isTreeLocked()) {
|
||||
new BatchOperation(action).run(monitor);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Rational Software - Initial API and implementation
|
||||
* Rational Software - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
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.
|
||||
* 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
|
||||
* <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.
|
||||
* <p>
|
||||
* 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.
|
||||
*/
|
||||
public interface IBuffer {
|
||||
|
||||
/**
|
||||
* Adds the given listener for changes to this buffer.
|
||||
* Has no effect if an identical listener is already registered or if the buffer
|
||||
* is closed.
|
||||
* Has no effect if an identical listener is already registered or if the buffer is closed.
|
||||
*
|
||||
* @param listener the listener of buffer changes
|
||||
*/
|
||||
public void addBufferChangedListener(IBufferChangedListener listener);
|
||||
|
||||
/**
|
||||
* Appends the given character array to the contents of the buffer.
|
||||
* This buffer will now have unsaved changes.
|
||||
|
@ -43,11 +41,12 @@ public interface IBuffer {
|
|||
* <p>
|
||||
* Has no effect if this buffer is read-only.
|
||||
* <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
|
||||
*/
|
||||
public void append(char[] text);
|
||||
|
||||
/**
|
||||
* Appends the given string to the contents of the buffer.
|
||||
* This buffer will now have unsaved changes.
|
||||
|
@ -56,11 +55,12 @@ public interface IBuffer {
|
|||
* <p>
|
||||
* Has no effect if this buffer is read-only.
|
||||
* <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);
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -70,17 +70,19 @@ public interface IBuffer {
|
|||
* attempt is made to close an already closed buffer, the second attempt has no effect.
|
||||
*/
|
||||
public void close();
|
||||
|
||||
/**
|
||||
* Returns the character at the given position in this buffer.
|
||||
* <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
|
||||
* @return the character at the given position in this buffer
|
||||
*/
|
||||
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.
|
||||
* <p>
|
||||
* 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
|
||||
* client wishes to hang on to the array in its current state, they should
|
||||
* make a copy.
|
||||
* </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
|
||||
*/
|
||||
public char[] getCharacters();
|
||||
|
||||
/**
|
||||
* Returns the contents of this buffer as a <code>String</code>. Like all strings,
|
||||
* the result is an immutable value object., It can also answer <code>null</code> if
|
||||
* 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} if
|
||||
* the buffer has not been initialized.
|
||||
* <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();
|
||||
|
||||
/**
|
||||
* Returns number of characters stored in this buffer.
|
||||
* <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
|
||||
*/
|
||||
public int getLength();
|
||||
|
||||
/**
|
||||
* Returns the resource element owning of this buffer.
|
||||
*
|
||||
* @return the resource element owning this buffer
|
||||
*/
|
||||
public IOpenable getOwner();
|
||||
|
||||
/**
|
||||
* Returns the given range of text in this buffer.
|
||||
* <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 length the number of characters to retrieve
|
||||
* @return the given range of text in this buffer
|
||||
*/
|
||||
public String getText(int offset, int length);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public IResource getUnderlyingResource();
|
||||
|
||||
/**
|
||||
* Returns whether this buffer has been modified since it
|
||||
* was opened or since it was last saved.
|
||||
* 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
|
||||
* the absence of any underlying resource, it will always return <code>true</code>).
|
||||
* @return a {@code boolean} indicating presence of unsaved changes (in
|
||||
* the absence of any underlying resource, it will always return {@code true}).
|
||||
*/
|
||||
public boolean hasUnsavedChanges();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Removes the given listener from this buffer.
|
||||
* 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
|
||||
*/
|
||||
public void removeBufferChangedListener(IBufferChangedListener listener);
|
||||
|
||||
/**
|
||||
* 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>length</code> must not be negative.
|
||||
* {@code position} and {@code position + length} must be in the range [0, getLength()].
|
||||
* {@code length} must not be negative.
|
||||
* <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 length the length of the affected text range in this buffer
|
||||
* @param text the replacing text as a character array
|
||||
*/
|
||||
public void replace(int position, int length, char[] 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>length</code> must not be negative.
|
||||
* {@code position} and {@code position + length} must be in the range [0, getLength()].
|
||||
* {@code length} must not be negative.
|
||||
* <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 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);
|
||||
|
||||
/**
|
||||
* Saves the contents of this buffer to its underlying resource. If
|
||||
* 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
|
||||
* has no effect.
|
||||
* <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.
|
||||
* 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
|
||||
* it is in sync with the workbench. This option ensures there is no
|
||||
* 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,
|
||||
* overwriting any existing one if need be.
|
||||
* In either case, if this method succeeds, the resource will be marked
|
||||
* as being local (even if it wasn't before).
|
||||
* <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 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.
|
||||
*
|
||||
* @exception CModelException if an error occurs writing the buffer to
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Sets the contents of this buffer to the given character array.
|
||||
* This buffer will now have unsaved changes.
|
||||
* Any client can set the contents of the buffer, not just the owner of the buffer.
|
||||
* Reports a buffer changed event.
|
||||
* <p>
|
||||
* Equivalent to <code>replace(0,getLength(),contents)</code>.
|
||||
* </p>
|
||||
* Equivalent to {@code replace(0, getLength(), contents)}.
|
||||
* <p>
|
||||
* Has no effect if this buffer is read-only.
|
||||
* <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
|
||||
*/
|
||||
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.
|
||||
* Any client can set the contents of the buffer, not just the owner of the buffer.
|
||||
* Reports a buffer changed event.
|
||||
* <p>
|
||||
* Equivalent to <code>replace(0,getLength(),contents)</code>.
|
||||
* </p>
|
||||
* Equivalent to {@code replace(0, getLength(), contents)}.
|
||||
* <p>
|
||||
* Has no effect if this buffer is read-only.
|
||||
* <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);
|
||||
|
||||
}
|
||||
|
|
|
@ -373,18 +373,16 @@ public interface ICElement extends IAdaptable {
|
|||
URI getLocationURI();
|
||||
|
||||
/**
|
||||
* Returns the underlying resource that contains
|
||||
* this element, or {@code null} if this element is not contained
|
||||
* in a resource.
|
||||
* Returns the underlying resource that contains this element, or {@code null} if this element
|
||||
* is not contained in a resource.
|
||||
*
|
||||
* @return the underlying resource, or {@code null} if none
|
||||
*/
|
||||
IResource getUnderlyingResource();
|
||||
|
||||
/**
|
||||
* Returns the Corresponding resource for
|
||||
* this element, or {@code null} if this element does not have
|
||||
* a corresponding resource.
|
||||
* Returns the corresponding resource for this element, or {@code null} if this element
|
||||
* does not have a corresponding resource.
|
||||
*
|
||||
* @return the corresponding resource, or {@code null} if none
|
||||
*/
|
||||
|
|
|
@ -48,7 +48,6 @@ import org.eclipse.core.resources.IResourceDelta;
|
|||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICElementDelta {
|
||||
|
||||
/**
|
||||
* Status constant indicating that the element has been added.
|
||||
*/
|
||||
|
|
|
@ -12,9 +12,7 @@ package org.eclipse.cdt.core.model;
|
|||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
|
||||
public interface IPathEntry {
|
||||
|
||||
/**
|
||||
* Entry kind constant describing a path entry identifying a
|
||||
* library. A library is an archive containing
|
||||
|
@ -104,5 +102,4 @@ public interface IPathEntry {
|
|||
* @return IPath
|
||||
*/
|
||||
IPath getPath();
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
@ -25,5 +24,4 @@ public interface ISourceRoot extends ICContainer {
|
|||
boolean isOnSourceEntry(IPath path);
|
||||
|
||||
boolean isOnSourceEntry(ICElement element);
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.settings.model;
|
||||
|
||||
|
@ -16,25 +16,26 @@ import org.eclipse.core.resources.IFolder;
|
|||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
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$
|
||||
/** calculated value, does not have to be final */
|
||||
|
||||
private final IPath[] exclusionPatterns;
|
||||
/** Calculated value, does not have to be final */
|
||||
char[][] fullCharExclusionPatterns = UNINIT_PATTERNS;
|
||||
|
||||
|
||||
ACExclusionFilterEntry(IPath path, IPath exclusionPatterns[] , int 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) {
|
||||
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) {
|
||||
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
|
||||
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;
|
||||
this.fullCharExclusionPatterns = new char[length][];
|
||||
IPath path = getFullPath();
|
||||
if(path == null)
|
||||
if (path == null)
|
||||
path = getLocation();
|
||||
IPath prefixPath = path.removeTrailingSeparator();
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
@ -98,7 +99,7 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
|
|||
|
||||
@Override
|
||||
public boolean equalsByContents(ICSettingEntry entry) {
|
||||
if(!super.equalsByContents(entry))
|
||||
if (!super.equalsByContents(entry))
|
||||
return false;
|
||||
|
||||
ACExclusionFilterEntry otherEntry = (ACExclusionFilterEntry)entry;
|
||||
|
@ -108,12 +109,12 @@ public abstract class ACExclusionFilterEntry extends ACPathEntry implements ICEx
|
|||
@Override
|
||||
protected String contentsToString() {
|
||||
String result = super.contentsToString();
|
||||
if(exclusionPatterns.length != 0){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
if (exclusionPatterns.length != 0) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(result);
|
||||
buf.append(" ; exclude: "); //$NON-NLS-1$
|
||||
for(int i = 0; i < exclusionPatterns.length; i++){
|
||||
if(i != 0)
|
||||
for (int i = 0; i < exclusionPatterns.length; i++) {
|
||||
if (i != 0)
|
||||
buf.append(", "); //$NON-NLS-1$
|
||||
buf.append(exclusionPatterns[i].toString());
|
||||
}
|
||||
|
|
|
@ -12,6 +12,12 @@
|
|||
*******************************************************************************/
|
||||
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.ICElement;
|
||||
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.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 static final char CEM_ESCAPE = '\\';
|
||||
public static final char CEM_CPROJECT = '=';
|
||||
|
@ -214,7 +214,8 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
public ICModel getCModel () {
|
||||
ICElement current = this;
|
||||
do {
|
||||
if (current instanceof ICModel) return (ICModel) current;
|
||||
if (current instanceof ICModel)
|
||||
return (ICModel) current;
|
||||
} while ((current = current.getParent()) != null);
|
||||
return null;
|
||||
}
|
||||
|
@ -234,14 +235,13 @@ public abstract class CElement extends PlatformObject implements ICElement {
|
|||
|
||||
@Override
|
||||
public IResource getUnderlyingResource() {
|
||||
IResource res = getResource();
|
||||
if (res == null) {
|
||||
ICElement p = getParent();
|
||||
if (p != null) {
|
||||
res = p.getUnderlyingResource();
|
||||
}
|
||||
}
|
||||
return res;
|
||||
ICElement current = this;
|
||||
do {
|
||||
IResource res = getResource();
|
||||
if (res != null)
|
||||
return res;
|
||||
} while ((current = current.getParent()) != null);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -20,8 +20,6 @@ import org.eclipse.cdt.core.model.ICElement;
|
|||
import org.eclipse.cdt.core.model.ICModel;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
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.IResource;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
|
@ -32,7 +30,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
|
||||
public class CModel extends Openable implements ICModel {
|
||||
|
||||
public CModel () {
|
||||
public CModel() {
|
||||
this(ResourcesPlugin.getWorkspace().getRoot());
|
||||
}
|
||||
|
||||
|
@ -56,9 +54,6 @@ public class CModel extends Openable implements ICModel {
|
|||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* ICModel#getCProject(String)
|
||||
*/
|
||||
@Override
|
||||
public ICProject getCProject(String 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
|
||||
* resource, or <code>null</code> if no C project yet exists
|
||||
* for the resource.
|
||||
* Returns the active C project associated with the specified resource,
|
||||
* or {@code null} if no C project yet exists for the resource.
|
||||
*
|
||||
* @exception IllegalArgumentException if the given resource
|
||||
* is not one of an IProject, IFolder, or IFile.
|
||||
* @exception IllegalArgumentException if the given resource is not one of
|
||||
* an IProject, IFolder, or IFile.
|
||||
*/
|
||||
public ICProject getCProject(IResource resource) {
|
||||
switch (resource.getType()) {
|
||||
case IResource.FOLDER:
|
||||
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:
|
||||
IProject project = resource.getProject();
|
||||
if (project == null)
|
||||
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) {
|
||||
// c model doesn't exist: cannot find any project
|
||||
// C model doesn't exist: cannot find any project.
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -111,7 +99,7 @@ public class CModel extends Openable implements ICModel {
|
|||
|
||||
@Override
|
||||
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) {
|
||||
runOperation(new CopyResourceElementsOperation(elements, containers, replace), elements,
|
||||
siblings, renamings, monitor);
|
||||
|
@ -123,7 +111,7 @@ public class CModel extends Openable implements ICModel {
|
|||
|
||||
@Override
|
||||
public void delete(ICElement[] elements, boolean force, IProgressMonitor monitor)
|
||||
throws CModelException {
|
||||
throws CModelException {
|
||||
CModelOperation op;
|
||||
if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) {
|
||||
op = new DeleteResourceElementsOperation(elements, force);
|
||||
|
@ -135,7 +123,7 @@ public class CModel extends Openable implements ICModel {
|
|||
|
||||
@Override
|
||||
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) {
|
||||
runOperation(new MoveResourceElementsOperation(elements, containers, replace), elements,
|
||||
siblings, renamings, monitor);
|
||||
|
@ -147,7 +135,7 @@ public class CModel extends Openable implements ICModel {
|
|||
|
||||
@Override
|
||||
public void rename(ICElement[] elements, ICElement[] destinations, String[] renamings,
|
||||
boolean force, IProgressMonitor monitor) throws CModelException {
|
||||
boolean force, IProgressMonitor monitor) throws CModelException {
|
||||
CModelOperation op;
|
||||
if (elements != null && elements[0] != null && elements[0].getElementType() <= ICElement.C_UNIT) {
|
||||
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,
|
||||
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 {
|
||||
// determine my children
|
||||
// Determine my children.
|
||||
IWorkspaceRoot root = (IWorkspaceRoot) getResource();
|
||||
IProject[] projects = root.getProjects();
|
||||
for (IProject project : projects) {
|
||||
|
@ -233,12 +221,12 @@ public class CModel extends Openable implements ICModel {
|
|||
public ICElement getHandleFromMemento(String token, MementoTokenizer memento) {
|
||||
switch (token.charAt(0)) {
|
||||
case CEM_CPROJECT:
|
||||
if (!memento.hasMoreTokens()) return this;
|
||||
if (!memento.hasMoreTokens())
|
||||
return this;
|
||||
String projectName = memento.nextToken();
|
||||
CElement project = (CElement) getCProject(projectName);
|
||||
if (project != null) {
|
||||
if (project != null)
|
||||
return project.getHandleFromMemento(memento);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
*/
|
||||
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
|
||||
|
||||
|
@ -122,7 +122,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
* Queue of reconcile deltas on working copies that have yet to be fired.
|
||||
* 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.
|
||||
|
@ -137,16 +137,16 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
protected Map<ICElement, ICElement> elementsOutOfSynchWithBuffers = new HashMap<ICElement, ICElement>(11);
|
||||
protected Map<ICElement, ICElement> elementsOutOfSynchWithBuffers = new HashMap<>(11);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
@ -161,7 +161,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
/**
|
||||
* 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.
|
||||
|
@ -172,7 +172,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
/**
|
||||
* 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 = {};
|
||||
|
||||
|
@ -244,8 +244,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
}
|
||||
}
|
||||
|
||||
// In case this is an external resource see if we can find
|
||||
// a file for it.
|
||||
// In case this is an external resource see if we can find a file for it.
|
||||
if (res == null) {
|
||||
res= ResourceLookup.selectFileForLocation(path, null);
|
||||
}
|
||||
|
@ -261,13 +260,13 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
int type = resource.getType();
|
||||
switch (type) {
|
||||
case IResource.PROJECT:
|
||||
return create((IProject)resource);
|
||||
return create((IProject) resource);
|
||||
case IResource.FILE:
|
||||
return create((IFile)resource, cproject);
|
||||
return create((IFile) resource, cproject);
|
||||
case IResource.FOLDER:
|
||||
return create((IFolder)resource, cproject);
|
||||
return create((IFolder) resource, cproject);
|
||||
case IResource.ROOT:
|
||||
return getCModel((IWorkspaceRoot)resource);
|
||||
return getCModel((IWorkspaceRoot) resource);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -291,9 +290,9 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
ICElement[] children = cproject.getChildren();
|
||||
for (int i = 0; i < children.length; ++i) {
|
||||
if (children[i] instanceof ISourceRoot) {
|
||||
ISourceRoot root = (ISourceRoot)children[i];
|
||||
ISourceRoot root = (ISourceRoot) children[i];
|
||||
if (root.isOnSourceEntry(folder)) {
|
||||
// Get the container
|
||||
// Get the container.
|
||||
IPath path = folder.getFullPath();
|
||||
path = path.removeFirstSegments(root.getPath().segmentCount());
|
||||
String[] segments = path.segments();
|
||||
|
@ -304,7 +303,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
return cfolder;
|
||||
}
|
||||
} else if (children[i] instanceof ICContainer) {
|
||||
ICContainer root = (ICContainer)children[i];
|
||||
ICContainer root = (ICContainer) children[i];
|
||||
IPath rootPath = root.getPath();
|
||||
IPath path = folder.getFullPath();
|
||||
if (rootPath.isPrefixOf(path) && cproject.isOnOutputEntry(folder)) {
|
||||
|
@ -389,11 +388,11 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
cfolder = sourceRoot;
|
||||
|
||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||
ArchiveContainer vlib = (ArchiveContainer)cproject.getArchiveContainer();
|
||||
ArchiveContainer vlib = (ArchiveContainer) cproject.getArchiveContainer();
|
||||
celement = new Archive(cfolder, file, (IBinaryArchive) bin);
|
||||
vlib.addChild(celement);
|
||||
} else {
|
||||
BinaryContainer vbin = (BinaryContainer)cproject.getBinaryContainer();
|
||||
BinaryContainer vbin = (BinaryContainer) cproject.getBinaryContainer();
|
||||
celement = new Binary(cfolder, file, (IBinaryObject) bin);
|
||||
vbin.addChild(celement);
|
||||
}
|
||||
|
@ -473,7 +472,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
return null;
|
||||
}
|
||||
|
||||
if(!locationURI.isAbsolute()) {
|
||||
if (!locationURI.isAbsolute()) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
|
@ -531,7 +530,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
|
||||
// Remove from the containers.
|
||||
if (celement instanceof IParent) {
|
||||
CElementInfo info = (CElementInfo)peekAtInfo(celement);
|
||||
CElementInfo info = (CElementInfo) peekAtInfo(celement);
|
||||
if (info != null) {
|
||||
ICElement[] children = info.getChildren();
|
||||
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
|
||||
if (celement instanceof CElement) {
|
||||
try {
|
||||
((CElement)celement).closing(info);
|
||||
((CElement) celement).closing(info);
|
||||
} catch (CModelException e) {
|
||||
//
|
||||
}
|
||||
|
@ -553,8 +552,8 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
// BinaryContainer/ArchiveContainer also.
|
||||
if (celement.getElementType() == ICElement.C_CCONTAINER) {
|
||||
ICProject cproject = celement.getCProject();
|
||||
CProjectInfo pinfo = (CProjectInfo)peekAtInfo(cproject);
|
||||
ArrayList<ICElement> list = new ArrayList<ICElement>(5);
|
||||
CProjectInfo pinfo = (CProjectInfo) peekAtInfo(cproject);
|
||||
ArrayList<ICElement> list = new ArrayList<>(5);
|
||||
if (pinfo != null && pinfo.vBin != null) {
|
||||
if (peekAtInfo(pinfo.vBin) != null) {
|
||||
try {
|
||||
|
@ -594,7 +593,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
}
|
||||
|
||||
// Remove the child from the parent list.
|
||||
//Parent parent = (Parent)celement.getParent();
|
||||
//Parent parent = (Parent) celement.getParent();
|
||||
//if (parent != null && peekAtInfo(parent) != null) {
|
||||
// parent.removeChild(celement);
|
||||
//}
|
||||
|
@ -611,7 +610,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
if (cfgDesc != null) {
|
||||
ICConfigExtensionReference[] refs = cfgDesc.get(CCorePlugin.BINARY_PARSER_UNIQ_ID);
|
||||
if (refs.length > 0) {
|
||||
ArrayList<BinaryParserConfig> list = new ArrayList<BinaryParserConfig>(refs.length);
|
||||
ArrayList<BinaryParserConfig> list = new ArrayList<>(refs.length);
|
||||
for (ICConfigExtensionReference ref : refs) {
|
||||
BinaryParserConfig config = new BinaryParserConfig(ref);
|
||||
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
|
||||
// so before bailing out give another try?
|
||||
// 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);
|
||||
if (f.length() == 0) {
|
||||
return null;
|
||||
|
@ -724,9 +723,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
System.arraycopy(bytes, 0, array, 0, count);
|
||||
bytes = array;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
} catch (CoreException | IOException e) {
|
||||
return null;
|
||||
} finally {
|
||||
if (is != null) {
|
||||
|
@ -750,8 +747,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
return binFile;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (CoreException e) {
|
||||
} catch (IOException | CoreException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -880,8 +876,8 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
case IResourceChangeEvent.PRE_DELETE:
|
||||
try {
|
||||
if (resource.getType() == IResource.PROJECT &&
|
||||
( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) ||
|
||||
((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){
|
||||
(((IProject) resource).hasNature(CProjectNature.C_NATURE_ID) ||
|
||||
((IProject) resource).hasNature(CCProjectNature.CC_NATURE_ID))) {
|
||||
this.preDeleteProject((IProject) resource);}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
@ -890,8 +886,8 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
case IResourceChangeEvent.PRE_CLOSE:
|
||||
try {
|
||||
if (resource.getType() == IResource.PROJECT &&
|
||||
( ((IProject)resource).hasNature(CProjectNature.C_NATURE_ID) ||
|
||||
((IProject)resource).hasNature(CCProjectNature.CC_NATURE_ID) )){
|
||||
(((IProject) resource).hasNature(CProjectNature.C_NATURE_ID) ||
|
||||
((IProject) resource).hasNature(CCProjectNature.CC_NATURE_ID))) {
|
||||
this.preCloseProject((IProject) resource);}
|
||||
} catch (CoreException e) {
|
||||
}
|
||||
|
@ -902,7 +898,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
if (delta != null) {
|
||||
checkForProjectRename(delta);
|
||||
ICElementDelta[] translatedDeltas = fDeltaProcessor.processResourceDelta(delta);
|
||||
if (translatedDeltas.length > 0) {
|
||||
if (translatedDeltas.length != 0) {
|
||||
for (ICElementDelta translatedDelta : translatedDeltas) {
|
||||
registerCModelDelta(translatedDelta);
|
||||
}
|
||||
|
@ -919,18 +915,18 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
|
||||
@Override
|
||||
public void handleEvent(CProjectDescriptionEvent event) {
|
||||
switch(event.getEventType()) {
|
||||
switch (event.getEventType()) {
|
||||
case CProjectDescriptionEvent.APPLIED:
|
||||
CProjectDescription newDes = (CProjectDescription)event.getNewCProjectDescription();
|
||||
CProjectDescription oldDes = (CProjectDescription)event.getOldCProjectDescription();
|
||||
if(oldDes != null && newDes != null) {
|
||||
CProjectDescription newDes = (CProjectDescription) event.getNewCProjectDescription();
|
||||
CProjectDescription oldDes = (CProjectDescription) event.getOldCProjectDescription();
|
||||
if (oldDes != null && newDes != null) {
|
||||
ICConfigurationDescription newCfg = newDes.getDefaultSettingConfiguration();
|
||||
ICConfigurationDescription oldCfg = oldDes.getDefaultSettingConfiguration();
|
||||
int flags = 0;
|
||||
if(oldCfg != null && newCfg != null){
|
||||
if(newCfg.getId().equals(oldCfg.getId())){
|
||||
if (oldCfg != null && newCfg != null) {
|
||||
if (newCfg.getId().equals(oldCfg.getId())) {
|
||||
ICDescriptionDelta cfgDelta = findCfgDelta(event.getProjectDelta(), newCfg.getId());
|
||||
if(cfgDelta != null){
|
||||
if (cfgDelta != null) {
|
||||
flags = cfgDelta.getChangeFlags() & (ICDescriptionDelta.EXT_REF | ICDescriptionDelta.OWNER);
|
||||
}
|
||||
} else {
|
||||
|
@ -965,13 +961,13 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
}
|
||||
}
|
||||
|
||||
private ICDescriptionDelta findCfgDelta(ICDescriptionDelta delta, String id){
|
||||
if(delta == null)
|
||||
private ICDescriptionDelta findCfgDelta(ICDescriptionDelta delta, String id) {
|
||||
if (delta == null)
|
||||
return null;
|
||||
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();
|
||||
if(s != null && id.equals(s.getId()))
|
||||
if (s != null && id.equals(s.getId()))
|
||||
return children[i];
|
||||
}
|
||||
return null;
|
||||
|
@ -979,7 +975,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
|
||||
@Override
|
||||
public void contentTypeChanged(ContentTypeChangeEvent event) {
|
||||
ContentTypeProcessor.processContentTypeChanges(new ContentTypeChangeEvent[]{ event });
|
||||
ContentTypeProcessor.processContentTypeChanges(new ContentTypeChangeEvent[] { event });
|
||||
}
|
||||
|
||||
public void contentTypeChanged(ContentTypeChangeEvent[] events) {
|
||||
|
@ -1020,7 +1016,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
fire(delta, ElementChangedEvent.POST_CHANGE);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return Status.OK_STATUS;
|
||||
|
@ -1123,7 +1119,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
}
|
||||
if (deltaToNotify != null) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
@ -1197,7 +1193,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
ICElement element = delta.getElement();
|
||||
if (cRoot.equals(element)) {
|
||||
for (ICElementDelta child : delta.getAffectedChildren()) {
|
||||
CElementDelta projectDelta = (CElementDelta)child;
|
||||
CElementDelta projectDelta = (CElementDelta) child;
|
||||
rootDelta.insertDeltaTree(projectDelta.getElement(), projectDelta);
|
||||
insertedTree = true;
|
||||
}
|
||||
|
@ -1209,7 +1205,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
}
|
||||
}
|
||||
} else {
|
||||
rootDelta.insertDeltaTree(element, (CElementDelta)delta);
|
||||
rootDelta.insertDeltaTree(element, (CElementDelta) delta);
|
||||
insertedTree = true;
|
||||
}
|
||||
}
|
||||
|
@ -1263,12 +1259,12 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
* its ancestors). So returns without updating the cache.
|
||||
*/
|
||||
protected synchronized void putInfos(ICElement openedElement, Map<ICElement, CElementInfo> newElements) {
|
||||
// remove children
|
||||
// Remove children.
|
||||
Object existingInfo = this.cache.peekAtInfo(openedElement);
|
||||
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) {
|
||||
CElement child = (CElement)children[i];
|
||||
CElement child = (CElement) children[i];
|
||||
try {
|
||||
child.close();
|
||||
} catch (CModelException e) {
|
||||
|
@ -1287,7 +1283,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
* but does not close this element.
|
||||
*/
|
||||
protected synchronized void removeChildrenInfo(ICElement openedElement) {
|
||||
// remove children
|
||||
// Remove children.
|
||||
Object existingInfo = this.cache.peekAtInfo(openedElement);
|
||||
if (openedElement instanceof IParent && existingInfo instanceof CElementInfo) {
|
||||
ICElement[] children = ((CElementInfo) existingInfo).getChildren();
|
||||
|
@ -1316,7 +1312,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
public Map<ICElement, CElementInfo> getTemporaryCache() {
|
||||
Map<ICElement, CElementInfo> result = this.temporaryCache.get();
|
||||
if (result == null) {
|
||||
result = new HashMap<ICElement, CElementInfo>();
|
||||
result = new HashMap<>();
|
||||
this.temporaryCache.set(result);
|
||||
}
|
||||
return result;
|
||||
|
@ -1382,25 +1378,25 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
}
|
||||
|
||||
private void preDeleteProject(IProject project) {
|
||||
// remove binary parsers
|
||||
// Remove binary parsers
|
||||
binaryParsersMap.remove(project);
|
||||
// stop the binary runner for this project
|
||||
// Stop the binary runner for this project
|
||||
removeBinaryRunner(project);
|
||||
// stop indexing jobs for this project
|
||||
// Stop indexing jobs for this project
|
||||
CCoreInternals.getPDOMManager().preDeleteProject(create(project));
|
||||
}
|
||||
|
||||
private void preCloseProject(IProject project) {
|
||||
// remove binary parsers
|
||||
// Remove binary parsers
|
||||
binaryParsersMap.remove(project);
|
||||
// stop the binary runner for this project
|
||||
// Stop the binary runner for this project
|
||||
removeBinaryRunner(project);
|
||||
// stop indexing jobs for this project
|
||||
// Stop indexing jobs for this project
|
||||
CCoreInternals.getPDOMManager().preCloseProject(create(project));
|
||||
}
|
||||
|
||||
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)
|
||||
factory = BufferManager.getDefaultBufferManager().getDefaultBufferFactory();
|
||||
|
||||
|
@ -1431,7 +1427,7 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
|
||||
Map<ITranslationUnit, WorkingCopy> perFactoryWorkingCopies = sharedWorkingCopies.get(factory);
|
||||
if (perFactoryWorkingCopies == null) {
|
||||
perFactoryWorkingCopies = new HashMap<ITranslationUnit, WorkingCopy>();
|
||||
perFactoryWorkingCopies = new HashMap<>();
|
||||
sharedWorkingCopies.put(factory, perFactoryWorkingCopies);
|
||||
}
|
||||
WorkingCopy workingCopy = perFactoryWorkingCopies.get(tu);
|
||||
|
@ -1439,8 +1435,8 @@ public class CModelManager implements IResourceChangeListener, IContentTypeChang
|
|||
workingCopy.useCount++;
|
||||
return workingCopy;
|
||||
}
|
||||
CreateWorkingCopyOperation op = new CreateWorkingCopyOperation(tu, perFactoryWorkingCopies,
|
||||
factory, requestor);
|
||||
CreateWorkingCopyOperation op =
|
||||
new CreateWorkingCopyOperation(tu, perFactoryWorkingCopies, factory, requestor);
|
||||
op.runOperation(monitor);
|
||||
return (IWorkingCopy) op.getResultElements()[0];
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.model;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
@ -160,21 +161,21 @@ public class CProject extends Openable implements ICProject {
|
|||
|
||||
@Override
|
||||
public IIncludeReference[] getIncludeReferences() throws CModelException {
|
||||
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
|
||||
CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this);
|
||||
IIncludeReference[] incRefs = null;
|
||||
if (pinfo != null) {
|
||||
incRefs = pinfo.incReferences;
|
||||
}
|
||||
if (incRefs == null) {
|
||||
IPathEntry[] entries = getResolvedPathEntries();
|
||||
ArrayList<IncludeReference> list = new ArrayList<IncludeReference>(entries.length);
|
||||
ArrayList<IncludeReference> list = new ArrayList<>(entries.length);
|
||||
for (IPathEntry entrie : entries) {
|
||||
if (entrie.getEntryKind() == IPathEntry.CDT_INCLUDE) {
|
||||
IIncludeEntry entry = (IIncludeEntry) entrie;
|
||||
list.add(new IncludeReference(this, entry));
|
||||
}
|
||||
}
|
||||
incRefs = list.toArray(new IIncludeReference[0]);
|
||||
incRefs = list.toArray(new IIncludeReference[list.size()]);
|
||||
if (pinfo != null) {
|
||||
pinfo.incReferences = incRefs;
|
||||
}
|
||||
|
@ -184,7 +185,7 @@ public class CProject extends Openable implements ICProject {
|
|||
|
||||
@Override
|
||||
public ILibraryReference[] getLibraryReferences() throws CModelException {
|
||||
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
|
||||
CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this);
|
||||
ILibraryReference[] libRefs = null;
|
||||
if (pinfo != null) {
|
||||
libRefs = pinfo.libReferences;
|
||||
|
@ -193,7 +194,7 @@ public class CProject extends Openable implements ICProject {
|
|||
if (libRefs == null) {
|
||||
BinaryParserConfig[] binConfigs = CModelManager.getDefault().getBinaryParser(getProject());
|
||||
IPathEntry[] entries = getResolvedPathEntries();
|
||||
ArrayList<ILibraryReference> list = new ArrayList<ILibraryReference>(entries.length);
|
||||
ArrayList<ILibraryReference> list = new ArrayList<>(entries.length);
|
||||
for (IPathEntry entrie : entries) {
|
||||
if (entrie.getEntryKind() == IPathEntry.CDT_LIBRARY) {
|
||||
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) {
|
||||
pinfo.libReferences = libRefs;
|
||||
}
|
||||
|
@ -224,14 +225,13 @@ public class CProject extends Openable implements ICProject {
|
|||
bin = parser.getBinary(entry.getFullLibraryPath());
|
||||
if (bin != null) {
|
||||
if (bin.getType() == IBinaryFile.ARCHIVE) {
|
||||
lib = new LibraryReferenceArchive(cproject, entry, (IBinaryArchive)bin);
|
||||
} else if (bin instanceof IBinaryObject){
|
||||
lib = new LibraryReferenceShared(cproject, entry, (IBinaryObject)bin);
|
||||
lib = new LibraryReferenceArchive(cproject, entry, (IBinaryArchive) bin);
|
||||
} else if (bin instanceof IBinaryObject) {
|
||||
lib = new LibraryReferenceShared(cproject, entry, (IBinaryObject) bin);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (CoreException e) {
|
||||
} catch (IOException | CoreException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ public class CProject extends Openable implements ICProject {
|
|||
String[] propertyNames= preferences.keys();
|
||||
for (String propertyName : propertyNames) {
|
||||
String value= preferences.get(propertyName, null);
|
||||
if (value != null && optionNames.contains(propertyName)){
|
||||
if (value != null && optionNames.contains(propertyName)) {
|
||||
options.put(propertyName, value.trim());
|
||||
}
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ public class CProject extends Openable implements ICProject {
|
|||
@Override
|
||||
public ISourceRoot[] getSourceRoots() throws CModelException {
|
||||
Object[] children = getChildren();
|
||||
ArrayList<ISourceRoot> result = new ArrayList<ISourceRoot>(children.length);
|
||||
ArrayList<ISourceRoot> result = new ArrayList<>(children.length);
|
||||
for (Object element : children) {
|
||||
if (element instanceof ISourceRoot) {
|
||||
result.add((ISourceRoot) element);
|
||||
|
@ -483,7 +483,7 @@ public class CProject extends Openable implements ICProject {
|
|||
*/
|
||||
@Override
|
||||
public ISourceRoot[] getAllSourceRoots() throws CModelException {
|
||||
CProjectInfo pinfo = (CProjectInfo)CModelManager.getDefault().peekAtInfo(this);
|
||||
CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this);
|
||||
ISourceRoot[] roots = null;
|
||||
if (pinfo != null) {
|
||||
if (pinfo.sourceRoots != null) {
|
||||
|
@ -518,7 +518,7 @@ public class CProject extends Openable implements ICProject {
|
|||
}
|
||||
|
||||
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) {
|
||||
if (entrie.getEntryKind() == IPathEntry .CDT_OUTPUT) {
|
||||
list.add(entrie);
|
||||
|
@ -583,14 +583,14 @@ public class CProject extends Openable implements ICProject {
|
|||
//IPathEntry[] entries = getResolvedPathEntries();
|
||||
ICSourceEntry[] entries = null;
|
||||
ICProjectDescription des = CProjectDescriptionManager.getInstance().getProjectDescription(getProject(), false);
|
||||
if(des != null){
|
||||
if (des != null) {
|
||||
ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
|
||||
if(cfg != null)
|
||||
if (cfg != null)
|
||||
entries = cfg.getResolvedSourceEntries();
|
||||
}
|
||||
|
||||
if(entries != null){
|
||||
ArrayList<ISourceRoot> list = new ArrayList<ISourceRoot>(entries.length);
|
||||
if (entries != null) {
|
||||
ArrayList<ISourceRoot> list = new ArrayList<>(entries.length);
|
||||
for (ICSourceEntry sourceEntry : entries) {
|
||||
ISourceRoot root = getSourceRoot(sourceEntry);
|
||||
if (root != null) {
|
||||
|
@ -599,7 +599,7 @@ public class CProject extends Openable implements ICProject {
|
|||
}
|
||||
return list;
|
||||
}
|
||||
return new ArrayList<ISourceRoot>(0);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
protected boolean computeChildren(OpenableInfo info, IResource res) throws CModelException {
|
||||
|
@ -712,7 +712,7 @@ public class CProject extends Openable implements ICProject {
|
|||
*/
|
||||
public void resetCaches() {
|
||||
CProjectInfo pinfo = (CProjectInfo) CModelManager.getDefault().peekAtInfo(this);
|
||||
if (pinfo != null){
|
||||
if (pinfo != null) {
|
||||
pinfo.resetCaches();
|
||||
}
|
||||
}
|
||||
|
@ -736,7 +736,7 @@ public class CProject extends Openable implements ICProject {
|
|||
if (!rootPath.isAbsolute()) {
|
||||
rootPath= getProject().getFullPath().append(rootPath);
|
||||
}
|
||||
CElement root = (CElement)findSourceRoot(rootPath);
|
||||
CElement root = (CElement) findSourceRoot(rootPath);
|
||||
if (root != null) {
|
||||
if (token != null) {
|
||||
return root.getHandleFromMemento(token, memento);
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.eclipse.core.runtime.IPath;
|
|||
* (e.g. closing them or updating binary containers).
|
||||
*/
|
||||
final class DeltaProcessor {
|
||||
|
||||
/**
|
||||
* 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];
|
||||
|
||||
// Hold on the element being renamed.
|
||||
private ICElement movedFromElement = null;
|
||||
private ICElement movedFromElement;
|
||||
|
||||
/**
|
||||
* Creates the create corresponding to this resource.
|
||||
|
@ -148,7 +147,7 @@ final class DeltaProcessor {
|
|||
Openable parent = (Openable) child.getParent();
|
||||
if (parent != null && parent.isOpen()) {
|
||||
CElementInfo info = parent.getElementInfo();
|
||||
// Check if the element exits
|
||||
// Check if the element exists.
|
||||
if (!info.includesChild(child)) {
|
||||
info.addChild(child);
|
||||
}
|
||||
|
@ -166,7 +165,7 @@ final class DeltaProcessor {
|
|||
// Remove the child from the parent list.
|
||||
ICElement parent = child.getParent();
|
||||
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)
|
||||
nonCResourcesChanged(parent, delta);
|
||||
} else if (current instanceof ICProject) {
|
||||
ICProject cprj = (ICProject)current;
|
||||
ICProject cprj = (ICProject) current;
|
||||
CModel cModel = CModelManager.getDefault().getCModel();
|
||||
if (!cprj.getProject().isOpen() || cModel.findCProject(cprj.getProject()) == null) {
|
||||
nonCResourcesChanged(parent, delta);
|
||||
|
|
|
@ -31,25 +31,23 @@ public class DestroyWorkingCopyOperation extends CModelOperation {
|
|||
*/
|
||||
@Override
|
||||
protected void executeOperation() throws CModelException {
|
||||
|
||||
WorkingCopy workingCopy = getWorkingCopy();
|
||||
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();
|
||||
if (!workingCopy.getParent().exists()) {
|
||||
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);
|
||||
if (wc != null) {
|
||||
//System.out.println("Destroying shared working copy " + workingCopy.toStringWithAncestors());//$NON-NLS-1$
|
||||
//CModelManager.getDefault().fire(delta, ElementChangedEvent.POST_RECONCILE);
|
||||
}
|
||||
|
||||
|
||||
// report C deltas
|
||||
// Report C deltas
|
||||
CElementDelta delta = new CElementDelta(this.getCModel());
|
||||
delta.removed(workingCopy);
|
||||
addDelta(delta);
|
||||
|
|
|
@ -1320,7 +1320,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
try {
|
||||
IMarker[] markers = project.findMarkers(ICModelMarker.PATHENTRY_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
|
||||
if (markers != null && markers.length > 0) {
|
||||
ArrayList<ICModelStatus> problemList = new ArrayList<ICModelStatus>();
|
||||
ArrayList<ICModelStatus> problemList = new ArrayList<>();
|
||||
for (IPathEntry entry : entries) {
|
||||
ICModelStatus status = PathEntryUtil.validatePathEntry(project2, entry, true, false);
|
||||
if (!status.isOK()) {
|
||||
|
@ -1349,7 +1349,7 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange
|
|||
int type = element.getElementType();
|
||||
|
||||
// Handle open, closing and removing of projects
|
||||
if ( type == ICElement.C_PROJECT) {
|
||||
if (type == ICElement.C_PROJECT) {
|
||||
ICProject cproject = (ICProject)element;
|
||||
if ((kind == ICElementDelta.REMOVED || kind == ICElementDelta.ADDED)) {
|
||||
if (kind == ICElementDelta.REMOVED) {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
|
@ -31,26 +31,21 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
|
|||
private List<IPathEntryStoreListener> fListeners;
|
||||
private IPathEntryStore fStore;
|
||||
|
||||
public PathEntryStoreProxy(IProject project){
|
||||
public PathEntryStoreProxy(IProject project) {
|
||||
super(project, PathEntryManager.PATHENTRY_STORE_UNIQ_ID);
|
||||
fListeners = Collections.synchronizedList(new ArrayList<IPathEntryStoreListener>());
|
||||
}
|
||||
|
||||
public IPathEntryStore getStore(){
|
||||
public IPathEntryStore getStore() {
|
||||
providerRequested();
|
||||
return fStore;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.resources.IPathEntryStore#addPathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void addPathEntryStoreListener(IPathEntryStoreListener listener) {
|
||||
fListeners.add(listener);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.resources.IPathEntryStore#removePathEntryStoreListener(org.eclipse.cdt.core.resources.IPathEntryStoreListener)
|
||||
*/
|
||||
@Override
|
||||
public void removePathEntryStoreListener(IPathEntryStoreListener listener) {
|
||||
fListeners.remove(listener);
|
||||
|
@ -61,7 +56,7 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
|
|||
notifyListeners(evt);
|
||||
}
|
||||
|
||||
private void notifyListeners(PathEntryStoreChangedEvent evt){
|
||||
private void notifyListeners(PathEntryStoreChangedEvent evt) {
|
||||
IPathEntryStoreListener[] observers = new IPathEntryStoreListener[fListeners.size()];
|
||||
fListeners.toArray(observers);
|
||||
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
|
||||
public void close() {
|
||||
super.close();
|
||||
|
@ -89,8 +81,8 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public ICExtensionReference getExtensionReference() {
|
||||
//TODO: calculate
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -109,7 +101,6 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
|
|||
public void setRawPathEntries(IPathEntry[] entries) throws CoreException {
|
||||
providerRequested();
|
||||
fStore.setRawPathEntries(entries);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -118,9 +109,8 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Object createDefaultProvider(ICConfigurationDescription cfgDes,
|
||||
boolean newStile) {
|
||||
if(newStile){
|
||||
protected Object createDefaultProvider(ICConfigurationDescription cfgDes, boolean newStile) {
|
||||
if (newStile) {
|
||||
return new ConfigBasedPathEntryStore(getProject());
|
||||
}
|
||||
return new DefaultPathEntryStore(getProject());
|
||||
|
@ -146,9 +136,8 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void postProcessProviderChange(Object newProvider,
|
||||
Object oldProvider) {
|
||||
// if(oldProvider != null)
|
||||
protected void postProcessProviderChange(Object newProvider, Object oldProvider) {
|
||||
// if (oldProvider != null)
|
||||
fireContentChangedEvent(getProject());
|
||||
}
|
||||
|
||||
|
@ -156,10 +145,9 @@ public class PathEntryStoreProxy extends AbstractCExtensionProxy implements IPat
|
|||
protected boolean doHandleEvent(CProjectDescriptionEvent event) {
|
||||
IPathEntryStore oldStore = fStore;
|
||||
boolean result = super.doHandleEvent(event);
|
||||
if(!result)
|
||||
if (!result)
|
||||
postProcessProviderChange(fStore, oldStore);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.eclipse.cdt.core.model.IPathEntryContainer;
|
|||
import org.eclipse.cdt.core.model.IProjectEntry;
|
||||
import org.eclipse.cdt.core.model.ISourceEntry;
|
||||
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
||||
import org.eclipse.cdt.utils.UNCPathConverter;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
|
|
@ -37,13 +37,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
*/
|
||||
|
||||
public class SourceManipulation extends Parent implements ISourceManipulation, ISourceReference {
|
||||
|
||||
/**
|
||||
* An empty list of Strings
|
||||
* An empty array of Strings
|
||||
*/
|
||||
protected static final String[] fgEmptyStrings = {};
|
||||
private boolean fIsActive= true;
|
||||
private short fIndex= 0;
|
||||
private short fIndex;
|
||||
|
||||
public SourceManipulation(ICElement parent, String name, int type) {
|
||||
super(parent, name, type);
|
||||
|
@ -54,7 +53,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
*/
|
||||
@Override
|
||||
public void copy(ICElement container, ICElement sibling, String rename, boolean force,
|
||||
IProgressMonitor monitor) throws CModelException {
|
||||
IProgressMonitor monitor) throws CModelException {
|
||||
if (container == null) {
|
||||
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 {
|
||||
return (SourceManipulationInfo)getElementInfo();
|
||||
return (SourceManipulationInfo) getElementInfo();
|
||||
}
|
||||
|
||||
public boolean isIdentical(SourceManipulation other) throws CModelException{
|
||||
return (this.equals(other)
|
||||
&& (this.getSourceManipulationInfo().hasSameContentsAs(other.getSourceManipulationInfo())));
|
||||
return this.equals(other)
|
||||
&& (this.getSourceManipulationInfo().hasSameContentsAs(other.getSourceManipulationInfo()));
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* @see CElement#generateInfos
|
||||
*/
|
||||
@Override
|
||||
|
@ -239,7 +238,7 @@ public class SourceManipulation extends Parent implements ISourceManipulation, I
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* @see CElement
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -9,10 +9,8 @@
|
|||
* QNX Software Systems - Initial API and implementation
|
||||
* Anton Leherbauer (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||
|
@ -25,7 +23,6 @@ import org.eclipse.core.runtime.Path;
|
|||
* SourceRoot
|
||||
*/
|
||||
public class SourceRoot extends CContainer implements ISourceRoot {
|
||||
|
||||
ICSourceEntry sourceEntry;
|
||||
|
||||
/**
|
||||
|
@ -47,18 +44,12 @@ public class SourceRoot extends CContainer implements ISourceRoot {
|
|||
return sourceEntry;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ISourceRoot#isOnclasspath(org.eclipse.cdt.core.model.ICElement)
|
||||
*/
|
||||
@Override
|
||||
public boolean isOnSourceEntry(ICElement element) {
|
||||
IPath path = element.getPath();
|
||||
return this.isOnSourceEntry(path);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.ISourceRoot#isOnSourceEntry(org.eclipse.core.resources.IResource)
|
||||
*/
|
||||
@Override
|
||||
public boolean isOnSourceEntry(IResource res) {
|
||||
IPath path = res.getFullPath();
|
||||
|
|
|
@ -78,27 +78,24 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
op.runOperation(monitor);
|
||||
} else {
|
||||
String contents = this.getSource();
|
||||
if (contents == null) return;
|
||||
if (contents == null)
|
||||
return;
|
||||
|
||||
try {
|
||||
IFile originalRes = (IFile)original.getResource();
|
||||
IFile originalRes = (IFile) original.getResource();
|
||||
String encoding = null;
|
||||
try {
|
||||
encoding = originalRes.getCharset();
|
||||
} catch (CoreException e) {
|
||||
// use no encoding
|
||||
// Use no encoding.
|
||||
}
|
||||
byte[] bytes = encoding == null ? contents.getBytes() : contents.getBytes(encoding);
|
||||
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
|
||||
if (originalRes.exists()) {
|
||||
originalRes.setContents(
|
||||
stream,
|
||||
force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
|
||||
null);
|
||||
int updateFlags = force ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY;
|
||||
originalRes.setContents(stream, updateFlags, monitor);
|
||||
} else {
|
||||
originalRes.create(
|
||||
stream,
|
||||
force,
|
||||
monitor);
|
||||
originalRes.create(stream, force, monitor);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new CModelException(e, ICModelStatusConstants.IO_EXCEPTION);
|
||||
|
@ -118,13 +115,13 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
DestroyWorkingCopyOperation op = new DestroyWorkingCopyOperation(this);
|
||||
op.runOperation(null);
|
||||
} catch (CModelException e) {
|
||||
// do nothing
|
||||
// Do nothing.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -132,7 +129,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
* Returns custom buffer factory
|
||||
*/
|
||||
@Override
|
||||
public IBufferFactory getBufferFactory(){
|
||||
public IBufferFactory getBufferFactory() {
|
||||
return this.bufferFactory;
|
||||
}
|
||||
|
||||
|
@ -170,7 +167,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
return null; // oops !!
|
||||
}
|
||||
|
||||
// look for it.
|
||||
// Look for it.
|
||||
ICElement element = workingCopyElement;
|
||||
ArrayList<ICElement> children = new ArrayList<ICElement>();
|
||||
while (element != null && element.getElementType() != ICElement.C_UNIT) {
|
||||
|
@ -221,7 +218,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IWorkingCopy getWorkingCopy(IProgressMonitor monitor){
|
||||
public IWorkingCopy getWorkingCopy(IProgressMonitor monitor) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -262,7 +259,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
}
|
||||
super.open(monitor);
|
||||
//if (monitor != null && monitor.isCanceled()) return;
|
||||
//if (this.problemRequestor != null && this.problemRequestor.isActive()){
|
||||
//if (this.problemRequestor != null && this.problemRequestor.isActive()) {
|
||||
// this.problemRequestor.beginReporting();
|
||||
// TranslationUnitProblemFinder.process(this, this.problemRequestor, monitor);
|
||||
// this.problemRequestor.endReporting();
|
||||
|
@ -280,7 +277,7 @@ public class WorkingCopy extends TranslationUnit implements IWorkingCopy {
|
|||
return null;
|
||||
|
||||
// Set the buffer source if needed
|
||||
if (buffer.getContents() == null){
|
||||
if (buffer.getContents() == null) {
|
||||
ITranslationUnit original= this.getOriginalElement();
|
||||
IBuffer originalBuffer = null;
|
||||
try {
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.index;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
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.IProgressMonitor;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Interface for accessing the index for one or more projects.
|
||||
*
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
|
@ -45,9 +45,6 @@ public class CPPASTLambdaExpression extends ASTNode implements ICPPASTLambdaExpr
|
|||
fCaptureDefault= CaptureDefault.UNSPECIFIED;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTExpression#copy()
|
||||
*/
|
||||
@Override
|
||||
public CPPASTLambdaExpression copy() {
|
||||
return copy(CopyStyle.withoutLocations);
|
||||
|
|
|
@ -12,6 +12,13 @@
|
|||
*******************************************************************************/
|
||||
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.index.IIndexManager;
|
||||
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.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
|
||||
* fragments contributed via the CIndex extension point.
|
||||
|
@ -431,14 +431,15 @@ public final class IndexProviderManager implements IElementChangedListener {
|
|||
case ICElement.C_MODEL:
|
||||
// Loop through the children
|
||||
ICElementDelta[] children = delta.getAffectedChildren();
|
||||
for (int i = 0; i < children.length; ++i)
|
||||
for (int i = 0; i < children.length; ++i) {
|
||||
processDelta(children[i]);
|
||||
}
|
||||
break;
|
||||
case ICElement.C_PROJECT:
|
||||
final ICProject cproject = (ICProject) delta.getElement();
|
||||
switch (delta.getKind()) {
|
||||
case ICElementDelta.REMOVED:
|
||||
List<ProvisionMapKey> toRemove = new ArrayList<ProvisionMapKey>();
|
||||
List<ProvisionMapKey> toRemove = new ArrayList<>();
|
||||
for (ProvisionMapKey key : provisionMap.keySet()) {
|
||||
if (key.getProject().equals(cproject.getProject())) {
|
||||
toRemove.add(key);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom;
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class CModelListener implements IElementChangedListener, IResourceChangeL
|
|||
return;
|
||||
|
||||
// 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);
|
||||
|
||||
// bug 171834 update last recently changed sources
|
||||
|
@ -84,7 +84,7 @@ public class CModelListener implements IElementChangedListener, IResourceChangeL
|
|||
break;
|
||||
case ICElement.C_PROJECT:
|
||||
// Find the appropriate indexer and pass the delta on
|
||||
final ICProject project = (ICProject)delta.getElement();
|
||||
final ICProject project = (ICProject) delta.getElement();
|
||||
switch (delta.getKind()) {
|
||||
case ICElementDelta.ADDED:
|
||||
fManager.addProject(project);
|
||||
|
|
|
@ -53,7 +53,7 @@ public class DeltaAnalyzer {
|
|||
final ICElement element = delta.getElement();
|
||||
switch (element.getElementType()) {
|
||||
case ICElement.C_UNIT:
|
||||
ITranslationUnit tu = (ITranslationUnit)element;
|
||||
ITranslationUnit tu = (ITranslationUnit) element;
|
||||
if (!tu.isWorkingCopy()) {
|
||||
handled.add(element.getResource());
|
||||
switch (delta.getKind()) {
|
||||
|
|
|
@ -14,17 +14,20 @@ import org.eclipse.cdt.core.settings.model.ICConfigExtensionReference;
|
|||
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.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICExtension {
|
||||
public IProject getProject();
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #getConfigExtensionReference()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public ICExtensionReference getExtensionReference();
|
||||
|
||||
/**
|
||||
* @since 5.2
|
||||
*/
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Markus Schorn - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
@ -60,8 +59,7 @@ public class CContentTypes {
|
|||
// fallback to workspace wide definitions.
|
||||
matcher= Platform.getContentTypeManager();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
matcher= Platform.getContentTypeManager();
|
||||
}
|
||||
|
||||
|
@ -95,8 +93,7 @@ public class CContentTypes {
|
|||
if (isPreferredContentType(candidate, preferCpp)) {
|
||||
priority+= 1;
|
||||
}
|
||||
}
|
||||
catch (CoreException e) {
|
||||
} catch (CoreException e) {
|
||||
// skip it
|
||||
}
|
||||
if (priority > bestPriority) {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2013 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Rapperswil, University of applied sciences and others
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* 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 returnValue;
|
||||
// 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.
|
||||
private int[] parameterOrder;
|
||||
private VisibilityEnum visibility = VisibilityEnum.v_private;
|
||||
|
|
|
@ -26,8 +26,8 @@ import org.eclipse.core.runtime.IPath;
|
|||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
public class CRefactoringMatchStore {
|
||||
private Map<IFile, IPath> fFileToPathMap= new HashMap<IFile, IPath>();
|
||||
private Map<IPath, SortedMap<CRefactoringMatch, CRefactoringMatch>> fPathToMatches= new HashMap<IPath, SortedMap<CRefactoringMatch, CRefactoringMatch>>();
|
||||
private Map<IFile, IPath> fFileToPathMap= new HashMap<>();
|
||||
private Map<IPath, SortedMap<CRefactoringMatch, CRefactoringMatch>> fPathToMatches= new HashMap<>();
|
||||
private Comparator<CRefactoringMatch> fOffsetComparator;
|
||||
|
||||
public CRefactoringMatchStore() {
|
||||
|
@ -50,7 +50,7 @@ public class CRefactoringMatchStore {
|
|||
private Map<CRefactoringMatch, CRefactoringMatch> getMapForPath(IPath path, boolean create) {
|
||||
SortedMap<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path);
|
||||
if (map == null && create) {
|
||||
map= new TreeMap<CRefactoringMatch, CRefactoringMatch>(fOffsetComparator);
|
||||
map= new TreeMap<>(fOffsetComparator);
|
||||
fPathToMatches.put(path, map);
|
||||
}
|
||||
return map;
|
||||
|
@ -73,7 +73,7 @@ public class CRefactoringMatchStore {
|
|||
}
|
||||
|
||||
public List<IFile> getFileList() {
|
||||
return new ArrayList<IFile>(fFileToPathMap.keySet());
|
||||
return new ArrayList<>(fFileToPathMap.keySet());
|
||||
}
|
||||
|
||||
public boolean contains(IResource file) {
|
||||
|
|
|
@ -83,9 +83,9 @@ public class RenameCSourceFolderChange extends Change {
|
|||
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();
|
||||
for (ICConfigurationDescription cfg : cfgs){
|
||||
for (ICConfigurationDescription cfg : cfgs) {
|
||||
ICSourceEntry[] entries = cfg.getSourceEntries();
|
||||
entries = renameEntry(entries);
|
||||
cfg.setSourceEntries(entries);
|
||||
|
@ -93,25 +93,24 @@ public class RenameCSourceFolderChange extends Change {
|
|||
CCorePlugin.getDefault().setProjectDescription(project, des, false, new NullProgressMonitor());
|
||||
}
|
||||
|
||||
private ICSourceEntry[] renameEntry(ICSourceEntry[] entries){
|
||||
private ICSourceEntry[] renameEntry(ICSourceEntry[] entries) {
|
||||
Set<ICSourceEntry> set = new HashSet<>();
|
||||
for (ICSourceEntry se : entries){
|
||||
String seLocation = se.getName();
|
||||
if (seLocation.equals(oldName.toPortableString())) {
|
||||
ICSourceEntry newSE = new CSourceEntry(newName, se.getExclusionPatterns(), se.getFlags());
|
||||
set.add(newSE);
|
||||
for (ICSourceEntry entry : entries) {
|
||||
String entryPath = entry.getName();
|
||||
if (entryPath.equals(oldName.toString())) {
|
||||
set.add(new CSourceEntry(newName, entry.getExclusionPatterns(), entry.getFlags()));
|
||||
} else {
|
||||
Set<IPath> exPatters = new HashSet<>();
|
||||
for (IPath filter : se.getExclusionPatterns()) {
|
||||
IPath oldSegments = oldName.removeFirstSegments(oldName.segmentCount() -1);
|
||||
if (filter.equals(oldSegments)) {
|
||||
exPatters.add(newName.removeFirstSegments(newName.segmentCount() - 1));
|
||||
IPath oldSegments = oldName.removeFirstSegments(oldName.segmentCount() - 1);
|
||||
Set<IPath> exclusionPatterns = new HashSet<>();
|
||||
for (IPath pattern : entry.getExclusionPatterns()) {
|
||||
if (pattern.equals(oldSegments)) {
|
||||
exclusionPatterns.add(newName.removeFirstSegments(newName.segmentCount() - 1));
|
||||
} 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()]);
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
* IBM Corporation - initial API and implementation
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.text.correction.proposals;
|
||||
|
||||
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$
|
||||
}
|
||||
fTranslationUnit= tu;
|
||||
fLinkedProposalModel= null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,12 +133,9 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
|
|||
fLinkedProposalModel= model;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see ICompletionProposal#getAdditionalProposalInfo()
|
||||
*/
|
||||
@Override
|
||||
public String getAdditionalProposalInfo() {
|
||||
final StringBuffer buf= new StringBuffer();
|
||||
final StringBuilder buf= new StringBuilder();
|
||||
|
||||
try {
|
||||
final TextChange change= getTextChange();
|
||||
|
@ -218,13 +213,13 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
|
|||
|
||||
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 {
|
||||
int startLine= text.getLineOfOffset(startOffset);
|
||||
int endLine= text.getLineOfOffset(endOffset);
|
||||
|
||||
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);
|
||||
buf.append("...<br>"); //$NON-NLS-1$
|
||||
dotsAdded= true;
|
||||
|
@ -237,7 +232,7 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
|
|||
buf.append("...<br>"); //$NON-NLS-1$
|
||||
dotsAdded= true;
|
||||
} 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;
|
||||
}
|
||||
|
@ -250,8 +245,8 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
|
|||
int from= Math.max(start, startOffset);
|
||||
int to= Math.min(end, endOffset);
|
||||
String content= text.get(from, to - from);
|
||||
if (surroundLinesOnly && (from == start) && Strings.containsOnlyWhitespaces(content)) {
|
||||
continue; // ignore empty lines except when range started in the middle of a line
|
||||
if (surroundLinesOnly && from == start && Strings.containsOnlyWhitespaces(content)) {
|
||||
continue; // Ignore empty lines except when range started in the middle of a line
|
||||
}
|
||||
for (int k= 0; k < content.length(); k++) {
|
||||
char ch= content.charAt(k);
|
||||
|
@ -263,18 +258,15 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
|
|||
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$
|
||||
}
|
||||
}
|
||||
} catch (BadLocationException e) {
|
||||
// ignore
|
||||
// Ignore.
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
|
||||
*/
|
||||
@Override
|
||||
public void apply(IDocument document) {
|
||||
try {
|
||||
|
@ -318,9 +310,6 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.text.correction.ChangeCorrectionProposal#performChange(org.eclipse.jface.text.IDocument, org.eclipse.ui.IEditorPart)
|
||||
*/
|
||||
@Override
|
||||
protected void performChange(IEditorPart part, IDocument document) throws CoreException {
|
||||
try {
|
||||
|
@ -366,7 +355,7 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
|
|||
source= tu.getSource();
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.log(e);
|
||||
source= new String(); // empty
|
||||
source= ""; //$NON-NLS-1$
|
||||
}
|
||||
Document document= new Document(source);
|
||||
document.setInitialLineDelimiter(StubUtility.getLineDelimiterUsed(tu));
|
||||
|
@ -379,15 +368,12 @@ public class TUCorrectionProposal extends ChangeCorrectionProposal {
|
|||
TextEdit rootEdit= new MultiTextEdit();
|
||||
change.setEdit(rootEdit);
|
||||
|
||||
// initialize text change
|
||||
// Initialize text change.
|
||||
IDocument document= change.getCurrentDocument(new NullProgressMonitor());
|
||||
addEdits(document, rootEdit);
|
||||
return change;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.text.correction.ChangeCorrectionProposal#createChange()
|
||||
*/
|
||||
@Override
|
||||
protected final Change createChange() throws CoreException {
|
||||
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());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class CTextFileChange extends TextFileChange {
|
|||
private static final String TEXT_TYPE = "c2"; //$NON-NLS-1$
|
||||
private ITranslationUnit fTranslationUnit;
|
||||
private IWorkingCopy fWorkingCopy;
|
||||
private int fAquireCount;
|
||||
private int fAcquireCount;
|
||||
|
||||
public CTextFileChange(String name, IFile file) {
|
||||
super(name, file);
|
||||
|
@ -65,7 +65,7 @@ public class CTextFileChange extends TextFileChange {
|
|||
@Override
|
||||
protected IDocument acquireDocument(IProgressMonitor pm) throws CoreException {
|
||||
IDocument doc= super.acquireDocument(pm);
|
||||
if (++fAquireCount == 1) {
|
||||
if (++fAcquireCount == 1) {
|
||||
if (fTranslationUnit instanceof TranslationUnit && fWorkingCopy == null) {
|
||||
fWorkingCopy= ((TranslationUnit) fTranslationUnit).getWorkingCopy(null, DocumentAdapter.FACTORY);
|
||||
if (!fTranslationUnit.isOpen()) {
|
||||
|
@ -88,7 +88,7 @@ public class CTextFileChange extends TextFileChange {
|
|||
@Override
|
||||
protected void releaseDocument(IDocument document, IProgressMonitor pm) throws CoreException {
|
||||
super.releaseDocument(document, pm);
|
||||
if (--fAquireCount == 0) {
|
||||
if (--fAcquireCount == 0) {
|
||||
if (fWorkingCopy != null) {
|
||||
fWorkingCopy.destroy();
|
||||
fWorkingCopy= null;
|
||||
|
|
|
@ -6,9 +6,8 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation9
|
||||
* QNX Software Systems - Initial API and implementation9
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.launch.internal.refactoring;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -42,16 +41,10 @@ import org.eclipse.ltk.core.refactoring.participants.RenameParticipant;
|
|||
*
|
||||
* @since 6.0
|
||||
*/
|
||||
public class ResourceRenameParticipant extends RenameParticipant implements
|
||||
IExecutableExtension {
|
||||
|
||||
public class ResourceRenameParticipant extends RenameParticipant implements IExecutableExtension {
|
||||
private String name;
|
||||
|
||||
private IResource resourceBeingRenamed;
|
||||
|
||||
/**
|
||||
* Initializes me.
|
||||
*/
|
||||
public ResourceRenameParticipant() {
|
||||
super();
|
||||
}
|
||||
|
@ -66,17 +59,14 @@ public class ResourceRenameParticipant extends RenameParticipant implements
|
|||
if (element instanceof IResource) {
|
||||
resourceBeingRenamed = (IResource) element;
|
||||
} else if (element instanceof IAdaptable) {
|
||||
resourceBeingRenamed = (IResource) ((IAdaptable) element)
|
||||
.getAdapter(IResource.class);
|
||||
resourceBeingRenamed = (IResource) ((IAdaptable) element).getAdapter(IResource.class);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Change createChange(IProgressMonitor pm) throws CoreException,
|
||||
OperationCanceledException {
|
||||
|
||||
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
|
||||
Change result = null;
|
||||
|
||||
if (resourceBeingRenamed instanceof IProject) {
|
||||
|
@ -85,22 +75,15 @@ public class ResourceRenameParticipant extends RenameParticipant implements
|
|||
Collection<ILaunchConfigurationType> launchTypes = getCLaunchConfigTypes();
|
||||
|
||||
if (!launchTypes.isEmpty()) {
|
||||
ILaunchManager mgr = DebugPlugin.getDefault()
|
||||
.getLaunchManager();
|
||||
ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager();
|
||||
|
||||
for (ILaunchConfigurationType type : launchTypes) {
|
||||
ILaunchConfiguration[] launches = mgr
|
||||
.getLaunchConfigurations(type);
|
||||
ILaunchConfiguration[] launches = mgr.getLaunchConfigurations(type);
|
||||
|
||||
for (ILaunchConfiguration next : launches) {
|
||||
if (next
|
||||
.getAttribute(
|
||||
ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME,
|
||||
"").equals(oldName)) { //$NON-NLS-1$
|
||||
|
||||
result = AbstractLaunchConfigChange.append(result,
|
||||
new ProjectRenameChange(next, oldName,
|
||||
newName));
|
||||
if (next.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, "").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() {
|
||||
Set<ILaunchConfigurationType> result = new java.util.HashSet<ILaunchConfigurationType>();
|
||||
Set<ILaunchConfigurationType> result = new HashSet<>();
|
||||
|
||||
// Get launch config types registered by CDT adopters
|
||||
Set<String> thirdPartyConfgTypeIds = new HashSet<String>(5);
|
||||
Set<String> thirdPartyConfgTypeIds = new HashSet<>(5);
|
||||
LaunchConfigAffinityExtensionPoint.getLaunchConfigTypeIds(thirdPartyConfgTypeIds);
|
||||
|
||||
ILaunchManager mgr = DebugPlugin.getDefault().getLaunchManager();
|
||||
|
@ -130,18 +113,15 @@ public class ResourceRenameParticipant extends RenameParticipant implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public RefactoringStatus checkConditions(IProgressMonitor pm,
|
||||
CheckConditionsContext context) throws OperationCanceledException {
|
||||
|
||||
public RefactoringStatus checkConditions(IProgressMonitor pm, CheckConditionsContext context)
|
||||
throws OperationCanceledException {
|
||||
// I have no conditions to check. Updating the launches is trivial
|
||||
return new RefactoringStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInitializationData(IConfigurationElement config,
|
||||
String propertyName, Object data) throws CoreException {
|
||||
|
||||
public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
|
||||
throws CoreException {
|
||||
this.name = config.getAttribute("name"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue