This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 110102 - indentation doesn't work
Summary: indentation doesn't work
Status: VERIFIED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: JSP (show other bugs)
Version: 6.x
Hardware: Sun All
: P1 blocker (vote)
Assignee: Marek Fukala
URL:
Keywords:
: 110128 111947 (view as bug list)
Depends on: 110129
Blocks:
  Show dependency tree
 
Reported: 2007-07-18 08:41 UTC by Jindrich Sedek
Modified: 2007-08-06 10:27 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The patch for Schlieman's IndentTask implementation (2.38 KB, patch)
2007-07-18 12:43 UTC, Marek Fukala
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jindrich Sedek 2007-07-18 08:41:13 UTC
HTML code is indented much more than it should be - cursor is move many tabs to right after pressing enter anywhere in
editor

scriptlet code is not indented at all - cursor is always set on first column

reformat code does nothing

the same problem appears in HTML editor with HTML code
Comment 1 Marek Fukala 2007-07-18 09:29:29 UTC
It was not possible to work in it yesterday because of issue #110001. I'll fix this ASAP.
Comment 2 Marek Fukala 2007-07-18 12:10:48 UTC
The problem with the html tags indentation is caused by several bugs:

1)a bug in Schlieman default indendent api implementation. The code in IndentFactory adds some indentation even in case
when the formatted language is not handled by Schlieman. For example in an html file with embedded javascript the
Schlieman implementation is called by the editor/indent infrastructure for text/x-javascript and
text/x-javascript/text/x-javascript-string languages. However these calls influences formatting of pure html text when
pressing enter outside of <script> tag.

fixed

Checking in IndentFactory.java;
/cvs/languages/engine/src/org/netbeans/modules/languages/features/IndentFactory.java,v  <--  IndentFactory.java
new revision: 1.2; previous revision: 1.1
done
Comment 3 Marek Fukala 2007-07-18 12:27:46 UTC
2) The mechanism of the generic Schlieman indentation indents the same code more times depending on number of embedded
languages handled by Schlieman. The code tries to find the deepest embedding on the specified offset and then uses the 
mimeType of the embedded language to find the indentation feature and then to reindent the code. This is OK, however the
infrastructure calls the IndentTask for all languages found in the file and so it happens that because of the described
mechanism the file is indented several times by the same indenter. 

For example: If you press enter in embedded javascript code in an html file the infrastrucure calls the Schlieman's
indentation twice - once of "text/x-javascript" and once for "text/x-javascript/text/x-javascript-string". However for
both calls the same language "text/x-javascript" language is found and the same indentation is done.

The problem is that the implementation of IndentTask factory has no possibility to check what is "its" mimetype. For
handcoded IndentTask implemented per language this is not a problem - the code always knows what is its language and
decide whether to reformat the file or not. This is not true for Schlieman - the same implementation of IndentTask is
registered for various mimetypes and hence the code cannot determine what to indent and what to ignore in the file. To
achieve this a change in editor/indent is necessary. In particular the Context class needs to have a possibility to get
the mimetype.

I have made the change above in the editor/indent and also fixed the described problem in the Schlieman implemenatation
 of IndentTask. Since the change in editor/indent is an API change I'll file a separate issue so we can do a fast track
review for it.
Comment 4 Marek Fukala 2007-07-18 12:41:24 UTC
The editor/indent api change issue #110129 has been filed.
Comment 5 Marek Fukala 2007-07-18 12:43:58 UTC
Created attachment 45306 [details]
The patch for Schlieman's IndentTask implementation
Comment 6 Marek Fukala 2007-07-18 12:45:55 UTC
*** Issue 110128 has been marked as a duplicate of this issue. ***
Comment 7 Marek Fukala 2007-07-18 13:15:05 UTC
3) html and jsp editor doesn't implement editor/indent SPI - fixed

Checking in html/editor/src/org/netbeans/modules/html/editor/resources/layer.xml;
/cvs/html/editor/src/org/netbeans/modules/html/editor/resources/layer.xml,v  <--  layer.xml
new revision: 1.16; previous revision: 1.15
done
Checking in web/jspsyntax/src/org/netbeans/modules/web/core/syntax/formatting/JspFormatter.java;
/cvs/web/jspsyntax/src/org/netbeans/modules/web/core/syntax/formatting/JspFormatter.java,v  <--  JspFormatter.java
new revision: 1.2; previous revision: 1.1
done
RCS file: /cvs/html/editor/src/org/netbeans/modules/html/editor/indent/HtmlIndentTaskFactory.java,v
done
Checking in html/editor/src/org/netbeans/modules/html/editor/indent/HtmlIndentTaskFactory.java;
/cvs/html/editor/src/org/netbeans/modules/html/editor/indent/HtmlIndentTaskFactory.java,v  <--  HtmlIndentTaskFactory.java
initial revision: 1.1
done
RCS file: /cvs/html/editor/src/org/netbeans/modules/html/editor/indent/HtmlIndentTask.java,v
done
Checking in html/editor/src/org/netbeans/modules/html/editor/indent/HtmlIndentTask.java;
/cvs/html/editor/src/org/netbeans/modules/html/editor/indent/HtmlIndentTask.java,v  <--  HtmlIndentTask.java
initial revision: 1.1
done
Checking in web/jspsyntax/src/org/netbeans/modules/web/core/syntax/resources/layer.xml;
/cvs/web/jspsyntax/src/org/netbeans/modules/web/core/syntax/resources/layer.xml,v  <--  layer.xml
new revision: 1.21; previous revision: 1.20
done
RCS file: /cvs/web/jspsyntax/src/org/netbeans/modules/web/core/syntax/indent/JspIndentTask.java,v
done
Checking in web/jspsyntax/src/org/netbeans/modules/web/core/syntax/indent/JspIndentTask.java;
/cvs/web/jspsyntax/src/org/netbeans/modules/web/core/syntax/indent/JspIndentTask.java,v  <--  JspIndentTask.java
initial revision: 1.1
done
RCS file: /cvs/web/jspsyntax/src/org/netbeans/modules/web/core/syntax/indent/JspIndentTaskFactory.java,v
done
Checking in web/jspsyntax/src/org/netbeans/modules/web/core/syntax/indent/JspIndentTaskFactory.java;
/cvs/web/jspsyntax/src/org/netbeans/modules/web/core/syntax/indent/JspIndentTaskFactory.java,v  <-- 
JspIndentTaskFactory.java
initial revision: 1.1
done
Checking in html/editor/nbproject/project.xml;
/cvs/html/editor/nbproject/project.xml,v  <--  project.xml
new revision: 1.21; previous revision: 1.20
done
Comment 8 Marek Fukala 2007-07-20 12:42:49 UTC
Applied the patch for Schlieman's IndentTask impl.

Checking in IndentFactory.java;
/cvs/languages/engine/src/org/netbeans/modules/languages/features/IndentFactory.java,v  <--  IndentFactory.java
new revision: 1.4; previous revision: 1.3
done
Comment 9 Jindrich Sedek 2007-07-31 10:03:42 UTC
verifed.
Build 200707310000
Comment 10 Martin Schovanek 2007-08-06 10:27:44 UTC
*** Issue 111947 has been marked as a duplicate of this issue. ***