What to do about variables in includes?

Our JSPs are structured to include a header.jsp and a footer.jsp. header.jsp
also includes two or three other jsps.

All of these jsps declare variables/usebeans. When editing a jsp that
includes these, IDEA marks all of these variables as undeclared, since they
are not declared in the actual jsp, but in the included ones. Will IDEA ever
search through includes to and load up the variables declared in them?

Ian.


0
6 comments

Ian,

IDEA should handle such variables correctly. Can you give an example when it
doesn't?

--
Best regards,
Mike Aizatsky.
-


JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Ian Zabel" <izabel@cirqit.com> wrote in message
news:acb56q$ljh$1@is.intellij.net...

Our JSPs are structured to include a header.jsp and a footer.jsp.

header.jsp

also includes two or three other jsps.

>

All of these jsps declare variables/usebeans. When editing a jsp that
includes these, IDEA marks all of these variables as undeclared, since

they

are not declared in the actual jsp, but in the included ones. Will IDEA

ever

search through includes to and load up the variables declared in them?

>

Ian.

>
>


0

Yes, you're right, this does work with 621. Nice! Sorry!
But, after testing a little more, if I "Go to Declaration" on one of these
included variables, I get this exception:

ERROR - mand.impl.CommandProcessorImpl -
ERROR - mand.impl.CommandProcessorImpl - IntelliJ IDEA (Ariadna)
3.0 Build #621
ERROR - mand.impl.CommandProcessorImpl - JDK: 1.3.1
ERROR - mand.impl.CommandProcessorImpl - VM: Java HotSpot(TM)
ClientVM
ERROR - mand.impl.CommandProcessorImpl - Vendor: Sun Microsystems
Inc.
ERROR - mand.impl.CommandProcessorImpl - OS: Windows 2000
ERROR - mand.impl.CommandProcessorImpl -
java.lang.NullPointerException
at
com.intellij.codeInsight.actions.BrowseSymbolAction.invoke(BrowseSymbolActio
n.java:61)
at com.intellij.codeInsight.actions.c.run(c.java)
at com.intellij.openapi.application.a.b.runWriteAction(b.java:91)
at com.intellij.codeInsight.actions.b.run(b.java:0)
at
com.intellij.command.impl.CommandProcessorImpl.a(CommandProcessorImpl.java:5
)
at com.intellij.codeInsight.actions.y.actionPerformed(y.java:22)
at com.intellij.codeInsight.d.o.c(o.java:15)
at
com.intellij.editor.impl.EditorManagerImpl.c(EditorManagerImpl.java:99)
at com.intellij.editor.impl.m.c(m.java:84)
at com.intellij.editor.impl.m.f(m.java:749)
at com.intellij.editor.impl.d.mouseClicked(d.java:8)
at java.awt.Component.processMouseEvent(Component.java:3718)
at java.awt.Component.processEvent(Component.java:3544)
at java.awt.Container.processEvent(Container.java:1164)
at java.awt.Component.dispatchEventImpl(Component.java:2593)
at java.awt.Container.dispatchEventImpl(Container.java:1213)
at java.awt.Component.dispatchEvent(Component.java:2497)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:2230)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
at java.awt.Container.dispatchEventImpl(Container.java:1200)
at java.awt.Window.dispatchEventImpl(Window.java:914)
at java.awt.Component.dispatchEvent(Component.java:2497)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)
at com.intellij.ide.d.dispatchEvent(d.java:33)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja
va:131)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java
:98)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)


Ian.

"Mike Aizatsky" <mike@intellij.com> wrote in message
news:acb5rl$m1j$1@is.intellij.net...

Ian,

>

IDEA should handle such variables correctly. Can you give an example when

it

doesn't?

>

--
Best regards,
Mike Aizatsky.
------------------------------
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"

>
>

"Ian Zabel" <izabel@cirqit.com> wrote in message
news:acb56q$ljh$1@is.intellij.net...

