mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Cosmetics.
This commit is contained in:
parent
68d17bbd55
commit
e9efc2eac0
12 changed files with 127 additions and 166 deletions
|
@ -10,7 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
|
||||
/**
|
||||
* A source range defines an element's source coordinates
|
||||
*
|
||||
|
@ -18,9 +17,8 @@ package org.eclipse.cdt.core.model;
|
|||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ISourceRange {
|
||||
|
||||
/**
|
||||
* Returns the 0-based starting position of this element.
|
||||
* Returns the zero-based starting position of this element.
|
||||
*/
|
||||
public int getStartPos();
|
||||
|
||||
|
|
|
@ -26,12 +26,12 @@ import org.eclipse.core.runtime.IPath;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
/**
|
||||
* Represents an entire C translation unit (<code>.c</code> source file).
|
||||
* The children are of type <code>IStructureElement</code>,
|
||||
* <code>IInclude</code>, etc..
|
||||
* Represents an entire C translation unit ({@code .c} source file).
|
||||
* The children are of type {@code IStructureElement},
|
||||
* {@code IInclude}, etc..
|
||||
* and appear in the order in which they are declared in the source.
|
||||
* If a <code>.c</code> file cannot be parsed, its structure remains unknown.
|
||||
* Use <code>ICElement.isStructureKnown</code> to determine whether this is
|
||||
* If a {@code .c} file cannot be parsed, its structure remains unknown.
|
||||
* Use {@code ICElement.isStructureKnown} to determine whether this is
|
||||
* the case.
|
||||
*
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
|
@ -99,12 +99,13 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
|
||||
/**
|
||||
* Style constant for {@link #getAST(IIndex, int)}.
|
||||
* Instructs the parser to make an attempt to create ast nodes for inactive code branches. The parser
|
||||
* makes its best effort to create ast for the inactive code branches but may decide to skip parts
|
||||
* of the inactive code (e.g. function bodies, entire code branches, etc.).
|
||||
* Instructs the parser to make an attempt to create ast nodes for inactive code branches.
|
||||
* The parser makes its best effort to create ast for the inactive code branches but may decide
|
||||
* to skip parts of the inactive code (e.g. function bodies, entire code branches, etc.).
|
||||
* <p>
|
||||
* The inactive nodes can be accessed via {@link IASTDeclarationListOwner#getDeclarations(boolean)} or
|
||||
* by using a visitor with {@link ASTVisitor#includeInactiveNodes} set to <code>true</code>.
|
||||
* The inactive nodes can be accessed via
|
||||
* {@link IASTDeclarationListOwner#getDeclarations(boolean)} or by using a visitor with
|
||||
* {@link ASTVisitor#includeInactiveNodes} set to {@code true}.
|
||||
*
|
||||
* @since 5.1
|
||||
*/
|
||||
|
@ -121,17 +122,19 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
* If the translation unit already includes the specified include declaration,
|
||||
* the import is not generated (it does not generate duplicates).
|
||||
*
|
||||
* @param name the name of the include declaration to add (For example: <code>"stdio.h"</code> or
|
||||
* <code>"sys/types.h"</code>)
|
||||
* @param sibling the existing element which the include declaration will be inserted immediately before (if
|
||||
* <code> null </code>, then this include will be inserted as the last include declaration.
|
||||
* @param name the name of the include declaration to add (For example: {@code "stdio.h"}
|
||||
* or {@code "sys/types.h"})
|
||||
* @param sibling the existing element which the include declaration will be inserted
|
||||
* immediately before (if {@code null}, then this include will be inserted as the last
|
||||
* include declaration).
|
||||
* @param monitor the progress monitor to notify
|
||||
* @return the newly inserted include declaration (or the previously existing one in case attempting to create a duplicate)
|
||||
* @return the newly inserted include declaration (or the previously existing one in case
|
||||
* attempting to create a duplicate)
|
||||
*
|
||||
* @exception CModelException if the element could not be created. Reasons include:
|
||||
* <ul>
|
||||
* <li> This C element does not exist or the specified sibling does not exist (ELEMENT_DOES_NOT_EXIST)</li>
|
||||
* <li> A <code>CoreException</code> occurred while updating an underlying resource
|
||||
* <li> A {@code CoreException} occurred while updating an underlying resource
|
||||
* <li> The specified sibling is not a child of this translation unit (INVALID_SIBLING)
|
||||
* <li> The name is not a valid import name (INVALID_NAME)
|
||||
* </ul>
|
||||
|
@ -143,12 +146,13 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
*
|
||||
* @param name the name of the using
|
||||
* @param monitor the progress monitor to notify
|
||||
* @return the newly inserted namespace declaration (or the previously existing one in case attempting to create a duplicate)
|
||||
* @return the newly inserted namespace declaration (or the previously existing one in case
|
||||
* attempting to create a duplicate)
|
||||
*
|
||||
* @exception CModelException if the element could not be created. Reasons include:
|
||||
* <ul>
|
||||
* <li>This C element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
|
||||
* <li> A <code>CoreException</code> occurred while updating an underlying resource
|
||||
* <li> A {@code CoreException} occurred while updating an underlying resource
|
||||
* <li> The name is not a valid package name (INVALID_NAME)
|
||||
* </ul>
|
||||
*/
|
||||
|
@ -165,21 +169,21 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
* @exception CModelException if the element could not be created. Reasons include:
|
||||
* <ul>
|
||||
* <li>This C element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
|
||||
* <li> A <code>CoreException</code> occurred while updating an underlying resource
|
||||
* <li> A {@code CoreException} occurred while updating an underlying resource
|
||||
* <li> The name is not a valid package name (INVALID_NAME)
|
||||
* </ul>
|
||||
*/
|
||||
INamespace createNamespace(String namespace, ICElement sibling, IProgressMonitor monitor) throws CModelException;
|
||||
|
||||
/**
|
||||
* Returns the shared working copy for this element, using the default <code>IBuffer</code>
|
||||
* factory, or <code>null</code>, if no working copy has been created for this element.
|
||||
* Returns the shared working copy for this element, using the default {@code IBuffer}
|
||||
* factory, or {@code null}, if no working copy has been created for this element.
|
||||
* <p>
|
||||
* Users of this method must not destroy the resulting working copy.
|
||||
*
|
||||
* @param bufferFactory
|
||||
* the given <code>IBuffer</code> factory
|
||||
* @return the found shared working copy for this element, or <code>null</code> if none
|
||||
* the given {@code IBuffer} factory
|
||||
* @return the found shared working copy for this element, or {@code null} if none
|
||||
* @see IBufferFactory
|
||||
* @since 5.1
|
||||
*/
|
||||
|
@ -194,30 +198,30 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
/**
|
||||
* Returns the smallest element within this translation unit that
|
||||
* includes the given source position (that is, a method, field, etc.), or
|
||||
* <code>null</code> if there is no element other than the translation
|
||||
* {@code null} if there is no element other than the translation
|
||||
* unit itself at the given position, or if the given position is not
|
||||
* within the source range of this translation unit.
|
||||
*
|
||||
* @param line a position inside the translation unit
|
||||
* @return the innermost C element enclosing a given source position or <code>null</code>
|
||||
* if none (excluding the translation unit).
|
||||
* @return the innermost C element enclosing a given source position or {@code null}
|
||||
* if none (excluding the translation unit).
|
||||
* @exception CModelException if the translation unit does not exist or if an
|
||||
* exception occurs while accessing its corresponding resource
|
||||
* exception occurs while accessing its corresponding resource
|
||||
*/
|
||||
ICElement getElementAtLine(int line) throws CModelException;
|
||||
|
||||
/**
|
||||
* Returns the smallest element within this translation unit that
|
||||
* includes the given source position (that is, a method, field, etc.), or
|
||||
* <code>null</code> if there is no element other than the translation
|
||||
* {@code null} if there is no element other than the translation
|
||||
* unit itself at the given position, or if the given position is not
|
||||
* within the source range of this translation unit.
|
||||
*
|
||||
* @param position a source position inside the translation unit
|
||||
* @return the innermost C element enclosing a given source position or <code>null</code>
|
||||
* if none (excluding the translation unit).
|
||||
* @return the innermost C element enclosing a given source position or {@code null}
|
||||
* if none (excluding the translation unit).
|
||||
* @exception CModelException if the translation unit does not exist or if an
|
||||
* exception occurs while accessing its corresponding resource
|
||||
* exception occurs while accessing its corresponding resource
|
||||
*/
|
||||
ICElement getElementAtOffset(int offset) throws CModelException;
|
||||
|
||||
|
@ -230,7 +234,7 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
* You have this behavior when at expansion of a macro.
|
||||
*
|
||||
* @param position a source position inside the translation unit
|
||||
* @return the innermost C element enclosing a given source position or <code>null</code>
|
||||
* @return the innermost C element enclosing a given source position or {@code null}
|
||||
* if none (excluding the translation unit).
|
||||
* @exception CModelException if the translation unit does not exist or if an
|
||||
* exception occurs while accessing its corresponding resource
|
||||
|
@ -242,12 +246,12 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
/**
|
||||
* Returns the include declaration in this translation unit with the given name.
|
||||
*
|
||||
* @param the name of the include to find (For example: <code>"stdio.h"</code>
|
||||
* or <code>"sys/types.h"</code>)
|
||||
* @param the name of the include to find (For example: {@code "stdio.h"}
|
||||
* or {@code "sys/types.h"})
|
||||
* @return a handle onto the corresponding include declaration. The include declaration may or
|
||||
* may not exist.
|
||||
*/
|
||||
IInclude getInclude(String name) ;
|
||||
IInclude getInclude(String name);
|
||||
|
||||
/**
|
||||
* Returns the include declarations in this translation unit
|
||||
|
@ -259,42 +263,42 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
IInclude[] getIncludes() throws CModelException;
|
||||
|
||||
/**
|
||||
* Returns a shared working copy on this element using the given factory to create the buffer, or this
|
||||
* element if this element is already a working copy. This API can only answer an already existing working
|
||||
* copy if it is based on the same original translation unit AND was using the same buffer factory (i.e.
|
||||
* as defined by <code>Object#equals</code>).
|
||||
* Returns a shared working copy on this element using the given factory to create the buffer,
|
||||
* or this element if this element is already a working copy. This API can only answer
|
||||
* an already existing working copy if it is based on the same original translation unit AND
|
||||
* was using the same buffer factory (i.e. as defined by {@code Object#equals}).
|
||||
* <p>
|
||||
* The life time of a shared working copy is as follows:
|
||||
* <ul>
|
||||
* <li>The first call to <code>getSharedWorkingCopy(...)</code> creates a new working copy for this
|
||||
* element</li>
|
||||
* <li>The first call to {@code getSharedWorkingCopy(...)} creates a new working copy for
|
||||
* this element</li>
|
||||
* <li>Subsequent calls increment an internal counter.</li>
|
||||
* <li>A call to <code>destroy()</code> decrements the internal counter.</li>
|
||||
* <li>A call to {@code destroy()} decrements the internal counter.</li>
|
||||
* <li>When this counter is 0, the working copy is destroyed.
|
||||
* </ul>
|
||||
* So users of this method must destroy exactly once the working copy.
|
||||
* <p>
|
||||
* Note that the buffer factory will be used for the life time of this working copy, i.e. if the working
|
||||
* copy is closed then reopened, this factory will be used. The buffer will be automatically initialized
|
||||
* with the original's compilation unit content upon creation.
|
||||
* Note that the buffer factory will be used for the life time of this working copy,
|
||||
* i.e. if the working copy is closed then reopened, this factory will be used. The buffer will
|
||||
* be automatically initialized with the original's compilation unit content upon creation.
|
||||
* <p>
|
||||
* When the shared working copy instance is created, an ADDED ICElementDelta is reported on this working
|
||||
* copy.
|
||||
* When the shared working copy instance is created, an ADDED ICElementDelta is reported on
|
||||
* this working copy.
|
||||
*
|
||||
* @param monitor
|
||||
* a progress monitor used to report progress while opening this compilation unit or
|
||||
* <code>null</code> if no progress should be reported
|
||||
* {@code null} if no progress should be reported
|
||||
* @param requestor
|
||||
* a requestor which will get notified of problems detected during reconciling as they are
|
||||
* discovered. The requestor can be set to <code>null</code> indicating that the client is not
|
||||
* interested in problems.
|
||||
* a requestor which will get notified of problems detected during reconciling as
|
||||
* they are discovered. The requestor can be set to {@code null} indicating that
|
||||
* the client is not interested in problems.
|
||||
* @exception CModelException
|
||||
* if the contents of this element can not be determined. Reasons include:
|
||||
* <ul>
|
||||
* <li> This C element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
|
||||
* </ul>
|
||||
* @return a shared working copy on this element using the given factory to create the buffer, or this
|
||||
* element if this element is already a working copy
|
||||
* @return a shared working copy on this element using the given factory to create the buffer,
|
||||
* or this element if this element is already a working copy
|
||||
* @see IBufferFactory
|
||||
* @see IProblemRequestor
|
||||
* @since 5.1
|
||||
|
@ -305,7 +309,7 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
* Returns the first using in this translation unit with the name
|
||||
* This is a handle-only method. The namespace declaration may or may not exist.
|
||||
*
|
||||
* @param name the name of the namespace declaration (For example, <code>"std"</code>)
|
||||
* @param name the name of the namespace declaration (For example, {@code "std"})
|
||||
*/
|
||||
IUsing getUsing(String name);
|
||||
|
||||
|
@ -324,7 +328,7 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
* Returns the first namespace declaration in this translation unit with the given name
|
||||
* This is a handle-only method. The namespace declaration may or may not exist.
|
||||
*
|
||||
* @param name the name of the namespace declaration (For example, <code>"std"</code>)
|
||||
* @param name the name of the namespace declaration (For example, {@code "std"})
|
||||
*/
|
||||
INamespace getNamespace(String name);
|
||||
|
||||
|
@ -352,17 +356,17 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
boolean isSourceUnit();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the code is C
|
||||
* Returns {@code true} if the code is C
|
||||
*/
|
||||
boolean isCLanguage();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the code is C++
|
||||
* Returns {@code true} if the code is C++
|
||||
*/
|
||||
boolean isCXXLanguage();
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if the code is assembly
|
||||
* Returns {@code true} if the code is assembly
|
||||
*/
|
||||
boolean isASMLanguage();
|
||||
|
||||
|
@ -403,47 +407,50 @@ public interface ITranslationUnit extends ICElement, IParent, IOpenable, ISource
|
|||
*
|
||||
* TODO (DS) I'm not sure it's a good idea to put a setter in this
|
||||
* interface. We should revisit this.
|
||||
*
|
||||
*/
|
||||
public void setIsStructureKnown(boolean wasSuccessful);
|
||||
|
||||
/**
|
||||
* Returns the absolute path of the location of the translation unit. May be <code>null</code>, in
|
||||
* case the location does not exist.
|
||||
* @return an absolute path to the location, or <code>null</code>
|
||||
* Returns the absolute path of the location of the translation unit. May be {@code null},
|
||||
* in case the location does not exist.
|
||||
*
|
||||
* @return an absolute path to the location, or {@code null}
|
||||
* @since 4.0
|
||||
*/
|
||||
public IPath getLocation();
|
||||
|
||||
/**
|
||||
* Returns the scanner info associated with this translation unit. May return <code>null</code> if no
|
||||
* configuration is available.
|
||||
* @param force if <code>true</code> a default info is returned, even if nothing is configured for this
|
||||
* translation unit
|
||||
* @return a scanner info for parsing the translation unit or <code>null</code> if none is configured
|
||||
* Returns the scanner info associated with this translation unit. May return {@code null}
|
||||
* if no configuration is available.
|
||||
*
|
||||
* @param force if {@code true} a default info is returned, even if nothing is configured
|
||||
* for this translation unit
|
||||
* @return a scanner info for parsing the translation unit or {@code null} if none
|
||||
* is configured
|
||||
* @since 4.0
|
||||
*/
|
||||
public IScannerInfo getScannerInfo(boolean force);
|
||||
|
||||
/**
|
||||
* Creates the full AST for this translation unit. May return <code>null</code> if the language
|
||||
* Creates the full AST for this translation unit. May return {@code null} if the language
|
||||
* of this translation unit does not support ASTs.
|
||||
* @return the AST for the translation unit or <code>null</code>
|
||||
* @return the AST for the translation unit or {@code null}
|
||||
* @throws CoreException
|
||||
* @since 4.0
|
||||
*/
|
||||
public IASTTranslationUnit getAST() throws CoreException;
|
||||
|
||||
/**
|
||||
* Creates an AST based on the requested style. May return <code>null</code> if the language of
|
||||
* Creates an AST based on the requested style. May return {@code null} if the language of
|
||||
* this translation unit does not support ASTs. If the index was supplied, the caller has to
|
||||
* hold a read lock on it. The returned AST is valid only while the index read lock is being
|
||||
* held and should not be accessed after releasing the lock.
|
||||
* @param index index to back up the parsing of the AST, may be <code>null</code>
|
||||
* @param style <code>0</code> or a combination of {@link #AST_SKIP_ALL_HEADERS},
|
||||
* held and should not be accessed after releasing the lock.
|
||||
*
|
||||
* @param index index to back up the parsing of the AST, may be {@code null}
|
||||
* @param style {@code 0} or a combination of {@link #AST_SKIP_ALL_HEADERS},
|
||||
* {@link #AST_SKIP_IF_NO_BUILD_INFO}, {@link #AST_SKIP_INDEXED_HEADERS}
|
||||
* and {@link #AST_CONFIGURE_USING_SOURCE_CONTEXT}.
|
||||
* @return the AST requested or <code>null</code>
|
||||
* @return the AST requested or {@code null}
|
||||
* @throws CoreException
|
||||
* @since 4.0
|
||||
*/
|
||||
|
|
|
@ -35,9 +35,6 @@ public class Include extends SourceManipulation implements IInclude {
|
|||
return standard;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.model.IInclude#getFullFileName()
|
||||
*/
|
||||
@Override
|
||||
public String getFullFileName() {
|
||||
return fullPath;
|
||||
|
|
|
@ -53,7 +53,7 @@ public interface IASTFileLocation extends IASTNodeLocation {
|
|||
public int getEndingLineNumber();
|
||||
|
||||
/**
|
||||
* Returns the inclusion statement that included this file, or <code>null</code> for
|
||||
* Returns the inclusion statement that included this file, or {@code null} for
|
||||
* a top-level file.
|
||||
* Also {@code null} when the file location does not belong to an AST node, e.g.
|
||||
* if it is obtained from a name in the index.
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.eclipse.core.runtime.IPath;
|
|||
import org.eclipse.core.runtime.Path;
|
||||
|
||||
/**
|
||||
* Factory for obtaining instances of IIndexFileLocation for workspace or external files, and
|
||||
* Factory for obtaining instances of IIndexFileLocation for workspace and external files, and
|
||||
* some utility methods for going in the opposite direction.
|
||||
*
|
||||
* @since 4.0
|
||||
|
@ -38,7 +38,7 @@ public class IndexLocationFactory {
|
|||
/**
|
||||
* Returns
|
||||
* <ul>
|
||||
* <li> the full path if this IIndexFileLocation if within the workspace root
|
||||
* <li> the full path if this IIndexFileLocation is within the workspace root
|
||||
* <li> the absolute path if this IIndexFileLocation is URI based and corresponds
|
||||
* to a location on the local file system
|
||||
* <li> otherwise, null
|
||||
|
|
|
@ -144,7 +144,7 @@ public final class CollectionUtils {
|
|||
* creates it with an empty list as the initial value.
|
||||
* @since 5.6
|
||||
*/
|
||||
static public <T, U> List<U> listMapGet(Map<T, List<U>> m, T t) {
|
||||
public static <T, U> List<U> listMapGet(Map<T, List<U>> m, T t) {
|
||||
List<U> result = m.get(t);
|
||||
if (result == null) {
|
||||
result = new ArrayList<U>();
|
||||
|
|
|
@ -72,9 +72,9 @@ public class PathUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* On Windows discover the {@link java.io.File#getCanonicalPath()} for
|
||||
* a given absolute path.
|
||||
* On other platforms, and for relative paths returns the passed in fullPath
|
||||
* On Windows returns the {@link java.io.File#getCanonicalPath()} for a given absolute path.
|
||||
* On other platforms, and for relative paths returns the the original path.
|
||||
*
|
||||
* @param fullPath
|
||||
* @return canonicalized IPath or passed in fullPath.
|
||||
* @since 5.3
|
||||
|
@ -198,10 +198,12 @@ public class PathUtil {
|
|||
|
||||
/**
|
||||
* Checks whether path1 is the same as path2.
|
||||
* @return <code>true</code> if path1 is the same as path2, and <code>false</code> otherwise
|
||||
*
|
||||
* <p>
|
||||
* Similar to IPath.equals(Object obj), but takes case sensitivity of the file system
|
||||
* into account.
|
||||
*
|
||||
* @return {@code true} if path1 is the same as path2, and {@code false} otherwise
|
||||
*
|
||||
* @since 5.1
|
||||
* @deprecated Use {@link #equalPath(IPath, IPath)} instead.
|
||||
*/
|
||||
|
@ -230,10 +232,11 @@ public class PathUtil {
|
|||
|
||||
/**
|
||||
* Checks whether path1 is the same as path2.
|
||||
* @return <code>true</code> if path1 is the same as path2, and <code>false</code> otherwise
|
||||
*
|
||||
* <p>
|
||||
* Similar to IPath.equals(Object obj), but takes case sensitivity of the file system
|
||||
* into account.
|
||||
*
|
||||
* @return {@code true} if path1 is the same as path2, and {@code false} otherwise
|
||||
* @since 5.3
|
||||
*/
|
||||
public static boolean equalPath(IPath path1, IPath path2) {
|
||||
|
@ -268,11 +271,11 @@ public class PathUtil {
|
|||
* <p>
|
||||
* An empty path is a prefix of all paths with the same device; a root path is a prefix of
|
||||
* all absolute paths with the same device.
|
||||
* </p>
|
||||
* @return <code>true</code> if path1 is a prefix of path2, and <code>false</code> otherwise
|
||||
*
|
||||
* <p>
|
||||
* Similar to IPath.isPrefixOf(IPath anotherPath), but takes case sensitivity of the file system
|
||||
* into account.
|
||||
*
|
||||
* @return {@code true} if path1 is a prefix of path2, and {@code false} otherwise
|
||||
* @since 5.1
|
||||
*/
|
||||
public static boolean isPrefix(IPath path1, IPath path2) {
|
||||
|
@ -306,11 +309,11 @@ public class PathUtil {
|
|||
/**
|
||||
* Returns the number of segments which match in path1 and path2
|
||||
* (device ids are ignored), comparing in increasing segment number order.
|
||||
*
|
||||
* @return the number of matching segments
|
||||
|
||||
* <p>
|
||||
* Similar to IPath.matchingFirstSegments(IPath anotherPath), but takes case sensitivity
|
||||
* of the file system into account.
|
||||
*
|
||||
* @return the number of matching segments
|
||||
* @since 5.1
|
||||
*/
|
||||
public static int matchingFirstSegments(IPath path1, IPath path2) {
|
||||
|
@ -333,7 +336,7 @@ public class PathUtil {
|
|||
}
|
||||
|
||||
/**
|
||||
* Find location of the program inspecting each path in the path list.
|
||||
* Finds location of the program inspecting each path in the path list.
|
||||
*
|
||||
* @param prog - program to find. For Windows, extensions "com" and "exe"
|
||||
* can be omitted.
|
||||
|
@ -345,30 +348,30 @@ public class PathUtil {
|
|||
* @since 5.3
|
||||
*/
|
||||
public static IPath findProgramLocation(String prog, String pathsStr) {
|
||||
if (prog==null || prog.trim().length()==0)
|
||||
if (prog == null || prog.trim().isEmpty())
|
||||
return null;
|
||||
|
||||
if (pathsStr==null)
|
||||
if (pathsStr == null)
|
||||
pathsStr = System.getenv("PATH"); //$NON-NLS-1$
|
||||
|
||||
if (pathsStr.trim().length()==0)
|
||||
if (pathsStr.trim().isEmpty())
|
||||
return null;
|
||||
|
||||
String locationStr = null;
|
||||
String[] dirs = pathsStr.split(File.pathSeparator);
|
||||
|
||||
// try to find "prog.exe" or "prog.com" on Windows
|
||||
// Try to find "prog.exe" or "prog.com" on Windows
|
||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
||||
for (String dir : dirs) {
|
||||
IPath dirLocation = new Path(dir);
|
||||
File file = null;
|
||||
|
||||
file = dirLocation.append(prog+".exe").toFile(); //$NON-NLS-1$
|
||||
file = dirLocation.append(prog + ".exe").toFile(); //$NON-NLS-1$
|
||||
if (file.isFile() && file.canRead()) {
|
||||
locationStr = file.getAbsolutePath();
|
||||
break;
|
||||
}
|
||||
file = dirLocation.append(prog+".com").toFile(); //$NON-NLS-1$
|
||||
file = dirLocation.append(prog + ".com").toFile(); //$NON-NLS-1$
|
||||
if (file.isFile() && file.canRead()) {
|
||||
locationStr = file.getAbsolutePath();
|
||||
break;
|
||||
|
@ -376,9 +379,9 @@ public class PathUtil {
|
|||
}
|
||||
}
|
||||
|
||||
// check "prog" on Unix and Windows too (if was not found) - could be cygwin or something
|
||||
// Check "prog" on Unix and Windows too (if was not found) - could be cygwin or something
|
||||
// do it in separate loop due to performance and correctness of Windows regular case
|
||||
if (locationStr==null) {
|
||||
if (locationStr == null) {
|
||||
for (String dir : dirs) {
|
||||
IPath dirLocation = new Path(dir);
|
||||
File file = null;
|
||||
|
@ -391,14 +394,14 @@ public class PathUtil {
|
|||
}
|
||||
}
|
||||
|
||||
if (locationStr!=null)
|
||||
if (locationStr != null)
|
||||
return new Path(locationStr);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find location of the program inspecting each path in the path list
|
||||
* Finds location of the program inspecting each path in the path list
|
||||
* defined by environment variable ${PATH}.
|
||||
*
|
||||
* @param prog - program to find. For Windows, extensions "com" and "exe"
|
||||
|
|
|
@ -52,8 +52,8 @@ public class InclusionContext {
|
|||
fCurrentDirectory = fTu.getResource().getParent().getLocation();
|
||||
IScannerInfo scannerInfo = fTu.getScannerInfo(true);
|
||||
fIncludeSearchPath = CPreprocessor.configureIncludeSearchPath(fCurrentDirectory.toFile(), scannerInfo);
|
||||
fIncludeResolutionCache = new HashMap<IncludeInfo, IPath>();
|
||||
fInverseIncludeResolutionCache = new HashMap<IPath, IncludeInfo>();
|
||||
fIncludeResolutionCache = new HashMap<>();
|
||||
fInverseIncludeResolutionCache = new HashMap<>();
|
||||
fPreferences = new IncludePreferences(cProject);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,9 +57,6 @@ public final class ASTProvider {
|
|||
fName= name;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return fName;
|
||||
|
@ -73,7 +70,6 @@ public final class ASTProvider {
|
|||
* <p>
|
||||
* If not yet cached and if the translation unit is open, an AST will be created by
|
||||
* this AST provider.
|
||||
* </p>
|
||||
*/
|
||||
public static final WAIT_FLAG WAIT_IF_OPEN= new WAIT_FLAG("wait if open"); //$NON-NLS-1$
|
||||
|
||||
|
@ -83,7 +79,6 @@ public final class ASTProvider {
|
|||
* If the translation unit is not open no AST will be provided.
|
||||
* <p>
|
||||
* No AST will be created by the AST provider.
|
||||
* </p>
|
||||
*/
|
||||
public static final WAIT_FLAG WAIT_ACTIVE_ONLY= new WAIT_FLAG("wait active only"); //$NON-NLS-1$
|
||||
|
||||
|
@ -92,7 +87,6 @@ public final class ASTProvider {
|
|||
* only wants the already available shared AST.
|
||||
* <p>
|
||||
* No AST will be created by the AST provider.
|
||||
* </p>
|
||||
*/
|
||||
public static final WAIT_FLAG WAIT_NO= new WAIT_FLAG("don't wait"); //$NON-NLS-1$
|
||||
|
||||
|
@ -105,27 +99,18 @@ public final class ASTProvider {
|
|||
* Internal activation listener.
|
||||
*/
|
||||
private class ActivationListener implements IPartListener2, IWindowListener {
|
||||
/*
|
||||
* @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
@Override
|
||||
public void partActivated(IWorkbenchPartReference ref) {
|
||||
if (isCEditor(ref) && !isActiveEditor(ref))
|
||||
activeEditorChanged(ref.getPart(true));
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
@Override
|
||||
public void partBroughtToTop(IWorkbenchPartReference ref) {
|
||||
if (isCEditor(ref) && !isActiveEditor(ref))
|
||||
activeEditorChanged(ref.getPart(true));
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
@Override
|
||||
public void partClosed(IWorkbenchPartReference ref) {
|
||||
if (isActiveEditor(ref)) {
|
||||
|
@ -133,50 +118,32 @@ public final class ASTProvider {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
@Override
|
||||
public void partDeactivated(IWorkbenchPartReference ref) {
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
@Override
|
||||
public void partOpened(IWorkbenchPartReference ref) {
|
||||
if (isCEditor(ref) && !isActiveEditor(ref))
|
||||
activeEditorChanged(ref.getPart(true));
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
@Override
|
||||
public void partHidden(IWorkbenchPartReference ref) {
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
@Override
|
||||
public void partVisible(IWorkbenchPartReference ref) {
|
||||
if (isCEditor(ref) && !isActiveEditor(ref))
|
||||
activeEditorChanged(ref.getPart(true));
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
@Override
|
||||
public void partInputChanged(IWorkbenchPartReference ref) {
|
||||
if (isCEditor(ref) && isActiveEditor(ref))
|
||||
activeEditorChanged(ref.getPart(true));
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
|
||||
*/
|
||||
@Override
|
||||
public void windowActivated(IWorkbenchWindow window) {
|
||||
IWorkbenchPartReference ref= window.getPartService().getActivePartReference();
|
||||
|
@ -184,16 +151,10 @@ public final class ASTProvider {
|
|||
activeEditorChanged(ref.getPart(true));
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
|
||||
*/
|
||||
@Override
|
||||
public void windowDeactivated(IWorkbenchWindow window) {
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
|
||||
*/
|
||||
@Override
|
||||
public void windowClosed(IWorkbenchWindow window) {
|
||||
if (fActiveEditor != null && fActiveEditor.getSite() != null && window == fActiveEditor.getSite().getWorkbenchWindow()) {
|
||||
|
@ -202,9 +163,6 @@ public final class ASTProvider {
|
|||
window.getPartService().removePartListener(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
|
||||
*/
|
||||
@Override
|
||||
public void windowOpened(IWorkbenchWindow window) {
|
||||
window.getPartService().addPartListener(this);
|
||||
|
@ -270,8 +228,9 @@ public final class ASTProvider {
|
|||
|
||||
// Ensure existing windows get connected
|
||||
IWorkbenchWindow[] windows= PlatformUI.getWorkbench().getWorkbenchWindows();
|
||||
for (int i= 0, length= windows.length; i < length; i++)
|
||||
for (int i= 0, length= windows.length; i < length; i++) {
|
||||
windows[i].getPartService().addPartListener(fActivationListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,7 +306,7 @@ public final class ASTProvider {
|
|||
fCache.setActiveElement(null);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled()
|
||||
*/
|
||||
void reconciled(IASTTranslationUnit ast, ICElement cElement, IProgressMonitor progressMonitor) {
|
||||
|
@ -364,7 +323,7 @@ public final class ASTProvider {
|
|||
*
|
||||
* @param cElement the translation unit
|
||||
* @param waitFlag condition for waiting for the AST to be built.
|
||||
* @param monitor a progress monitor, may be <code>null</code>
|
||||
* @param monitor a progress monitor, may be {@code null}
|
||||
* @param astRunnable the runnable taking the AST
|
||||
* @return the status returned by the ASTRunnable
|
||||
*/
|
||||
|
@ -390,8 +349,8 @@ public final class ASTProvider {
|
|||
* @param tu The translation unit to get the AST for.
|
||||
* @param index index with read lock held.
|
||||
* @param waitFlag condition for waiting for the AST to be built.
|
||||
* @param monitor a progress monitor, may be <code>null</code>.
|
||||
* @return the shared AST, or <code>null</code> if the shared AST is not available.
|
||||
* @param monitor a progress monitor, may be {@code null}.
|
||||
* @return the shared AST, or {@code null} if the shared AST is not available.
|
||||
*/
|
||||
public final IASTTranslationUnit acquireSharedAST(ITranslationUnit tu, IIndex index,
|
||||
WAIT_FLAG waitFlag, IProgressMonitor monitor) {
|
||||
|
@ -417,8 +376,8 @@ public final class ASTProvider {
|
|||
*
|
||||
* @param tu the translation unit.
|
||||
* @param waitFlag condition for waiting for the AST to be built.
|
||||
* @return <code>true</code> if the AST cache can be used for the given translation unit,
|
||||
* <code>false</code> otherwise.
|
||||
* @return {@code true} if the AST cache can be used for the given translation unit,
|
||||
* {@code false} otherwise.
|
||||
*/
|
||||
private boolean prepareForUsingCache(ITranslationUnit tu, WAIT_FLAG waitFlag) {
|
||||
if (!tu.isOpen())
|
||||
|
|
|
@ -51,7 +51,7 @@ public class CRefactoringContext extends RefactoringContext {
|
|||
public CRefactoringContext(CRefactoring refactoring) {
|
||||
super(refactoring);
|
||||
refactoring.setContext(this);
|
||||
fASTCache = new ConcurrentHashMap<ITranslationUnit, IASTTranslationUnit>();
|
||||
fASTCache = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,7 @@ class InclusionRequest {
|
|||
fBinding = binding;
|
||||
fDeclaringFiles = Collections.unmodifiableMap(declaringHeaders);
|
||||
fReachable = reachable;
|
||||
fCandidatePaths = new ArrayList<IPath>(new HashSet<IPath>(fDeclaringFiles.values()));
|
||||
fCandidatePaths = new ArrayList<>(new HashSet<>(fDeclaringFiles.values()));
|
||||
}
|
||||
|
||||
public IBinding getBinding() {
|
||||
|
|
|
@ -10,23 +10,20 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.ui;
|
||||
|
||||
|
||||
/**
|
||||
* Interface related to {@link IFunctionSummary} denoting an include required for a function.
|
||||
* <p>
|
||||
* Clients may implement this interface.
|
||||
* </p>
|
||||
* @see IFunctionSummary
|
||||
*/
|
||||
public interface IRequiredInclude {
|
||||
|
||||
/**
|
||||
* Get the include name.
|
||||
* Returns the include name.
|
||||
*/
|
||||
String getIncludeName();
|
||||
|
||||
/**
|
||||
* Returns whether the include is to search on "standard places" like /usr/include first .
|
||||
* Returns whether the include is to search on "standard places" like /usr/include first.
|
||||
* An include is standard if it starts with <code>"<"</code>.
|
||||
*/
|
||||
boolean isStandard();
|
||||
|
|
Loading…
Add table
Reference in a new issue