How to include flex source directory in package name?

We have a very large flex-based application that started out way back with Flex 1.0 and way back then Macromedia (now Adobe) did not give us any directions on how we were supposed to put the flex source code in our project directory.  Being inexperienced we just created a directory called flex and just copied that directory to the server and everything worked fine. So it looked something like this:

(root)

(root)\flex\main.mxml

(root)\flex\common\Utilities.as

[...]

(root)\flex\panels\order\OrderItem.as

[...etc]


This structure caused us problems with Adobe's development tools when we migrated to flex 2 because we use CVS.  CVS doesn't allow you to move/rename/delete directories so we were stuck with the directory structure we had originally created.  This meant that our package names had to look like "flex.panels.order" instead of one of the more traditional java-type package names. We were able to find workarounds to use the development tools and everything was eventually working.  Now though we have Intellij 8.x to edit with and it doesn't seem to like our package names.  For instance, in the above OrderItem.as file:

package flex.panels.order {


import flex.main;

import flex.common.Utilities;


public class OrderItem {

     public var mainApp:flex.main = flex.main(Application.application);

//of code goes here

}

}

the package name "flex.panels.order" gets an error highlight that says "Package name 'flex.panels.order' does not correspond to file path 'panels.order'."  What can I do to get Idea to recognize the package name as being correct?  Note: Idea does not have any problem with the import statements.  I don't know why.

One additional thing thats more an annoyance then a problem.  Our Application class was named with a lowercase name (main.mxml).  This turns out to cause a conflict with a class in the flex frameworks and if we ever have to refer to our application class for something (like a constant, a variable, or a method, etc) the flex compiler throws an error (Can not resolve a multiname reference unambiguously).  To work correctly we must use the fullly quallified name (FQN) of the Class wherever we refer to it. Under actionscript the import line is still required even when you are using the FQN.  But Idea's code analysis doesn't seem to know that and will display a warning on the import line saying it's an unused import.  When we do an optimize imports, the line gets removed and we then get an error when we try to compile (Type was not found) and have to manually add it back in.  Other then not doing an optimize imports on flex files is there anything we can do so Idea will not consider the import unused and try to remove it?

2 comments
Comment actions Permalink

Please mark (root) as source folder.
Issue with fqn seems to be
http://www.jetbrains.net/jira/browse/IDEADEV-34254, if the problem with
unused import still exists after setting correct source directory, then
please file JIRA request.

Ronald Kinion wrote:

We have a very large flex-based application that started out way back with Flex 1.0 and way back then Macromedia (now Adobe) did not give us any directions on how we were supposed to put the flex source code in our project directory. Being inexperienced we just created a directory called flex and j
ust copied that directory to the server and everything worked fine. So it looked something like this:

(root)
(root)\flex\main.mxml
(root)\flex\common\Utilities.as



(root)\flex\panels\order\OrderItem.as



This structure caused us problems with Adobe's development tools when we migrated to flex 2 because we use CVS. CVS doesn't allow you to move/rename/delete directories so we were stuck with the directory structure we had originally created. This meant that our package names had to look like "flex.
panels.order" instead of one of the more traditional java-type package names. We were able to find workarounds to use the development tools and everything was eventually working. Now though we have Intellij 8.x to edit with and it doesn't seem to like our package names. For instance, in the above
OrderItem.as file:

package flex.panels.order {


import flex.main;
import flex.common.Utilities;


public class OrderItem {
public var mainApp:flex.main = flex.main(Application.application);
//of code goes here

}

}

the package name "flex.panels.order" gets an error highlight that says "Package name 'flex.panels.order' does not correspond to file path 'panels.order'." What can I do to get Idea to recognize the package name as being correct? Note: Idea does not have any problem with the import statements. I d
on't know why.

One additional thing thats more an annoyance then a problem. Our Application class was named with a lowercase name (main.mxml). This turns out to cause a conflict with a class in the flex frameworks and if we ever have to refer to our application class for something (like a constant, a variable, o
r a method, etc) the flex compiler throws an error (Can not resolve a multiname reference unambiguously). To work correctly we must use the fullly quallified name (FQN) of the Class wherever we refer to it. Under actionscript the import line is still required even when you are using the FQN. But I
dea's code analysis doesn't seem to know that and will display a warning on the import line saying it's an unused import. When we do an optimize imports, the line gets removed and we then get an error when we try to compile (Type was not found) and have to manually add it back in. Other then not d
oing an optimize imports on flex files is there anything we can do so Idea will not consider the import unused and try to remove it?

---
Original message URL: http://www.jetbrains.net/devnet/message/5232110#5232110



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

Please mark (root) as source folder.
Issue with fqn seems to be
http://www.jetbrains.net/jira/browse/IDEADEV-34254 , if the problem with
unused import still exists after setting correct source directory, then
please file JIRA request.

Marking the root as the source folder worked after I unmarked the flex directory as a source.  I'm a little worried about other files being used but it may be a small price to pay.

IDEADEV-34254 does seem to be the same bug I'm experiencing with the flex.main, it did not go away when I marked the project root as a source folder.

I created IDEA-21932 http://www.jetbrains.net/jira/browse/IDEA-21932 for this issue.

0

Please sign in to leave a comment.