Eclipse CDT
7.0

org.eclipse.cdt.core.model
Class CoreModelUtil

java.lang.Object
  extended by org.eclipse.cdt.core.model.CoreModelUtil

public class CoreModelUtil
extends java.lang.Object


Constructor Summary
CoreModelUtil()
           
 
Method Summary
static ITranslationUnit findTranslationUnit(IFile file)
          Returns the translation unit for the file given or null.
static ITranslationUnit findTranslationUnitForLocation(IPath location, ICProject preferredProject)
          Searches for a translation unit within the cprojects.
static IBinaryParser getBinaryParser(org.eclipse.cdt.core.settings.model.ICConfigExtensionReference ref)
          Instantiate binary parser for given extension reference.
static java.lang.String[] getBinaryParserIds(org.eclipse.cdt.core.settings.model.ICConfigurationDescription[] cfgs)
          Returns binary parser IDs for configurations
static org.eclipse.cdt.core.settings.model.ICConfigurationDescription[] getReferencedConfigurationDescriptions(org.eclipse.cdt.core.settings.model.ICConfigurationDescription cfgDes, boolean writable)
          Returns the configuration descriptions referenced directly by the specified configuration description.
static org.eclipse.cdt.core.settings.model.ICConfigurationDescription[] getReferencingConfigurationDescriptions(org.eclipse.cdt.core.settings.model.ICConfigurationDescription cfgDes, boolean writable)
          Returns the list of all configuration descriptions which directly reference the specified configuration description.
static int indexOf(char toBeFound, char[] array)
          Answers the first index in the array for which the corresponding character is equal to toBeFound.
static int indexOf(char toBeFound, char[] array, int start)
          Answers the first index in the array for which the corresponding character is equal to toBeFound starting the search at index start.
static boolean isExcluded(IPath resourcePath, char[][] exclusionPatterns)
          Returns whether the given resource path matches one of the exclusion patterns.
static boolean isExcluded(IResource resource, char[][] exclusionPatterns)
          Returns whether the given resource matches one of the exclusion patterns.
static boolean isExcludedPath(IPath resourcePath, IPath[] exclusionPatterns)
          Returns whether the given path matches one of the exclusion patterns.
static boolean match(char[] pattern, char[] name, boolean isCaseSensitive)
          Answers true if the pattern matches the given name, false otherwise.
static boolean match(char[] pattern, int patternStart, int patternEnd, char[] name, int nameStart, int nameEnd, boolean isCaseSensitive)
          Answers true if the a sub-pattern matches the subpart of the given name, false otherwise. char[] pattern matching, accepting wild-cards '*' and '?'.
static boolean pathMatch(char[] pattern, char[] filepath, boolean isCaseSensitive, char pathSeparator)
          Answers true if the pattern matches the filepath using the pathSepatator, false otherwise.
static void setBinaryParserIds(org.eclipse.cdt.core.settings.model.ICConfigurationDescription[] cfgs, java.lang.String[] pids)
          Sets binary parser ID list to given configurations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoreModelUtil

public CoreModelUtil()
Method Detail

isExcludedPath

public static boolean isExcludedPath(IPath resourcePath,
                                     IPath[] exclusionPatterns)
Returns whether the given path matches one of the exclusion patterns.

Parameters:
resourcePath -
exclusionPatterns -
Returns:
true if the given path matches one of the exclusion patterns.

isExcluded

public static final boolean isExcluded(IResource resource,
                                       char[][] exclusionPatterns)
Returns whether the given resource matches one of the exclusion patterns.


isExcluded

public static final boolean isExcluded(IPath resourcePath,
                                       char[][] exclusionPatterns)
Returns whether the given resource path matches one of the exclusion patterns.


match

public static final boolean match(char[] pattern,
                                  char[] name,
                                  boolean isCaseSensitive)
