[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.technology.dltk] Re: Ruby module in DLTK

Thanks for the helpful answers. Is there also a way to search within the 
context of a IType? I would like to find the ITypes that correspond to an 
ITypes superclass names. The original IType will typically have imports and 
such that uniquely define the superclasses, but the search engine might find 
additional ITypes that have the right name.


"Andrei Sobolev" <haiodo@xxxxxxxxx> wrote in message 
news:g1oct5$ifi$1@xxxxxxxxxxxxxxxxxxxx
> Hi Felix,
>
>> I am writing some code that looks at the Ruby ITypes within an
>> ISourceModule. I guess it makes makes (but is a little confusing) that a
>> Ruby module becomes an IType, but is there any way to easily distinguish
>> Ruby modules from Ruby classes?
>
> For this purpose you need to call IType.getFlags() method and check for 
> Modifiers.AccModule flag. It it is set then
> IType is a module. If not set then it is class.
>>
>> Another issue I have is that IScriptProject.findType(String,
>> IProgressMonitor) does not find the above Ruby module when I use
>> IType.getFullyQualifiedName() as the first parameters. What am I doing
>> wrong?
>
> To find types you should use SearchEngine.searchAllTypeNames() methods.
>
> Example of using it to search types by name:
>
> IProject prj = myProject;
> IScriptProject project = DLTKCore.create(prj);
> String patternString = "myClass*";
>
> // Requestor will accept matches
> TypeNameMatchRequestor requestor = myRequestor;
> IDLTKSearchScope scope = SearchEngine.createSearchScope(project);
> try {
> SearchEngine engine = new SearchEngine();
> engine.searchAllTypeNames(null, 0, patternString.toCharArray(),
> SearchPattern.R_EXACT_MATCH | SearchPattern.R_PATTERN_MATCH,
> IDLTKSearchConstants.TYPE, scope, requestor,
> IDLTKSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
> } catch (CoreException e) {
> e.printStackTrace();
> }
>
>
> For more information about search you could look at SearchTests class from 
> org.eclipse.dltk.tcl.core.tests plugin.
>>
>> Thanks, Felix
>>
>>