Bug 237775 - [content assist] Duplicate page directive imports added by content assist
Summary: [content assist] Duplicate page directive imports added by content assist
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: jst.jsp (show other bugs)
Version: 2.0.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.2 M3   Edit
Assignee: Aidyl Kareh CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard: qplan
Keywords: plan
Depends on:
Blocks:
 
Reported: 2008-06-19 08:23 EDT by Mauro Molinari CLA
Modified: 2009-09-28 14:26 EDT (History)
2 users (show)

See Also:
nsand.dev: review+


Attachments
Bug Fix Patch (2.23 KB, patch)
2009-09-03 09:40 EDT, Aidyl Kareh CLA
nsand.dev: iplog+
nsand.dev: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mauro Molinari CLA 2008-06-19 08:23:39 EDT
Build ID: M20080221-1800

Steps To Reproduce:
1. create a new Dynamic Web Project (with Dynamic Web Module 2.4 and Java 5.0)
2. create a new Java class like this:

package a;

public class TestClass
{

}

3. in WebContent, create a new JSP, name it test.jsp and accept al the defaults.

This JSP is created:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

</body>
</html>

4. at line 10, start a scriptlet and try to define a TestClass viariable, in this way:

// cut //
<body>
  <%
      TestCl <= invoke code completion here!
  %>
</body>
// cut //

5. invoke code completion as shown above: select TestClass as the completion proposal suggests

6. the result is the following:
=> an import is added after <!DOCTYPE>:
<%@page import="a.TestClass"%>
(this is ok!)
=> your class name is completed as "TestCls", instead of "TestClass"!

7. try to remove the last "s" of "TestCls" and invoke code completion again

8. select the suggested TestClass again; the result is the following:
=> another import is added, right after the first one, and also wrong:
<%@page import="a.TestClass"%>
<%@page import="TestClass"%>
=> the class name is still completed as "TestCls" instead of "TestClass"
Comment 1 Cameron Bateman CLA 2009-05-08 18:28:59 EDT
What is interesting is that this is particular to the package name "a".  The same problem doesn't manifest if the class is "b.TestClass" or "aa.TestClass".
Comment 2 Aidyl Kareh CLA 2009-09-03 09:40:03 EDT
Created attachment 146389 [details]
Bug Fix Patch

Problem was caused by several errors in the JSPProposalCollector class. The incorrect code completion was caused by an error when removing the signature from the class name. Thus, in the recreation scenario, the regular expression "a." was being removed from "a.TestClass" instead of "a\\.". This caused for all the 'a' characters followed by any character to be removed. The multiple page import of the same class was caused by a problem on the condition that determines when the auto adding of the page import is needed. Fixed code to address these problems.
Comment 3 Nick Sandonato CLA 2009-09-28 13:42:19 EDT
Patch looks good. Thanks, Aidyl.