Answers true if the pattern matches the given name, false otherwise. This char[] pattern matching accepts wild-cards '*' and '?'. When not case sensitive, the pattern is assumed to already be lowercased, the name will be lowercased character per character as comparing. If name is null, the answer is false. If pattern is null, the answer is true if name is not null.

For example:
  1.  
       pattern = { '?', 'b', '*' }
       name = { 'a', 'b', 'c' , 'd' }
       isCaseSensitive = true
       result => true
      
     
  2.  
       pattern = { '?', 'b', '?' }
       name = { 'a', 'b', 'c' , 'd' }
       isCaseSensitive = true
       result => false
      
     
  3.  
       pattern = { 'b', '*' }
       name = { 'a', 'b', 'c' , 'd' }
       isCaseSensitive = true
       result => false
      
     

Parameters:
pattern - the given pattern
name - the given name
isCaseSensitive - flag to know whether or not the matching should be case sensitive
Returns:
true if the pattern matches the given name, false otherwise

match

public static final boolean match(char[] pattern,
                                  int patternStart,
                                  int patternEnd,
                                  char[] name,
                                  int nameStart,
                                  int nameEnd,
                                  boolean isCaseSensitive)
Answers true if the a sub-pattern matches the subpart of the given name, false otherwise. char[] pattern matching, accepting wild-cards '*' and '?'. Can match only subset of name/pattern. end positions are non-inclusive. The subpattern is defined by the patternStart and pattternEnd positions. When not case sensitive, the pattern is assumed to already be lowercased, the name will be lowercased character per character as comparing.

For example:
  1.  
       pattern = { '?', 'b', '*' }
       patternStart = 1
       patternEnd = 3
       name = { 'a', 'b', 'c' , 'd' }
       nameStart = 1
       nameEnd = 4
       isCaseSensitive = true
       result => true
      
     
  2.  
       pattern = { '?', 'b', '*' }
       patternStart = 1
       patternEnd = 2
       name = { 'a', 'b', 'c' , 'd' }
       nameStart = 1
       nameEnd = 2
       isCaseSensitive = true
       result => false
      
     

Parameters:
pattern - the given pattern
patternStart - the given pattern start
patternEnd - the given pattern end
name - the given name
nameStart - the given name start
nameEnd - the given name end
isCaseSensitive - flag to know if the matching should be case sensitive
Returns:
true if the a sub-pattern matches the subpart of the given name, false otherwise

pathMatch

public static final boolean pathMatch(char[] pattern,
                                      char[] filepath,
                                      boolean isCaseSensitive,
                                      char pathSeparator)
Answers true if the pattern matches the filepath using the pathSepatator, false otherwise. Path char[] pattern matching, accepting wild-cards '**', '*' and '?' (using Ant directory tasks conventions, also see "http://jakarta.apache.org/ant/manual/dirtasks.html#defaultexcludes"). Path pattern matching is enhancing regular pattern matching in supporting extra rule where '**' represent any folder combination. Special rule: - foo\ is equivalent to foo\** When not case sensitive, the pattern is assumed to already be lowercased, the name will be lowercased character per character as comparing.

Parameters:
pattern - the given pattern
filepath - the given path
isCaseSensitive - to find out whether or not the matching should be case sensitive
pathSeparator - the given path separator
Returns:
true if the pattern matches the filepath using the pathSepatator, false otherwise

indexOf

public static final int indexOf(char toBeFound,
                                char[] array)
Answers the first index in the array for which the corresponding character is equal to toBeFound. Answers -1 if no occurrence of this character is found.

For example:
  1.  
       toBeFound = 'c'
       array = { ' a', 'b', 'c', 'd' }
       result => 2
      
     
  2.  
       toBeFound = 'e'
       array = { ' a', 'b', 'c', 'd' }
       result => -1
      
     

Parameters:
toBeFound - the character to search
array - the array to be searched
Returns:
the first index in the array for which the corresponding character is equal to toBeFound, -1 otherwise
Throws:
java.lang.NullPointerException - if array is null

