ModuleManager.getModules()

Hi,
In my plugin I am trying to get the content roots, by doing the
following. Somehow the list of modules I am getting is empty. My project has
just one module, is that the reason ? or I need to do something different ?
Its in build 1151.

thanks,
Dash.

ModuleManager.getInstance(myProject).getModules();

for (int i = 0; i < modules.length; i++) {
Module module = modules+;

VirtualFile files[] =
ModuleRootManager.getInstance(module).getContentRoots();
}





4 comments

Debabrata Dash wrote:

Hi,
In my plugin I am trying to get the content roots, by doing the
following. Somehow the list of modules I am getting is empty. My project
has just one module, is that the reason ? or I need to do something
different ? Its in build 1151.

thanks,
Dash.

ModuleManager.getInstance(myProject).getModules();

for (int i = 0; i < modules.length; i++) {
Module module = modules+;

VirtualFile files[] =
ModuleRootManager.getInstance(module).getContentRoots();
}


Debabrata,
sorry, I am afraid I fail to understand your code.
ModuleManager.getModules() returns some values - where do you put them?
Return value of the call 'ModuleManager.getInstance(myProject).getModules()'
is apparently not assigned anywhere...

Confused,
Dmitry

--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0

Sorry in the code, I had...

Module[] modules = ModuleManager.getInstance(myProject).getModules();

System.out.println(modules.length);

And it always printed 0.

-Dash.

"Dmitry Lomov (JetBrains)" <Dmitry.Lomov@jetbrains.com> wrote in message
news:c0csf0$b1q$2@is.intellij.net...

Debabrata Dash wrote:

>

Hi,
In my plugin I am trying to get the content roots, by doing the
following. Somehow the list of modules I am getting is empty. My project
has just one module, is that the reason ? or I need to do something
different ? Its in build 1151.

>

thanks,
Dash.

>

ModuleManager.getInstance(myProject).getModules();

>

for (int i = 0; i < modules.length; i++) {
Module module = modules+;

>

VirtualFile files[] =
ModuleRootManager.getInstance(module).getContentRoots();
}

>

Debabrata,
sorry, I am afraid I fail to understand your code.
ModuleManager.getModules() returns some values - where do you put them?
Return value of the call

'ModuleManager.getInstance(myProject).getModules()'

is apparently not assigned anywhere...

>

Confused,
Dmitry

>

--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"



0

Debabrata Dash wrote:

Sorry in the code, I had...

Module[] modules = ModuleManager.getInstance(myProject).getModules();

System.out.println(modules.length);

And it always printed 0.


Where do you get 'myProject' from?
I think I need a broader context - apparently 'myProject' is not a project
you think it is :). I am sure that getModules works right, since this method
is used all over IDEA's own code, which works (mostly) :)

Cheers,
Dmitry


-Dash.

"Dmitry Lomov (JetBrains)" <Dmitry.Lomov@jetbrains.com> wrote in message
news:c0csf0$b1q$2@is.intellij.net...

>> Debabrata Dash wrote:
>>
>> > Hi,
>> > In my plugin I am trying to get the content roots, by doing the
>> > following. Somehow the list of modules I am getting is empty. My
>> > project has just one module, is that the reason ? or I need to do
>> > something different ? Its in build 1151.
>> >
>> > thanks,
>> > Dash.
>> >
>> > ModuleManager.getInstance(myProject).getModules();
>> >
>> > for (int i = 0; i < modules.length; i++) {
>> > Module module = modules+;
>> >
>> > VirtualFile files[] =
>> > ModuleRootManager.getInstance(module).getContentRoots();
>> > }
>>
>> Debabrata,
>> sorry, I am afraid I fail to understand your code.
>> ModuleManager.getModules() returns some values - where do you put them?
>> Return value of the call

'ModuleManager.getInstance(myProject).getModules()'

>> is apparently not assigned anywhere...
>>
>> Confused,
>> Dmitry
>>
>> --
>> Dmitry Lomov
>> Software Developer
>> JetBrains Inc.
>> http://www.jetbrains.com
>> "Develop with pleasure!"

--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0

Hmm.... I must be doing something really doppy...

I get myProject from AbstractVcs, which gets initialized at the time of
component initialization.

-Dash.

"Dmitry Lomov (JetBrains)" <Dmitry.Lomov@jetbrains.com> wrote in message
news:c0fc75$pj2$1@is.intellij.net...

Debabrata Dash wrote:

>

Sorry in the code, I had...

>

Module[] modules = ModuleManager.getInstance(myProject).getModules();

>

System.out.println(modules.length);

>

And it always printed 0.

>

Where do you get 'myProject' from?
I think I need a broader context - apparently 'myProject' is not a project
you think it is :). I am sure that getModules works right, since this

method

is used all over IDEA's own code, which works (mostly) :)

>

Cheers,
Dmitry

>

>

-Dash.

>

"Dmitry Lomov (JetBrains)" <Dmitry.Lomov@jetbrains.com> wrote in message
news:c0csf0$b1q$2@is.intellij.net...

>> Debabrata Dash wrote:
>>
>> > Hi,
>> > In my plugin I am trying to get the content roots, by doing the
>> > following. Somehow the list of modules I am getting is empty. My
>> > project has just one module, is that the reason ? or I need to do
>> > something different ? Its in build 1151.
>> >
>> > thanks,
>> > Dash.
>> >
>> > ModuleManager.getInstance(myProject).getModules();
>> >
>> > for (int i = 0; i < modules.length; i++) {
>> > Module module = modules+;
>> >
>> > VirtualFile files[] =
>> > ModuleRootManager.getInstance(module).getContentRoots();
>> > }
>>
>> Debabrata,
>> sorry, I am afraid I fail to understand your code.
>> ModuleManager.getModules() returns some values - where do you put them?
>> Return value of the call

'ModuleManager.getInstance(myProject).getModules()'

>> is apparently not assigned anywhere...
>>
>> Confused,
>> Dmitry
>>
>> --
>> Dmitry Lomov
>> Software Developer
>> JetBrains Inc.
>> http://www.jetbrains.com
>> "Develop with pleasure!"

>

--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"



0

Please sign in to leave a comment.