platform-ui-home/code-conventions/index.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (view) (download) (as text)

1 : tod 1.1 <html>
2 : cmclaren 1.4 <head>
3 :     <title>Code Conventions for the Platform UI Team</title>
4 :     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5 :     <link rel="stylesheet" href="http://dev.eclipse.org/default_style.css" type="text/css">
6 :     </head>
7 :     <body bgcolor="#FFFFFF" text="#000000">
8 :     <table border=0 cellspacing=5 cellpadding=2 width="100%" >
9 :     <tr>
10 :     <td align=LEFT valign=TOP colspan="2" bgcolor="#0080C0">
11 :     <b><font color="#FFFFFF" face="Arial,Helvetica">Code Conventions for the Platform UI Team</font></b>
12 :     </td>
13 :     </tr>
14 :     <tr>
15 :     <td align=right valign=top width="2%">
16 : nick 1.9 <img src="http://dev.eclipse.org/images/Adarrow.gif" border=0 height=16 width=16 alt = "arrow">
17 : cmclaren 1.4 </td>
18 :     <td width="98%">
19 : dpollock 1.7 <p>The main Eclipse coding conventions can be found <a href="http://dev.eclipse.org/conventions.html">here</a>.</p>
20 :     <p>The Platform UI team separates the issue of coding
21 :     conventions into two components: formatting, and compiler
22 :     warnings and errors.</p>
23 :     <p>For formatting, all of our code is formatted using the
24 :     built-in "Java Conventions" formatter provided by JDT. All
25 :     of imports should be organized using the default settings.
26 :     We discourage the use of the "Sort Memebers" functionality;
27 :     however, if you are creating new files, feel free to use it
28 :     if you wish. Do not use "Sort Members" on existing
29 :     code.</p>
30 :     <p>For compiler settings, we recommend changing the
31 :     following items from "Ignore" to "Warning". As a note, it
32 :     is required that all Platform UI code (excluding code in
33 :     "org.eclipse.ui.tests") does not contain non-externalized
34 :     strings.
35 :     <ul>
36 :     <li>Style</li>
37 :     <ul>
38 :     <li>Indirect access to a static member</li>
39 :     <li>Possible accidental boolean assignment</li>
40 :     <li>Undocumented empty block</li>
41 :     </ul>
42 :     <li>Advanced</li>
43 :     <ul>
44 :     <li>Local variable declaration hides another field
45 :     or variable</li>
46 :     <li>Field declaration hides another field or
47 :     variable</li>
48 :     <li>Usage of non-externalized strings</li>
49 :     </ul>
50 :     <li>Unused Code</li>
51 :     <ul>
52 :     <li>Local variable is never read</li>
53 :     <li>Unused or unread private members</li>
54 :     <li>Usage of deprecated API</li>
55 :     <li>Unnecessary semicolon</li>
56 :     <li>Unnecessary cast or 'instanceof' operation</li>
57 :     </ul>
58 :     </ul>
59 :     <p>These settings can be imported from this
60 : dpollock 1.8 <a href="codeconventions.epf">file</a>.
61 : nick 1.9 </td>
62 :     </tr>
63 :     <tr>
64 :     <td align=right valign=top width="2%">
65 :     <img src="http://dev.eclipse.org/images/Adarrow.gif" border=0 height=16 width=16 alt = "arrow">
66 :     </td>
67 :     <td width="98%">
68 :     <p>Platform UI covers several components: JFace, the Generic Workbench, and the IDE.
69 :     </p>
70 :     <p>
71 :     Code in these components should respect the API boundaries of these other components
72 :     (i.e. treat other components as if they were owned by another team).
73 :     In particular, code in the <code>org.eclipse.ui.ide</code> plug-in should not refer
74 :     to internal classes in <code>org.eclipse.ui</code> or <code>org.eclipse.ui.workbench</code>.
75 :     The IDE should follow the same rules as any other RCP application.
76 :     <p>
77 :     Code in these components should respect the API boundaries of these other components
78 :     (i.e. treat other components as if they were owned by another team).
79 :     In particular, code in the <code>org.eclipse.ui.ide</code> plug-in should not refer
80 :     to internal classes in <code>org.eclipse.ui</code> or <code>org.eclipse.ui.workbench</code>.
81 :     The IDE should follow the same rules as any other RCP application.
82 :     </p>
83 :     </td>
84 :     </tr>
85 :     <tr>
86 :     <td align=right valign=top width="2%">
87 :     <img src="http://dev.eclipse.org/images/Adarrow.gif" border=0 height=16 width=16 alt = "arrow">
88 :     </td>
89 :     <td width="98%">
90 :     <p>In the IDE, we occasionally need to map between workspace resources and workbench objects.
91 :     For example, when closing a project, we need to determine the affected editors by checking
92 :     whether their input corresponds to a file in the project. Although the IDE provides IFileEditorInput
93 :     and FileEditorInput, we must not assume that this is the only kind of editor input that
94 :     can represent an workspace file. When mapping from an editor input, use the adaptable mechanism
95 :     rather than instanceof checks for [I]FileEditorInput. See ResourceUtil.getFile(IEditorInput) for
96 :     a convenience method that will do this properly.
97 :     </p>
98 : cmclaren 1.4 </td>
99 :     </tr>
100 :     </table>
101 :     </body>
102 : tod 1.1 </html>