Our JSPs are structured to include a header.jsp and a footer.jsp.

header.jsp

also includes two or three other jsps.

>

All of these jsps declare variables/usebeans. When editing a jsp that
includes these, IDEA marks all of these variables as undeclared, since

they

are not declared in the actual jsp, but in the included ones. Will IDEA

ever

search through includes to and load up the variables declared in them?

>

Ian.

>
>

>
>


0

The only missing part of this is if I have a JSP that is just on it's own,
and is included at compile time and uses variables declared in the JSP
including it, none of these variables are found. I don't expect this to work
though, because this JSP does not have any includes itself. It's just a
snippet of JSP code, basically.

Sort of like this:

1.jsp:

HashMap products;
<%@ include file="2.jsp"%>

2.jsp:

products = new HashMap();


In 2.jsp, products will not be found, since it is declared in 1.jsp.

I don't know if there's certain way in the JSP language to sort of "require"
that a certain variable be declared in any JSP including the current JSP,
and specify its type, but I assume this would be the only way to let IDEA
recognize this variable.

Ian.




"Mike Aizatsky" <mike@intellij.com> wrote in message
news:acb5rl$m1j$1@is.intellij.net...

Ian,

>

IDEA should handle such variables correctly. Can you give an example when

it

doesn't?

>

--
Best regards,
Mike Aizatsky.
------------------------------
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"

>
>

"Ian Zabel" <izabel@cirqit.com> wrote in message
news:acb56q$ljh$1@is.intellij.net...

Our JSPs are structured to include a header.jsp and a footer.jsp.

header.jsp

also includes two or three other jsps.

>

All of these jsps declare variables/usebeans. When editing a jsp that
includes these, IDEA marks all of these variables as undeclared, since

they

are not declared in the actual jsp, but in the included ones. Will IDEA

ever

search through includes to and load up the variables declared in them?

>

Ian.

>
>

>
>


0

Ian,

It's a known problem. However we consider such a style as extremely bad
practice. So we don't think it will be ever fixed.

--
Best regards,
Mike Aizatsky.
-


JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


"Ian Zabel" <izabel@cirqit.com> wrote in message
news:acb7mp$noo$1@is.intellij.net...

The only missing part of this is if I have a JSP that is just on it's own,
and is included at compile time and uses variables declared in the JSP
including it, none of these variables are found. I don't expect this to

work

though, because this JSP does not have any includes itself. It's just a
snippet of JSP code, basically.

>

Sort of like this:

>

1.jsp:

>

HashMap products;
<%@ include file="2.jsp"%>

>

2.jsp:

>

products = new HashMap();

>
>

In 2.jsp, products will not be found, since it is declared in 1.jsp.

>

I don't know if there's certain way in the JSP language to sort of

"require"

that a certain variable be declared in any JSP including the current JSP,
and specify its type, but I assume this would be the only way to let IDEA
recognize this variable.

>

Ian.

>
>
>
>

"Mike Aizatsky" <mike@intellij.com> wrote in message
news:acb5rl$m1j$1@is.intellij.net...

Ian,

>

IDEA should handle such variables correctly. Can you give an example

when

it

doesn't?

>

--
Best regards,
Mike Aizatsky.
------------------------------
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"

>
>

"Ian Zabel" <izabel@cirqit.com> wrote in message
news:acb56q$ljh$1@is.intellij.net...

Our JSPs are structured to include a header.jsp and a footer.jsp.

header.jsp

also includes two or three other jsps.

>

All of these jsps declare variables/usebeans. When editing a jsp that
includes these, IDEA marks all of these variables as undeclared, since

they

are not declared in the actual jsp, but in the included ones. Will

IDEA

ever

search through includes to and load up the variables declared in them?

>

Ian.

>
>

>
>

>
>


0

I agree! It is extremely bad practice. Thanks for the response.


"Mike Aizatsky" <mike@intellij.com> wrote in message
news:acbdtg$t9c$1@is.intellij.net...