indexOf

public static final int indexOf(char toBeFound,
                                char[] array,
                                int start)
Answers the first index in the array for which the corresponding character is equal to toBeFound starting the search at index start. Answers -1 if no occurrence of this character is found.

For example:
  1.  
       toBeFound = 'c'
       array = { ' a', 'b', 'c', 'd' }
       start = 2
       result => 2
      
     
  2.  
       toBeFound = 'c'
       array = { ' a', 'b', 'c', 'd' }
       start = 3
       result => -1
      
     
  3.  
       toBeFound = 'e'
       array = { ' a', 'b', 'c', 'd' }
       start = 1
       result => -1
      
     

Parameters:
toBeFound - the character to search
array - the array to be searched
start - the starting index
Returns:
the first index in the array for which the corresponding character is equal to toBeFound, -1 otherwise
Throws:
java.lang.NullPointerException - if array is null
java.lang.ArrayIndexOutOfBoundsException - if start is lower than 0

findTranslationUnitForLocation

public static ITranslationUnit findTranslationUnitForLocation(IPath location,
                                                              ICProject preferredProject)
                                                       throws CModelException
Searches for a translation unit within the cprojects. For external files the ones from the given project are preferred.

Throws:
CModelException
Since:
4.0

findTranslationUnit

public static ITranslationUnit findTranslationUnit(IFile file)
Returns the translation unit for the file given or null.


getReferencedConfigurationDescriptions

public static org.eclipse.cdt.core.settings.model.ICConfigurationDescription[] getReferencedConfigurationDescriptions(org.eclipse.cdt.core.settings.model.ICConfigurationDescription cfgDes,
                                                                                                                      boolean writable)
Returns the configuration descriptions referenced directly by the specified configuration description. The result will not contain duplicates. Returns an empty array if there are no referenced configuration descriptions.

Parameters:
cfgDes -
writable - - specifies whether the returned descriptions should be writable or read-only
Returns:
a list of configuration descriptions
Since:
4.0
See Also:
getReferencingConfigurationDescriptions(ICConfigurationDescription, boolean)

getReferencingConfigurationDescriptions

public static org.eclipse.cdt.core.settings.model.ICConfigurationDescription[] getReferencingConfigurationDescriptions(org.eclipse.cdt.core.settings.model.ICConfigurationDescription cfgDes,
                                                                                                                       boolean writable)
Returns the list of all configuration descriptions which directly reference the specified configuration description. Returns an empty array if there are no referencing configuration descriptions.

Parameters:
cfgDes -
writable - - specifies whether the returned descriptions should be writable or read-only
Returns:
a list of configuration descriptions referencing this configuration description
Since:
4.0
See Also:
getReferencedConfigurationDescriptions(ICConfigurationDescription, boolean)

getBinaryParserIds

public static java.lang.String[] getBinaryParserIds(org.eclipse.cdt.core.settings.model.ICConfigurationDescription[] cfgs)
Returns binary parser IDs for configurations

Parameters:
cfgs - - array of configurations where we need search
Returns:
- array of binary parser ids (Strings)

setBinaryParserIds

public static void setBinaryParserIds(org.eclipse.cdt.core.settings.model.ICConfigurationDescription[] cfgs,
                                      java.lang.String[] pids)
Sets binary parser ID list to given configurations

Parameters:
cfgs - - array of configurations where we need search
pids - - array of binary parser ids (Strings)

getBinaryParser

public static IBinaryParser getBinaryParser(org.eclipse.cdt.core.settings.model.ICConfigExtensionReference ref)
                                     throws CoreException
Instantiate binary parser for given extension reference.

Parameters:
ref - binary parser extension reference
Returns:
a binary parser instance
Throws:
CoreException - if the parser could not be created
Since:
5.3

Eclipse CDT
7.0

Copyright (c) IBM Corp. and others 2004, 2012. All Rights Reserved.