Skip to content

Commit

Permalink
Code Style settings: Type Annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfatin committed Sep 7, 2012
1 parent 391174b commit 85a2fae
Show file tree
Hide file tree
Showing 6 changed files with 440 additions and 0 deletions.
Expand Up @@ -64,6 +64,20 @@ public static ScalaCodeStyleSettings getInstance(Project project) {
public static final int MULTILINE_STRING_QUOTES_AND_INDENT = 1; public static final int MULTILINE_STRING_QUOTES_AND_INDENT = 1;
public static final int MULTILINE_STRING_ALL = 2; public static final int MULTILINE_STRING_ALL = 2;


//type annotations
public int LOCAL_PROPERTY_TYPE_ANNOTATION = TypeAnnotationRequirement.Optional.ordinal();
public int PUBLIC_PROPERTY_TYPE_ANNOTATION = TypeAnnotationRequirement.Preferred.ordinal();
public int PROTECTED_PROPERTY_TYPE_ANNOTATION = TypeAnnotationRequirement.Preferred.ordinal();
public int PRIVATE_PROPERTY_TYPE_ANNOTATION = TypeAnnotationRequirement.Optional.ordinal();
public int OVERRIDING_PROPERTY_TYPE_ANNOTATION = TypeAnnotationPolicy.Regular.ordinal();
public int SIMPLE_PROPERTY_TYPE_ANNOTATION = TypeAnnotationPolicy.Optional.ordinal();

public int LOCAL_METHOD_TYPE_ANNOTATION = TypeAnnotationRequirement.Optional.ordinal();
public int PUBLIC_METHOD_TYPE_ANNOTATION = TypeAnnotationRequirement.Preferred.ordinal();
public int PROTECTED_METHOD_TYPE_ANNOTATION = TypeAnnotationRequirement.Preferred.ordinal();
public int PRIVATE_METHOD_TYPE_ANNOTATION = TypeAnnotationRequirement.Optional.ordinal();
public int OVERRIDING_METHOD_TYPE_ANNOTATION = TypeAnnotationPolicy.Regular.ordinal();
public int SIMPLE_METHOD_TYPE_ANNOTATION = TypeAnnotationPolicy.Optional.ordinal();


public ScalaCodeStyleSettings(CodeStyleSettings container) { public ScalaCodeStyleSettings(CodeStyleSettings container) {
super("ScalaCodeStyleSettings", container); super("ScalaCodeStyleSettings", container);
Expand Down
Expand Up @@ -13,5 +13,6 @@ class ScalaTabbedCodeStylePanel(currentSettings: CodeStyleSettings, settings: Co
protected override def initTabs(settings: CodeStyleSettings) { protected override def initTabs(settings: CodeStyleSettings) {
super.initTabs(settings) super.initTabs(settings)
addTab(new MultiLineStringCodeStylePanel(settings)) addTab(new MultiLineStringCodeStylePanel(settings))
addTab(new TypeAnnotationsPanel(settings))
} }
} }
@@ -0,0 +1,21 @@
package org.jetbrains.plugins.scala.lang.formatting.settings;

/**
* Pavel Fatin
*/
public enum TypeAnnotationPolicy {
Optional("Optional"),
Regular("As Usual");

private String myDescription;

private TypeAnnotationPolicy(String description) {
myDescription = description;
}


@Override
public String toString() {
return myDescription;
}
}
@@ -0,0 +1,22 @@
package org.jetbrains.plugins.scala.lang.formatting.settings;

/**
* Pavel Fatin
*/
public enum TypeAnnotationRequirement {
Optional("Optional"),
Preferred("Add"),
Required("Add & Check");

private String myDescription;

private TypeAnnotationRequirement(String description) {
myDescription = description;
}


@Override
public String toString() {
return myDescription;
}
}
@@ -0,0 +1,239 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.plugins.scala.lang.formatting.settings.TypeAnnotationsPanel">
<grid id="27dc6" binding="contentPanel" layout-manager="GridLayoutManager" row-count="16" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="524"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<vspacer id="fd78d">
<constraints>
<grid row="15" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<hspacer id="6daaa">
<constraints>
<grid row="15" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="70647" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Value"/>
</properties>
</component>
<component id="7c086" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Method"/>
</properties>
</component>
<component id="13a50" class="com.intellij.ui.TitledSeparator">
<constraints>
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Instance Type Annotations"/>
</properties>
</component>
<component id="31556" class="javax.swing.JComboBox" binding="myPublicPropertyComboBox">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="b0417" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Public:"/>
</properties>
</component>
<component id="f77a5" class="javax.swing.JLabel">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Protected:"/>
</properties>
</component>
<component id="db8b7" class="javax.swing.JLabel">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Private:"/>
</properties>
</component>
<component id="8752f" class="javax.swing.JComboBox" binding="myProtectedPropertyComboBox">
<constraints>
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="85dfa" class="javax.swing.JComboBox" binding="myPrivatePropertyComboBox">
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="8ccc6" class="javax.swing.JComboBox" binding="myPublicMethodComboBox">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="102d7" class="javax.swing.JComboBox" binding="myProtectedMethodComboBox">
<constraints>
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="f448" class="javax.swing.JComboBox" binding="myPrivateMethodComboBox">
<constraints>
<grid row="4" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="bf5b6" class="com.intellij.ui.TitledSeparator">
<constraints>
<grid row="10" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Special Cases"/>
</properties>
</component>
<component id="38181" class="javax.swing.JLabel">
<constraints>
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Value"/>
</properties>
</component>
<component id="9c42f" class="javax.swing.JLabel">
<constraints>
<grid row="11" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Method"/>
</properties>
</component>
<component id="2e4ee" class="javax.swing.JComboBox" binding="myOverridingPropertyComboBox">
<constraints>
<grid row="12" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="7630a" class="javax.swing.JComboBox" binding="myOverridingMethodComboBox">
<constraints>
<grid row="12" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="f2818" class="com.intellij.ui.TitledSeparator">
<constraints>
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Local Type Annotations"/>
</properties>
</component>
<component id="351bb" class="javax.swing.JLabel">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Value"/>
</properties>
</component>
<component id="3dfdd" class="javax.swing.JLabel">
<constraints>
<grid row="7" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Method"/>
</properties>
</component>
<component id="808ae" class="javax.swing.JComboBox" binding="myLocalPropertyComboBox">
<constraints>
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="24c60" class="javax.swing.JComboBox" binding="myLocalMethodComboBox">
<constraints>
<grid row="8" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="afe8a" class="javax.swing.JLabel">
<constraints>
<grid row="12" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Overriding:"/>
</properties>
</component>
<component id="39dac" class="javax.swing.JLabel">
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Local:"/>
</properties>
</component>
<component id="7177f" class="javax.swing.JLabel">
<constraints>
<grid row="13" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Simple:"/>
</properties>
</component>
<component id="b18a9" class="javax.swing.JComboBox" binding="mySimplePropertyComboBox">
<constraints>
<grid row="13" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="663c0" class="javax.swing.JComboBox" binding="mySimpleMethodComboBox">
<constraints>
<grid row="13" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
<component id="21c5b" class="javax.swing.JLabel">
<constraints>
<grid row="14" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&lt;html&gt;&lt;body&gt;&#10;&lt;br&gt;&#10;&lt;strong&gt;Legend:&lt;/strong&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Add - insert in generated code.&lt;/li&gt;&#10;&lt;li&gt;Check - warn when not present.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/body&gt;&lt;/html&gt;"/>
</properties>
</component>
<vspacer id="c77b8">
<constraints>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="1" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="-1" height="10"/>
<maximum-size width="-1" height="10"/>
</grid>
</constraints>
</vspacer>
<vspacer id="c3afc">
<constraints>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="1" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="-1" height="10"/>
<maximum-size width="-1" height="10"/>
</grid>
</constraints>
</vspacer>
</children>
</grid>
</form>

0 comments on commit 85a2fae

Please sign in to comment.