Ian,

>

It's a known problem. However we consider such a style as extremely bad
practice. So we don't think it will be ever fixed.

>

--
Best regards,
Mike Aizatsky.
------------------------------
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"

>
>

"Ian Zabel" <izabel@cirqit.com> wrote in message
news:acb7mp$noo$1@is.intellij.net...

The only missing part of this is if I have a JSP that is just on it's

own,

and is included at compile time and uses variables declared in the JSP
including it, none of these variables are found. I don't expect this to

work

though, because this JSP does not have any includes itself. It's just a
snippet of JSP code, basically.

>

Sort of like this:

>

1.jsp:

>

HashMap products;
<%@ include file="2.jsp"%>

>

2.jsp:

>

products = new HashMap();

>
>

In 2.jsp, products will not be found, since it is declared in 1.jsp.

>

I don't know if there's certain way in the JSP language to sort of

"require"

that a certain variable be declared in any JSP including the current

JSP,

and specify its type, but I assume this would be the only way to let

IDEA

recognize this variable.

>

Ian.

>
>
>
>

"Mike Aizatsky" <mike@intellij.com> wrote in message
news:acb5rl$m1j$1@is.intellij.net...

Ian,

>

IDEA should handle such variables correctly. Can you give an example

when

it

doesn't?

>

--
Best regards,
Mike Aizatsky.
------------------------------
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"

>
>

"Ian Zabel" <izabel@cirqit.com> wrote in message
news:acb56q$ljh$1@is.intellij.net...

Our JSPs are structured to include a header.jsp and a footer.jsp.

header.jsp

also includes two or three other jsps.

>

All of these jsps declare variables/usebeans. When editing a jsp

that

includes these, IDEA marks all of these variables as undeclared,

since

they

are not declared in the actual jsp, but in the included ones. Will

IDEA

ever

search through includes to and load up the variables declared in

them?

>

Ian.

>
>

>
>

>
>

>
>


0

I'm having a problem where if the including page has an import, and the
included page declares a variable which is of the imported type, the
including page doesn't recognize the fully-qualified type.

For example:
a.jsp:
<%@page import="java.util.ArrayList" %>
<%@include file="b.jsp" %>

<%
x.add("hello");
java.util.Collections.fill(x, "foo");
%>

-


b.jsp:
<% ArrayList x = new ArrayList(); %>

When editing a.jsp, IDEA recognizes bar as a variable of type "ArrayList",
but not of type "java.util.ArrayList". So IDEA gives "fill(java.util.List,
...) ... cannot be applied to (ArrayList, java.lang.String)" and add() is
written in red. Also, when I change b.jsp to:
<% java.util.ArrayList x = new java.util.ArrayList(); %>
a.jsp's highlighting returns to normal only after I change a.jsp in some
way.

I realize that relying on imports from the including file is bad practice,
but I've got a number of pages not written by me that do so, and I'd rather
not have to fix them all to work with them. I don't expect the included
files to look okay, but it'd be nice if you could catch this for the
including files.

-Walter Mundt

"Mike Aizatsky" <mike@intellij.com> wrote in message
news:acb5rl$m1j$1@is.intellij.net...

Ian,

>

IDEA should handle such variables correctly. Can you give an example when

it

doesn't?

>

--
Best regards,
Mike Aizatsky.
------------------------------
JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"

>
>

"Ian Zabel" <izabel@cirqit.com> wrote in message
news:acb56q$ljh$1@is.intellij.net...

Our JSPs are structured to include a header.jsp and a footer.jsp.

header.jsp

also includes two or three other jsps.

>

All of these jsps declare variables/usebeans. When editing a jsp that
includes these, IDEA marks all of these variables as undeclared, since

they

are not declared in the actual jsp, but in the included ones. Will IDEA

ever

search through includes to and load up the variables declared in them?

>

Ian.

>
>

>
>



0

Please sign in to leave a comment.