Merge idea133 into master

This CL merges the following CLs from aosp/idea133 into aosp/master.

dabd634b Snapshot e2750ea61032f2a041cb012bb7b90cffa0deba73 from idea/133.124 of git://git.jetbrains.org/idea/community.git
29ab773f Make default test target run Android specific tests
967117a7 Merge "Make default test target run Android specific tests" into idea133
1eb71f20 Bump memory settings for unit tests
b13ea0d4 Don't bind the delete key to restoring property in layout editor
a20ccfa9 Add Gradle import module
0980f4a2 Add gradle-import to build script
cee6f8ca Fix Gradle notification lookup on Windows.
8668e1be Snapshot 020d29497847701e84e383d965abf543b80758e2 from idea/133.370 of git://git.jetbrains.org/idea/community.git
18f77669 Merge remote-tracking branch 'aosp/snapshot-master' into merge
36ac8cba Update from Guava 13.0.1 to Guava 15
4d451f93 Update libraries to lombok 0.2.2
ee06b1d0 Remove lint-cli dependency from the idea project
ab73dade Updater: add unit tests.
dd558b6e Updater: on Windows, add "Retry" on file op failures.
f2f7178a Snapshot c11f3ac9bbde3f85d1f837ec3eb48a395ed7dd10 from idea/133.471 of git://git.jetbrains.org/idea/community.git
5e4c77db Merge remote-tracking branch 'aosp/snapshot-master' into merge
8d957349 Fix junit.jar path in updater project.
58c3e0ae Include cloud tools tests in default test group
63cd9779 Temporarily disable errors in project structure dialog
e2d6089d Snapshot b9931c55d2175b6552f90b2225eb09c13bd6dfed from idea/133.609 of git://git.jetbrains.org/idea/community.git
031a291e Merge remote-tracking branch 'aosp/snapshot-master' into merge
ea628d6e Remove versions from Info.plist
809cb3e7 Snapshot 9e6329d622cc9649c9c035f28faddc29564a5b7a from idea/133.696 of git://git.jetbrains.org/idea/community.git
d6cfe6ec Merge remote-tracking branch 'aosp/snapshot-master' into merge
38f8c6f0 Gracefully handle build.gradle files in modules without a configured JDK
70ae6f2a Snapshot dc1944e804515a346297e368c3b9c35a203c9912 from idea/133.818 of git://git.jetbrains.org/idea/community.git
ac91a6de Merge remote-tracking branch 'aosp/snapshot-master' into merge
2f51d957 Gradle: respect build classpath order and use both classes and sources jars if available
0ecdb509 Snapshot c50a8ad26a72432f26e39046d6a6f21fd7a190ee from idea/134.1160 of git://git.jetbrains.org/idea/community.git
e8c22ad7 Merge remote-tracking branch 'aosp/snapshot-master' into merge
72253f7d Turn off android framework detection
93f77ee6 Temporarily remove GCT tests
88f318c9 Snapshot 34f078c3452e79ba209d28a551962857e0970e5d from idea/134.1342 of git://git.jetbrains.org/idea/community.git
afb54e4b Merge remote-tracking branch 'aosp/snapshot-master' into merge
4dc795dc Fix updater UI tests.
57a49ed1 Studio patch: more logging.
aa614ee0 table greyer (ability to disable a table)
5c571417 Use Gradle model prebuilts v0.9.0 in Studio.
cb38c25d build script: Run jarjar on the updater
f273ca07 Add App Engine templates dir to build
7607404f Removed android-builder library from Studio (not needed.)
8f29b4eb Merge idea133 changes into master

Change-Id: I12231f26e886dbf5e2e5ac0b1c4bfe18f274d78f
diff --git a/plugins/groovy/hotswap/agentSrc/org/groovy/debug/hotswap/ResetAgent.java b/plugins/groovy/hotswap/agentSrc/org/groovy/debug/hotswap/ResetAgent.java
index a3e7023..35b3577 100644
--- a/plugins/groovy/hotswap/agentSrc/org/groovy/debug/hotswap/ResetAgent.java
+++ b/plugins/groovy/hotswap/agentSrc/org/groovy/debug/hotswap/ResetAgent.java
@@ -2,6 +2,7 @@
 
 import org.objectweb.asm.*;
 
+import java.lang.String;
 import java.lang.instrument.ClassFileTransformer;
 import java.lang.instrument.IllegalClassFormatException;
 import java.lang.instrument.Instrumentation;
@@ -18,7 +19,15 @@
  */
 @SuppressWarnings({"UtilityClassWithoutPrivateConstructor", "UnusedDeclaration"})
 public class ResetAgent {
-  private static final String timStampFieldStart = "__timeStamp__239_neverHappen";
+  private static final String timeStampFieldStart = "__timeStamp__239_neverHappen";
+  private static final byte[] timeStampFieldStartBytes;
+  
+  static {
+    timeStampFieldStartBytes = new byte[timeStampFieldStart.length()];
+    for (int i = 0; i < timeStampFieldStart.length(); i++) {
+      timeStampFieldStartBytes[i] = (byte)timeStampFieldStart.charAt(i);
+    }
+  }
 
   private static boolean initialized;
 
@@ -44,18 +53,30 @@
     });
   }
 
-  private static boolean hasTimestampField(byte[] buffer) {
-    try {
-      return new String(buffer, "ISO-8859-1").contains(timStampFieldStart);
-    } catch (Throwable e) {
-      return true;
+  private static boolean matches(byte[] array, byte[] subArray, int start) {
+    for (int i = 0; i < subArray.length; i++) {
+      if (array[start + i] != subArray[i]) {
+        return false;
+      }
     }
+    return true;
+  }
+
+  private static boolean containsSubArray(byte[] array, byte[] subArray) {
+    int maxLength = array.length - subArray.length;
+    for (int i = 0; i < maxLength; i++) {
+      if (matches(array, subArray, i)) {
+        return true;
+      }
+    }
+    return false;
   }
 
   private static byte[] removeTimestampField(byte[] newBytes) {
-    if (!hasTimestampField(newBytes)) {
+    if (!containsSubArray(newBytes, timeStampFieldStartBytes)) {
       return null;
     }
+    
 
     final boolean[] changed = new boolean[]{false};
     final ClassWriter writer = new ClassWriter(0);
@@ -76,7 +97,7 @@
 
     @Override
     public FieldVisitor visitField(int i, String name, String s1, String s2, Object o) {
-      if (name.startsWith(timStampFieldStart)) {
+      if (name.startsWith(timeStampFieldStart)) {
         //remove the field
         changed[0] = true;
         return null;
@@ -92,7 +113,7 @@
         return new MethodAdapter(mw) {
           @Override
           public void visitFieldInsn(int opCode, String s, String name, String desc) {
-            if (name.startsWith(timStampFieldStart) && opCode == Opcodes.PUTSTATIC) {
+            if (name.startsWith(timeStampFieldStart) && opCode == Opcodes.PUTSTATIC) {
               visitInsn(Type.LONG_TYPE.getDescriptor().equals(desc) ? Opcodes.POP2 : Opcodes.POP);
             } else {
               super.visitFieldInsn(opCode, s, name, desc);
diff --git a/plugins/groovy/hotswap/gragent.jar b/plugins/groovy/hotswap/gragent.jar
index 8794d67..b0e1767 100644
--- a/plugins/groovy/hotswap/gragent.jar
+++ b/plugins/groovy/hotswap/gragent.jar
Binary files differ
diff --git a/plugins/groovy/jetgroovy.iml b/plugins/groovy/jetgroovy.iml
index bd8506c..c8bb19d 100644
--- a/plugins/groovy/jetgroovy.iml
+++ b/plugins/groovy/jetgroovy.iml
@@ -35,6 +35,7 @@
     <orderEntry type="module" module-name="java-indexing-api" />
     <orderEntry type="module" module-name="groovy-jps-plugin" />
     <orderEntry type="module" module-name="ByteCodeViewer" />
+    <orderEntry type="module" module-name="properties-psi-api" />
   </component>
 </module>
 
diff --git a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java
index 8030a30..d8d3297 100644
--- a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java
+++ b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java
@@ -56,7 +56,6 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Future;
 
 /**
@@ -237,7 +236,7 @@
   private static void rememberStubSources(CompileContext context, Map<ModuleBuildTarget, Collection<GroovycOSProcessHandler.OutputItem>> compiled) {
     Map<String, String> stubToSrc = STUB_TO_SRC.get(context);
     if (stubToSrc == null) {
-      STUB_TO_SRC.set(context, stubToSrc = new ConcurrentHashMap<String, String>());
+      STUB_TO_SRC.set(context, stubToSrc = new HashMap<String, String>());
     }
     for (Collection<GroovycOSProcessHandler.OutputItem> items : compiled.values()) {
       for (GroovycOSProcessHandler.OutputItem item : items) {
@@ -329,12 +328,18 @@
                                             GroovycOSProcessHandler.OutputItem item,
                                             Map<ModuleBuildTarget, String> generationOutputs,
                                             String compilerOutput,
-                                            ModuleBuildTarget srcTarget) throws IOException {
+                                            @NotNull ModuleBuildTarget srcTarget) throws IOException {
     if (chunk.getModules().size() > 1 && !srcTarget.equals(chunk.representativeTarget())) {
       File output = new File(item.outputPath);
 
+      String srcTargetOutput = generationOutputs.get(srcTarget);
+      if (srcTargetOutput == null) {
+        LOG.info("No output for " + srcTarget + "; outputs=" + generationOutputs + "; targets = " + chunk.getTargets());
+        return item.outputPath;
+      }
+
       //todo honor package prefixes
-      File correctRoot = new File(generationOutputs.get(srcTarget));
+      File correctRoot = new File(srcTargetOutput);
       File correctOutput = new File(correctRoot, FileUtil.getRelativePath(new File(compilerOutput), output));
 
       FileUtil.rename(output, correctOutput);
@@ -374,7 +379,7 @@
     return toCompile;
   }
 
-  private static boolean updateDependencies(CompileContext context,
+  private boolean updateDependencies(CompileContext context,
                                             ModuleChunk chunk,
                                             DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder,
                                             List<File> toCompile,
@@ -394,7 +399,17 @@
           final String outputPath = FileUtil.toSystemIndependentName(item.outputPath);
           final File outputFile = new File(outputPath);
           outputConsumer.registerOutputFile(target, outputFile, Collections.singleton(sourcePath));
-          callback.associate(outputPath, sourcePath, new ClassReader(FileUtil.loadFileBytes(outputFile)));
+          try {
+            callback.associate(outputPath, sourcePath, new ClassReader(FileUtil.loadFileBytes(outputFile)));
+          }
+          catch (Throwable e) {
+            // need this to make sure that unexpected errors in, for example, ASM will not ruin the compilation  
+            final String message = "Class dependency information may be incomplete! Error parsing generated class " + item.outputPath;
+            LOG.info(message, e);
+            context.processMessage(new CompilerMessage(
+              myBuilderName, BuildMessage.Kind.WARNING, message + "\n" + CompilerMessage.getTextFromThrowable(e), sourcePath)
+            );
+          }
           successfullyCompiledFiles.add(new File(sourcePath));
         }
       }
diff --git a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOSProcessHandler.java b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOSProcessHandler.java
index 47b7fe5..9a5a3d0 100644
--- a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOSProcessHandler.java
+++ b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOSProcessHandler.java
@@ -58,14 +58,14 @@
     super.notifyTextAvailable(text, outputType);
 
     if (LOG.isDebugEnabled()) {
-      LOG.debug("Received from groovyc: " + text);
+      LOG.debug("Received from groovyc " + outputType + ": " + text);
     }
 
     if (outputType == ProcessOutputTypes.SYSTEM) {
       return;
     }
 
-    if (outputType == ProcessOutputTypes.STDERR) {
+    if (outputType == ProcessOutputTypes.STDERR && !text.startsWith("Picked up JAVA_TOOL_OPTIONS")) {
       stdErr.append(StringUtil.convertLineSeparators(text));
       return;
     }
@@ -197,14 +197,17 @@
 
   public boolean shouldRetry() {
     if (getProcess().exitValue() != 0) {
+      LOG.debug("Non-zero exit code");
       return true;
     }
     for (CompilerMessage message : compilerMessages) {
       if (message.getKind() == BuildMessage.Kind.ERROR) {
+        LOG.debug("Error message: " + message);
         return true;
       }
     }
     if (getStdErr().length() > 0) {
+      LOG.debug("Non-empty stderr: '" + getStdErr() + "'");
       return true;
     }
     return false;
diff --git a/plugins/groovy/resources/fileTemplates/code/Spock SetUp Method.groovy.ft b/plugins/groovy/resources/fileTemplates/code/Spock_SetUp_Method.groovy.ft
similarity index 100%
rename from plugins/groovy/resources/fileTemplates/code/Spock SetUp Method.groovy.ft
rename to plugins/groovy/resources/fileTemplates/code/Spock_SetUp_Method.groovy.ft
diff --git a/plugins/groovy/resources/fileTemplates/code/Spock SetUp Method.groovy.html b/plugins/groovy/resources/fileTemplates/code/Spock_SetUp_Method.groovy.html
similarity index 100%
rename from plugins/groovy/resources/fileTemplates/code/Spock SetUp Method.groovy.html
rename to plugins/groovy/resources/fileTemplates/code/Spock_SetUp_Method.groovy.html
diff --git a/plugins/groovy/resources/icons/JetgroovyIcons.java b/plugins/groovy/resources/icons/JetgroovyIcons.java
index 2781405..d7beb42 100644
--- a/plugins/groovy/resources/icons/JetgroovyIcons.java
+++ b/plugins/groovy/resources/icons/JetgroovyIcons.java
@@ -53,6 +53,7 @@
     public static final Icon Groovy_16x16 = load("/icons/groovy/groovy_16x16.png"); // 16x16
     public static final Icon Groovy_32x32 = load("/icons/groovy/groovy_32x32.png"); // 32x32
     public static final Icon GroovyDoc = load("/icons/groovy/GroovyDoc.png"); // 16x16
+    public static final Icon GroovyModule = load("/icons/groovy/groovyModule.png"); // 24x24
     public static final Icon Interface = load("/icons/groovy/interface.png"); // 16x16
     public static final Icon Method = load("/icons/groovy/method.png"); // 16x16
     public static final Icon Property = load("/icons/groovy/property.png"); // 16x16
diff --git a/plugins/groovy/resources/icons/griffon/griffon-icon-24x24.png b/plugins/groovy/resources/icons/griffon/griffon-icon-24x24.png
index e085bbe..cfab09e 100644
--- a/plugins/groovy/resources/icons/griffon/griffon-icon-24x24.png
+++ b/plugins/groovy/resources/icons/griffon/griffon-icon-24x24.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/griffon/griffon.png b/plugins/groovy/resources/icons/griffon/griffon.png
index 41ea0c1..2c58869 100644
--- a/plugins/groovy/resources/icons/griffon/griffon.png
+++ b/plugins/groovy/resources/icons/griffon/griffon.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/griffon/griffonToolWindow.png b/plugins/groovy/resources/icons/griffon/griffonToolWindow.png
index fd96eae..66ec8ab 100644
--- a/plugins/groovy/resources/icons/griffon/griffonToolWindow.png
+++ b/plugins/groovy/resources/icons/griffon/griffonToolWindow.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/GroovyDoc.png b/plugins/groovy/resources/icons/groovy/GroovyDoc.png
index cdc3421..841eed0 100644
--- a/plugins/groovy/resources/icons/groovy/GroovyDoc.png
+++ b/plugins/groovy/resources/icons/groovy/GroovyDoc.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/abstractClass.png b/plugins/groovy/resources/icons/groovy/abstractClass.png
index 229d4d3..fecef36 100644
--- a/plugins/groovy/resources/icons/groovy/abstractClass.png
+++ b/plugins/groovy/resources/icons/groovy/abstractClass.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/annotationType.png b/plugins/groovy/resources/icons/groovy/annotationType.png
index 17d335b..27e6d2b 100644
--- a/plugins/groovy/resources/icons/groovy/annotationType.png
+++ b/plugins/groovy/resources/icons/groovy/annotationType.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/ant_task.png b/plugins/groovy/resources/icons/groovy/ant_task.png
index c18ea93..240db23 100644
--- a/plugins/groovy/resources/icons/groovy/ant_task.png
+++ b/plugins/groovy/resources/icons/groovy/ant_task.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/class.png b/plugins/groovy/resources/icons/groovy/class.png
index 2daede4..645d17f 100644
--- a/plugins/groovy/resources/icons/groovy/class.png
+++ b/plugins/groovy/resources/icons/groovy/class.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/def.png b/plugins/groovy/resources/icons/groovy/def.png
index 861ebd9..c601caf 100644
--- a/plugins/groovy/resources/icons/groovy/def.png
+++ b/plugins/groovy/resources/icons/groovy/def.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/dynamicProperty.png b/plugins/groovy/resources/icons/groovy/dynamicProperty.png
index 27d38eb..3a06c68 100644
--- a/plugins/groovy/resources/icons/groovy/dynamicProperty.png
+++ b/plugins/groovy/resources/icons/groovy/dynamicProperty.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/dynamicProperty_13.png b/plugins/groovy/resources/icons/groovy/dynamicProperty_13.png
index 23ccf4e..dc10de6 100644
--- a/plugins/groovy/resources/icons/groovy/dynamicProperty_13.png
+++ b/plugins/groovy/resources/icons/groovy/dynamicProperty_13.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/enum.png b/plugins/groovy/resources/icons/groovy/enum.png
index fb0f982..992445e 100644
--- a/plugins/groovy/resources/icons/groovy/enum.png
+++ b/plugins/groovy/resources/icons/groovy/enum.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/field.png b/plugins/groovy/resources/icons/groovy/field.png
index c76203a..d84c1dc 100644
--- a/plugins/groovy/resources/icons/groovy/field.png
+++ b/plugins/groovy/resources/icons/groovy/field.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/gant_16x16.png b/plugins/groovy/resources/icons/groovy/gant_16x16.png
index b52626f..d945c13 100644
--- a/plugins/groovy/resources/icons/groovy/gant_16x16.png
+++ b/plugins/groovy/resources/icons/groovy/gant_16x16.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/gant_sdk.png b/plugins/groovy/resources/icons/groovy/gant_sdk.png
index 2076c7e..0166f83 100644
--- a/plugins/groovy/resources/icons/groovy/gant_sdk.png
+++ b/plugins/groovy/resources/icons/groovy/gant_sdk.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/gant_target.png b/plugins/groovy/resources/icons/groovy/gant_target.png
index dc66cc9..a34d07e 100644
--- a/plugins/groovy/resources/icons/groovy/gant_target.png
+++ b/plugins/groovy/resources/icons/groovy/gant_target.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/groovyModule.png b/plugins/groovy/resources/icons/groovy/groovyModule.png
new file mode 100644
index 0000000..11d6a41
--- /dev/null
+++ b/plugins/groovy/resources/icons/groovy/groovyModule.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/[email protected] b/plugins/groovy/resources/icons/groovy/[email protected]
new file mode 100644
index 0000000..b421a44
--- /dev/null
+++ b/plugins/groovy/resources/icons/groovy/[email protected]
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/groovy_13x13.png b/plugins/groovy/resources/icons/groovy/groovy_13x13.png
index 376e5bc..a324e2d 100644
--- a/plugins/groovy/resources/icons/groovy/groovy_13x13.png
+++ b/plugins/groovy/resources/icons/groovy/groovy_13x13.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/groovy_16x16.png b/plugins/groovy/resources/icons/groovy/groovy_16x16.png
index b7db528..f79d447 100644
--- a/plugins/groovy/resources/icons/groovy/groovy_16x16.png
+++ b/plugins/groovy/resources/icons/groovy/groovy_16x16.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/groovy_32x32.png b/plugins/groovy/resources/icons/groovy/groovy_32x32.png
index 8818a18..127211e 100644
--- a/plugins/groovy/resources/icons/groovy/groovy_32x32.png
+++ b/plugins/groovy/resources/icons/groovy/groovy_32x32.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/interface.png b/plugins/groovy/resources/icons/groovy/interface.png
index cd4db43..3b81274 100644
--- a/plugins/groovy/resources/icons/groovy/interface.png
+++ b/plugins/groovy/resources/icons/groovy/interface.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/method.png b/plugins/groovy/resources/icons/groovy/method.png
index 5534601..3e9fbed 100644
--- a/plugins/groovy/resources/icons/groovy/method.png
+++ b/plugins/groovy/resources/icons/groovy/method.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/property.png b/plugins/groovy/resources/icons/groovy/property.png
index b957db0..3a06c68 100644
--- a/plugins/groovy/resources/icons/groovy/property.png
+++ b/plugins/groovy/resources/icons/groovy/property.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/groovy/variable.png b/plugins/groovy/resources/icons/groovy/variable.png
index e57146b..0fce3e8 100644
--- a/plugins/groovy/resources/icons/groovy/variable.png
+++ b/plugins/groovy/resources/icons/groovy/variable.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/mvc/action_method.png b/plugins/groovy/resources/icons/mvc/action_method.png
index 8c07fb9..f9c6e5c 100644
--- a/plugins/groovy/resources/icons/mvc/action_method.png
+++ b/plugins/groovy/resources/icons/mvc/action_method.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/mvc/config_folder_closed.png b/plugins/groovy/resources/icons/mvc/config_folder_closed.png
index 54ada8d..6a9e8e5 100644
--- a/plugins/groovy/resources/icons/mvc/config_folder_closed.png
+++ b/plugins/groovy/resources/icons/mvc/config_folder_closed.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/mvc/controller.png b/plugins/groovy/resources/icons/mvc/controller.png
index d10517a..c3e28a1 100644
--- a/plugins/groovy/resources/icons/mvc/controller.png
+++ b/plugins/groovy/resources/icons/mvc/controller.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/mvc/domain_class.png b/plugins/groovy/resources/icons/mvc/domain_class.png
index 2e5984b..3963c99 100644
--- a/plugins/groovy/resources/icons/mvc/domain_class.png
+++ b/plugins/groovy/resources/icons/mvc/domain_class.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/mvc/groovy_mvc_plugin.png b/plugins/groovy/resources/icons/mvc/groovy_mvc_plugin.png
index 0b26153..cfae8c2 100644
--- a/plugins/groovy/resources/icons/mvc/groovy_mvc_plugin.png
+++ b/plugins/groovy/resources/icons/mvc/groovy_mvc_plugin.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/mvc/modelsNode.png b/plugins/groovy/resources/icons/mvc/modelsNode.png
index 52e70be..b1d89f6 100644
--- a/plugins/groovy/resources/icons/mvc/modelsNode.png
+++ b/plugins/groovy/resources/icons/mvc/modelsNode.png
Binary files differ
diff --git a/plugins/groovy/resources/icons/mvc/service.png b/plugins/groovy/resources/icons/mvc/service.png
index ff6fa11..1a71923 100644
--- a/plugins/groovy/resources/icons/mvc/service.png
+++ b/plugins/groovy/resources/icons/mvc/service.png
Binary files differ
diff --git a/plugins/groovy/resources/intentionDescriptions/GrRedundantElseIntention/description.html b/plugins/groovy/resources/intentionDescriptions/GrRedundantElseIntention/description.html
index 416ec7a..d819b88 100644
--- a/plugins/groovy/resources/intentionDescriptions/GrRedundantElseIntention/description.html
+++ b/plugins/groovy/resources/intentionDescriptions/GrRedundantElseIntention/description.html
@@ -1,7 +1,5 @@
 <html>
 <body>
 This intention detaches <b>else</b> clause from the <b>if</b> statement, if corresponding <b>then</b> clause never completes normally.
-<!-- tooltip end -->
-Text after this comment will not be shown in tooltips.
 </body>
 </html>
\ No newline at end of file
diff --git a/plugins/groovy/resources/intentionDescriptions/GrSortMapKeysIntention/after.groovy.template b/plugins/groovy/resources/intentionDescriptions/GrSortMapKeysIntention/after.groovy.template
new file mode 100644
index 0000000..3aac7db
--- /dev/null
+++ b/plugins/groovy/resources/intentionDescriptions/GrSortMapKeysIntention/after.groovy.template
@@ -0,0 +1,3 @@
+def phones = [Ann  : 23467,
+              Max  : 78564,
+              Peter: 45678]
\ No newline at end of file
diff --git a/plugins/groovy/resources/intentionDescriptions/GrSortMapKeysIntention/before.groovy.template b/plugins/groovy/resources/intentionDescriptions/GrSortMapKeysIntention/before.groovy.template
new file mode 100644
index 0000000..eb77284
--- /dev/null
+++ b/plugins/groovy/resources/intentionDescriptions/GrSortMapKeysIntention/before.groovy.template
@@ -0,0 +1 @@
+def phones = [Peter: 45678, Max : 78564, Ann : 23467]
\ No newline at end of file
diff --git a/plugins/groovy/resources/intentionDescriptions/GrSortMapKeysIntention/description.html b/plugins/groovy/resources/intentionDescriptions/GrSortMapKeysIntention/description.html
new file mode 100644
index 0000000..eb90b0c
--- /dev/null
+++ b/plugins/groovy/resources/intentionDescriptions/GrSortMapKeysIntention/description.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+This intention sorts map entries alphabetically.
+</body>
+</html>
\ No newline at end of file
diff --git a/plugins/groovy/resources/intentionDescriptions/ReplaceIfWithTernaryIntention/description.html b/plugins/groovy/resources/intentionDescriptions/ReplaceIfWithTernaryIntention/description.html
index e7e00ed..6311f24 100644
--- a/plugins/groovy/resources/intentionDescriptions/ReplaceIfWithTernaryIntention/description.html
+++ b/plugins/groovy/resources/intentionDescriptions/ReplaceIfWithTernaryIntention/description.html
@@ -1,7 +1,5 @@
 <html>
 <body>
 This intention replaces if-statement with equivalent ternary operator
-<!-- tooltip end -->
-Text after this comment will not be shown in tooltips.
 </body>
 </html>
\ No newline at end of file
diff --git a/plugins/groovy/resources/standardDsls/defaultMethods.gdsl b/plugins/groovy/resources/standardDsls/defaultMethods.gdsl
index 8464717..e9f72c8 100644
--- a/plugins/groovy/resources/standardDsls/defaultMethods.gdsl
+++ b/plugins/groovy/resources/standardDsls/defaultMethods.gdsl
@@ -18,7 +18,6 @@
 import com.intellij.psi.PsiType
 import com.intellij.psi.util.PsiUtil
 
-import static standardDsls.Constants.STRING
 /**
  * @author Maxim.Medvedev
  */
@@ -61,27 +60,6 @@
   delegatesTo(findClass("java.lang.String"))
 }
 
-[Integer, Double, Float, Byte, Long, Short, Number].each {
-  def className = it.canonicalName
-  contributor(ctype: className) {
-    method name: "plus", type: className, params: [arg: className]
-    method name: "minus", type: className, params: [arg: className]
-    method name: "multiply", type: className, params: [arg: className]
-    method name: "power", type: className, params: [arg: className]
-    method name: "div", type: className, params: [arg: className]
-    method name: "mod", type: className, params: [arg: className]
-    method name: "or", type: className, params: [arg: className]
-    method name: "and", type: className, params: [arg: className]
-    method name: "xor", type: className, params: [arg: className]
-    method name: "next", type: className
-    method name: "previous", type: className
-    method name: "negative", type: className
-    method name: "positive", type: className
-
-    method name: "plus", type: STRING, params: [arg: STRING]
-  }
-}
-
 contributor(ctype: 'groovy.lang.MetaClass') {
   property name: 'static'
 }
diff --git a/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/DependentGroovycRunner.java b/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/DependentGroovycRunner.java
index d340342..835c91d 100644
--- a/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/DependentGroovycRunner.java
+++ b/plugins/groovy/rt/src/org/jetbrains/groovy/compiler/rt/DependentGroovycRunner.java
@@ -188,13 +188,7 @@
         continue;
       }
 
-      unit.addSource(new SourceUnit(file, unit.getConfiguration(), unit.getClassLoader(), unit.getErrorCollector()) {
-        public void parse() throws CompilationFailedException {
-          System.out.println(GroovyRtConstants.PRESENTABLE_MESSAGE + "Parsing " + file.getName() + "...");
-          super.parse();
-          System.out.println(GroovyRtConstants.CLEAR_PRESENTABLE);
-        }
-      });
+      unit.addSource(new SourceUnit(file, unit.getConfiguration(), unit.getClassLoader(), unit.getErrorCollector()));
     }
   }
 
diff --git a/plugins/groovy/src/META-INF/plugin.xml b/plugins/groovy/src/META-INF/plugin.xml
index a9ff529..45fde1f 100644
--- a/plugins/groovy/src/META-INF/plugin.xml
+++ b/plugins/groovy/src/META-INF/plugin.xml
@@ -105,6 +105,8 @@
 
     <membersContributor implementation="org.jetbrains.plugins.groovy.markup.XmlMarkupBuilderNonCodeMemberContributor"/>
 
+    <closureMissingMethodContributor implementation="org.jetbrains.plugins.groovy.lang.resolve.PluginXmlClosureMemberContributor"/>
+
     <astTransformContributor implementation="org.jetbrains.plugins.groovy.lang.resolve.ast.DelegatedMethodsContributor"/>
     <astTransformContributor implementation="org.jetbrains.plugins.groovy.lang.resolve.ast.AutoExternalizeContributor"/>
     <astTransformContributor implementation="org.jetbrains.plugins.groovy.lang.resolve.ast.AutoCloneContributor"/>
@@ -189,7 +191,7 @@
   </extensions>
 
   <extensions defaultExtensionNs="com.intellij">
-    <navbar implementation="org.jetbrains.plugins.groovy.navbar.GrNavBarModelExtension"/>
+    <navbar implementation="org.jetbrains.plugins.groovy.navbar.GrNavBarModelExtension" order="after defaultNavbar"/>
 
     <declarationRangeHandler key="org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod"
                              implementationClass="org.jetbrains.plugins.groovy.codeInsight.hint.GrMethodDeclarationRangeHandler"/>
@@ -1027,116 +1029,116 @@
     <!-- control flow -->
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.DemorgansLawIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.SplitIfIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.InvertIfIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.GrRedundantElseIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.FlipIfIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.ReplaceTernaryWithIfElseIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.ReplaceIfWithTernaryIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.SimplifyTernaryOperatorIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.CreateParameterForFieldIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.MergeIfAndIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.ExpandBooleanIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.FlipConjunctionIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.FlipComparisonIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.NegateComparisonIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.MergeElseIfIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.SplitElseIfIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.control.flow</categoryKey>
+      <categoryKey>intention.category.control.flow</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.control.FlipConditionalIntention</className>
     </intentionAction>
 
     <!-- closures -->
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.closures</categoryKey>
+      <categoryKey>intention.category.closures</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.closure.MakeClosureCallExplicitIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.closures</categoryKey>
+      <categoryKey>intention.category.closures</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.closure.MakeClosureCallImplicitIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.closures</categoryKey>
+      <categoryKey>intention.category.closures</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.closure.ForToEachIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.closures</categoryKey>
+      <categoryKey>intention.category.closures</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.closure.EachToForIntention</className>
     </intentionAction>
     <!--
     todo make this work
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.closures</categoryKey>
+      <categoryKey>intention.category.closures</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.closure.ConvertClosureArgToItIntention</className>
     </intentionAction>
     -->
@@ -1145,14 +1147,14 @@
     <!-- comments -->
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.comments</categoryKey>
+      <categoryKey>intention.category.comments</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.comments.ChangeToCStyleCommentIntention</className>
     </intentionAction>
     <!--
     todo make this work
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.comments</categoryKey>
+      <categoryKey>intention.category.comments</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.comments.ChangeToEndOfLineCommentIntention</className>
     </intentionAction>
     -->
@@ -1160,194 +1162,194 @@
     <!-- conversions -->
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.ConvertJavaStyleArrayIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.ConvertIntegerToDecimalIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.ConvertIntegerToHexIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.ConvertIntegerToOctalIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.ConvertIntegerToBinaryIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.IndexingMethodConversionIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.IndexedExpressionConversionIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.strings.ConvertGStringToStringIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.strings.ConvertMultilineStringToSingleLineIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.strings.ConvertToRegexIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.strings.ConvertToDollarSlashRegexIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.strings.GrConvertStringToCharIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.strings.RemoveUnnecessaryEscapeCharactersIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.strings.GrBreakStringOnLineBreaksIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.GrSplitDeclarationIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.RemoveParenthesesFromMethodCallIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.RemoveUnnecessaryBracesInGStringIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.ConvertMapToClassIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.strings.ConvertConcatenationToGstringIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.RenameFileWithClassIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.MoveClassToNewFileIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.ConvertMethodToClosureIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.strings.ConvertStringToMultilineIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.ConvertClosureToMethodIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.ConvertSimpleGetterToPropertyIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.GrConvertTypeCastToSafeCastIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.conversions</categoryKey>
+      <categoryKey>intention.category.conversions</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.conversions.ConvertJunitAssertionToAssertStatementIntention</className>
     </intentionAction>
 
     <!-- groovy style -->
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.style</categoryKey>
+      <categoryKey>intention.category.groovy.style</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.style.JavaStylePropertiesInvocationIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.style</categoryKey>
+      <categoryKey>intention.category.groovy.style</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.style.RemoveUnnecessarySemicolonsIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.style</categoryKey>
+      <categoryKey>intention.category.groovy.style</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.style.ImportStaticIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.style</categoryKey>
+      <categoryKey>intention.category.groovy.style</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.style.ImportOnDemandIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.style</categoryKey>
+      <categoryKey>intention.category.groovy.style</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.style.ConvertToGeeseBracesIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.style</categoryKey>
+      <categoryKey>intention.category.groovy.style</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.style.RemoveRedundantClassPropertyIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.style</categoryKey>
+      <categoryKey>intention.category.groovy.style</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.style.ConvertFromGeeseBracesIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.style</categoryKey>
+      <categoryKey>intention.category.groovy.style</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.style.RemoveUnnecessaryReturnIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.style</categoryKey>
+      <categoryKey>intention.category.groovy.style</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.style.AddReturnTypeFix</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.style</categoryKey>
+      <categoryKey>intention.category.groovy.style</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.style.parameterToEntry.ConvertParameterToMapEntryIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.style</categoryKey>
+      <categoryKey>intention.category.groovy.style</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.style.ReplaceAbstractClassInstanceByMapIntention</className>
     </intentionAction>
 
@@ -1360,59 +1362,66 @@
     <!--declaration-->
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.declaration</categoryKey>
+      <categoryKey>intention.category.groovy.declaration</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.declaration.GrCreateSubclassAction</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.declaration</categoryKey>
+      <categoryKey>intention.category.groovy.declaration</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.declaration.GrCreateFieldForParameterIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.declaration</categoryKey>
+      <categoryKey>intention.category.groovy.declaration</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.declaration.GrSetStrongTypeIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.declaration</categoryKey>
+      <categoryKey>intention.category.groovy.declaration</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.declaration.GrMakeMemberPublicIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.declaration</categoryKey>
+      <categoryKey>intention.category.groovy.declaration</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.declaration.GrMakeMemberProtectedIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.declaration</categoryKey>
+      <categoryKey>intention.category.groovy.declaration</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.declaration.GrMakeMemberPrivateIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.declaration</categoryKey>
+      <categoryKey>intention.category.groovy.declaration</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.declaration.GrIntroduceLocalVariableIntention</className>
     </intentionAction>
 
     <!--other-->
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.other</categoryKey>
+      <categoryKey>intention.category.groovy.other</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.other.GrCreateMissingSwitchBranchesIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.other</categoryKey>
+      <categoryKey>intention.category.groovy.other</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.other.GrAliasImportIntention</className>
     </intentionAction>
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.other</categoryKey>
+      <categoryKey>intention.category.groovy.other</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.other.GrCopyStringConcatenationContentIntention</className>
     </intentionAction>
+
     <intentionAction>
       <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
-      <categoryKey>intention.category.groovy/intention.category.groovy.declaration</categoryKey>
+      <categoryKey>intention.category.groovy.other</categoryKey>
+      <className>org.jetbrains.plugins.groovy.intentions.other.GrSortMapKeysIntention</className>
+    </intentionAction>
+
+    <intentionAction>
+      <bundleName>org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle</bundleName>
+      <categoryKey>intention.category.groovy.declaration</categoryKey>
       <className>org.jetbrains.plugins.groovy.intentions.declaration.GrRemoveExplicitTypeDeclarationIntention</className>
     </intentionAction>
 
diff --git a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationAwareInjector.java b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationAwareInjector.java
index 5f3a421..de8841f 100644
--- a/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationAwareInjector.java
+++ b/plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/GrConcatenationAwareInjector.java
@@ -48,10 +48,10 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationNameValuePair;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringInjection;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
 
 import java.util.LinkedList;
@@ -124,7 +124,7 @@
     void processInjections() {
       final PsiElement firstOperand = myOperands[0];
       final PsiElement topBlock = ControlFlowUtils.findControlFlowOwner(firstOperand);
-      final LocalSearchScope searchScope = new LocalSearchScope(new PsiElement[]{topBlock instanceof PsiCodeBlock
+      final LocalSearchScope searchScope = new LocalSearchScope(new PsiElement[]{topBlock instanceof GrCodeBlock
                                                                                  ? topBlock : firstOperand.getContainingFile()}, "", true);
       final THashSet<PsiModifierListOwner> visitedVars = new THashSet<PsiModifierListOwner>();
       final LinkedList<PsiElement> places = new LinkedList<PsiElement>();
@@ -135,8 +135,8 @@
           assert list != null;
 
           final String methodName;
-          if (methodCall instanceof GrMethodCallExpression) {
-            GrExpression invoked = ((GrMethodCallExpression)methodCall).getInvokedExpression();
+          if (methodCall instanceof GrMethodCall) {
+            GrExpression invoked = ((GrMethodCall)methodCall).getInvokedExpression();
             final String referenceName = invoked instanceof GrReferenceExpression? ((GrReferenceExpression)invoked).getReferenceName() : null;
             if ("super".equals(referenceName) || "this".equals(referenceName)) { // constructor call
               final PsiClass psiClass = PsiTreeUtil.getParentOfType(methodCall, PsiClass.class, true);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.java
index d2f8ba7..9b587e2 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,20 +30,16 @@
  */
 public class GroovyBundle {
 
-  private static Reference<ResourceBundle> ourBundle;
-
-  @NonNls
-  private static final String BUNDLE = "org.jetbrains.plugins.groovy.GroovyBundle";
-
-  @NotNull
-  public static String message(@PropertyKey(resourceBundle = BUNDLE)String key, Object... params) {
+  public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
     return CommonBundle.message(getBundle(), key, params);
   }
 
-  private static ResourceBundle getBundle() {
-    ResourceBundle bundle = null;
+  private static Reference<ResourceBundle> ourBundle;
+  @NonNls
+  private static final String BUNDLE = "org.jetbrains.plugins.groovy.GroovyBundle";
 
-    if (ourBundle != null) bundle = ourBundle.get();
+  private static ResourceBundle getBundle() {
+    ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
 
     if (bundle == null) {
       bundle = ResourceBundle.getBundle(BUNDLE);
@@ -51,5 +47,4 @@
     }
     return bundle;
   }
-
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties
index a2704e2..c3b8164 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/GroovyBundle.properties
@@ -369,3 +369,6 @@
 highlight.constructor.calls.of.a.non.static.inner.classes.without.enclosing.instance.passed=Highlight constructor calls of non-static inner classes without enclosing instance passed
 doc.end.expected='*/' expected
 mixing.private.and.public.protected.methods.of.the.same.name=Mixing private and public/protected methods of the same name
+explicit.constructors.are.not.allowed.in.immutable.class=Explicit constructors are not allowed for @Immutable class
+repetitive.method.name.0=Repetitive method name ''{0}''
+assign.expected='=' expected
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/DumpGroovyControlFlowAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/DumpGroovyControlFlowAction.java
index bcba952..6c34488 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/DumpGroovyControlFlowAction.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/DumpGroovyControlFlowAction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -74,7 +74,7 @@
     final List<GrControlFlowOwner> result = new ArrayList<GrControlFlowOwner>();
 
     for (GrControlFlowOwner owner = ControlFlowUtils.findControlFlowOwner(elementAtCaret);
-         owner != null;
+         owner != null && !result.contains(owner);
          owner = ControlFlowUtils.findControlFlowOwner(owner)) {
       result.add(owner);
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/GroovyTemplatesFactory.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/GroovyTemplatesFactory.java
index c89add1..841db6f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/GroovyTemplatesFactory.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/GroovyTemplatesFactory.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.GroovyBundle;
+import org.jetbrains.plugins.groovy.GroovyFileType;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -78,6 +79,7 @@
                                            @NotNull final String name,
                                            @NotNull String fileName,
                                            @NotNull String templateName,
+                                           boolean allowReformatting,
                                            @NonNls String... parameters) throws IncorrectOperationException {
     final FileTemplate template = FileTemplateManager.getInstance().getInternalTemplate(templateName);
 
@@ -95,16 +97,15 @@
       text = template.getText(properties);
     }
     catch (Exception e) {
-      throw new RuntimeException("Unable to load template for " + FileTemplateManager.getInstance().internalTemplateToSubject(templateName),
-                                 e);
+      throw new RuntimeException("Unable to load template for " + FileTemplateManager.getInstance().internalTemplateToSubject(templateName), e);
     }
 
     final PsiFileFactory factory = PsiFileFactory.getInstance(project);
-    PsiFile file = factory.createFileFromText(fileName, text);
+    PsiFile file = factory.createFileFromText(fileName, GroovyFileType.GROOVY_FILE_TYPE, text);
 
     file = (PsiFile)directory.add(file);
 
-    if (file != null && template.isReformatCode()) {
+    if (file != null && allowReformatting && template.isReformatCode()) {
       new ReformatCodeProcessor(project, file, null, false).run();
     }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewGroovyClassAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewGroovyClassAction.java
index 8f054d2..4ab2c67 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewGroovyClassAction.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewGroovyClassAction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -107,7 +107,7 @@
 
   protected final GrTypeDefinition doCreate(PsiDirectory dir, String className, String templateName) throws IncorrectOperationException {
     final String fileName = className + NewGroovyActionBase.GROOVY_EXTENSION;
-    final PsiFile fromTemplate = GroovyTemplatesFactory.createFromTemplate(dir, className, fileName, templateName);
+    final PsiFile fromTemplate = GroovyTemplatesFactory.createFromTemplate(dir, className, fileName, templateName, true);
     if (fromTemplate instanceof GroovyFile) {
       CodeStyleManager.getInstance(fromTemplate.getManager()).reformat(fromTemplate);
       return ((GroovyFile)fromTemplate).getTypeDefinitions()[0];
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewScriptAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewScriptAction.java
index 197d74f..0e14335 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewScriptAction.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/NewScriptAction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
 import com.intellij.ide.actions.JavaCreateTemplateInPackageAction;
 import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.actionSystem.LangDataKeys;
-import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiDirectory;
 import com.intellij.psi.PsiElement;
@@ -66,7 +65,7 @@
   @NotNull
   protected GroovyFile doCreate(PsiDirectory directory, String newName, String templateName) throws IncorrectOperationException {
     String fileName = newName + "." + extractExtension(templateName);
-    PsiFile file = GroovyTemplatesFactory.createFromTemplate(directory, newName, fileName, templateName);
+    PsiFile file = GroovyTemplatesFactory.createFromTemplate(directory, newName, fileName, templateName, true);
     if (file instanceof GroovyFile) return (GroovyFile)file;
     final String description = file.getFileType().getDescription();
     throw new IncorrectOperationException(GroovyBundle.message("groovy.file.extension.is.not.mapped.to.groovy.file.type", description));
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyCodeInsightBundle.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyCodeInsightBundle.java
index 615e0be..1823fd7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyCodeInsightBundle.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyCodeInsightBundle.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
 package org.jetbrains.plugins.groovy.actions.generate;
 
 import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.PropertyKey;
 
 import java.util.ResourceBundle;
@@ -29,23 +30,21 @@
  * Date: 02.06.2008
  */
 public class GroovyCodeInsightBundle {
-  private static Reference<ResourceBundle> ourBundle;
 
-  @NonNls
-  private static final String BUNDLE = "org.jetbrains.plugins.groovy.actions.generate.GroovyCodeInsightBundle";
-
-  public static String message(@PropertyKey(resourceBundle = BUNDLE)String key, Object... params) {
+  public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
     return CommonBundle.message(getBundle(), key, params);
   }
 
-  private static ResourceBundle getBundle() {
-    ResourceBundle bundle = null;
+  private static Reference<ResourceBundle> ourBundle;
+  @NonNls
+  private static final String BUNDLE = "org.jetbrains.plugins.groovy.actions.generate.GroovyCodeInsightBundle";
 
-    if (ourBundle != null) bundle = ourBundle.get();
+  private static ResourceBundle getBundle() {
+    ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
 
     if (bundle == null) {
       bundle = ResourceBundle.getBundle(BUNDLE);
-      ourBundle = new SoftReference<ResourceBundle  >(bundle);
+      ourBundle = new SoftReference<ResourceBundle>(bundle);
     }
     return bundle;
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyGenerationInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyGenerationInfo.java
index 2ebb3e4..068e96d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyGenerationInfo.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/GroovyGenerationInfo.java
@@ -39,11 +39,10 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
 import org.jetbrains.plugins.groovy.refactoring.GroovyChangeContextUtil;
 
-import static org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil.isWhiteSpace;
-
 /**
  * @author peter
  */
@@ -147,12 +146,12 @@
       if (body != null) {
         PsiElement l = body.getLBrace();
         if (l != null) l = l.getNextSibling();
-        while (isWhiteSpace(l)) l = l.getNextSibling();
+        while (PsiImplUtil.isWhiteSpaceOrNls(l)) l = l.getNextSibling();
         if (l == null) l = body;
 
         PsiElement r = body.getRBrace();
         if (r != null) r = r.getPrevSibling();
-        while (isWhiteSpace(r)) r = r.getPrevSibling();
+        while (PsiImplUtil.isWhiteSpaceOrNls(r)) r = r.getPrevSibling();
         if (r == null) r = body;
 
         int start = l.getTextRange().getStartOffset();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/equals/GroovyGenerateEqualsHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/equals/GroovyGenerateEqualsHandler.java
index d48edee..94545ec 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/equals/GroovyGenerateEqualsHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/equals/GroovyGenerateEqualsHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -77,7 +77,7 @@
 
       if (Messages.showYesNoDialog(project, text,
           GroovyCodeInsightBundle.message("generate.equals.and.hashcode.already.defined.title"),
-          Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) {
+          Messages.getQuestionIcon()) == Messages.YES) {
         if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
           public Boolean compute() {
             try {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/missing/GroovyGenerateMethodMissingHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/missing/GroovyGenerateMethodMissingHandler.java
index fe4cf52..5b11c73 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/missing/GroovyGenerateMethodMissingHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/missing/GroovyGenerateMethodMissingHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.text.StringUtil;
@@ -127,7 +126,7 @@
 
       if (Messages.showYesNoDialog(project, text,
                                    GroovyCodeInsightBundle.message("generate.method.missing.already.defined.title"),
-                                   Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) {
+                                   Messages.getQuestionIcon()) == Messages.YES) {
         final PsiMethod finalMethod = method;
         if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
           public Boolean compute() {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/missing/GroovyGeneratePropertyMissingHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/missing/GroovyGeneratePropertyMissingHandler.java
index ed21afa..857d1d1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/missing/GroovyGeneratePropertyMissingHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/actions/generate/missing/GroovyGeneratePropertyMissingHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.text.StringUtil;
@@ -158,7 +157,7 @@
 
       if (Messages.showYesNoDialog(project, text,
                                    GroovyCodeInsightBundle.message("generate.property.missing.already.defined.title"),
-                                   Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) {
+                                   Messages.getQuestionIcon()) == Messages.YES) {
         final PsiMethod finalGetter = getter;
         final PsiMethod finalSetter = setter;
         if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GrRemoveAnnotationIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GrRemoveAnnotationIntention.java
new file mode 100644
index 0000000..ca371b9
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GrRemoveAnnotationIntention.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.annotator;
+
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiElement;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.intentions.base.Intention;
+import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
+
+/**
+ * Created by Max Medvedev on 06/02/14
+ */
+public class GrRemoveAnnotationIntention extends Intention {
+  @Override
+  protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
+    element.delete();
+  }
+
+  @NotNull
+  @Override
+  protected PsiElementPredicate getElementPredicate() {
+    return new PsiElementPredicate() {
+      @Override
+      public boolean satisfiedBy(PsiElement element) {
+        return element instanceof GrAnnotation;
+      }
+    };
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
index e4dfc6d..dee417b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,23 +17,30 @@
 package org.jetbrains.plugins.groovy.annotator;
 
 import com.intellij.codeInsight.ClassUtil;
+import com.intellij.codeInsight.daemon.impl.analysis.HighlightClassUtil;
 import com.intellij.codeInsight.daemon.impl.quickfix.AddMethodBodyFix;
 import com.intellij.codeInsight.daemon.impl.quickfix.CreateConstructorMatchingSuperFix;
 import com.intellij.codeInsight.daemon.impl.quickfix.DeleteMethodBodyFix;
 import com.intellij.codeInsight.generation.OverrideImplementExploreUtil;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.codeInsight.intention.QuickFixFactory;
+import com.intellij.codeInspection.InspectionManager;
+import com.intellij.codeInspection.LocalQuickFix;
+import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.lang.ASTNode;
 import com.intellij.lang.annotation.Annotation;
 import com.intellij.lang.annotation.AnnotationHolder;
 import com.intellij.lang.injection.InjectedLanguageManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtilCore;
 import com.intellij.openapi.project.IndexNotReadyException;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.light.LightElement;
+import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.search.searches.SuperMethodsSearch;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.util.*;
@@ -50,6 +57,7 @@
 import org.jetbrains.plugins.groovy.GroovyBundle;
 import org.jetbrains.plugins.groovy.GroovyFileType;
 import org.jetbrains.plugins.groovy.annotator.intentions.*;
+import org.jetbrains.plugins.groovy.codeInspection.bugs.GrModifierFix;
 import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection;
 import org.jetbrains.plugins.groovy.config.GroovyConfigUtils;
 import org.jetbrains.plugins.groovy.lang.documentation.GroovyPresentationUtil;
@@ -91,6 +99,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
 import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
+import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
 import org.jetbrains.plugins.groovy.lang.resolve.ast.GrInheritConstructorContributor;
@@ -206,7 +215,7 @@
 
       if (typeElement instanceof GrDisjunctionTypeElement) {
         final GrTypeElement[] elements = ((GrDisjunctionTypeElement)typeElement).getTypeElements();
-        PsiType[] types = new PsiType[elements.length];
+        PsiType[] types = PsiType.createArray(elements.length);
         for (int i = 0; i < elements.length; i++) {
           types[i] = elements[i].getType();
         }
@@ -296,6 +305,7 @@
     checkThisOrSuperReferenceExpression(referenceExpression, myHolder);
     checkFinalFieldAccess(referenceExpression);
     checkFinalParameterAccess(referenceExpression);
+
     if (ResolveUtil.isKeyOfMap(referenceExpression)) {
       PsiElement nameElement = referenceExpression.getReferenceNameElement();
       LOG.assertTrue(nameElement != null);
@@ -398,7 +408,9 @@
   private static void checkSameNameMethodsWithDifferentAccessModifiers(AnnotationHolder holder, GrMethod[] methods) {
     MultiMap<String, GrMethod> map = MultiMap.create();
     for (GrMethod method : methods) {
-      map.putValue(method.getName(), method);
+      if (!method.isConstructor()) {
+        map.putValue(method.getName(), method);
+      }
     }
 
     for (Map.Entry<String, Collection<GrMethod>> entry : map.entrySet()) {
@@ -550,6 +562,9 @@
     checkInnerMethod(myHolder, method);
     checkOptionalParametersInAbstractMethod(myHolder, method);
 
+    checkConstructorOfImmutableClass(myHolder, method);
+    checkGetterOfImmutable(myHolder, method);
+
     final PsiElement nameIdentifier = method.getNameIdentifierGroovy();
     if (nameIdentifier.getNode().getElementType() == GroovyTokenTypes.mSTRING_LITERAL) {
       checkStringLiteral(nameIdentifier);
@@ -580,6 +595,43 @@
     checkOverridingMethod(myHolder, method);
   }
 
+  private static void checkGetterOfImmutable(AnnotationHolder holder, GrMethod method) {
+    if (!GroovyPropertyUtils.isSimplePropertyGetter(method)) return;
+
+    PsiClass aClass = method.getContainingClass();
+    if (aClass == null) return;
+
+    PsiModifierList aClassModifierList = aClass.getModifierList();
+    if (aClassModifierList == null) return;
+
+    if (!PsiImplUtil.hasImmutableAnnotation(aClassModifierList)) return;
+
+
+    PsiField field = GroovyPropertyUtils.findFieldForAccessor(method, false);
+    if (field == null || !(field instanceof GrField)) return;
+
+    GrModifierList fieldModifierList = ((GrField)field).getModifierList();
+    if (fieldModifierList == null) return;
+
+    if (fieldModifierList.hasExplicitVisibilityModifiers()) return;
+
+    holder.createErrorAnnotation(method.getNameIdentifierGroovy(), GroovyBundle.message("repetitive.method.name.0", method.getName()));
+  }
+
+  private static void checkConstructorOfImmutableClass(AnnotationHolder holder, GrMethod method) {
+    if (!method.isConstructor()) return;
+
+    PsiClass aClass = method.getContainingClass();
+    if (aClass == null) return;
+
+    PsiModifierList modifierList = aClass.getModifierList();
+    if (modifierList == null) return;
+
+    if (!PsiImplUtil.hasImmutableAnnotation(modifierList)) return;
+
+    holder.createErrorAnnotation(method.getNameIdentifierGroovy(), GroovyBundle.message("explicit.constructors.are.not.allowed.in.immutable.class"));
+  }
+
   private static void checkOverridingMethod(@NotNull AnnotationHolder holder, @NotNull GrMethod method) {
     final List<HierarchicalMethodSignature> signatures = method.getHierarchicalMethodSignature().getSuperSignatures();
 
@@ -900,8 +952,8 @@
     if (modifierList.hasExplicitModifier(VOLATILE) && modifierList.hasExplicitModifier(FINAL)) {
       final Annotation annotation =
         holder.createErrorAnnotation(modifierList, GroovyBundle.message("illegal.combination.of.modifiers.volatile.and.final"));
-      annotation.registerFix(new GrModifierFix(member, modifierList, VOLATILE, true, false));
-      annotation.registerFix(new GrModifierFix(member, modifierList, FINAL, true, false));
+      registerFix(annotation, new GrModifierFix(member, VOLATILE, true, false, GrModifierFix.MODIFIER_LIST), modifierList);
+      registerFix(annotation, new GrModifierFix(member, FINAL, true, false, GrModifierFix.MODIFIER_LIST), modifierList);
     }
 
     checkModifierIsNotAllowed(modifierList, NATIVE, GroovyBundle.message("variable.cannot.be.native"), holder);
@@ -914,6 +966,16 @@
     }
   }
 
+  private static void registerFix(Annotation annotation, LocalQuickFix fix, PsiElement place) {
+    final InspectionManager manager = InspectionManager.getInstance(place.getProject());
+    assert !place.getTextRange().isEmpty();
+
+    final ProblemDescriptor descriptor = manager.createProblemDescriptor(place, place, annotation.getMessage(),
+                                                                         annotation.getHighlightType(), true, LocalQuickFix.EMPTY_ARRAY);
+    final TextRange range = TextRange.create(annotation.getStartOffset(), annotation.getEndOffset());
+    annotation.registerFix(fix, range, null, descriptor);
+  }
+
   private static void checkModifierIsNotAllowed(@NotNull GrModifierList modifierList,
                                                 @NotNull @GrModifier.GrModifierConstant String modifier,
                                                 @Nullable String message,
@@ -927,10 +989,9 @@
                                                     @NotNull AnnotationHolder holder,
                                                     final boolean explicit) {
     if (explicit ? modifierList.hasModifierProperty(modifier) : modifierList.hasExplicitModifier(modifier)) {
-      PsiElement toHighlight = PsiUtil.findModifierInList(modifierList, modifier);
-      if (toHighlight == null) toHighlight = modifierList;
-      final Annotation annotation = holder.createErrorAnnotation(toHighlight, message);
-      annotation.registerFix(new GrModifierFix((PsiMember)modifierList.getParent(), modifierList, modifier, true, false));
+      PsiElement modifierOrList = getModifierOrList(modifierList, modifier);
+      final Annotation annotation = holder.createErrorAnnotation(modifierOrList, message);
+      registerFix(annotation, new GrModifierFix((PsiMember)modifierList.getParent(), modifier, true, false, GrModifierFix.MODIFIER_LIST), modifierList);
     }
   }
 
@@ -1052,9 +1113,8 @@
   private void checkTypeArgForPrimitive(@Nullable GrTypeElement element, String message) {
     if (element == null || !(element.getType() instanceof PsiPrimitiveType)) return;
 
-    myHolder.
-      createErrorAnnotation(element, message).
-      registerFix(new GrReplacePrimitiveTypeWithWrapperFix(element));
+    final Annotation annotation = myHolder.createErrorAnnotation(element, message);
+    registerFix(annotation, new GrReplacePrimitiveTypeWithWrapperFix(element), element);
   }
 
   @Override
@@ -1383,6 +1443,7 @@
   }
 
 
+  @Override
   public void visitAnnotation(GrAnnotation annotation) {
     final GrCodeReferenceElement ref = annotation.getClassReference();
     final PsiElement resolved = ref.resolve();
@@ -1405,7 +1466,7 @@
 
     String description = CustomAnnotationChecker.isAnnotationApplicable(annotation, annotation.getParent());
     if (description != null) {
-      myHolder.createErrorAnnotation(ref, description);
+      myHolder.createErrorAnnotation(ref, description).registerFix(new GrRemoveAnnotationIntention());
     }
   }
 
@@ -1421,7 +1482,8 @@
     }
 
     Map<PsiElement, String> errors = ContainerUtil.newHashMap();
-    CustomAnnotationChecker.checkAnnotationArguments(errors, anno, annotation.getClassReference(), annotationArgumentList.getAttributes(), true);
+    CustomAnnotationChecker.checkAnnotationArguments(errors, anno, annotation.getClassReference(), annotationArgumentList.getAttributes(),
+                                                     true);
     for (Map.Entry<PsiElement, String> entry : errors.entrySet()) {
       myHolder.createErrorAnnotation(entry.getKey(), entry.getValue());
     }
@@ -1457,11 +1519,14 @@
     }
 
     final GrAnnotationMemberValue value = nameValuePair.getValue();
-
-    checkAnnotationAttributeValue(value, value);
+    if (value != null) {
+      checkAnnotationAttributeValue(value, value);
+    }
   }
 
-  private boolean checkAnnotationAttributeValue(GrAnnotationMemberValue value, PsiElement toHighlight) {
+  private boolean checkAnnotationAttributeValue(@Nullable GrAnnotationMemberValue value, @NotNull PsiElement toHighlight) {
+    if (value == null) return false;
+
     if (value instanceof GrLiteral) return false;
     if (value instanceof GrClosableBlock) return false;
     if (value instanceof GrAnnotation) return false;
@@ -1501,6 +1566,12 @@
       }
       return false;
     }
+    if (value instanceof GrUnaryExpression) {
+      final IElementType tokenType = ((GrUnaryExpression)value).getOperationTokenType();
+      if (tokenType == GroovyTokenTypes.mMINUS || tokenType == GroovyTokenTypes.mPLUS) {
+        return checkAnnotationAttributeValue(((GrUnaryExpression)value).getOperand(), toHighlight);
+      }
+    }
 
     myHolder.createErrorAnnotation(toHighlight, GroovyBundle.message("expected.0.to.be.inline.constant", value.getText()));
     return true;
@@ -1693,12 +1764,12 @@
     }
 
     if (!JavaPsiFacade.getInstance(typeDefinition.getProject()).getResolveHelper().isAccessible(abstractMethod, typeDefinition, null)) {
-      annotation.registerFix(new GrModifierFix(abstractMethod, abstractMethod.getModifierList(), PUBLIC, true, true));
-      annotation.registerFix(new GrModifierFix(abstractMethod, abstractMethod.getModifierList(), PROTECTED, true, true));
+      registerFix(annotation, new GrModifierFix(abstractMethod, PUBLIC, true, true, GrModifierFix.MODIFIER_LIST_OWNER), abstractMethod);
+      registerFix(annotation, new GrModifierFix(abstractMethod, PROTECTED, true, true, GrModifierFix.MODIFIER_LIST_OWNER), abstractMethod);
     }
 
     if (!(typeDefinition instanceof GrAnnotationTypeDefinition) && typeDefinition.getModifierList() != null) {
-      annotation.registerFix(new GrModifierFix(typeDefinition, typeDefinition.getModifierList(), ABSTRACT, false, true));
+      registerFix(annotation, new GrModifierFix(typeDefinition, ABSTRACT, false, true, GrModifierFix.MODIFIER_LIST_OWNER), typeDefinition);
     }
   }
 
@@ -1716,13 +1787,13 @@
     else {
       annotation.registerFix(new DeleteMethodBodyFix(method));
     }
-    annotation.registerFix(new GrModifierFix(method, method.getModifierList(), ABSTRACT, false, false));
+    registerFix(annotation, new GrModifierFix(method, ABSTRACT, false, false, GrModifierFix.MODIFIER_LIST_OWNER), method);
     if (makeClassAbstract) {
       final PsiClass containingClass = method.getContainingClass();
       if (containingClass != null) {
-        final GrModifierList list = (GrModifierList)containingClass.getModifierList();
+        final PsiModifierList list = containingClass.getModifierList();
         if (list != null && !list.hasModifierProperty(ABSTRACT)) {
-          annotation.registerFix(new GrModifierFix(containingClass, list, ABSTRACT, false, true));
+          registerFix(annotation, new GrModifierFix(containingClass, ABSTRACT, false, true, GrModifierFix.MODIFIER_LIST), list);
         }
       }
     }
@@ -1736,12 +1807,7 @@
 
     checkModifierIsNotAllowed(modifiersList, VOLATILE, GroovyBundle.message("method.has.incorrect.modifier.volatile"), holder);
 
-    if (method.hasModifierProperty(FINAL) && method.hasModifierProperty(ABSTRACT)) {
-      final Annotation annotation =
-        holder.createErrorAnnotation(modifiersList, GroovyBundle.message("illegal.combination.of.modifiers.abstract.and.final"));
-      annotation.registerFix(new GrModifierFix(method, modifiersList, FINAL, false, false));
-      annotation.registerFix(new GrModifierFix(method, modifiersList, ABSTRACT, false, false));
-    }
+    checkForAbstractAndFinalCombination(holder, method, modifiersList);
 
     //script methods
     boolean isMethodAbstract = modifiersList.hasExplicitModifier(ABSTRACT);
@@ -1792,11 +1858,19 @@
     if (method.hasModifierProperty(NATIVE) && method.getBlock() != null) {
       final Annotation annotation = holder.createErrorAnnotation(getModifierOrList(modifiersList, NATIVE),
                                                                  GroovyBundle.message("native.methods.cannot.have.body"));
-      annotation.registerFix(new GrModifierFix((PsiMember)modifiersList.getParent(), modifiersList, NATIVE, true, false));
+      registerFix(annotation, new GrModifierFix((PsiMember)modifiersList.getParent(), NATIVE, true, false, GrModifierFix.MODIFIER_LIST), modifiersList);
       annotation.registerFix(new DeleteMethodBodyFix(method));
     }
   }
 
+  private static void checkForAbstractAndFinalCombination(AnnotationHolder holder, GrMember member, GrModifierList modifiersList) {
+    if (member.hasModifierProperty(FINAL) && member.hasModifierProperty(ABSTRACT)) {
+      final Annotation annotation = holder.createErrorAnnotation(modifiersList, GroovyBundle.message("illegal.combination.of.modifiers.abstract.and.final"));
+      registerFix(annotation, new GrModifierFix(member, FINAL, false, false, GrModifierFix.MODIFIER_LIST), modifiersList);
+      registerFix(annotation, new GrModifierFix(member, ABSTRACT, false, false, GrModifierFix.MODIFIER_LIST), modifiersList);
+    }
+  }
+
   @NotNull
   private static PsiElement getModifierOrList(@NotNull GrModifierList modifiersList, @GrModifier.GrModifierConstant final String modifier) {
     PsiElement m = PsiUtil.findModifierInList(modifiersList, modifier);
@@ -1834,17 +1908,13 @@
       PsiClass psiClass = classType.resolve();
 
       if (psiClass != null && psiClass.hasModifierProperty(FINAL)) {
-        final Annotation annotation =
-          holder.createErrorAnnotation(typeDefinition.getNameIdentifierGroovy(), GroovyBundle.message("final.class.cannot.be.extended"));
-        annotation.registerFix(new GrModifierFix(typeDefinition, modifiersList, FINAL, false, false));
+        final Annotation annotation = holder.createErrorAnnotation(typeDefinition.getNameIdentifierGroovy(), GroovyBundle.message("final.class.cannot.be.extended"));
+        registerFix(annotation, new GrModifierFix(typeDefinition, FINAL, false, false, GrModifierFix.MODIFIER_LIST_OWNER), typeDefinition);
       }
     }
 
-    if (!typeDefinition.isEnum() && modifiersList.hasModifierProperty(ABSTRACT) && modifiersList.hasModifierProperty(FINAL)) {
-      final Annotation annotation =
-        holder.createErrorAnnotation(modifiersList, GroovyBundle.message("illegal.combination.of.modifiers.abstract.and.final"));
-      annotation.registerFix(new GrModifierFix(typeDefinition, modifiersList, FINAL, false, false));
-      annotation.registerFix(new GrModifierFix(typeDefinition, modifiersList, ABSTRACT, false, false));
+    if (!typeDefinition.isEnum()) {
+      checkForAbstractAndFinalCombination(holder, typeDefinition, modifiersList);
     }
 
     checkModifierIsNotAllowed(modifiersList, TRANSIENT, GroovyBundle.message("modifier.transient.not.allowed.here"), holder);
@@ -1864,7 +1934,7 @@
       @GrModifier.GrModifierConstant String name = modifier.getText();
       if (set.contains(name)) {
         final Annotation annotation = holder.createErrorAnnotation(list, GroovyBundle.message("duplicate.modifier", name));
-        annotation.registerFix(new GrModifierFix(member, list, name, false, false));
+        registerFix(annotation, new GrModifierFix(member, name, false, false, GrModifierFix.MODIFIER_LIST), list);
       }
       else {
         set.add(name);
@@ -1880,13 +1950,13 @@
     if (hasPrivate && hasPublic || hasPrivate && hasProtected || hasPublic && hasProtected) {
       final Annotation annotation = holder.createErrorAnnotation(modifierList, GroovyBundle.message("illegal.combination.of.modifiers"));
       if (hasPrivate) {
-        annotation.registerFix(new GrModifierFix(member, modifierList, PRIVATE, false, false));
+        registerFix(annotation, new GrModifierFix(member, PRIVATE, false, false, GrModifierFix.MODIFIER_LIST), modifierList);
       }
       if (hasProtected) {
-        annotation.registerFix(new GrModifierFix(member, modifierList, PROTECTED, false, false));
+        registerFix(annotation, new GrModifierFix(member, PROTECTED, false, false, GrModifierFix.MODIFIER_LIST), modifierList);
       }
       if (hasPublic) {
-        annotation.registerFix(new GrModifierFix(member, modifierList, PUBLIC, false, false));
+        registerFix(annotation, new GrModifierFix(member, PUBLIC, false, false, GrModifierFix.MODIFIER_LIST), modifierList);
       }
     }
     else if (member instanceof PsiMethod &&
@@ -1894,8 +1964,8 @@
              hasPublic &&
              !GroovyConfigUtils.getInstance().isVersionAtLeast(member, "1.8.4")) {
       final PsiElement publicModifier = ObjectUtils.assertNotNull(PsiUtil.findModifierInList(modifierList, PUBLIC));
-      holder.createErrorAnnotation(publicModifier, GroovyBundle.message("public.modifier.is.not.allowed.in.interfaces"))
-        .registerFix(new GrModifierFix(member, modifierList, PUBLIC, false, false));
+      final Annotation annotation = holder.createErrorAnnotation(publicModifier, GroovyBundle.message("public.modifier.is.not.allowed.in.interfaces"));
+      registerFix(annotation, new GrModifierFix(member, PUBLIC, false, false, GrModifierFix.MODIFIER_LIST), modifierList);
     }
     else if (member instanceof PsiClass &&
              member.getContainingClass() == null &&
@@ -1957,7 +2027,7 @@
 
   private static void checkCyclicInheritance(AnnotationHolder holder,
                                              GrTypeDefinition typeDefinition) {
-    final PsiClass psiClass = getCircularClass(typeDefinition, new HashSet<PsiClass>());
+    final PsiClass psiClass = HighlightClassUtil.getCircularClass(typeDefinition, new HashSet<PsiClass>());
     if (psiClass != null) {
       String qname = psiClass.getQualifiedName();
       assert qname != null;
@@ -1966,31 +2036,6 @@
     }
   }
 
-  @Nullable
-  private static PsiClass getCircularClass(PsiClass aClass, Collection<PsiClass> usedClasses) {
-    if (usedClasses.contains(aClass)) {
-      return aClass;
-    }
-    try {
-      usedClasses.add(aClass);
-      PsiClass[] superTypes = aClass.getSupers();
-      for (PsiElement superType : superTypes) {
-        while (superType instanceof PsiClass) {
-          if (!CommonClassNames.JAVA_LANG_OBJECT.equals(((PsiClass)superType).getQualifiedName())) {
-            PsiClass circularClass = getCircularClass((PsiClass)superType, usedClasses);
-            if (circularClass != null) return circularClass;
-          }
-          // check class qualifier
-          superType = superType.getParent();
-        }
-      }
-    }
-    finally {
-      usedClasses.remove(aClass);
-    }
-    return null;
-  }
-
   private static void checkForWildCards(AnnotationHolder holder, @Nullable GrReferenceList clause) {
     if (clause == null) return;
     final GrCodeReferenceElement[] elements = clause.getReferenceElementsGroovy();
@@ -2019,7 +2064,8 @@
     final String qName = typeDefinition.getQualifiedName();
     if (qName != null) {
       JavaPsiFacade facade = JavaPsiFacade.getInstance(typeDefinition.getProject());
-      final PsiClass[] classes = facade.findClasses(qName, typeDefinition.getResolveScope());
+      GlobalSearchScope scope = inferClassScopeForSearchingDuplicates(typeDefinition);
+      final PsiClass[] classes = facade.findClasses(qName, scope);
       if (classes.length > 1) {
         String packageName = getPackageName(typeDefinition);
 
@@ -2035,12 +2081,25 @@
     }
   }
 
+  private static GlobalSearchScope inferClassScopeForSearchingDuplicates(GrTypeDefinition typeDefinition) {
+    GlobalSearchScope defaultScope = typeDefinition.getResolveScope();
+
+    PsiFile file = typeDefinition.getContainingFile();
+    if (file instanceof GroovyFile && ((GroovyFile)file).isScript()) {
+      Module module = ModuleUtilCore.findModuleForPsiElement(file);
+      if (module != null) {
+        return defaultScope.intersectWith(module.getModuleScope());
+      }
+    }
+    return defaultScope;
+  }
+
   private static String getPackageName(GrTypeDefinition typeDefinition) {
     final PsiFile file = typeDefinition.getContainingFile();
     String packageName = "<default package>";
     if (file instanceof GroovyFile) {
       final String name = ((GroovyFile)file).getPackageName();
-      if (name.length() > 0) packageName = name;
+      if (!name.isEmpty()) packageName = name;
     }
     return packageName;
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateClassActionBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateClassActionBase.java
index 91aa725..1ef7d15 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateClassActionBase.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateClassActionBase.java
@@ -96,13 +96,14 @@
                                                    @NotNull final String name,
                                                    @NotNull final PsiManager manager,
                                                    @Nullable final PsiElement contextElement,
-                                                   @NotNull final String templateName) {
+                                                   @NotNull final String templateName,
+                                                   boolean allowReformatting) {
     AccessToken accessToken = WriteAction.start();
 
     try {
       GrTypeDefinition targetClass = null;
       try {
-        PsiFile file = GroovyTemplatesFactory.createFromTemplate(directory, name, name + ".groovy", templateName);
+        PsiFile file = GroovyTemplatesFactory.createFromTemplate(directory, name, name + ".groovy", templateName, allowReformatting);
         for (PsiElement element : file.getChildren()) {
           if (element instanceof GrTypeDefinition) {
             targetClass = ((GrTypeDefinition)element);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateClassFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateClassFix.java
index effc8a3..ed9f04a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateClassFix.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateClassFix.java
@@ -86,7 +86,8 @@
         PsiDirectory targetDirectory = getTargetDirectory(project, qualifier, name, module, getText());
         if (targetDirectory == null) return;
 
-        final GrTypeDefinition targetClass = createClassByType(targetDirectory, name, manager, myRefElement, GroovyTemplates.GROOVY_CLASS);
+        final GrTypeDefinition targetClass = createClassByType(targetDirectory, name, manager, myRefElement, GroovyTemplates.GROOVY_CLASS,
+                                                               true);
         if (targetClass == null) return;
 
         PsiType[] argTypes = getArgTypes(myRefElement);
@@ -249,7 +250,7 @@
         if (targetDirectory == null) return;
 
         String templateName = getTemplateName(getType());
-        final PsiClass targetClass = createClassByType(targetDirectory, name, manager, myRefElement, templateName);
+        final PsiClass targetClass = createClassByType(targetDirectory, name, manager, myRefElement, templateName, true);
         if (targetClass == null) return;
 
         bindRef(targetClass, myRefElement);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateSetterFromUsageFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateSetterFromUsageFix.java
index da0689b..2b98f5c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateSetterFromUsageFix.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/CreateSetterFromUsageFix.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@
   protected PsiType[] getArgumentTypes() {
     final GrReferenceExpression ref = getRefExpr();
     assert PsiUtil.isLValue(ref);
-    PsiType initializer = TypeInferenceHelper.getInitializerFor(ref);
+    PsiType initializer = TypeInferenceHelper.getInitializerTypeFor(ref);
     if (initializer == null || initializer == PsiType.NULL) {
       initializer = TypesUtil.getJavaLangObject(ref);
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GrModifierFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GrModifierFix.java
deleted file mode 100644
index 6d8c6ac..0000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GrModifierFix.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jetbrains.plugins.groovy.annotator.intentions;
-
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiMember;
-import com.intellij.psi.PsiModifierList;
-import com.intellij.psi.PsiModifierListOwner;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.GroovyBundle;
-import org.jetbrains.plugins.groovy.intentions.base.Intention;
-import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
-import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
-
-/**
- * @author Maxim.Medvedev
- */
-public class GrModifierFix extends Intention {
-  private final String myModifier;
-  private final String myText;
-  private final boolean myDoSet;
-  private final PsiModifierList myModifierList;
-
-  public GrModifierFix(@NotNull PsiMember member,
-                       @NotNull PsiModifierList modifierList,
-                       @GrModifier.GrModifierConstant String modifier,
-                       boolean showContainingClass,
-                       boolean doSet) {
-    myModifierList = modifierList;
-    myModifier = modifier;
-    myDoSet = doSet;
-
-    myText = org.jetbrains.plugins.groovy.codeInspection.bugs.GrModifierFix.initText(member, showContainingClass, modifier, doSet);
-  }
-
-  @NotNull
-  @Override
-  public String getText() {
-    return myText;
-  }
-
-  @Override
-  protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
-    assert myModifierList.isValid();
-    myModifierList.setModifierProperty(myModifier, myDoSet);
-  }
-
-  @NotNull
-  @Override
-  protected PsiElementPredicate getElementPredicate() {
-    return new PsiElementPredicate() {
-      @Override
-      public boolean satisfiedBy(PsiElement element) {
-        return element instanceof PsiModifierList || element instanceof PsiModifierListOwner;
-      }
-    };
-  }
-
-  @NotNull
-  public String getFamilyName() {
-    return GroovyBundle.message("change.modifier.family.name");
-  }
-}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GrReplacePrimitiveTypeWithWrapperFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GrReplacePrimitiveTypeWithWrapperFix.java
index 5793ce5..626ae5c2 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GrReplacePrimitiveTypeWithWrapperFix.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/GrReplacePrimitiveTypeWithWrapperFix.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,31 +15,31 @@
  */
 package org.jetbrains.plugins.groovy.annotator.intentions;
 
+import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiClassType;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiPrimitiveType;
+import com.intellij.psi.PsiType;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.codeInspection.GroovyFix;
 import org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle;
-import org.jetbrains.plugins.groovy.intentions.base.Intention;
-import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
 
 /**
  * @author Max Medvedev
  */
-public class GrReplacePrimitiveTypeWithWrapperFix extends Intention {
+public class GrReplacePrimitiveTypeWithWrapperFix extends GroovyFix {
   private static final Logger LOG = Logger.getInstance(GrReplacePrimitiveTypeWithWrapperFix.class);
 
-  private final GrTypeElement myTypeElement;
   private final String myBoxedName;
 
   public GrReplacePrimitiveTypeWithWrapperFix(GrTypeElement typeElement) {
     LOG.assertTrue(typeElement.isValid());
-    myTypeElement = typeElement;
 
     final PsiType type = typeElement.getType();
     LOG.assertTrue(type instanceof PsiPrimitiveType);
@@ -49,7 +49,7 @@
 
   @NotNull
   @Override
-  public String getText() {
+  public String getName() {
     return GroovyIntentionsBundle.message("replace.with.wrapper", myBoxedName);
   }
 
@@ -60,35 +60,18 @@
   }
 
   @Override
-  public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
-    return myTypeElement.isValid() && myTypeElement.getType() instanceof PsiPrimitiveType;
-  }
+  protected void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
+    final PsiElement element = descriptor.getPsiElement();
+    assert element instanceof GrTypeElement : element;
 
-  @Override
-  protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
-    final PsiType type = myTypeElement.getType();
+    GrTypeElement typeElement = (GrTypeElement)element;
+    final PsiType type = typeElement.getType();
     if (!(type instanceof PsiPrimitiveType)) return;
 
-    final PsiClassType boxed = ((PsiPrimitiveType)type).getBoxedType(myTypeElement);
+    final PsiClassType boxed = ((PsiPrimitiveType)type).getBoxedType(typeElement);
     final GrTypeElement newTypeElement = GroovyPsiElementFactory.getInstance(project).createTypeElement(boxed);
 
-    final PsiElement replaced = myTypeElement.replace(newTypeElement);
+    final PsiElement replaced = typeElement.replace(newTypeElement);
     JavaCodeStyleManager.getInstance(project).shortenClassReferences(replaced);
   }
-
-  @NotNull
-  @Override
-  protected PsiElementPredicate getElementPredicate() {
-    return new PsiElementPredicate() {
-      @Override
-      public boolean satisfiedBy(PsiElement element) {
-        return myTypeElement.isValid();
-      }
-    };
-  }
-
-  @Override
-  public boolean startInWriteAction() {
-    return true;
-  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/QuickfixUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/QuickfixUtil.java
index 604ac2f..a6319d8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/QuickfixUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/QuickfixUtil.java
@@ -197,7 +197,7 @@
       for (PsiType type : PsiUtil.getArgumentTypes(referenceExpression, false)) {
         unboxedTypes.add(TypesUtil.unboxPrimitiveTypeWrapperAndEraseGenerics(type));
       }
-      final PsiType[] types = unboxedTypes.toArray(new PsiType[unboxedTypes.size()]);
+      final PsiType[] types = unboxedTypes.toArray(PsiType.createArray(unboxedTypes.size()));
       final String[] names = getMethodArgumentsNames(referenceExpression.getProject(), types);
       final List<ParamInfo> infos = swapArgumentsAndTypes(names, types);
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicToolWindowWrapper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicToolWindowWrapper.java
index 002c2d6..2670bca 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicToolWindowWrapper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/annotator/intentions/dynamic/DynamicToolWindowWrapper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.markup.TextAttributes;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.ui.SimpleToolWindowPanel;
 import com.intellij.openapi.wm.IdeFocusManager;
@@ -456,7 +455,7 @@
                                              GroovyBundle.message("dynamic.property.deletion"), Messages.getQuestionIcon());
       }
 
-      if (result != DialogWrapper.OK_EXIT_CODE) return false;
+      if (result != Messages.OK) return false;
     }
 
     removeNamedElement(((DNamedElement)namedElement));
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GrReassignedLocalVarsChecker.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GrReassignedLocalVarsChecker.java
index d15268b..eaeee5b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GrReassignedLocalVarsChecker.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInsight/GrReassignedLocalVarsChecker.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,19 +19,24 @@
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.util.NullableComputable;
 import com.intellij.openapi.util.RecursionManager;
+import com.intellij.openapi.util.Ref;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiManager;
 import com.intellij.psi.PsiReference;
 import com.intellij.psi.PsiType;
 import com.intellij.psi.search.searches.ReferencesSearch;
-import com.intellij.psi.util.CachedValue;
-import com.intellij.psi.util.CachedValueProvider;
-import com.intellij.psi.util.CachedValuesManager;
-import com.intellij.psi.util.PsiModificationTracker;
+import com.intellij.psi.util.*;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
 import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyRecursiveElementVisitor;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
 import org.jetbrains.plugins.groovy.lang.psi.dataFlow.types.TypeInferenceHelper;
@@ -40,15 +45,79 @@
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
 
 import java.util.Collection;
+import java.util.Set;
 
 /**
  * @author Max Medvedev
  */
 public class GrReassignedLocalVarsChecker {
   private static final Key<CachedValue<PsiType>> LEAST_UPPER_BOUND_TYPE = Key.create("least upper bound type");
+  private static final Key<CachedValue<Set<String>>> ASSIGNED_VARS = Key.create("assigned vars inside block");
+  private static final Key<CachedValue<Boolean>> REASSIGNED_VAR = Key.create("least upper bound type");
 
   @Nullable
-  public static PsiType checkReassignedVar(GrReferenceExpression refExpr, boolean honorCompileStatic) {
+  public static Boolean isReassignedVar(@NotNull final GrReferenceExpression refExpr) {
+    if (!PsiUtil.isCompileStatic(refExpr)) {
+      return false;
+    }
+
+    if (refExpr.getQualifier() != null) {
+      return false;
+    }
+
+    final PsiElement resolved = refExpr.resolve();
+    if (!GroovyRefactoringUtil.isLocalVariable(resolved)) {
+      return false;
+    }
+
+    assert resolved != null;
+    CachedValue<Boolean> data = resolved.getUserData(REASSIGNED_VAR);
+    if (data == null) {
+      data = CachedValuesManager.getManager(refExpr.getProject()).createCachedValue(new CachedValueProvider<Boolean>() {
+        @Nullable
+        @Override
+        public Result<Boolean> compute() {
+          return Result.create(isReassignedVarImpl((GrVariable)resolved), PsiModificationTracker.MODIFICATION_COUNT, ProjectRootManager.getInstance(resolved.getProject()));
+        }
+      }, false);
+      resolved.putUserData(REASSIGNED_VAR, data);
+    }
+    return data.getValue();
+  }
+
+  private static boolean isReassignedVarImpl(@NotNull final GrVariable resolved) {
+    final GrControlFlowOwner variableScope = PsiTreeUtil.getParentOfType(resolved, GrCodeBlock.class, GroovyFile.class);
+    if (variableScope == null) return false;
+
+    final String name = resolved.getName();
+    final Ref<Boolean> isReassigned = Ref.create(false);
+    for (PsiElement scope = resolved.getParent().getNextSibling(); scope != null; scope = scope.getNextSibling()) {
+      if (scope instanceof GroovyPsiElement) {
+        ((GroovyPsiElement)scope).accept(new GroovyRecursiveElementVisitor() {
+          @Override
+          public void visitClosure(GrClosableBlock closure) {
+            if (getUsedVarsInsideBlock(closure).contains(name)) {
+              isReassigned.set(true);
+            }
+          }
+
+          @Override
+          public void visitElement(GroovyPsiElement element) {
+            if (isReassigned.get()) return;
+            super.visitElement(element);
+          }
+        });
+
+        if (isReassigned.get()) break;
+      }
+    }
+
+    return isReassigned.get();
+  }
+
+
+  @Nullable
+  public static PsiType getReassignedVarType(GrReferenceExpression refExpr, boolean honorCompileStatic) {
     if (honorCompileStatic && !PsiUtil.isCompileStatic(refExpr) || refExpr.getQualifier() != null) {
       return null;
     }
@@ -63,41 +132,26 @@
   }
 
   @Nullable
-  private static PsiType getLeastUpperBoundByVar(final GrVariable resolved) {
+  private static PsiType getLeastUpperBoundByVar(@NotNull final GrVariable resolved) {
     CachedValue<PsiType> data = resolved.getUserData(LEAST_UPPER_BOUND_TYPE);
     if (data == null) {
       data = CachedValuesManager.getManager(resolved.getProject()).createCachedValue(new CachedValueProvider<PsiType>() {
         @Override
         public Result<PsiType> compute() {
-          return Result.create(getLeastUpperBoundByVarImpl(resolved), PsiModificationTracker.MODIFICATION_COUNT, ProjectRootManager.getInstance(
-            resolved.getProject()));
+          return Result.create(getLeastUpperBoundByVarImpl(resolved), PsiModificationTracker.MODIFICATION_COUNT, ProjectRootManager.getInstance(resolved.getProject()));
         }
       }, false);
+      resolved.putUserData(LEAST_UPPER_BOUND_TYPE, data);
     }
     return data.getValue();
   }
 
   @Nullable
-  private static PsiType getLeastUpperBoundByVarImpl(final GrVariable resolved) {
+  private static PsiType getLeastUpperBoundByVarImpl(@NotNull final GrVariable resolved) {
     return RecursionManager.doPreventingRecursion(resolved, false, new NullableComputable<PsiType>() {
       @Override
       public PsiType compute() {
-        final GrControlFlowOwner flowOwner = ControlFlowUtils.findControlFlowOwner(resolved);
-        final Collection<PsiReference> all = ReferencesSearch.search(resolved, resolved.getResolveScope()).findAll();
-        boolean hasClosureReassigns = false;
-        for (PsiReference reference : all) {
-          final PsiElement ref = reference.getElement();
-          if (ref instanceof GrReferenceExpression &&
-              PsiUtil.isLValue(((GrReferenceExpression)ref)) &&
-              ControlFlowUtils.findControlFlowOwner(ref) != flowOwner) {
-            hasClosureReassigns = true;
-            break;
-          }
-        }
-
-        if (!hasClosureReassigns) {
-          return null;
-        }
+        final Collection<PsiReference> all = ReferencesSearch.search(resolved).findAll();
 
         final GrExpression initializer = resolved.getInitializerGroovy();
         PsiType result = initializer != null ? initializer.getType() : null;
@@ -105,13 +159,52 @@
         final PsiManager manager = resolved.getManager();
         for (PsiReference reference : all) {
           final PsiElement ref = reference.getElement();
-          if (ref instanceof GrReferenceExpression &&
-              PsiUtil.isLValue(((GrReferenceExpression)ref))) {
-            result = TypesUtil.getLeastUpperBoundNullable(result, TypeInferenceHelper.getInitializerFor(ref), manager);
+          if (ref instanceof GrReferenceExpression && PsiUtil.isLValue(((GrReferenceExpression)ref))) {
+            result = TypesUtil.getLeastUpperBoundNullable(result, TypeInferenceHelper.getInitializerTypeFor(ref), manager);
           }
         }
         return result;
       }
     });
   }
+
+  @NotNull
+  private static Set<String> getUsedVarsInsideBlock(@NotNull final GrCodeBlock block) {
+    CachedValue<Set<String>> data = block.getUserData(ASSIGNED_VARS);
+
+    if (data == null) {
+      data = CachedValuesManager.getManager(block.getProject()).createCachedValue(new CachedValueProvider<Set<String>>() {
+        @Nullable
+        @Override
+        public Result<Set<String>> compute() {
+          final Set<String> result = ContainerUtil.newHashSet();
+
+          block.acceptChildren(new GroovyRecursiveElementVisitor() {
+
+            @Override
+            public void visitOpenBlock(GrOpenBlock openBlock) {
+              result.addAll(getUsedVarsInsideBlock(openBlock));
+            }
+
+            @Override
+            public void visitClosure(GrClosableBlock closure) {
+              result.addAll(getUsedVarsInsideBlock(closure));
+            }
+
+            @Override
+            public void visitReferenceExpression(GrReferenceExpression referenceExpression) {
+              if (referenceExpression.getQualifier() == null && referenceExpression.getReferenceName() != null) {
+                result.add(referenceExpression.getReferenceName());
+              }
+            }
+          });
+          return Result.create(result, block);
+        }
+      }, false);
+      block.putUserData(ASSIGNED_VARS, data);
+    }
+
+    return data.getValue();
+  }
+
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.java
index 552c291..8c4a204 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
 package org.jetbrains.plugins.groovy.codeInspection;
 
 import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.PropertyKey;
 
 import java.util.ResourceBundle;
@@ -29,25 +30,21 @@
  */
 public class GroovyInspectionBundle {
 
-  private static Reference<ResourceBundle> ourBundle;
-
-  @NonNls
-  private static final String BUNDLE = "org.jetbrains.plugins.groovy.codeInspection.GroovyInspectionBundle";
-
-  public static String message(@PropertyKey(resourceBundle = BUNDLE)String key, Object... params) {
+  public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
     return CommonBundle.message(getBundle(), key, params);
   }
 
-  private static ResourceBundle getBundle() {
-    ResourceBundle bundle = null;
+  private static Reference<ResourceBundle> ourBundle;
+  @NonNls
+  private static final String BUNDLE = "org.jetbrains.plugins.groovy.codeInspection.GroovyInspectionBundle";
 
-    if (ourBundle != null) bundle = ourBundle.get();
+  private static ResourceBundle getBundle() {
+    ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
 
     if (bundle == null) {
       bundle = ResourceBundle.getBundle(BUNDLE);
-      ourBundle = new SoftReference<ResourceBundle  >(bundle);
+      ourBundle = new SoftReference<ResourceBundle>(bundle);
     }
     return bundle;
   }
-
 }
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties
index 5ccb19b..3d658f0 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovyInspectionBundle.properties
@@ -85,7 +85,7 @@
 replace.0.with.1=Replace {0} with binary {1}
 gr.deprecated.api.usage=Deprecated API inspection
 category.method.0.cannot.be.applied.to.1=Category method ''{0}'' cannot be applied to ''{1}''
-local.var.0.is.reassigned.in.closure=Local variable {0} is reassigned in {1} with other type
+local.var.0.is.reassigned=Local variable ''{0}'' is reassigned
 anonymous.class=anonymous class
 closure=closure
 other.scope=Other scope
@@ -106,4 +106,7 @@
 target.0.does.not.exist=Target ''{0}'' does not exist
 target.annotation.is.unused=@Target is unused
 change.lvalue.type=Change variable ''{0}'' type to ''{1}''
-replace.qualified.name.with.import=Replace qualified name with import
\ No newline at end of file
+replace.qualified.name.with.import=Replace qualified name with import
+highlight.assignments.from.void=Highlight assignments from void type
+comments.count.as.content=Comments count as content
+ignore.when.catch.parameter.is.named.ignore.or.ignored=Ignore when catch parameter is named ignore or ignored
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/CallInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/CallInfo.java
new file mode 100644
index 0000000..1dea914
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/CallInfo.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+
+/**
+ * Created by Max Medvedev on 05/02/14
+ */
+public interface CallInfo<Call extends GroovyPsiElement> {
+  @Nullable
+  GrArgumentList getArgumentList();
+
+  @Nullable
+  PsiType[] getArgumentTypes();
+
+  @Nullable
+  GrExpression getInvokedExpression();
+
+  @Nullable
+  PsiType getQualifierInstanceType();
+
+  @NotNull
+  PsiElement getHighlightElementForCategoryQualifier() throws UnsupportedOperationException;
+
+  @NotNull
+  PsiElement getElementToHighlight();
+
+  @NotNull
+  GroovyResolveResult advancedResolve();
+
+  @NotNull
+  GroovyResolveResult[] multiResolve();
+
+  @NotNull
+  Call getCall();
+
+  @NotNull
+  GrExpression[] getExpressionArguments();
+
+  @NotNull
+  GrClosableBlock[] getClosureArguments();
+
+  @NotNull
+  GrNamedArgument[] getNamedArguments();
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/CallInfoBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/CallInfoBase.java
new file mode 100644
index 0000000..1d4e938
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/CallInfoBase.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+
+/**
+ * Created by Max Medvedev on 05/02/14
+ */
+public abstract class CallInfoBase<T extends GrCall> implements CallInfo<T> {
+  private final T myCall;
+  private final PsiType[] myArgTypes;
+
+  protected CallInfoBase(T call) {
+    myCall = call;
+    myArgTypes = inferArgTypes();
+  }
+
+  @Nullable
+  protected abstract PsiType[] inferArgTypes();
+
+  @Nullable
+  @Override
+  public GrArgumentList getArgumentList() {
+    return myCall.getArgumentList();
+  }
+
+  @Nullable
+  @Override
+  public PsiType[] getArgumentTypes() {
+    return myArgTypes;
+  }
+
+  @NotNull
+  @Override
+  public GroovyResolveResult advancedResolve() {
+    return myCall.advancedResolve();
+  }
+
+  @NotNull
+  @Override
+  public GroovyResolveResult[] multiResolve() {
+    return myCall.multiResolve(false);
+  }
+
+  @NotNull
+  @Override
+  public T getCall() {
+    return myCall;
+  }
+
+  @NotNull
+  public GrExpression[] getExpressionArguments() {
+    return myCall.getExpressionArguments();
+  }
+
+  @NotNull
+  public GrClosableBlock[] getClosureArguments() {
+    return myCall.getClosureArguments();
+  }
+
+  @NotNull
+  public GrNamedArgument[] getNamedArguments() {
+    return myCall.getNamedArguments();
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/ConstructorCallInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/ConstructorCallInfo.java
new file mode 100644
index 0000000..238d885
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/ConstructorCallInfo.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+
+/**
+ * Created by Max Medvedev on 05/02/14
+ */
+public interface ConstructorCallInfo<T extends GroovyPsiElement> extends CallInfo<T> {
+  GroovyResolveResult[] multiResolveClass();
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/ConstructorCallInfoBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/ConstructorCallInfoBase.java
new file mode 100644
index 0000000..90d5ea3
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/ConstructorCallInfoBase.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrConstructorCall;
+
+/**
+ * Created by Max Medvedev on 05/02/14
+ */
+public abstract class ConstructorCallInfoBase<T extends GrConstructorCall> extends CallInfoBase<T> implements ConstructorCallInfo<T> {
+  public ConstructorCallInfoBase(T call) {
+    super(call);
+  }
+
+  public GroovyResolveResult[] multiResolveClass() {
+    return getCall().multiResolveClass();
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/DelegatingCallInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/DelegatingCallInfo.java
new file mode 100644
index 0000000..f5bb288
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/DelegatingCallInfo.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+
+/**
+ * Created by Max Medvedev on 05/02/14
+ */
+public class DelegatingCallInfo<T extends GroovyPsiElement> implements CallInfo<T> {
+  private final CallInfo<T> myDelegate;
+
+  public DelegatingCallInfo(CallInfo<T> delegate) {
+    myDelegate = delegate;
+  }
+
+  @Nullable
+  @Override
+  public GrArgumentList getArgumentList() {
+    return myDelegate.getArgumentList();
+  }
+
+  @Nullable
+  @Override
+  public PsiType[] getArgumentTypes() {
+    return myDelegate.getArgumentTypes();
+  }
+
+  @Nullable
+  @Override
+  public GrExpression getInvokedExpression() {
+    return myDelegate.getInvokedExpression();
+  }
+
+  @Nullable
+  @Override
+  public PsiType getQualifierInstanceType() {
+    return myDelegate.getQualifierInstanceType();
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getHighlightElementForCategoryQualifier() throws UnsupportedOperationException {
+    return myDelegate.getHighlightElementForCategoryQualifier();
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getElementToHighlight() {
+    return myDelegate.getElementToHighlight();
+  }
+
+  @NotNull
+  @Override
+  public GroovyResolveResult advancedResolve() {
+    return myDelegate.advancedResolve();
+  }
+
+  @NotNull
+  @Override
+  public GroovyResolveResult[] multiResolve() {
+    return myDelegate.multiResolve();
+  }
+
+  @NotNull
+  @Override
+  public T getCall() {
+    return myDelegate.getCall();
+  }
+
+  @NotNull
+  @Override
+  public GrExpression[] getExpressionArguments() {
+    return myDelegate.getExpressionArguments();
+  }
+
+  @NotNull
+  @Override
+  public GrClosableBlock[] getClosureArguments() {
+    return myDelegate.getClosureArguments();
+  }
+
+  @NotNull
+  @Override
+  public GrNamedArgument[] getNamedArguments() {
+    return myDelegate.getNamedArguments();
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrBinaryExprInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrBinaryExprInfo.java
new file mode 100644
index 0000000..54750a9
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrBinaryExprInfo.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
+
+/**
+ * Created by Max Medvedev on 05/02/14
+ */
+public class GrBinaryExprInfo implements CallInfo<GrBinaryExpression> {
+  private final GrBinaryExpression myExpr;
+
+  public GrBinaryExprInfo(GrBinaryExpression expr) {
+    myExpr = expr;
+  }
+
+  @Nullable
+  @Override
+  public GrArgumentList getArgumentList() {
+    return null;
+  }
+
+  @Nullable
+  @Override
+  public PsiType[] getArgumentTypes() {
+    GrExpression operand = myExpr.getRightOperand();
+
+    return new PsiType[]{operand != null ? operand.getType() : null};
+  }
+
+  @Nullable
+  @Override
+  public GrExpression getInvokedExpression() {
+    return myExpr.getLeftOperand();
+  }
+
+  @Nullable
+  @Override
+  public PsiType getQualifierInstanceType() {
+    return myExpr.getLeftOperand().getType();
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getHighlightElementForCategoryQualifier() {
+    return myExpr.getOperationToken();
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getElementToHighlight() {
+    return myExpr.getOperationToken();
+  }
+
+  @NotNull
+  @Override
+  public GroovyResolveResult advancedResolve() {
+    return PsiImplUtil.extractUniqueResult(multiResolve());
+  }
+
+  @NotNull
+  @Override
+  public GroovyResolveResult[] multiResolve() {
+    return myExpr.multiResolve(false);
+  }
+
+  @NotNull
+  @Override
+  public GrBinaryExpression getCall() {
+    return myExpr;
+  }
+
+  @NotNull
+  @Override
+  public GrExpression[] getExpressionArguments() {
+    GrExpression right = myExpr.getRightOperand();
+    if (right != null) {
+      return new GrExpression[]{right};
+    }
+    else {
+      return GrExpression.EMPTY_ARRAY;
+    }
+  }
+
+  @NotNull
+  @Override
+  public GrClosableBlock[] getClosureArguments() {
+    return GrClosableBlock.EMPTY_ARRAY;
+  }
+
+  @NotNull
+  @Override
+  public GrNamedArgument[] getNamedArguments() {
+    return GrNamedArgument.EMPTY_ARRAY;
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrCastFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrCastFix.java
index 44109f9..d5a3467 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrCastFix.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrCastFix.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrSafeCastExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 
 /**
  * @author Maxim.Medvedev
@@ -42,8 +43,8 @@
   private static final Logger LOG = Logger.getInstance(GrCastFix.class);
   private PsiType myExpectedType;
 
-  public GrCastFix(PsiType expectedType) {
-    myExpectedType = expectedType;
+  public GrCastFix(PsiType expectedType, GrExpression expression) {
+    myExpectedType = PsiImplUtil.normalizeWildcardTypeByPosition(expectedType, expression);
   }
 
   @Override
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrConstructorInvocationInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrConstructorInvocationInfo.java
new file mode 100644
index 0000000..cdc00ce
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrConstructorInvocationInfo.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrConstructorInvocation;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
+
+/**
+ * Created by Max Medvedev on 05/02/14
+ */
+public class GrConstructorInvocationInfo extends ConstructorCallInfoBase<GrConstructorInvocation>
+  implements ConstructorCallInfo<GrConstructorInvocation> {
+  protected GrConstructorInvocationInfo(GrConstructorInvocation call) {
+    super(call);
+  }
+
+  @Nullable
+  @Override
+  protected PsiType[] inferArgTypes() {
+    return PsiUtil.getArgumentTypes(getArgumentList());
+  }
+
+  @NotNull
+  @Override
+  public GrExpression getInvokedExpression() {
+    return getCall().getInvokedExpression();
+  }
+
+  @Nullable
+  @Override
+  public PsiType getQualifierInstanceType() {
+    return getInvokedExpression().getType();
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getHighlightElementForCategoryQualifier() {
+    throw new UnsupportedOperationException("not applicable");
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getElementToHighlight() {
+    return getCall().getArgumentList();
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrEnumConstantInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrEnumConstantInfo.java
new file mode 100644
index 0000000..436ded4
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrEnumConstantInfo.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant;
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
+
+/**
+ * Created by Max Medvedev on 05/02/14
+ */
+public class GrEnumConstantInfo extends ConstructorCallInfoBase<GrEnumConstant> implements ConstructorCallInfo<GrEnumConstant> {
+  public GrEnumConstantInfo(GrEnumConstant constant) {
+    super(constant);
+  }
+
+  @Nullable
+  @Override
+  protected PsiType[] inferArgTypes() {
+    GrEnumConstant call = getCall();
+    GrArgumentList argList = call.getArgumentList();
+    if (argList != null) {
+      return PsiUtil.getArgumentTypes(argList);
+    }
+    else {
+      return PsiType.EMPTY_ARRAY;
+    }
+  }
+
+  @Nullable
+  @Override
+  public GrExpression getInvokedExpression() {
+    return null;
+  }
+
+  @Nullable
+  @Override
+  public PsiType getQualifierInstanceType() {
+    return null;
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getHighlightElementForCategoryQualifier() {
+    throw new UnsupportedOperationException("not applicable");
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getElementToHighlight() {
+    GrEnumConstant constant = getCall();
+    GrArgumentList argList = constant.getArgumentList();
+    if (argList != null) return argList;
+
+    return constant.getNameIdentifierGroovy();
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrIndexPropertyInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrIndexPropertyInfo.java
new file mode 100644
index 0000000..1efd015
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrIndexPropertyInfo.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrIndexProperty;
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
+
+/**
+ * Created by Max Medvedev on 05/02/14
+ */
+public class GrIndexPropertyInfo extends CallInfoBase<GrIndexProperty> {
+  protected GrIndexPropertyInfo(GrIndexProperty call) {
+    super(call);
+  }
+
+  @Nullable
+  @Override
+  protected PsiType[] inferArgTypes() {
+    return PsiUtil.getArgumentTypes(getCall().getInvokedExpression(), true);
+  }
+
+  @NotNull
+  @Override
+  public GrExpression getInvokedExpression() {
+    return getCall().getInvokedExpression();
+  }
+
+  @Nullable
+  @Override
+  public PsiType getQualifierInstanceType() {
+    return getInvokedExpression().getType();
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getHighlightElementForCategoryQualifier() {
+    GrExpression invoked = getInvokedExpression();
+    if (invoked instanceof GrReferenceExpression) {
+      PsiElement refNameElement = ((GrReferenceExpression)invoked).getReferenceNameElement();
+      if (refNameElement != null) {
+        return refNameElement;
+      }
+    }
+
+    return invoked;
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getElementToHighlight() {
+    return getCall().getArgumentList();
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrListOrMapInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrListOrMapInfo.java
new file mode 100644
index 0000000..1a09254
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrListOrMapInfo.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.findUsages.LiteralConstructorReference;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
+
+/**
+ * Created by Max Medvedev on 05/02/14
+ */
+public class GrListOrMapInfo implements ConstructorCallInfo<GrListOrMap> {
+  private final GrListOrMap myListOrMap;
+  private final LiteralConstructorReference myReference;
+
+  public GrListOrMapInfo(GrListOrMap listOrMap) {
+    myListOrMap = listOrMap;
+
+    assert listOrMap.getReference() instanceof LiteralConstructorReference;
+    myReference = ((LiteralConstructorReference)listOrMap.getReference());
+  }
+
+  @Nullable
+  @Override
+  public GrArgumentList getArgumentList() {
+    return null;
+  }
+
+  @Nullable
+  @Override
+  public PsiType[] getArgumentTypes() {
+    if (myListOrMap.isMap()) {
+      GrNamedArgument[] args = myListOrMap.getNamedArguments();
+      if (args.length == 0) return new PsiType[]{myListOrMap.getType()};
+
+      return PsiUtil.getArgumentTypes(args, GrExpression.EMPTY_ARRAY, GrClosableBlock.EMPTY_ARRAY, true, null, false);
+    }
+    else {
+      GrExpression[] args = myListOrMap.getInitializers();
+      return PsiUtil.getArgumentTypes(GrNamedArgument.EMPTY_ARRAY, args, GrClosableBlock.EMPTY_ARRAY, true, null, false);
+    }
+  }
+
+  @Nullable
+  @Override
+  public GrExpression getInvokedExpression() {
+    return null;
+  }
+
+  @Nullable
+  @Override
+  public PsiType getQualifierInstanceType() {
+    return null;
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getHighlightElementForCategoryQualifier() throws UnsupportedOperationException {
+    throw new UnsupportedOperationException("not applicable");
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getElementToHighlight() {
+    return myListOrMap;
+  }
+
+  @NotNull
+  @Override
+  public GroovyResolveResult advancedResolve() {
+    return PsiImplUtil.extractUniqueResult(multiResolve());
+  }
+
+  @NotNull
+  @Override
+  public GroovyResolveResult[] multiResolve() {
+    GroovyResolveResult[] results = myReference.multiResolve(false);
+    if (results.length == 1 && results[0].getElement() instanceof PsiClass) {
+      return GroovyResolveResult.EMPTY_ARRAY; //the same behaviour as constructor calls
+    }
+    return results;
+  }
+
+  @NotNull
+  @Override
+  public GrListOrMap getCall() {
+    return myListOrMap;
+  }
+
+  @Override
+  public GroovyResolveResult[] multiResolveClass() {
+    return new GroovyResolveResult[]{new GroovyResolveResultImpl(myReference.getConstructedClassType().resolveGenerics())};
+  }
+
+  @NotNull
+  @Override
+  public GrExpression[] getExpressionArguments() {
+    return myListOrMap.isMap() ? GrExpression.EMPTY_ARRAY : myListOrMap.getInitializers();
+  }
+
+  @NotNull
+  @Override
+  public GrClosableBlock[] getClosureArguments() {
+    return GrClosableBlock.EMPTY_ARRAY;
+  }
+
+  @NotNull
+  @Override
+  public GrNamedArgument[] getNamedArguments() {
+    return myListOrMap.isMap() ? myListOrMap.getNamedArguments() : GrNamedArgument.EMPTY_ARRAY;
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrMethodCallInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrMethodCallInfo.java
new file mode 100644
index 0000000..721a6eb
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrMethodCallInfo.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrReferenceResolveUtil;
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
+
+/**
+ * Created by Max Medvedev on 05/02/14
+ */
+public class GrMethodCallInfo extends CallInfoBase<GrMethodCall> implements CallInfo<GrMethodCall> {
+  public GrMethodCallInfo(GrMethodCall call) {
+    super(call);
+  }
+
+  @Nullable
+  @Override
+  protected PsiType[] inferArgTypes() {
+    return PsiUtil.getArgumentTypes(getCall().getInvokedExpression(), true);
+  }
+
+  @Override
+  public GrExpression getInvokedExpression() {
+    return getCall().getInvokedExpression();
+  }
+
+  @Override
+  public PsiType getQualifierInstanceType() {
+    GrExpression invoked = getCall().getInvokedExpression();
+    return invoked instanceof GrReferenceExpression ? GrReferenceResolveUtil.getQualifierType((GrReferenceExpression)invoked) : null;
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getHighlightElementForCategoryQualifier() {
+    GrExpression invoked = getCall().getInvokedExpression();
+    if (invoked instanceof GrReferenceExpression) {
+      PsiElement nameElement = ((GrReferenceExpression)invoked).getReferenceNameElement();
+      if (nameElement != null) {
+        return nameElement;
+      }
+    }
+    return invoked;
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getElementToHighlight() {
+    GrArgumentList argList = getCall().getArgumentList();
+    if (argList.getTextLength() == 0) {
+      return getCall();
+    }
+    return argList;
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrNewExpressionInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrNewExpressionInfo.java
new file mode 100644
index 0000000..3634455
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GrNewExpressionInfo.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.codeInspection.assignment;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
+
+/**
+ * Created by Max Medvedev on 05/02/14
+ */
+public class GrNewExpressionInfo extends ConstructorCallInfoBase<GrNewExpression> {
+
+  public GrNewExpressionInfo(GrNewExpression expr) {
+    super(expr);
+  }
+
+  @Nullable
+  @Override
+  protected PsiType[] inferArgTypes() {
+    return PsiUtil.getArgumentTypes(getCall().getReferenceElement(), true);
+  }
+
+  @Nullable
+  @Override
+  public GrExpression getInvokedExpression() {
+    return null;
+  }
+
+  @Nullable
+  @Override
+  public PsiType getQualifierInstanceType() {
+    return null;
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getHighlightElementForCategoryQualifier() {
+    throw new UnsupportedOperationException("no categories are applicable to new expression");
+  }
+
+  @NotNull
+  @Override
+  public PsiElement getElementToHighlight() {
+    GrNewExpression call = getCall();
+
+    GrArgumentList argList = call.getArgumentList();
+    if (argList != null) return argList;
+
+    GrCodeReferenceElement ref = call.getReferenceElement();
+    if (ref != null) return ref;
+
+    throw new IncorrectOperationException("reference of new expression should exist if it is a constructor call");
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java
index fff8538..970b391 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyAssignabilityCheckInspection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,12 +18,14 @@
 
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.codeInspection.*;
+import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
 import com.intellij.lang.annotation.Annotation;
 import com.intellij.lang.annotation.AnnotationHolder;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Pair;
+import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.PsiSubstitutorImpl;
 import com.intellij.psi.tree.IElementType;
@@ -58,6 +60,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrSpreadArgument;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrThrowStatement;
@@ -69,18 +72,20 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.*;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
+import org.jetbrains.plugins.groovy.lang.psi.dataFlow.types.TypeInferenceHelper;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager;
 import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrReferenceResolveUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
 import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.ClosureParameterEnhancer;
 import org.jetbrains.plugins.groovy.lang.psi.util.*;
 import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
 
+import javax.swing.*;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
@@ -90,6 +95,10 @@
 public class GroovyAssignabilityCheckInspection extends BaseInspection {
   private static final Logger LOG = Logger.getInstance(GroovyAssignabilityCheckInspection.class);
 
+  private static final String SHORT_NAME = "GroovyAssignabilityCheck";
+
+  public boolean myHighlightAssignmentsFromVoid = true;
+
   @Nls
   @NotNull
   @Override
@@ -102,6 +111,14 @@
     return true;
   }
 
+  @Nullable
+  @Override
+  public JComponent createOptionsPanel() {
+    final MultipleCheckboxOptionsPanel optionsPanel = new MultipleCheckboxOptionsPanel(this);
+    optionsPanel.addCheckbox(GroovyInspectionBundle.message("highlight.assignments.from.void"), "myHighlightAssignmentsFromVoid");
+    return optionsPanel;
+  }
+
   @Nls
   @NotNull
   @Override
@@ -127,9 +144,17 @@
       final PsiType rType = expression.getType();
       if (rType == null) return;
 
+      if (PsiUtil.isVoidMethodCall(expression)) {
+        if (isHighlightAssignmentsFromVoid(expression)) {
+          registerError(toHighlight, GroovyBundle.message("cannot.assign", PsiType.VOID.getPresentableText(),
+                                                          expectedType.getPresentableText()));
+        }
+        return;
+      }
+
       if (!TypesUtil.isAssignable(expectedType, rType, expression)) {
         final List<LocalQuickFix> fixes = ContainerUtil.newArrayList();
-        fixes.add(new GrCastFix(expectedType));
+        fixes.add(new GrCastFix(expectedType, expression));
 
         String varName = getLValueVarName(toHighlight);
         if (varName != null) {
@@ -141,6 +166,21 @@
       }
     }
 
+    private static boolean isHighlightAssignmentsFromVoid(PsiElement place) {
+      final GroovyAssignabilityCheckInspection instance = getInspectionInstance(place.getContainingFile(), place.getProject());
+      if (instance != null) {
+        return instance.myHighlightAssignmentsFromVoid;
+      }
+
+      return false;
+    }
+
+    private static GroovyAssignabilityCheckInspection getInspectionInstance(PsiFile file, Project project) {
+      final InspectionProfile profile = InspectionProjectProfileManager.getInstance(project).getInspectionProfile();
+      return (GroovyAssignabilityCheckInspection)profile.getUnwrappedTool(SHORT_NAME, file);
+    }
+
+
     @Nullable
     private static String getLValueVarName(PsiElement highlight) {
       final PsiElement parent = highlight.getParent();
@@ -221,7 +261,7 @@
         if (flowOwner != null && returnType != null && returnType != PsiType.VOID) {
           if (ControlFlowUtils.isReturnValue(expression, flowOwner) &&
               !isNewInstanceInitialingByTuple(expression) &&
-              expression.getType() != PsiType.VOID) {
+              !PsiUtil.isVoidMethodCall(expression)) {
             checkAssignability(returnType, expression, getExpressionPartToHighlight(expression));
           }
         }
@@ -272,14 +312,10 @@
         for (GrExpression lValue : lValues) {
           PsiType lType = lValue.getNominalType();
           // For assignments with spread dot
-          if (isListAssignment(lValue) && lType != null && lType instanceof PsiClassType) {
-            final PsiClassType pct = (PsiClassType)lType;
-            final PsiClass clazz = pct.resolve();
-            if (clazz != null && CommonClassNames.JAVA_UTIL_LIST.equals(clazz.getQualifiedName())) {
-              final PsiType[] types = pct.getParameters();
-              if (types.length == 1 && types[0] != null && rType != null) {
-                checkAssignability(types[0], rType, tupleExpression, getExpressionPartToHighlight(lValue));
-              }
+          if (GroovyRefactoringUtil.isSpreadAssignment(lValue)) {
+            final PsiType argType = extractIterableArg(lType);
+            if (argType != null && rType != null) {
+              checkAssignability(argType, rType, tupleExpression, getExpressionPartToHighlight(lValue));
             }
             return;
           }
@@ -298,15 +334,10 @@
     private void checkAssignment(GrExpression lValue, GrExpression rValue) {
       PsiType lType = lValue.getNominalType();
       PsiType rType = rValue.getType();
-      // For assignments with spread dot
-      if (isListAssignment(lValue) && lType != null && lType instanceof PsiClassType) {
-        final PsiClassType pct = (PsiClassType)lType;
-        final PsiClass clazz = pct.resolve();
-        if (clazz != null && CommonClassNames.JAVA_UTIL_LIST.equals(clazz.getQualifiedName())) {
-          final PsiType[] types = pct.getParameters();
-          if (types.length == 1 && types[0] != null && rType != null) {
-            checkAssignability(types[0], rValue, getExpressionPartToHighlight(lValue));
-          }
+      if (GroovyRefactoringUtil.isSpreadAssignment(lValue)) {
+        final PsiType argType = extractIterableArg(lType);
+        if (argType != null && rValue != null) {
+          checkAssignability(argType, rValue, getExpressionPartToHighlight(lValue));
         }
         return;
       }
@@ -325,6 +356,11 @@
       }
     }
 
+    @Nullable
+    private static PsiType extractIterableArg(@Nullable PsiType type) {
+      return com.intellij.psi.util.PsiUtil.extractIterableTypeParameter(type, false);
+    }
+
     @Override
     public void visitVariable(GrVariable variable) {
       super.visitVariable(variable);
@@ -400,43 +436,43 @@
       GrCodeReferenceElement refElement = newExpression.getReferenceElement();
       if (refElement == null) return;
 
-      checkConstructorCall(newExpression, refElement);
+      GrNewExpressionInfo info = new GrNewExpressionInfo(newExpression);
+      checkConstructorCall(info);
     }
 
-    private void checkConstructorCall(GrConstructorCall constructorCall, GroovyPsiElement refElement) {
-      final GrArgumentList argList = constructorCall.getArgumentList();
-      if (hasErrorElements(argList)) return;
+    private void checkConstructorCall(ConstructorCallInfo<?> info) {
+      if (hasErrorElements(info.getArgumentList())) return;
 
-      if (!checkCannotInferArgumentTypes(refElement)) return;
-      final GroovyResolveResult constructorResolveResult = constructorCall.advancedResolve();
+      if (!checkCannotInferArgumentTypes(info)) return;
+      final GroovyResolveResult constructorResolveResult = info.advancedResolve();
       final PsiElement constructor = constructorResolveResult.getElement();
 
       if (constructor != null) {
-        if (!checkConstructorApplicability(constructorResolveResult, refElement, true)) return;
+        if (!checkConstructorApplicability(constructorResolveResult, info, true)) return;
       }
       else {
-        final GroovyResolveResult[] results = constructorCall.multiResolve(false);
+        final GroovyResolveResult[] results = info.multiResolve();
         if (results.length > 0) {
           for (GroovyResolveResult result : results) {
             PsiElement resolved = result.getElement();
             if (resolved instanceof PsiMethod) {
-              if (!checkConstructorApplicability(result, refElement, false)) return;
+              if (!checkConstructorApplicability(result, info, false)) return;
             }
           }
-          registerError(getElementToHighlight(refElement, argList), GroovyBundle.message("constructor.call.is.ambiguous"));
+          registerError(info.getElementToHighlight(), GroovyBundle.message("constructor.call.is.ambiguous"));
         }
         else {
-          final GrExpression[] expressionArguments = constructorCall.getExpressionArguments();
-          final boolean hasClosureArgs = PsiImplUtil.hasClosureArguments(constructorCall);
-          final boolean hasNamedArgs = PsiImplUtil.hasNamedArguments(constructorCall.getArgumentList());
+          final GrExpression[] expressionArguments = info.getExpressionArguments();
+          final boolean hasClosureArgs = info.getClosureArguments().length > 0;
+          final boolean hasNamedArgs = info.getNamedArguments().length > 0;
           if (hasClosureArgs ||
               hasNamedArgs && expressionArguments.length > 0 ||
               !hasNamedArgs && expressionArguments.length > 0 && !isOnlyOneMapParam(expressionArguments)) {
-            final GroovyResolveResult[] resolveResults = constructorCall.multiResolveClass();
+            final GroovyResolveResult[] resolveResults = info.multiResolveClass();
             if (resolveResults.length == 1) {
               final PsiElement element = resolveResults[0].getElement();
               if (element instanceof PsiClass) {
-                registerError(getElementToHighlight(refElement, argList),
+                registerError(info.getElementToHighlight(),
                               GroovyBundle.message("cannot.apply.default.constructor", ((PsiClass)element).getName()));
                 return;
               }
@@ -445,22 +481,14 @@
         }
       }
 
-      checkNamedArgumentsType(constructorCall);
+      checkNamedArgumentsType(info);
     }
 
     private static boolean isOnlyOneMapParam(GrExpression[] exprs) {
       if (!(exprs.length == 1)) return false;
 
       final GrExpression e = exprs[0];
-      return TypesUtil.isAssignableByMethodCallConversion(TypesUtil.createTypeByFQClassName(CommonClassNames.JAVA_UTIL_MAP, e), e.getType(),
-                                                          e);
-    }
-
-    @NotNull
-    private static PsiElement getElementToHighlight(@NotNull PsiElement refElement, @Nullable GrArgumentList argList) {
-      PsiElement elementToHighlight = argList;
-      if (elementToHighlight == null || elementToHighlight.getTextLength() == 0) elementToHighlight = refElement;
-      return elementToHighlight;
+      return TypesUtil.isAssignableByMethodCallConversion(TypesUtil.createTypeByFQClassName(CommonClassNames.JAVA_UTIL_MAP, e), e.getType(), e);
     }
 
     @NotNull
@@ -482,27 +510,7 @@
       final GroovyResolveResult[] results = ((LiteralConstructorReference)reference).multiResolve(false);
       if (results.length == 0) return;
 
-      if (results.length == 1) {
-        final GroovyResolveResult result = results[0];
-        final PsiElement element = result.getElement();
-        if (element instanceof PsiClass) {
-          if (!listOrMap.isMap()) {
-            registerError(listOrMap, GroovyBundle.message("cannot.apply.default.constructor", ((PsiClass)element).getName()));
-          }
-        }
-        else if (element instanceof PsiMethod && ((PsiMethod)element).isConstructor()) {
-          checkLiteralConstructorApplicability(result, listOrMap, true);
-        }
-      }
-      else {
-        for (GroovyResolveResult result : results) {
-          PsiElement resolved = result.getElement();
-          if (resolved instanceof PsiMethod) {
-            if (!checkLiteralConstructorApplicability(result, listOrMap, false)) return;
-          }
-          registerError(listOrMap, GroovyBundle.message("constructor.call.is.ambiguous"));
-        }
-      }
+      checkConstructorCall(new GrListOrMapInfo(listOrMap));
     }
 
     @Override
@@ -516,146 +524,127 @@
       }
     }
 
-    private boolean checkLiteralConstructorApplicability(GroovyResolveResult result, GrListOrMap listOrMap, boolean checkUnknownArgs) {
-      final PsiElement element = result.getElement();
-      LOG.assertTrue(element instanceof PsiMethod && ((PsiMethod)element).isConstructor());
-      final PsiMethod constructor = (PsiMethod)element;
-
-      final GrExpression[] exprArgs;
-      final GrNamedArgument[] namedArgs;
-      if (listOrMap.isMap()) {
-        exprArgs = GrExpression.EMPTY_ARRAY;
-        namedArgs = listOrMap.getNamedArguments();
-      }
-      else {
-        exprArgs = listOrMap.getInitializers();
-        namedArgs = GrNamedArgument.EMPTY_ARRAY;
-      }
-
-      if (exprArgs.length == 0 && !PsiUtil.isConstructorHasRequiredParameters(constructor)) return true;
-
-      PsiType[] argumentTypes = PsiUtil.getArgumentTypes(namedArgs, exprArgs, GrClosableBlock.EMPTY_ARRAY, false, null, false);
-      if (listOrMap.isMap() && namedArgs.length == 0) {
-        argumentTypes = new PsiType[]{listOrMap.getType()};
-      }
-
-      GrClosureSignatureUtil.ApplicabilityResult applicable =
-        PsiUtil.isApplicableConcrete(argumentTypes, constructor, result.getSubstitutor(), listOrMap, false);
-      switch (applicable) {
-        case inapplicable:
-          highlightInapplicableMethodUsage(result, listOrMap, constructor, argumentTypes);
-          return false;
-        case canBeApplicable:
-          if (checkUnknownArgs) {
-            highlightUnknownArgs(listOrMap);
-          }
-          return !checkUnknownArgs;
-        default:
-          return true;
-      }
-    }
-
     private boolean checkConstructorApplicability(GroovyResolveResult constructorResolveResult,
-                                                  GroovyPsiElement place,
+                                                  CallInfo<?> info,
                                                   boolean checkUnknownArgs) {
       final PsiElement element = constructorResolveResult.getElement();
-      LOG.assertTrue(element instanceof PsiMethod && ((PsiMethod)element).isConstructor());
+      LOG.assertTrue(element instanceof PsiMethod && ((PsiMethod)element).isConstructor(), element);
       final PsiMethod constructor = (PsiMethod)element;
 
-      final GrArgumentList argList = PsiUtil.getArgumentsList(place);
+      final GrArgumentList argList = info.getArgumentList();
       if (argList != null) {
         final GrExpression[] exprArgs = argList.getExpressionArguments();
-
         if (exprArgs.length == 0 && !PsiUtil.isConstructorHasRequiredParameters(constructor)) return true;
       }
 
-      PsiType[] types = PsiUtil.getArgumentTypes(place, true);
+      PsiType[] types = info.getArgumentTypes();
       PsiClass containingClass = constructor.getContainingClass();
       if (types != null && containingClass != null) {
-        types = GrInnerClassConstructorUtil.addEnclosingArgIfNeeded(types, place, containingClass);
+        final PsiType[] newTypes = GrInnerClassConstructorUtil.addEnclosingArgIfNeeded(types, info.getCall(), containingClass);
+        if (newTypes.length != types.length) {
+          return checkMethodApplicability(constructorResolveResult, checkUnknownArgs, new DelegatingCallInfo(info) {
+            @Nullable
+            @Override
+            public PsiType[] getArgumentTypes() {
+              return newTypes;
+            }
+          });
+        }
       }
-      return checkMethodApplicability(constructorResolveResult, place, checkUnknownArgs, types);
+
+      return checkMethodApplicability(constructorResolveResult, checkUnknownArgs, info);
     }
 
     @Override
     public void visitConstructorInvocation(GrConstructorInvocation invocation) {
       super.visitConstructorInvocation(invocation);
-      checkConstructorCall(invocation, invocation.getInvokedExpression());
+      GrConstructorInvocationInfo info = new GrConstructorInvocationInfo(invocation);
+      checkConstructorCall(info);
+      checkNamedArgumentsType(info);
     }
 
     @Override
     public void visitIndexProperty(GrIndexProperty expression) {
       super.visitIndexProperty(expression);
 
-      if (!checkCannotInferArgumentTypes(expression.getInvokedExpression())) return;
+      checkIndexProperty(new GrIndexPropertyInfo(expression));
+    }
 
-      final GrExpression invoked = expression.getInvokedExpression();
+    private void checkIndexProperty(CallInfo<? extends GrIndexProperty> info) {
+      if (hasErrorElements(info.getArgumentList())) return;
 
-      if (hasErrorElements(expression.getArgumentList())) return;
+      if (!checkCannotInferArgumentTypes(info)) return;
 
-      final PsiType type = invoked.getType();
-      final PsiType[] types = PsiUtil.getArgumentTypes(expression.getArgumentList(), true);
-      if (type instanceof PsiArrayType) {
-        assert types != null;
+      final PsiType type = info.getQualifierInstanceType();
+      final PsiType[] types = info.getArgumentTypes();
 
-        if (PsiUtil.isLValue(expression)) {
-          if (types.length == 2 &&
-              TypesUtil.isAssignable(PsiType.INT, types[0], expression) &&
-              TypesUtil.isAssignable(((PsiArrayType)type).getComponentType(), types[1], expression)) {
-            return;
-          }
-        }
-        else {
-          if (types.length == 1 && TypesUtil.isAssignable(PsiType.INT, types[0], expression)) {
-            return;
-          }
-        }
-      }
+      if (checkSimpleArrayAccess(info, type, types)) return;
 
-      final GroovyResolveResult[] results = expression.multiResolve(false);
+      final GroovyResolveResult[] results = info.multiResolve();
+      final GroovyResolveResult resolveResult = info.advancedResolve();
 
-      if (results.length == 1) {
-        final GroovyResolveResult resolveResult = results[0];
+      if (resolveResult.getElement() != null) {
         PsiElement resolved = resolveResult.getElement();
 
         if (resolved instanceof PsiMethod && !resolveResult.isInvokedOnProperty()) {
-          checkMethodApplicability(resolveResult, invoked, true);
+          checkMethodApplicability(resolveResult, true, info);
         }
         else if (resolved instanceof GrField) {
-          checkCallApplicability(((GrField)resolved).getTypeGroovy(), invoked, true);
+          checkCallApplicability(((GrField)resolved).getTypeGroovy(), true, info);
         }
         else if (resolved instanceof PsiField) {
-          checkCallApplicability(((PsiField)resolved).getType(), invoked, true);
+          checkCallApplicability(((PsiField)resolved).getType(), true, info);
         }
       }
       else if (results.length > 0) {
-        for (GroovyResolveResult resolveResult : results) {
-          PsiElement resolved = resolveResult.getElement();
-          if (resolved instanceof PsiMethod && !resolveResult.isInvokedOnProperty()) {
-            if (!checkMethodApplicability(resolveResult, invoked, false)) return;
+        for (GroovyResolveResult result : results) {
+          PsiElement resolved = result.getElement();
+          if (resolved instanceof PsiMethod && !result.isInvokedOnProperty()) {
+            if (!checkMethodApplicability(result, false, info)) return;
           }
           else if (resolved instanceof GrField) {
-            if (!checkCallApplicability(((GrField)resolved).getTypeGroovy(), invoked, false)) return;
+            if (!checkCallApplicability(((GrField)resolved).getTypeGroovy(), false, info)) return;
           }
           else if (resolved instanceof PsiField) {
-            if (!checkCallApplicability(((PsiField)resolved).getType(), invoked, false)) return;
+            if (!checkCallApplicability(((PsiField)resolved).getType(), false, info)) return;
           }
         }
 
-        registerError(getElementToHighlight(invoked, PsiUtil.getArgumentsList(invoked)), GroovyBundle.message("method.call.is.ambiguous"));
+        registerError(info.getElementToHighlight(), GroovyBundle.message("method.call.is.ambiguous"));
       }
       else {
         final String typesString = buildArgTypesList(types);
-        registerError(PsiUtil.getArgumentsList(invoked), GroovyBundle.message("cannot.find.operator.overload.method", typesString));
+        registerError(info.getElementToHighlight(), GroovyBundle.message("cannot.find.operator.overload.method", typesString));
       }
     }
 
-    private boolean checkCannotInferArgumentTypes(PsiElement place) {
-      if (PsiUtil.getArgumentTypes(place, true) != null) {
+    private static boolean checkSimpleArrayAccess(CallInfo<? extends GrIndexProperty> info, PsiType type, PsiType[] types) {
+      if (!(type instanceof PsiArrayType)) return false;
+
+      assert types != null;
+
+      if (PsiUtil.isLValue(info.getCall())) {
+        if (types.length == 2 &&
+            TypesUtil.isAssignable(PsiType.INT, types[0], info.getCall()) &&
+            TypesUtil.isAssignable(((PsiArrayType)type).getComponentType(), types[1], info.getCall())) {
+          return true;
+        }
+      }
+      else {
+        if (types.length == 1 && TypesUtil.isAssignable(PsiType.INT, types[0], info.getCall())) {
+          return true;
+        }
+      }
+
+      return false;
+    }
+
+    private boolean checkCannotInferArgumentTypes(CallInfo info) {
+      if (info.getArgumentTypes() != null) {
         return true;
       }
       else {
-        highlightUnknownArgs(place);
+        highlightUnknownArgs(info);
         return false;
       }
     }
@@ -663,22 +652,34 @@
     @Override
     public void visitMethodCallExpression(GrMethodCallExpression methodCallExpression) {
       super.visitMethodCallExpression(methodCallExpression);
-      checkMethodCall(methodCallExpression, methodCallExpression.getInvokedExpression());
+      checkMethodCall(new GrMethodCallInfo(methodCallExpression));
     }
 
     @Override
     public void visitApplicationStatement(GrApplicationStatement applicationStatement) {
       super.visitApplicationStatement(applicationStatement);
-      checkMethodCall(applicationStatement, applicationStatement.getInvokedExpression());
+      checkMethodCall(new GrMethodCallInfo(applicationStatement));
+    }
+
+    @Override
+    public void visitBinaryExpression(GrBinaryExpression binary) {
+      super.visitBinaryExpression(binary);
+      checkOperator(new GrBinaryExprInfo(binary));
     }
 
     @Override
     public void visitEnumConstant(GrEnumConstant enumConstant) {
       super.visitEnumConstant(enumConstant);
-      checkConstructorCall(enumConstant, enumConstant);
+      GrEnumConstantInfo info = new GrEnumConstantInfo(enumConstant);
+      checkConstructorCall(info);
+      checkNamedArgumentsType(info);
     }
 
-    private void checkNamedArgumentsType(GrCall call) {
+    private void checkNamedArgumentsType(CallInfo<?> info) {
+      GroovyPsiElement rawCall = info.getCall();
+      if (!(rawCall instanceof GrCall)) return;
+      GrCall call = (GrCall)rawCall;
+
       GrNamedArgument[] namedArguments = PsiUtil.getFirstMapNamedArguments(call);
 
       if (namedArguments.length == 0) return;
@@ -700,14 +701,11 @@
 
         if (PsiUtil.isRawClassMemberAccess(namedArgumentExpression)) continue;
 
-        PsiType expressionType = namedArgumentExpression.getType();
+        PsiType expressionType = TypesUtil.boxPrimitiveType(namedArgumentExpression.getType(), call.getManager(), call.getResolveScope());
         if (expressionType == null) continue;
 
-        expressionType = TypesUtil.boxPrimitiveType(expressionType, call.getManager(), call.getResolveScope());
-
         if (!descriptor.checkType(expressionType, call)) {
-          registerError(namedArgumentExpression,
-                        "Type of argument '" + labelName + "' can not be '" + expressionType.getPresentableText() + "'");
+          registerError(namedArgumentExpression, "Type of argument '" + labelName + "' can not be '" + expressionType.getPresentableText() + "'");
         }
       }
     }
@@ -724,13 +722,49 @@
       return false;
     }
 
-    private void checkMethodCall(GrCall call, GrExpression invoked) {
-      if (hasErrorElements(call.getArgumentList())) return;
+    private void checkOperator(CallInfo<? extends GrBinaryExpression> info) {
+      if (hasErrorElements(info.getCall())) return;
 
-      if (invoked instanceof GrReferenceExpression) {
-        final GrReferenceExpression referenceExpression = (GrReferenceExpression)invoked;
-        GroovyResolveResult resolveResult = call.advancedResolve();
-        GroovyResolveResult[] results = call.multiResolve(false); //cached
+      GroovyResolveResult[] results = info.multiResolve();
+      GroovyResolveResult resolveResult = info.advancedResolve();
+
+      if (isOperatorWithSimpleTypes(info.getCall(), resolveResult)) return;
+
+      if (!checkCannotInferArgumentTypes(info)) return;
+
+      if (resolveResult.getElement() != null) {
+        checkMethodApplicability(resolveResult, true, info);
+      }
+      else if (results.length > 0) {
+        for (GroovyResolveResult result : results) {
+          if (!checkMethodApplicability(result, false, info)) return;
+        }
+
+        registerError(info.getElementToHighlight(), GroovyBundle.message("method.call.is.ambiguous"));
+      }
+    }
+
+    private static boolean isOperatorWithSimpleTypes(GrBinaryExpression binary, GroovyResolveResult result) {
+      if (result.getElement() != null && result.isApplicable()) {
+        return false;
+      }
+
+      GrExpression left = binary.getLeftOperand();
+      GrExpression right = binary.getRightOperand();
+
+      PsiType ltype = left.getType();
+      PsiType rtype = right != null ? right.getType() : null;
+
+      return TypesUtil.isNumericType(ltype) && (rtype == null || TypesUtil.isNumericType(rtype));
+    }
+
+    private void checkMethodCall(CallInfo<? extends GrMethodCall> info) {
+      if (hasErrorElements(info.getArgumentList())) return;
+
+      if (info.getInvokedExpression() instanceof GrReferenceExpression) {
+        final GrReferenceExpression referenceExpression = (GrReferenceExpression)info.getInvokedExpression();
+        GroovyResolveResult resolveResult = info.advancedResolve();
+        GroovyResolveResult[] results = info.multiResolve();
 
         PsiElement resolved = resolveResult.getElement();
         if (resolved == null) {
@@ -738,73 +772,71 @@
           if (qualifier == null && GrHighlightUtil.isDeclarationAssignment(referenceExpression)) return;
         }
 
-        if (!checkCannotInferArgumentTypes(referenceExpression)) return;
+        if (!checkCannotInferArgumentTypes(info)) return;
 
         final PsiType type = referenceExpression.getType();
         if (resolved != null) {
           if (resolved instanceof PsiMethod && !resolveResult.isInvokedOnProperty()) {
-            checkMethodApplicability(resolveResult, referenceExpression, true);
+            checkMethodApplicability(resolveResult, true, info);
           }
           else {
-            checkCallApplicability(type, referenceExpression, true);
+            checkCallApplicability(type, true, info);
           }
         }
         else if (results.length > 0) {
           for (GroovyResolveResult result : results) {
-            resolved = result.getElement();
-            if (resolved instanceof PsiMethod && !result.isInvokedOnProperty()) {
-              if (!checkMethodApplicability(result, referenceExpression, false)) return;
+            PsiElement current = result.getElement();
+            if (current instanceof PsiMethod && !result.isInvokedOnProperty()) {
+              if (!checkMethodApplicability(result, false, info)) return;
             }
             else {
-              if (!checkCallApplicability(type, referenceExpression, false)) return;
+              if (!checkCallApplicability(type, false, info)) return;
             }
           }
 
-          registerError(getElementToHighlight(referenceExpression, PsiUtil.getArgumentsList(referenceExpression)),
-                        GroovyBundle.message("method.call.is.ambiguous"));
+          registerError(info.getElementToHighlight(), GroovyBundle.message("method.call.is.ambiguous"));
         }
       }
-      else if (invoked != null) { //it checks in visitRefExpr(...)
-        final PsiType type = invoked.getType();
-        checkCallApplicability(type, invoked, true);
+      else if (info.getInvokedExpression() != null) { //it checks in visitRefExpr(...)
+        final PsiType type = info.getInvokedExpression().getType();
+        checkCallApplicability(type, true, info);
       }
 
-      checkNamedArgumentsType(call);
+      checkNamedArgumentsType(info);
     }
 
-    private void highlightInapplicableMethodUsage(GroovyResolveResult methodResolveResult,
-                                                  GroovyPsiElement place,
-                                                  PsiMethod method,
-                                                  PsiType[] argumentTypes) {
+    private void highlightInapplicableMethodUsage(@NotNull GroovyResolveResult methodResolveResult,
+                                                  @NotNull CallInfo info,
+                                                  @NotNull PsiMethod method) {
       final PsiClass containingClass =
         method instanceof GrGdkMethod ? ((GrGdkMethod)method).getStaticMethod().getContainingClass() : method.getContainingClass();
 
+      PsiType[] argumentTypes = info.getArgumentTypes();
       if (containingClass == null) {
-        registerCannotApplyError(place, argumentTypes, method.getName());
+        registerCannotApplyError(method.getName(), info);
         return;
       }
       final String typesString = buildArgTypesList(argumentTypes);
-      final PsiElementFactory factory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory();
+      final PsiElementFactory factory = JavaPsiFacade.getElementFactory(method.getProject());
       final PsiClassType containingType = factory.createType(containingClass, methodResolveResult.getSubstitutor());
       final String canonicalText = containingType.getInternalCanonicalText();
-      String message;
-      if (method.isConstructor()) {
-        message = GroovyBundle.message("cannot.apply.constructor", method.getName(), canonicalText, typesString);
-      }
-      else {
-        message = GroovyBundle.message("cannot.apply.method1", method.getName(), canonicalText, typesString);
-      }
+      String message = method.isConstructor() ? GroovyBundle.message("cannot.apply.constructor", method.getName(), canonicalText, typesString)
+                                              : GroovyBundle.message("cannot.apply.method1", method.getName(), canonicalText, typesString);
 
-      final GrArgumentList argumentsList = PsiUtil.getArgumentsList(place);
-      registerError(getElementToHighlight(place, argumentsList), message,
-                    genCastFixes(GrClosureSignatureUtil.createSignature(methodResolveResult), argumentTypes, argumentsList),
+      registerError(info.getElementToHighlight(), message,
+                    genCastFixes(GrClosureSignatureUtil.createSignature(methodResolveResult), argumentTypes, info.getArgumentList()),
                     ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
     }
 
     private static LocalQuickFix[] genCastFixes(GrSignature signature, PsiType[] argumentTypes, @Nullable GrArgumentList argumentList) {
       if (argumentList == null) return LocalQuickFix.EMPTY_ARRAY;
+      final List<GrExpression> args = getExpressionArgumentsOfCall(argumentList);
 
-      final List<GrClosureSignature> signatures = GrClosureSignatureUtil.generateSimpleSignature(signature);
+      if (args == null) {
+        return LocalQuickFix.EMPTY_ARRAY;
+      }
+
+      final List<GrClosureSignature> signatures = GrClosureSignatureUtil.generateSimpleSignatures(signature);
 
       List<Pair<Integer, PsiType>> allErrors = new ArrayList<Pair<Integer, PsiType>>();
       for (GrClosureSignature closureSignature : signatures) {
@@ -822,26 +854,29 @@
 
       final ArrayList<LocalQuickFix> fixes = new ArrayList<LocalQuickFix>();
       for (Pair<Integer, PsiType> error : allErrors) {
-        fixes.add(new ParameterCastFix(error.first, error.second));
+        fixes.add(new ParameterCastFix(error.first, error.second, args.get(error.first)));
       }
 
       return fixes.toArray(new LocalQuickFix[fixes.size()]);
     }
 
-    private boolean checkCallApplicability(PsiType type, GroovyPsiElement invokedExpr, boolean checkUnknownArgs) {
+    private boolean checkCallApplicability(PsiType type, boolean checkUnknownArgs, CallInfo info) {
 
-      PsiType[] argumentTypes = PsiUtil.getArgumentTypes(invokedExpr, true);
+      PsiType[] argumentTypes = info.getArgumentTypes();
+      GrExpression invoked = info.getInvokedExpression();
+      if (invoked == null) return true;
+
       if (type instanceof GrClosureType) {
         if (argumentTypes == null) return true;
 
-        GrClosureSignatureUtil.ApplicabilityResult result = PsiUtil.isApplicableConcrete(argumentTypes, (GrClosureType)type, invokedExpr);
+        GrClosureSignatureUtil.ApplicabilityResult result = PsiUtil.isApplicableConcrete(argumentTypes, (GrClosureType)type, info.getCall());
         switch (result) {
           case inapplicable:
-            registerCannotApplyError(invokedExpr, argumentTypes, invokedExpr.getText());
+            registerCannotApplyError(invoked.getText(), info);
             return false;
           case canBeApplicable:
             if (checkUnknownArgs) {
-              highlightUnknownArgs(invokedExpr);
+              highlightUnknownArgs(info);
             }
             return !checkUnknownArgs;
           default:
@@ -849,30 +884,27 @@
         }
       }
       else if (type != null) {
-        final GroovyResolveResult[] calls = ResolveUtil.getMethodCandidates(type, "call", invokedExpr, argumentTypes);
+        final GroovyResolveResult[] calls = ResolveUtil.getMethodCandidates(type, "call", invoked, argumentTypes);
         for (GroovyResolveResult result : calls) {
           PsiElement resolved = result.getElement();
           if (resolved instanceof PsiMethod && !result.isInvokedOnProperty()) {
-            if (!checkMethodApplicability(result, invokedExpr, checkUnknownArgs && calls.length == 1)) return false;
+            if (!checkMethodApplicability(result, checkUnknownArgs, info)) return false;
           }
           else if (resolved instanceof PsiField) {
-            if (!checkCallApplicability(((PsiField)resolved).getType(), invokedExpr, checkUnknownArgs && calls.length == 1)) return false;
+            if (!checkCallApplicability(((PsiField)resolved).getType(), checkUnknownArgs && calls.length == 1, info)) return false;
           }
         }
-        if (calls.length == 0 && !(invokedExpr instanceof GrString)) {
-          registerCannotApplyError(invokedExpr, argumentTypes, invokedExpr.getText());
+        if (calls.length == 0 && !(invoked instanceof GrString)) {
+          registerCannotApplyError(invoked.getText(), info);
         }
         return true;
       }
       return true;
     }
 
-    private void registerCannotApplyError(PsiElement place, PsiType[] argumentTypes, String invokedText) {
-      final String typesString = buildArgTypesList(argumentTypes);
-      String message = GroovyBundle.message("cannot.apply.method.or.closure", invokedText, typesString);
-      PsiElement elementToHighlight = PsiUtil.getArgumentsList(place);
-      if (elementToHighlight == null || elementToHighlight.getTextRange().getLength() == 0) elementToHighlight = place;
-      registerError(elementToHighlight, message);
+    private void registerCannotApplyError(String invokedText, CallInfo info) {
+      final String typesString = buildArgTypesList(info.getArgumentTypes());
+      registerError(info.getElementToHighlight(), GroovyBundle.message("cannot.apply.method.or.closure", invokedText, typesString));
     }
 
     private static String buildArgTypesList(PsiType[] argTypes) {
@@ -890,33 +922,26 @@
     }
 
     private boolean checkMethodApplicability(@NotNull GroovyResolveResult methodResolveResult,
-                                             @NotNull GroovyPsiElement place,
-                                             boolean checkUnknownArgs) {
-      return checkMethodApplicability(methodResolveResult, place, checkUnknownArgs, PsiUtil.getArgumentTypes(place, true));
-    }
-
-    private boolean checkMethodApplicability(@NotNull GroovyResolveResult methodResolveResult,
-                                             @NotNull GroovyPsiElement place,
                                              boolean checkUnknownArgs,
-                                             @Nullable PsiType[] argumentTypes) {
+                                             @NotNull CallInfo info) {
       final PsiElement element = methodResolveResult.getElement();
       if (!(element instanceof PsiMethod)) return true;
       if (element instanceof GrBuilderMethod) return true;
 
       final PsiMethod method = (PsiMethod)element;
-      if ("call".equals(method.getName()) && place instanceof GrReferenceExpression) {
-        final GrExpression qualifierExpression = ((GrReferenceExpression)place).getQualifierExpression();
+      if ("call".equals(method.getName()) && info.getInvokedExpression() instanceof GrReferenceExpression) {
+        final GrExpression qualifierExpression = ((GrReferenceExpression)info.getInvokedExpression()).getQualifierExpression();
         if (qualifierExpression != null) {
           final PsiType type = qualifierExpression.getType();
           if (type instanceof GrClosureType) {
-            GrClosureSignatureUtil.ApplicabilityResult result = PsiUtil.isApplicableConcrete(argumentTypes, (GrClosureType)type, place);
+            GrClosureSignatureUtil.ApplicabilityResult result = PsiUtil.isApplicableConcrete(info.getArgumentTypes(), (GrClosureType)type, info.getInvokedExpression());
             switch (result) {
               case inapplicable:
-                highlightInapplicableMethodUsage(methodResolveResult, place, method, argumentTypes);
+                highlightInapplicableMethodUsage(methodResolveResult, info, method);
                 return false;
               case canBeApplicable:
                 if (checkUnknownArgs) {
-                  highlightUnknownArgs(place);
+                  highlightUnknownArgs(info);
                 }
                 return !checkUnknownArgs;
               default:
@@ -926,32 +951,33 @@
         }
       }
 
-      if (method instanceof GrGdkMethod && place instanceof GrReferenceExpression) {
+      if (method instanceof GrGdkMethod && info.getInvokedExpression() instanceof GrReferenceExpression) {
         final PsiMethod staticMethod = ((GrGdkMethod)method).getStaticMethod();
-        final PsiType qualifierType = inferQualifierTypeByPlace((GrReferenceExpression)place);
+        final PsiType qualifierType = info.getQualifierInstanceType();
 
-        final GrExpression qualifier = PsiImplUtil.getRuntimeQualifier((GrReferenceExpression)place);
+        GrReferenceExpression invoked = (GrReferenceExpression)info.getInvokedExpression();
+        final GrExpression qualifier = PsiImplUtil.getRuntimeQualifier(invoked);
 
         //check methods processed by @Category(ClassWhichProcessMethod) annotation
         if (qualifierType != null &&
             !GdkMethodUtil.isCategoryMethod(staticMethod, qualifierType, qualifier, methodResolveResult.getSubstitutor()) &&
-            !checkCategoryQualifier((GrReferenceExpression)place, qualifier, staticMethod, methodResolveResult.getSubstitutor())) {
-          registerError(((GrReferenceExpression)place).getReferenceNameElement(), GroovyInspectionBundle
+            !checkCategoryQualifier(invoked, qualifier, staticMethod, methodResolveResult.getSubstitutor())) {
+          registerError(info.getHighlightElementForCategoryQualifier(), GroovyInspectionBundle
             .message("category.method.0.cannot.be.applied.to.1", method.getName(), qualifierType.getCanonicalText()));
           return false;
         }
       }
 
-      if (argumentTypes == null) return true;
+      if (info.getArgumentTypes() == null) return true;
 
-      GrClosureSignatureUtil.ApplicabilityResult applicable = PsiUtil.isApplicableConcrete(argumentTypes, method, methodResolveResult.getSubstitutor(), place, false);
+      GrClosureSignatureUtil.ApplicabilityResult applicable = PsiUtil.isApplicableConcrete(info.getArgumentTypes(), method, methodResolveResult.getSubstitutor(), info.getCall(), false);
       switch (applicable) {
         case inapplicable:
-          highlightInapplicableMethodUsage(methodResolveResult, place, method, argumentTypes);
+          highlightInapplicableMethodUsage(methodResolveResult, info, method);
           return false;
         case canBeApplicable:
           if (checkUnknownArgs) {
-            highlightUnknownArgs(place);
+            highlightUnknownArgs(info);
           }
           return !checkUnknownArgs;
         default:
@@ -991,34 +1017,39 @@
       return null;
     }
 
-    private void highlightUnknownArgs(@NotNull PsiElement place) {
-      final PsiElement toHighlight = getElementToHighlight(place, PsiUtil.getArgumentsList(place));
-      registerError(toHighlight, GroovyBundle.message("cannot.infer.argument.types"), LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.WEAK_WARNING);
+    private void highlightUnknownArgs(@NotNull CallInfo info) {
+      registerError(info.getElementToHighlight(), GroovyBundle.message("cannot.infer.argument.types"), LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.WEAK_WARNING);
     }
   }
 
-  private static boolean isListAssignment(GrExpression lValue) {
-    if (lValue instanceof GrReferenceExpression) {
-      GrReferenceExpression expression = (GrReferenceExpression)lValue;
-      final PsiElement dot = expression.getDotToken();
-      //noinspection ConstantConditions
-      if (dot != null && dot.getNode().getElementType() == GroovyTokenTypes.mSPREAD_DOT) {
-        return true;
-      }
-      else {
-        final GrExpression qualifier = expression.getQualifierExpression();
-        if (qualifier != null) return isListAssignment(qualifier);
-      }
-    }
-    return false;
-  }
-
   @Nullable
-  private static PsiType inferQualifierTypeByPlace(GrReferenceExpression place) {
-    if (place.getParent() instanceof GrIndexProperty) {
-      return place.getType();
+  private static List<GrExpression> getExpressionArgumentsOfCall(@NotNull GrArgumentList argumentList) {
+    final GrExpression[] argArray = argumentList.getExpressionArguments();
+    final ArrayList<GrExpression> args = ContainerUtil.newArrayList();
+
+    for (GrExpression arg : argArray) {
+      if (arg instanceof GrSpreadArgument) {
+        GrExpression spreaded = ((GrSpreadArgument)arg).getArgument();
+        if (spreaded instanceof GrListOrMap && !((GrListOrMap)spreaded).isMap()) {
+          Collections.addAll(args, ((GrListOrMap)spreaded).getInitializers());
+        }
+        else {
+          return null;
+        }
+      }
+      else {
+        args.add(arg);
+      }
     }
-    return GrReferenceResolveUtil.getQualifierType(place);
+
+    final PsiElement parent = argumentList.getParent();
+    if (parent instanceof GrIndexProperty && PsiUtil.isLValue((GroovyPsiElement)parent)) {
+      args.add(TypeInferenceHelper.getInitializerFor((GrExpression)parent));
+    }
+    else if (parent instanceof GrMethodCallExpression) {
+      ContainerUtil.addAll(args, ((GrMethodCallExpression)parent).getClosureArguments());
+    }
+    return args;
   }
 
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovySillyAssignmentInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovySillyAssignmentInspection.java
index d32f298..9c33e5a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovySillyAssignmentInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovySillyAssignmentInspection.java
@@ -52,12 +52,12 @@
     return true;
   }
 
+  @NotNull
   public BaseInspectionVisitor buildVisitor() {
     return new Visitor();
   }
 
-  private static class Visitor
-      extends BaseInspectionVisitor {
+  private static class Visitor extends BaseInspectionVisitor {
 
     public void visitAssignmentExpression(@NotNull GrAssignmentExpression assignment) {
       super.visitAssignmentExpression(assignment);
@@ -71,8 +71,7 @@
       if (rhs == null) {
         return;
       }
-      if (!(rhs instanceof GrReferenceExpression) ||
-          !(lhs instanceof GrReferenceExpression)) {
+      if (!(rhs instanceof GrReferenceExpression) || !(lhs instanceof GrReferenceExpression)) {
         return;
       }
       final GrReferenceExpression rhsReference = (GrReferenceExpression) rhs;
@@ -94,8 +93,7 @@
       }
       final PsiElement rhsReferent = rhsReference.resolve();
       final PsiElement lhsReferent = lhsReference.resolve();
-      if (rhsReferent != null && lhsReferent != null &&
-          !rhsReferent.equals(lhsReferent)) {
+      if (rhsReferent == null || lhsReferent == null || !rhsReferent.equals(lhsReferent)) {
         return;
       }
       registerError(assignment);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyUncheckedAssignmentOfMemberOfRawTypeInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyUncheckedAssignmentOfMemberOfRawTypeInspection.java
index 52b091a..d69140c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyUncheckedAssignmentOfMemberOfRawTypeInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/GroovyUncheckedAssignmentOfMemberOfRawTypeInspection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,6 +40,8 @@
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 
+import static org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil.isSpreadAssignment;
+
 /**
  * @author Maxim.Medvedev
  */
@@ -62,6 +64,7 @@
     return true;
   }
 
+  @NotNull
   protected BaseInspectionVisitor buildVisitor() {
     return new Visitor();
   }
@@ -149,7 +152,7 @@
       PsiType rType = rValue.getType();
 
       // For assignments with spread dot
-      if (isListAssignment(lValue) && lType != null && lType instanceof PsiClassType) {
+      if (isSpreadAssignment(lValue) && lType != null && lType instanceof PsiClassType) {
         final PsiClassType pct = (PsiClassType)lType;
         final PsiClass clazz = pct.resolve();
         if (clazz != null && CommonClassNames.JAVA_UTIL_LIST.equals(clazz.getQualifiedName())) {
@@ -178,20 +181,5 @@
       }
     }
 
-    private static boolean isListAssignment(GrExpression lValue) {
-      if (lValue instanceof GrReferenceExpression) {
-        GrReferenceExpression expression = (GrReferenceExpression)lValue;
-        final PsiElement dot = expression.getDotToken();
-        //noinspection ConstantConditions
-        if (dot != null && dot.getNode().getElementType() == GroovyTokenTypes.mSPREAD_DOT) {
-          return true;
-        }
-        else {
-          final GrExpression qual = expression.getQualifierExpression();
-          if (qual != null) return isListAssignment(qual);
-        }
-      }
-      return false;
-    }
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/ParameterCastFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/ParameterCastFix.java
index 1e11751..4ee984e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/ParameterCastFix.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/assignment/ParameterCastFix.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,13 +31,13 @@
  * @author Max Medvedev
  */
 public class ParameterCastFix extends GroovyFix {
-  private final int myParam;
+  private final GrExpression myArgument;
   private final PsiType myType;
   private String myName;
 
-  public ParameterCastFix(int param, PsiType type) {
-    myParam = param;
-    myType = type;
+  public ParameterCastFix(int param, @NotNull PsiType type, @NotNull GrExpression argument) {
+    myArgument = argument;
+    myType = PsiImplUtil.normalizeWildcardTypeByPosition(type, argument);
 
     StringBuilder builder = new StringBuilder();
     builder.append("Cast ");
@@ -57,7 +57,7 @@
         builder.append("th");
         break;
     }
-    builder.append(" parameter to ").append(type.getCanonicalText());
+    builder.append(" parameter to ").append(myType.getPresentableText());
 
 
     myName = builder.toString();
@@ -69,12 +69,7 @@
     final GrArgumentList list = element instanceof GrArgumentList ? (GrArgumentList)element :PsiUtil.getArgumentsList(element);
     if (list == null) return;
 
-    final GrExpression[] arguments = list.getExpressionArguments();
-
-    final int p = PsiImplUtil.hasNamedArguments(list) ? myParam - 1 : myParam;
-    if (arguments.length <= p) return;
-
-    GrCastFix.doCast(project, myType, arguments[p]);
+    GrCastFix.doCast(project, myType, myArgument);
   }
 
   @NotNull
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GrModifierFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GrModifierFix.java
index 28b8f54..15cf050 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GrModifierFix.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GrModifierFix.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,9 +17,8 @@
 
 import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiMember;
-import com.intellij.psi.PsiModifierList;
+import com.intellij.psi.*;
+import com.intellij.util.Function;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.GroovyBundle;
@@ -30,40 +29,44 @@
  * @author Max Medvedev
  */
 public class GrModifierFix extends GroovyFix {
-  @NotNull private final PsiModifierList myModifierList;
+  public static final Function<ProblemDescriptor, PsiModifierList> MODIFIER_LIST = new Function<ProblemDescriptor, PsiModifierList>() {
+    @Override
+    public PsiModifierList fun(ProblemDescriptor descriptor) {
+      final PsiElement element = descriptor.getPsiElement();
+      assert element instanceof PsiImportList : element;
+      return (PsiModifierList)element;
+    }
+  };
+
+  public static final Function<ProblemDescriptor, PsiModifierList> MODIFIER_LIST_OWNER = new Function<ProblemDescriptor, PsiModifierList>() {
+    @Override
+    public PsiModifierList fun(ProblemDescriptor descriptor) {
+      final PsiElement element = descriptor.getPsiElement();
+      assert element instanceof PsiModifierListOwner : element;
+      return ((PsiModifierListOwner)element).getModifierList();
+    }
+  };
+
+
   private final String myModifier;
   private final String myText;
   private final boolean myDoSet;
+  private final Function<ProblemDescriptor, PsiModifierList> myModifierListProvider;
 
   public GrModifierFix(@NotNull PsiMember member,
-                       @NotNull PsiModifierList modifierList,
                        @GrModifier.GrModifierConstant String modifier,
                        boolean showContainingClass,
-                       boolean doSet) {
-    myModifierList = modifierList;
+                       boolean doSet,
+                       Function<ProblemDescriptor, PsiModifierList> modifierListProvider) {
     myModifier = modifier;
     myDoSet = doSet;
+    myModifierListProvider = modifierListProvider;
 
     myText = initText(member, showContainingClass, myModifier, myDoSet);
   }
 
   public static String initText(final PsiMember member, final boolean showContainingClass, final String modifier, final boolean doSet) {
-    String name;
-    if (showContainingClass) {
-      final PsiClass containingClass = member.getContainingClass();
-      String containingClassName;
-      if (containingClass != null) {
-        containingClassName = containingClass.getName() + ".";
-      }
-      else {
-        containingClassName = "";
-      }
-
-      name = containingClassName + member.getName();
-    }
-    else {
-      name = member.getName();
-    }
+    String name = getMemberName(member, showContainingClass);
     String modifierText = toPresentableText(modifier);
 
     if (doSet) {
@@ -74,6 +77,17 @@
     }
   }
 
+  private static String getMemberName(PsiMember member, boolean showContainingClass) {
+    if (showContainingClass) {
+      final PsiClass containingClass = member.getContainingClass();
+      String containingClassName = containingClass != null ? containingClass.getName() + "." : "";
+      return containingClassName + member.getName();
+    }
+    else {
+      return member.getName();
+    }
+  }
+
   public static String toPresentableText(String modifier) {
     return GroovyBundle.message(modifier + ".visibility.presentation");
   }
@@ -91,7 +105,11 @@
 
   @Override
   protected void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
-    assert myModifierList.isValid();
-    myModifierList.setModifierProperty(myModifier, myDoSet);
+    final PsiModifierList modifierList = getModifierList(descriptor);
+    modifierList.setModifierProperty(myModifier, myDoSet);
+  }
+
+  private PsiModifierList getModifierList(ProblemDescriptor descriptor) {
+    return myModifierListProvider.fun(descriptor);
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyAccessibilityInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyAccessibilityInspection.java
index 634d32e..5532217 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyAccessibilityInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyAccessibilityInspection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
  */
 package org.jetbrains.plugins.groovy.codeInspection.bugs;
 
+import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
@@ -22,6 +23,7 @@
 import com.intellij.psi.util.PsiFormatUtilBase;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.ArrayUtil;
+import com.intellij.util.Function;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NotNull;
@@ -135,7 +137,16 @@
         String modifier = modifiers[i];
         modifierListCopy.setModifierProperty(modifier, true);
         if (facade.getResolveHelper().isAccessible(refElement, modifierListCopy, location, accessObjectClass, null)) {
-          fixes.add(new GrModifierFix(refElement, refElement.getModifierList(), modifier, true, true));
+          fixes.add(new GrModifierFix(refElement, modifier, true, true, new Function<ProblemDescriptor, PsiModifierList>() {
+            @Override
+            public PsiModifierList fun(ProblemDescriptor descriptor) {
+              final PsiElement element = descriptor.getPsiElement();
+              assert element instanceof GrReferenceElement : element;
+              final PsiElement resolved = ((GrReferenceElement)element).resolve();
+              assert resolved instanceof PsiModifierListOwner : resolved;
+              return ((PsiModifierListOwner)resolved).getModifierList();
+            }
+          }));
         }
       }
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/GrReassignedInClosureLocalVarInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/GrReassignedInClosureLocalVarInspection.java
index 54579db..82a688f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/GrReassignedInClosureLocalVarInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/GrReassignedInClosureLocalVarInspection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,16 +21,12 @@
 import com.intellij.psi.PsiType;
 import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.codeInsight.GrReassignedLocalVarsChecker;
 import org.jetbrains.plugins.groovy.codeInspection.BaseInspection;
 import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor;
 import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
-import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner;
 import org.jetbrains.plugins.groovy.lang.psi.GrNamedElement;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
 
@@ -58,8 +54,7 @@
     return true;
   }
 
-
-
+  @NotNull
   @Override
   protected BaseInspectionVisitor buildVisitor() {
     return new BaseInspectionVisitor() {
@@ -71,38 +66,18 @@
         final PsiElement resolved = referenceExpression.resolve();
         if (!GroovyRefactoringUtil.isLocalVariable(resolved)) return;
 
-        final PsiType checked = GrReassignedLocalVarsChecker.checkReassignedVar(referenceExpression, false);
-        if (checked == null) return;
-
-        final GrControlFlowOwner varFlowOwner = ControlFlowUtils.findControlFlowOwner(resolved);
-        final GrControlFlowOwner refFlorOwner = ControlFlowUtils.findControlFlowOwner(referenceExpression);
-        if (isOtherScopeAndType(referenceExpression, checked, varFlowOwner, refFlorOwner)) {
-          String flowDescription = getFlowDescription(refFlorOwner);
-          final String message = message("local.var.0.is.reassigned.in.closure", ((GrNamedElement)resolved).getName(), flowDescription);
+        if (isOtherTypeOrDifferent(referenceExpression, (GrVariable)resolved) ) {
+          final String message = message("local.var.0.is.reassigned", ((GrNamedElement)resolved).getName());
           registerError(referenceExpression, message, LocalQuickFix.EMPTY_ARRAY, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
         }
       }
     };
   }
 
-  private static boolean isOtherScopeAndType(GrReferenceExpression referenceExpression,
-                                             PsiType checked,
-                                             GrControlFlowOwner varFlowOwner,
-                                             GrControlFlowOwner refFlorOwner) {
-    return varFlowOwner != refFlorOwner && !TypesUtil.isAssignable(referenceExpression.getType(), checked, referenceExpression);
-  }
+  private static boolean isOtherTypeOrDifferent(@NotNull GrReferenceExpression referenceExpression, GrVariable resolved) {
+    if (ControlFlowUtils.findControlFlowOwner(referenceExpression) != ControlFlowUtils.findControlFlowOwner(resolved)) return true;
 
-  private static String getFlowDescription(GrControlFlowOwner refFlorOwner) {
-    String flowDescription;
-    if (refFlorOwner instanceof GrClosableBlock) {
-      flowDescription = message("closure");
-    }
-    else if (refFlorOwner instanceof GrAnonymousClassDefinition) {
-      flowDescription = message("anonymous.class");
-    }
-    else {
-      flowDescription = message("other.scope");
-    }
-    return flowDescription;
+    final PsiType currentType = referenceExpression.getType();
+    return currentType != null && currentType != PsiType.NULL && !ControlFlowUtils.findAccess(resolved, referenceExpression, false, true).isEmpty();
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/UnnecessaryQualifiedReferenceInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/UnnecessaryQualifiedReferenceInspection.java
index 49ec3ce..b175cbc 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/UnnecessaryQualifiedReferenceInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/confusing/UnnecessaryQualifiedReferenceInspection.java
@@ -18,10 +18,7 @@
 import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiMember;
-import com.intellij.psi.PsiModifier;
+import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.IncorrectOperationException;
@@ -143,6 +140,8 @@
   }
 
   private static boolean canBeSimplified(PsiElement element) {
+    if (PsiTreeUtil.getParentOfType(element, PsiComment.class) != null) return false;
+
     if (element instanceof GrCodeReferenceElement) {
       if (PsiTreeUtil.getParentOfType(element, GrImportStatement.class, GrPackageDefinition.class) != null) return false;
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/GroovyUnnecessaryContinueInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/GroovyUnnecessaryContinueInspection.java
index 2eed53a..20b43d3 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/GroovyUnnecessaryContinueInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/GroovyUnnecessaryContinueInspection.java
@@ -94,23 +94,14 @@
         return;
       }
 
-      if (!(continuedStatement instanceof GrLoopStatement)) {
-        return;
-      }
-      final GrCondition body = ((GrLoopStatement) continuedStatement).getBody();
-      if (body == null) {
-        return;
-      }
-      if (body instanceof GrBlockStatement) {
-        if (ControlFlowUtils.blockCompletesWithStatement((GrBlockStatement) body,
-            continueStatement)) {
-          registerStatementError(continueStatement);
-        }
-      } else if (body instanceof GrStatement) {
-        if (ControlFlowUtils.statementCompletesWithStatement((GrStatement) body,
-            continueStatement)) {
-          registerStatementError(continueStatement);
-        }
+      if (!(continuedStatement instanceof GrLoopStatement)) return;
+      final GrStatement body = ((GrLoopStatement)continuedStatement).getBody();
+      if (body == null) return;
+
+
+      if (body instanceof GrBlockStatement && ControlFlowUtils.blockCompletesWithStatement((GrBlockStatement)body, continueStatement) ||
+          !(body instanceof GrBlockStatement) && ControlFlowUtils.statementCompletesWithStatement(body, continueStatement)){
+        registerStatementError(continueStatement);
       }
     }
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/finalVar/GrFinalVariableAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/finalVar/GrFinalVariableAccessInspection.java
index c86790d..2b2025d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/finalVar/GrFinalVariableAccessInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/control/finalVar/GrFinalVariableAccessInspection.java
@@ -43,6 +43,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.ReadWriteVariableInstruction;
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.ControlFlowBuilder;
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.GrFieldControlFlowPolicy;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 
 import java.util.*;
@@ -310,6 +311,8 @@
     if (field instanceof GrEnumConstant) return true;
     if (field.getInitializerGroovy() != null) return true;
 
+    if (isImmutableField(field)) return true;
+
     final boolean isStatic = field.hasModifierProperty(PsiModifier.STATIC);
 
     final GrTypeDefinition aClass = ((GrTypeDefinition)field.getContainingClass());
@@ -367,6 +370,19 @@
     return true;
   }
 
+  private static boolean isImmutableField(@NotNull GrField field) {
+    GrModifierList fieldModifierList = field.getModifierList();
+    if (fieldModifierList != null && fieldModifierList.hasExplicitVisibilityModifiers()) return false;
+
+    PsiClass aClass = field.getContainingClass();
+    if (aClass == null) return false;
+
+    PsiModifierList modifierList = aClass.getModifierList();
+    if (modifierList == null) return false;
+
+    return PsiImplUtil.hasImmutableAnnotation(modifierList);
+  }
+
   @NotNull
   private static List<GrMethod> getChainedConstructors(@NotNull GrMethod constructor) {
     final HashSet<Object> visited = ContainerUtil.newHashSet();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/declaration/GrMethodMayBeStaticInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/declaration/GrMethodMayBeStaticInspection.java
index 3c912d7..386c8301 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/declaration/GrMethodMayBeStaticInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/declaration/GrMethodMayBeStaticInspection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,12 +17,14 @@
 
 import com.intellij.codeInspection.InspectionManager;
 import com.intellij.codeInspection.LocalQuickFix;
+import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.codeInspection.ProblemHighlightType;
 import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
 import com.intellij.openapi.util.Condition;
 import com.intellij.psi.*;
 import com.intellij.psi.search.searches.OverridingMethodsSearch;
 import com.intellij.psi.search.searches.SuperMethodsSearch;
+import com.intellij.util.Function;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.codeInspection.BaseInspection;
 import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor;
@@ -63,8 +65,16 @@
       @Override
       public void visitMethod(GrMethod method) {
         if (checkMethod(method)) {
-          LocalQuickFix[] fixes = new LocalQuickFix[]{new GrModifierFix(method, method.getModifierList(), PsiModifier.STATIC, false, true)};
-          registerError(method.getNameIdentifierGroovy(), GroovyInspectionBundle.message("method.may.be.static"), fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
+          final GrModifierFix modifierFix = new GrModifierFix(method, PsiModifier.STATIC, false, true, new Function<ProblemDescriptor, PsiModifierList>() {
+            @Override
+            public PsiModifierList fun(ProblemDescriptor descriptor) {
+              final PsiElement element = descriptor.getPsiElement();
+              final PsiElement parent = element.getParent();
+              assert parent instanceof GrMethod : "element: " + element + ", parent:" + parent;
+              return ((GrMethod)parent).getModifierList();
+            }
+          });
+          registerError(method.getNameIdentifierGroovy(), GroovyInspectionBundle.message("method.may.be.static"), new LocalQuickFix[]{modifierFix}, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
         }
       }
     };
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/exception/GroovyEmptyCatchBlockInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/exception/GroovyEmptyCatchBlockInspection.java
index 231bc90..50ff0bc 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/exception/GroovyEmptyCatchBlockInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/exception/GroovyEmptyCatchBlockInspection.java
@@ -18,16 +18,26 @@
 import com.intellij.codeInsight.daemon.impl.quickfix.RenameElementFix;
 import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemHighlightType;
+import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
+import com.intellij.psi.PsiComment;
+import com.intellij.psi.PsiElement;
 import org.jetbrains.annotations.Nls;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.codeInspection.BaseInspection;
 import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor;
+import org.jetbrains.plugins.groovy.codeInspection.GroovyInspectionBundle;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrCatchClause;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
+
+import javax.swing.*;
 
 public class GroovyEmptyCatchBlockInspection extends BaseInspection {
+  public boolean myIgnore = true;
+  public boolean myCountCommentsAsContent = true;
 
   @Nls
   @NotNull
@@ -41,11 +51,21 @@
     return "Empty 'catch' block";
   }
 
+  @NotNull
   public BaseInspectionVisitor buildVisitor() {
     return new Visitor();
   }
 
-  private static class Visitor extends BaseInspectionVisitor {
+  @Nullable
+  @Override
+  public JComponent createOptionsPanel() {
+    MultipleCheckboxOptionsPanel panel = new MultipleCheckboxOptionsPanel(this);
+    panel.addCheckbox(GroovyInspectionBundle.message("comments.count.as.content"), "myCountCommentsAsContent");
+    panel.addCheckbox(GroovyInspectionBundle.message("ignore.when.catch.parameter.is.named.ignore.or.ignored"), "myIgnore");
+    return panel;
+  }
+
+  private class Visitor extends BaseInspectionVisitor {
 
     public void visitCatchClause(GrCatchClause catchClause) {
       super.visitCatchClause(catchClause);
@@ -56,15 +76,29 @@
 
       final GrParameter parameter = catchClause.getParameter();
       if (parameter == null) return;
-      if (GrExceptionUtil.ignore(parameter)) return;
+      if (myIgnore && GrExceptionUtil.ignore(parameter)) return;
 
-      final LocalQuickFix[] fixes = {new RenameElementFix(parameter, "ignored")};
+      final LocalQuickFix[] fixes = myIgnore
+                                    ? new RenameElementFix[]{new RenameElementFix(parameter, "ignored")}
+                                    : LocalQuickFix.EMPTY_ARRAY;
       registerError(catchClause.getFirstChild(), "Empty '#ref' block #loc", fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
     }
 
-    private static boolean isEmpty(@NotNull GrOpenBlock body) {
+    private boolean isEmpty(@NotNull GrOpenBlock body) {
       final GrStatement[] statements = body.getStatements();
-      return statements.length == 0;
+      if (statements.length != 0) return false;
+
+      if (myCountCommentsAsContent) {
+        final PsiElement brace = body.getLBrace();
+        if (brace != null) {
+          final PsiElement next = PsiUtil.skipWhitespaces(brace.getNextSibling(), true);
+          if (next instanceof PsiComment) {
+            return false;
+          }
+        }
+      }
+
+      return true;
     }
   }
 }
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/local/GroovyPostHighlightingPass.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/local/GroovyPostHighlightingPass.java
index 107b593..fc28259d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/local/GroovyPostHighlightingPass.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/local/GroovyPostHighlightingPass.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
 import com.intellij.codeInsight.CodeInsightSettings;
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
-import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerEx;
 import com.intellij.codeInsight.daemon.HighlightDisplayKey;
 import com.intellij.codeInsight.daemon.impl.*;
 import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
@@ -30,16 +29,22 @@
 import com.intellij.codeInspection.InspectionProfile;
 import com.intellij.codeInspection.ProblemHighlightType;
 import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
+import com.intellij.diagnostic.AttachmentFactory;
+import com.intellij.diagnostic.LogMessageEx;
 import com.intellij.lang.annotation.Annotation;
 import com.intellij.lang.annotation.AnnotationHolder;
 import com.intellij.lang.annotation.AnnotationSession;
 import com.intellij.lang.annotation.HighlightSeverity;
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.command.CommandProcessor;
+import com.intellij.openapi.command.undo.UndoManager;
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.ProjectFileIndex;
 import com.intellij.openapi.roots.ProjectRootManager;
+import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -48,6 +53,7 @@
 import com.intellij.psi.impl.PsiClassImplUtil;
 import com.intellij.psi.search.searches.OverridingMethodsSearch;
 import com.intellij.psi.search.searches.SuperMethodsSearch;
+import com.intellij.util.DocumentUtil;
 import com.intellij.util.Processor;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
@@ -75,6 +81,8 @@
  * @author ilyas
  */
 public class GroovyPostHighlightingPass extends TextEditorHighlightingPass {
+  private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.codeInspection.local.GroovyPostHighlightingPass");
+
   private final GroovyFile myFile;
   private final Editor myEditor;
   private volatile Set<GrImportStatement> myUnusedImports;
@@ -133,19 +141,21 @@
 
         if (deadCodeEnabled &&
             element instanceof GrNamedElement && element instanceof PsiModifierListOwner &&
-            !PostHighlightingPass.isImplicitUsage((PsiModifierListOwner)element, progress) &&
+            !PostHighlightingPass.isImplicitUsage(element.getProject(), (PsiModifierListOwner)element, progress) &&
             !GroovySuppressableInspectionTool.isElementToolSuppressedIn(element, GroovyUnusedDeclarationInspection.SHORT_NAME)) {
           PsiElement nameId = ((GrNamedElement)element).getNameIdentifierGroovy();
           if (nameId.getNode().getElementType() == GroovyTokenTypes.mIDENT) {
             String name = ((GrNamedElement)element).getName();
-            if (element instanceof GrTypeDefinition && !PostHighlightingPass.isClassUsed((GrTypeDefinition)element, progress, usageHelper)) {
+            if (element instanceof GrTypeDefinition && !PostHighlightingPass.isClassUsed(myProject,
+                                                                                         element.getContainingFile(), (GrTypeDefinition)element, progress, usageHelper
+            )) {
               HighlightInfo highlightInfo = PostHighlightingPass.createUnusedSymbolInfo(nameId, "Class " + name + " is unused", HighlightInfoType.UNUSED_SYMBOL);
               QuickFixAction.registerQuickFixAction(highlightInfo, new SafeDeleteFix(element), unusedDefKey);
               ContainerUtil.addIfNotNull(unusedDeclarations, highlightInfo);
             }
             else if (element instanceof GrMethod) {
               GrMethod method = (GrMethod)element;
-              if (!PostHighlightingPass.isMethodReferenced(method, progress, usageHelper)) {
+              if (!PostHighlightingPass.isMethodReferenced(method.getProject(), method.getContainingFile(), method, progress, usageHelper)) {
                 String message = (method.isConstructor() ? "Constructor" : "Method") + " " + name + " is unused";
                 HighlightInfo highlightInfo = PostHighlightingPass.createUnusedSymbolInfo(nameId, message, HighlightInfoType.UNUSED_SYMBOL);
                 QuickFixAction.registerQuickFixAction(highlightInfo, new SafeDeleteFix(method), unusedDefKey);
@@ -222,7 +232,7 @@
   }
 
   private static boolean isFieldUnused(GrField field, ProgressIndicator progress, GlobalUsageHelper usageHelper) {
-    if (!PostHighlightingPass.isFieldUnused(field, progress, usageHelper)) return false;
+    if (!PostHighlightingPass.isFieldUnused(field.getProject(), field.getContainingFile(), field, progress, usageHelper)) return false;
     final GrAccessorMethod[] getters = field.getGetters();
     final GrAccessorMethod setter = field.getSetter();
 
@@ -300,7 +310,7 @@
 
     final Runnable optimize = myOptimizeRunnable;
     if (optimize != null && timeToOptimizeImports()) {
-      PostHighlightingPass.invokeOnTheFlyImportOptimizer(new Runnable() {
+      invokeOnTheFlyImportOptimizer(new Runnable() {
         @Override
         public void run() {
           optimize.run();
@@ -309,6 +319,34 @@
     }
   }
 
+  public static void invokeOnTheFlyImportOptimizer(@NotNull final Runnable runnable,
+                                                   @NotNull final PsiFile file,
+                                                   @NotNull final Editor editor) {
+    final long stamp = editor.getDocument().getModificationStamp();
+    ApplicationManager.getApplication().invokeLater(new Runnable() {
+      @Override
+      public void run() {
+        if (file.getProject().isDisposed() || editor.isDisposed() || editor.getDocument().getModificationStamp() != stamp) return;
+        //no need to optimize imports on the fly during undo/redo
+        final UndoManager undoManager = UndoManager.getInstance(editor.getProject());
+        if (undoManager.isUndoInProgress() || undoManager.isRedoInProgress()) return;
+        PsiDocumentManager.getInstance(file.getProject()).commitAllDocuments();
+        String beforeText = file.getText();
+        final long oldStamp = editor.getDocument().getModificationStamp();
+        DocumentUtil.writeInRunUndoTransparentAction(runnable);
+        if (oldStamp != editor.getDocument().getModificationStamp()) {
+          String afterText = file.getText();
+          if (Comparing.strEqual(beforeText, afterText)) {
+            LOG.error(
+              LogMessageEx.createEvent("Import optimizer  hasn't optimized any imports", file.getViewProvider().getVirtualFile().getPath(),
+                                       AttachmentFactory.createAttachment(file.getViewProvider().getVirtualFile())));
+          }
+        }
+      }
+    });
+  }
+
+
   private static TextRange calculateRangeToUse(GrImportStatement unusedImport) {
     final TextRange range = unusedImport.getTextRange();
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/noReturnMethod/MissingReturnInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/noReturnMethod/MissingReturnInspection.java
index fc23c01..31a9740 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/noReturnMethod/MissingReturnInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/noReturnMethod/MissingReturnInspection.java
@@ -16,6 +16,7 @@
 package org.jetbrains.plugins.groovy.codeInspection.noReturnMethod;
 
 import com.intellij.codeInspection.ProblemsHolder;
+import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.*;
@@ -29,16 +30,26 @@
 import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementVisitor;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction;
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.MaybeReturnInstruction;
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.impl.ThrowingInstruction;
 import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.GroovyExpectedTypesProvider;
+import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * @author ven
@@ -67,7 +78,7 @@
 
     public static ReturnStatus getReturnStatus(PsiElement subject) {
       if (subject instanceof GrClosableBlock) {
-        final PsiType inferredReturnType = GroovyExpectedTypesProvider.getExpectedClosureReturnType((GrClosableBlock)subject);
+        final PsiType inferredReturnType = getExpectedClosureReturnType((GrClosableBlock)subject);
         if (inferredReturnType instanceof PsiClassType) {
           PsiClass resolved = ((PsiClassType)inferredReturnType).resolve();
           if (resolved != null && !(resolved instanceof PsiTypeParameter)) return mustReturnValue;
@@ -83,6 +94,55 @@
     }
   }
 
+  @Nullable
+  public static PsiType getExpectedClosureReturnType(GrClosableBlock closure) {
+    List<PsiType> expectedReturnTypes = new ArrayList<PsiType>();
+
+    PsiElement parent = closure.getParent();
+    if (parent instanceof GrArgumentList && parent.getParent() instanceof GrMethodCall || parent instanceof GrMethodCall) {
+      GrMethodCall call = (GrMethodCall)(parent instanceof GrArgumentList ? parent.getParent() : parent);
+
+      GroovyResolveResult[] variants = call.getCallVariants(null);
+
+      for (GroovyResolveResult variant : variants) {
+        Map<GrExpression,Pair<PsiParameter,PsiType>> map =
+          GrClosureSignatureUtil.mapArgumentsToParameters(variant, closure, true, true, call.getNamedArguments(), call.getExpressionArguments(), call.getClosureArguments());
+
+        if (map != null) {
+          Pair<PsiParameter, PsiType> pair = map.get(closure);
+          if (pair == null) continue;
+
+          PsiParameter parameter = pair.getFirst();
+
+          PsiType type = parameter.getType();
+          if (TypesUtil.isPsiClassTypeToClosure(type)) {
+            PsiType[] parameters = ((PsiClassType)type).getParameters();
+            if (parameters.length == 1) {
+              expectedReturnTypes.add(parameters[0]);
+            }
+          }
+        }
+      }
+    }
+    else {
+      final Set<PsiType> expectedTypes = GroovyExpectedTypesProvider.getDefaultExpectedTypes(closure);
+
+      for (PsiType expectedType : expectedTypes) {
+        if (TypesUtil.isPsiClassTypeToClosure(expectedType)) {
+          PsiType[] parameters = ((PsiClassType)expectedType).getParameters();
+          if (parameters.length == 1) {
+            expectedReturnTypes.add(parameters[0]);
+          }
+        }
+      }
+    }
+
+    for (PsiType type : expectedReturnTypes) {
+      if (PsiType.VOID.equals(type)) return PsiType.VOID;
+    }
+    return TypesUtil.getLeastUpperBoundNullable(expectedReturnTypes, closure.getManager());
+  }
+
   @NotNull
   public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder problemsHolder, boolean onTheFly) {
     return new GroovyPsiElementVisitor(new GroovyElementVisitor() {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unassignedVariable/UnassignedVariableAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unassignedVariable/UnassignedVariableAccessInspection.java
index 511c19d..d84e99b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unassignedVariable/UnassignedVariableAccessInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unassignedVariable/UnassignedVariableAccessInspection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrWhileStatement;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrTraditionalForClause;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
@@ -87,7 +88,7 @@
     ReadWriteVariableInstruction[] reads = ControlFlowBuilderUtil.getReadsWithoutPriorWrites(flow, true);
     for (ReadWriteVariableInstruction read : reads) {
       PsiElement element = read.getElement();
-      if (element instanceof GroovyPsiElement) {
+      if (element instanceof GroovyPsiElement && !(element instanceof GrClosableBlock)) {
         String name = read.getVariableName();
         GroovyPsiElement property = ResolveUtil.resolveProperty((GroovyPsiElement)element, name);
         if (property != null &&
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java
index 3bc8412..7259fa7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -81,6 +81,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrReferenceResolveUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
+import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
 import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
@@ -224,6 +225,7 @@
           final PsiClass outerClass = clazz.getContainingClass();
           if (com.intellij.psi.util.PsiUtil.isInnerClass(clazz) &&
               outerClass != null &&
+              newExpression.getArgumentList() != null &&
               !PsiUtil.hasEnclosingInstanceInScope(outerClass, newExpression, true) &&
               !hasEnclosingInstanceInArgList(newExpression.getArgumentList(), outerClass)) {
             String qname = clazz.getQualifiedName();
@@ -237,7 +239,7 @@
     return null;
   }
 
-  private static boolean hasEnclosingInstanceInArgList(GrArgumentList list, PsiClass enclosingClass) {
+  private static boolean hasEnclosingInstanceInArgList(@NotNull GrArgumentList list, @NotNull PsiClass enclosingClass) {
     if (PsiImplUtil.hasNamedArguments(list)) return false;
 
     GrExpression[] args = list.getExpressionArguments();
@@ -546,24 +548,26 @@
                                              HighlightInfo info,
                                              boolean compileStatic,
                                              final HighlightDisplayKey key) {
-    PsiClass targetClass = QuickfixUtil.findTargetClass(refExpr, compileStatic);
+   PsiClass targetClass = QuickfixUtil.findTargetClass(refExpr, compileStatic);
     if (targetClass == null) return;
 
-    if (!compileStatic) {
-      addDynamicAnnotation(info, refExpr, key);
-    }
+    if (!(targetClass instanceof SyntheticElement) || (targetClass instanceof GroovyScriptClass)) {
+      if (!compileStatic) {
+        addDynamicAnnotation(info, refExpr, key);
+      }
 
-    QuickFixAction.registerQuickFixAction(info, new CreateFieldFromUsageFix(refExpr), key);
+      QuickFixAction.registerQuickFixAction(info, new CreateFieldFromUsageFix(refExpr), key);
 
-    if (PsiUtil.isAccessedForReading(refExpr)) {
-      QuickFixAction.registerQuickFixAction(info, new CreateGetterFromUsageFix(refExpr, targetClass), key);
-    }
-    if (PsiUtil.isLValue(refExpr)) {
-      QuickFixAction.registerQuickFixAction(info, new CreateSetterFromUsageFix(refExpr), key);
-    }
+      if (PsiUtil.isAccessedForReading(refExpr)) {
+        QuickFixAction.registerQuickFixAction(info, new CreateGetterFromUsageFix(refExpr, targetClass), key);
+      }
+      if (PsiUtil.isLValue(refExpr)) {
+        QuickFixAction.registerQuickFixAction(info, new CreateSetterFromUsageFix(refExpr), key);
+      }
 
-    if (refExpr.getParent() instanceof GrCall && refExpr.getParent() instanceof GrExpression) {
-      QuickFixAction.registerQuickFixAction(info, new CreateMethodFromUsageFix(refExpr), key);
+      if (refExpr.getParent() instanceof GrCall && refExpr.getParent() instanceof GrExpression) {
+        QuickFixAction.registerQuickFixAction(info, new CreateMethodFromUsageFix(refExpr), key);
+      }
     }
 
     if (!refExpr.isQualified()) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unusedDef/UnusedDefInspection.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unusedDef/UnusedDefInspection.java
index 3cf0b38..0386ab5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unusedDef/UnusedDefInspection.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/unusedDef/UnusedDefInspection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiReference;
-import com.intellij.psi.search.LocalSearchScope;
 import com.intellij.psi.search.searches.ReferencesSearch;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.util.Processor;
@@ -208,7 +207,7 @@
         }
       }
 
-      return ReferencesSearch.search(var, new LocalSearchScope(scope)).forEach(new Processor<PsiReference>() {
+      return ReferencesSearch.search(var, var.getUseScope()).forEach(new Processor<PsiReference>() {
         public boolean process(PsiReference ref) {
           return ControlFlowUtils.findControlFlowOwner(ref.getElement()) == scope;
         }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/ControlFlowUtils.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/ControlFlowUtils.java
index b1a497d..999d2bd 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/ControlFlowUtils.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/utils/ControlFlowUtils.java
@@ -23,6 +23,7 @@
 import com.intellij.psi.util.CachedValueProvider;
 import com.intellij.psi.util.CachedValuesManager;
 import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.ArrayUtil;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.HashSet;
 import org.jetbrains.annotations.NotNull;
@@ -43,6 +44,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrUnaryExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
+import org.jetbrains.plugins.groovy.lang.psi.api.util.GrStatementOwner;
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.AfterCallInstruction;
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction;
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.ReadWriteVariableInstruction;
@@ -117,21 +119,18 @@
     if (statementIsBreakTarget(switchStatement)) {
       return true;
     }
+
     final GrCaseSection[] caseClauses = switchStatement.getCaseSections();
 
-    if (caseClauses.length == 0) {
-      return true;
-    }
-    boolean hasDefaultCase = false;
-    for (GrCaseSection clause : caseClauses) {
-      if (clause.isDefault()) {
-        hasDefaultCase = true;
+    if (ContainerUtil.find(caseClauses, new Condition<GrCaseSection>() {
+      @Override
+      public boolean value(GrCaseSection section) {
+        return section.isDefault();
       }
+    }) == null) {
+      return true;
     }
 
-    if (!hasDefaultCase) {
-      return true;
-    }
     final GrCaseSection lastClause = caseClauses[caseClauses.length - 1];
     final GrStatement[] statements = lastClause.getStatements();
     if (statements.length == 0) {
@@ -296,25 +295,44 @@
       if (statementToCheck == null) {
         return false;
       }
-      final GrStatement container = getContainingStatement(statementToCheck);
+
+      final PsiElement container = statementToCheck.getParent();
       if (container == null) {
         return false;
       }
-      if (isLoop(container)) {
+
+      if (container instanceof GrLoopStatement) {
         return false;
       }
-      if (container instanceof GrBlockStatement) {
-        if (!statementIsLastInBlock((GrBlockStatement)container, statementToCheck)) {
+      else if (container instanceof GrCaseSection) {
+        final GrCaseSection caseSection = (GrCaseSection)container;
+
+        if (!statementIsLastInBlock(caseSection, statementToCheck)) return false;
+
+        final PsiElement parent = container.getParent();
+        assert parent instanceof GrSwitchStatement;
+        final GrSwitchStatement switchStatement = (GrSwitchStatement)parent;
+
+        final GrCaseSection[] sections = switchStatement.getCaseSections();
+        if (ArrayUtil.getLastElement(sections) != caseSection) {
           return false;
         }
-        if (container.equals(body)) {
-          return true;
+      }
+      else if (container instanceof GrOpenBlock) {
+        final GrOpenBlock block = (GrOpenBlock)container;
+
+        if (!statementIsLastInBlock(block, statementToCheck)) return false;
+        final PsiElement parent = block.getParent();
+        if (parent instanceof GrBlockStatement) {
+          final GrBlockStatement blockStatement = (GrBlockStatement)parent;
+          if (blockStatement == body) return true;
         }
-        statementToCheck = PsiTreeUtil.getParentOfType(container, GrStatement.class);
       }
-      else {
-        statementToCheck = container;
+      else if (container instanceof GrClosableBlock) {
+        return false;
       }
+
+      statementToCheck = getContainingStatement(statementToCheck);
     }
   }
 
@@ -338,7 +356,7 @@
       if (container instanceof GrCodeBlock) {
         if (elementToCheck instanceof GrStatement) {
           final GrCodeBlock codeBlock = (GrCodeBlock)container;
-          if (!statementIsLastInCodeBlock(codeBlock, (GrStatement)elementToCheck)) {
+          if (!statementIsLastInBlock(codeBlock, (GrStatement)elementToCheck)) {
             return false;
           }
         }
@@ -372,7 +390,7 @@
         return false;
       }
       if (container instanceof GrCodeBlock) {
-        if (!statementIsLastInCodeBlock((GrCodeBlock)container, (GrStatement)statementToCheck)) {
+        if (!statementIsLastInBlock((GrCodeBlock)container, (GrStatement)statementToCheck)) {
           return false;
         }
         if (container.equals(body)) {
@@ -386,7 +404,7 @@
     }
   }
 
-  private static boolean isLoop(@NotNull GroovyPsiElement element) {
+  private static boolean isLoop(@NotNull PsiElement element) {
     return element instanceof GrLoopStatement;
   }
 
@@ -401,20 +419,10 @@
   }
 
   private static boolean statementIsLastInBlock(@NotNull GrBlockStatement block, @NotNull GrStatement statement) {
-    final GrStatement[] statements = block.getBlock().getStatements();
-    for (int i = statements.length - 1; i >= 0; i--) {
-      final GrStatement childStatement = statements[i];
-      if (statement.equals(childStatement)) {
-        return true;
-      }
-      if (!(childStatement instanceof GrReturnStatement)) {
-        return false;
-      }
-    }
-    return false;
+    return statementIsLastInBlock(block.getBlock(), statement);
   }
 
-  private static boolean statementIsLastInCodeBlock(@NotNull GrCodeBlock block, @NotNull GrStatement statement) {
+  private static boolean statementIsLastInBlock(@NotNull GrStatementOwner block, @NotNull GrStatement statement) {
     final GrStatement[] statements = block.getStatements();
     for (int i = statements.length - 1; i >= 0; i--) {
       final GrStatement childStatement = statements[i];
@@ -709,15 +717,10 @@
    * @param ahead if true search for next write. if false searches for previous write
    * @return all write instructions leading to (or preceding) the place
    */
-  public static ReadWriteVariableInstruction[] findWriteAccess(GrVariable local, final PsiElement place, boolean ahead) {
-    List<ReadWriteVariableInstruction> res = findAccess(local, place, ahead, true);
-    return res.toArray(new ReadWriteVariableInstruction[res.size()]);
-  }
-
   public static List<ReadWriteVariableInstruction> findAccess(GrVariable local, final PsiElement place, boolean ahead, boolean writeAccessOnly) {
     LOG.assertTrue(!(local instanceof GrField), local.getClass());
 
-    final GrControlFlowOwner owner = findControlFlowOwner(local);
+    final GrControlFlowOwner owner = findControlFlowOwner(place);
     assert owner != null;
 
     final Instruction cur = findInstruction(place, owner.getControlFlow());
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GrReferenceAdjuster.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GrReferenceAdjuster.java
index d61b435..5bdfac0 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GrReferenceAdjuster.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GrReferenceAdjuster.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -63,25 +63,25 @@
   }
 
   @Override
-  public ASTNode process(ASTNode element, boolean addImports, boolean incompleteCode, boolean useFqInJavadoc, boolean useFqInCode) {
+  public ASTNode process(@NotNull ASTNode element, boolean addImports, boolean incompleteCode, boolean useFqInJavadoc, boolean useFqInCode) {
     final TextRange range = element.getTextRange();
     process(element.getPsi(), range.getStartOffset(), range.getEndOffset(), addImports, incompleteCode, useFqInJavadoc, useFqInCode);
     return element;
   }
 
   @Override
-  public ASTNode process(ASTNode element, boolean addImports, boolean incompleteCode, Project project) {
+  public ASTNode process(@NotNull ASTNode element, boolean addImports, boolean incompleteCode, Project project) {
     final GroovyCodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project).getCustomSettings(GroovyCodeStyleSettings.class);
     return process(element, addImports, incompleteCode, settings.USE_FQ_CLASS_NAMES_IN_JAVADOC, settings.USE_FQ_CLASS_NAMES);
   }
 
   @Override
-  public void processRange(ASTNode element, int startOffset, int endOffset, boolean useFqInJavadoc, boolean useFqInCode) {
+  public void processRange(@NotNull ASTNode element, int startOffset, int endOffset, boolean useFqInJavadoc, boolean useFqInCode) {
     process(element.getPsi(), startOffset, endOffset, true, true, useFqInJavadoc, useFqInCode);
   }
 
   @Override
-  public void processRange(ASTNode element, int startOffset, int endOffset, Project project) {
+  public void processRange(@NotNull ASTNode element, int startOffset, int endOffset, Project project) {
     final GroovyCodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project).getCustomSettings(GroovyCodeStyleSettings.class);
     processRange(element, startOffset, endOffset, settings.USE_FQ_CLASS_NAMES_IN_JAVADOC, settings.USE_FQ_CLASS_NAMES);
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyCodeStyleSettings.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyCodeStyleSettings.java
index 1f1f57e..ef1024a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyCodeStyleSettings.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyCodeStyleSettings.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,13 +41,14 @@
   public boolean USE_FLYING_GEESE_BRACES = false;
 
   public boolean SPACE_IN_NAMED_ARGUMENT = true;
-  public boolean ALIGN_MULTILINE_LIST_OR_MAP = false;
+  public boolean ALIGN_MULTILINE_LIST_OR_MAP = true;
   public boolean SPACE_WITHIN_LIST_OR_MAP = false;
-  public boolean ALIGN_NAMED_ARGS_IN_MAP = false;
+  public boolean ALIGN_NAMED_ARGS_IN_MAP = true;
   public boolean SPACE_BEFORE_CLOSURE_LBRACE = true;
   public boolean SPACE_WITHIN_GSTRING_INJECTION_BRACES = false;
   public boolean SPACE_WITHIN_TUPLE_EXPRESSION = false;
   public boolean INDENT_LABEL_BLOCKS = false;
+  public boolean SPACE_AROUND_REGEX_OPERATORS = true;
 
   //imports
   public boolean USE_FQ_CLASS_NAMES = false;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyLanguageCodeStyleSettingsProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyLanguageCodeStyleSettingsProvider.java
index e2ce60e..0aecf6c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyLanguageCodeStyleSettingsProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyLanguageCodeStyleSettingsProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -166,7 +166,7 @@
                                    "SPACE_AROUND_ADDITIVE_OPERATORS",
                                    "SPACE_AROUND_MULTIPLICATIVE_OPERATORS",
                                    "SPACE_AROUND_SHIFT_OPERATORS",
-                                   "SPACE_AROUND_UNARY_OPERATOR",
+                                   //"SPACE_AROUND_UNARY_OPERATOR",
                                    "SPACE_AFTER_COMMA",
                                    "SPACE_AFTER_COMMA_IN_TYPE_ARGUMENTS",
                                    "SPACE_BEFORE_COMMA",
@@ -223,13 +223,15 @@
                                    "SPACE_BEFORE_ANOTATION_PARAMETER_LIST",
                                    "SPACE_WITHIN_ANNOTATION_PARENTHESES"
       );
-      consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_IN_NAMED_ARGUMENT", "In named argument after ':'",
-                                CodeStyleSettingsCustomizable.SPACES_OTHER);
+      consumer.renameStandardOption("SPACE_AROUND_RELATIONAL_OPERATORS", "Relational operators (<, >, <=, >=, <=>)");
+      consumer.renameStandardOption("SPACE_AROUND_UNARY_OPERATOR", "Unary operators (!, -, +, ++, --, *)");
+
+      consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_IN_NAMED_ARGUMENT", "In named argument after ':'", CodeStyleSettingsCustomizable.SPACES_OTHER);
       consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_WITHIN_LIST_OR_MAP", "List and maps literals", CodeStyleSettingsCustomizable.SPACES_WITHIN);
       consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_BEFORE_CLOSURE_LBRACE", "Closure left brace in method calls", CodeStyleSettingsCustomizable.SPACES_BEFORE_LEFT_BRACE);
       consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_WITHIN_GSTRING_INJECTION_BRACES", "GString injection braces", CodeStyleSettingsCustomizable.SPACES_WITHIN);
-      consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_WITHIN_TUPLE_EXPRESSION", "Tuple assignment expression",
-                                CodeStyleSettingsCustomizable.SPACES_WITHIN);
+      consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_WITHIN_TUPLE_EXPRESSION", "Tuple assignment expression", CodeStyleSettingsCustomizable.SPACES_WITHIN);
+      consumer.showCustomOption(GroovyCodeStyleSettings.class, "SPACE_AROUND_REGEX_OPERATORS", "Regexp expression (==~, =~)", CodeStyleSettingsCustomizable.SPACES_AROUND_OPERATORS);
       return;
     }
     if (settingsType == SettingsType.BLANK_LINES_SETTINGS) {
@@ -326,8 +328,7 @@
         super.apply(settings, options);
         options.LABEL_INDENT_SIZE = getFieldValue(myLabelIndent, Integer.MIN_VALUE, options.LABEL_INDENT_SIZE);
         options.LABEL_INDENT_ABSOLUTE = ABSOLUTE.equals(myLabelIndentStyle.getSelectedItem());
-        settings.getCustomSettings(GroovyCodeStyleSettings.class).INDENT_LABEL_BLOCKS = RELATIVE
-          .equals(myLabelIndentStyle.getSelectedItem());
+        settings.getCustomSettings(GroovyCodeStyleSettings.class).INDENT_LABEL_BLOCKS = RELATIVE.equals(myLabelIndentStyle.getSelectedItem());
       }
 
       public void reset(@NotNull final CodeStyleSettings settings, @NotNull final CommonCodeStyleSettings.IndentOptions options) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompiler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompiler.java
index b01fbb7..2a62258 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompiler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/compiler/GroovyCompiler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -141,7 +141,7 @@
                                                   "(you can do it yourself later in Settings | Compiler | Resource patterns)",
                                                   "AST Transformations Found",
                                                   JetgroovyIcons.Groovy.Groovy_32x32);
-      if (result == 0) {
+      if (result == Messages.YES) {
         CompilerConfiguration.getInstance(myProject).addResourceFilePattern(AST_TRANSFORM_FILE_NAME);
       } else {
         configuration.transformsOk = true;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyAwareModuleBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyAwareModuleBuilder.java
index 978d7c7..db51e01 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyAwareModuleBuilder.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyAwareModuleBuilder.java
@@ -18,6 +18,8 @@
 import com.intellij.ide.util.projectWizard.JavaModuleBuilder;
 import com.intellij.ide.util.projectWizard.ModuleWizardStep;
 import com.intellij.ide.util.projectWizard.SettingsStep;
+import com.intellij.ide.util.projectWizard.WizardContext;
+import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
 import icons.JetgroovyIcons;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -37,7 +39,7 @@
 
   @SuppressWarnings("UnusedDeclaration")
   public GroovyAwareModuleBuilder() {
-    this("groovy", "Groovy", "Simple module with attached Groovy library", null);
+    this("groovy", "Groovy", "Simple module with attached Groovy library", JetgroovyIcons.Groovy.GroovyModule);
   }
 
   protected GroovyAwareModuleBuilder(String builderId, String presentableName, String description, Icon bigIcon) {
@@ -54,6 +56,11 @@
   }
 
   @Override
+  public ModuleWizardStep[] createWizardSteps(@NotNull WizardContext wizardContext, @NotNull ModulesProvider modulesProvider) {
+    return ModuleWizardStep.EMPTY_ARRAY;
+  }
+
+  @Override
   public String getBuilderId() {
     return myBuilderId;
   }
@@ -83,6 +90,16 @@
     return "Groovy";
   }
 
+  @Override
+  public String getParentGroup() {
+    return getModuleTypeName();
+  }
+
+  @Override
+  public boolean isTemplateBased() {
+    return true;
+  }
+
   @Nullable
   protected MvcFramework getFramework() {
     return null;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java
index 015102a..ff05249 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/config/GroovyConfigUtils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,17 +46,19 @@
  * @author ilyas
  */
 public abstract class GroovyConfigUtils extends AbstractConfigUtils {
-  @NonNls private static final Pattern GROOVY_ALL_JAR_PATTERN = Pattern.compile("groovy-all-(.*)\\.jar");
-  private static GroovyConfigUtils myGroovyConfigUtils;
+  @NonNls public static final Pattern GROOVY_ALL_JAR_PATTERN = Pattern.compile("groovy-all(-(.*))?\\.jar");
+  @NonNls public static final Pattern GROOVY_JAR_PATTERN = Pattern.compile("groovy(-(\\d.*))?\\.jar");
 
-  @NonNls public static final String GROOVY_JAR_PATTERN_NOVERSION = "groovy\\.jar";
-  @NonNls public static final String GROOVY_JAR_PATTERN = "groovy-(\\d.*)\\.jar";
   public static final String NO_VERSION = "<no version>";
   public static final String GROOVY1_7 = "1.7";
   public static final String GROOVY1_8 = "1.8";
   public static final String GROOVY2_0 = "2.0";
   public static final String GROOVY2_1 = "2.1";
   public static final String GROOVY2_2 = "2.2";
+  public static final String GROOVY2_2_2 = "2.2.2";
+  public static final String GROOVY2_3 = "2.3";
+
+  private static GroovyConfigUtils myGroovyConfigUtils;
 
   private GroovyConfigUtils() {
   }
@@ -84,9 +86,6 @@
   public String getSDKVersion(@NotNull final String path) {
     String groovyJarVersion = getSDKJarVersion(path + "/lib", GROOVY_JAR_PATTERN, MANIFEST_PATH);
     if (groovyJarVersion == null) {
-      groovyJarVersion = getSDKJarVersion(path + "/lib", GROOVY_JAR_PATTERN_NOVERSION, MANIFEST_PATH);
-    }
-    if (groovyJarVersion == null) {
       groovyJarVersion = getSDKJarVersion(path + "/lib", GROOVY_ALL_JAR_PATTERN, MANIFEST_PATH);
     }
     if (groovyJarVersion == null) {
@@ -143,7 +142,6 @@
     if (file != null && file.isDirectory()) {
       final String path = file.getPath();
       if (GroovyUtils.getFilesInDirectoryByPattern(path + "/lib", GROOVY_JAR_PATTERN).length > 0 ||
-          GroovyUtils.getFilesInDirectoryByPattern(path + "/lib", GROOVY_JAR_PATTERN_NOVERSION).length > 0 ||
           GroovyUtils.getFilesInDirectoryByPattern(path + "/embeddable", GROOVY_ALL_JAR_PATTERN).length > 0 ||
           GroovyUtils.getFilesInDirectoryByPattern(path, GROOVY_JAR_PATTERN).length > 0) {
         return true;
@@ -160,7 +158,7 @@
       int result = Messages
         .showOkCancelDialog(GroovyBundle.message("groovy.like.library.found.text", module.getName(), library.getName(), getSDKLibVersion(library)),
                             GroovyBundle.message("groovy.like.library.found"), JetgroovyIcons.Groovy.Groovy_32x32);
-      if (result == 0) {
+      if (result == Messages.OK) {
         AccessToken accessToken = WriteAction.start();
 
         try {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java
index 39aa7a0..26e5cad 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/DefaultGroovyShellRunner.java
@@ -19,7 +19,6 @@
 import com.intellij.execution.configurations.JavaParameters;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.roots.ModuleRootManager;
-import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.JavaPsiFacade;
 import com.intellij.psi.search.GlobalSearchScope;
@@ -28,12 +27,8 @@
 import org.jetbrains.plugins.groovy.config.GroovyConfigUtils;
 import org.jetbrains.plugins.groovy.runner.DefaultGroovyScriptRunner;
 import org.jetbrains.plugins.groovy.runner.GroovyScriptRunConfiguration;
-import org.jetbrains.plugins.groovy.runner.GroovyScriptRunner;
-import org.jetbrains.plugins.groovy.util.GroovyUtils;
 import org.jetbrains.plugins.groovy.util.LibrariesUtil;
 
-import java.io.File;
-
 /**
  * @author Sergey Evdokimov
  */
@@ -49,54 +44,32 @@
   @Override
   public JavaParameters createJavaParameters(@NotNull Module module) throws ExecutionException {
     JavaParameters res = GroovyScriptRunConfiguration.createJavaParametersWithSdk(module);
-    boolean useBundled = !hasGroovyAll(module);
     DefaultGroovyScriptRunner.configureGenericGroovyRunner(res, module, "org.codehaus.groovy.tools.shell.Main", false, true);
-    if (useBundled) {
-      String libRoot = GroovyUtils.getBundledGroovyJar().getParent();
-      File libDir = new File(libRoot + "/groovy/lib");
-      assert libDir.isDirectory();
-      for (File file : libDir.listFiles()) {
-        res.getClassPath().add(file);
-      }
-
-      GroovyScriptRunner.setGroovyHome(res, FileUtil.toCanonicalPath(libRoot  + "/groovy"));
-    }
     res.setWorkingDirectory(getWorkingDirectory(module));
-
     return res;
   }
 
   @Override
   public boolean canRun(@NotNull Module module) {
     VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
-    return contentRoots.length > 0;
+    return contentRoots.length > 0 && hasGroovyWithNeededJars(module);
   }
 
   @NotNull
   @Override
   public String getTitle(@NotNull Module module) {
     String homePath = LibrariesUtil.getGroovyHomePath(module);
-    boolean bundled = false;
-    if (homePath == null || !hasGroovyAll(module)) {
-      homePath = GroovyUtils.getBundledGroovyJar().getParentFile().getParent();
-      bundled = true;
-    }
+    assert homePath != null;
+
     String version = GroovyConfigUtils.getInstance().getSDKVersion(homePath);
-    return version == AbstractConfigUtils.UNDEFINED_VERSION ? "" : " (" + (bundled ? "Bundled " : "") + "Groovy " + version + ")";
+    return version == AbstractConfigUtils.UNDEFINED_VERSION ? "" : " (Groovy " + version + ")";
   }
 
-  private static boolean hasGroovyAll(Module module) {
+  static boolean hasGroovyWithNeededJars(Module module) {
     GlobalSearchScope scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module);
     JavaPsiFacade facade = JavaPsiFacade.getInstance(module.getProject());
-    return (facade.findClass("org.apache.commons.cli.CommandLineParser", scope) != null ||
-            facade.findClass("groovyjarjarcommonscli.CommandLineParser", scope) != null) &&
-           facade.findClass("groovy.ui.GroovyMain", scope) != null;
-  }
-
-  @NotNull
-  @Override
-  public String transformUserInput(@NotNull String userInput) {
-    //return StringUtil.replace(userInput, "\n", "###\\n");
-    return userInput;
+    return (facade.findClass("org.apache.commons.cli.CommandLineParser", scope) != null || facade.findClass("groovyjarjarcommonscli.CommandLineParser", scope) != null) &&
+           facade.findClass("groovy.ui.GroovyMain", scope) != null  &&
+           facade.findClass("org.fusesource.jansi.AnsiConsole", scope) != null;
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleRunner.java
index bf46a21..1932da4 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleRunner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyConsoleRunner.java
@@ -69,13 +69,11 @@
   @NotNull
   @Override
   public String getTitle(@NotNull Module module) {
-    String homePath = LibrariesUtil.getGroovyHomePath(module);
-    boolean bundled = false;
-    if (homePath == null || !hasGroovyAll(module)) {
-      homePath = GroovyUtils.getBundledGroovyJar().getParentFile().getParent();
-      bundled = true;
-    }
-    String version = GroovyConfigUtils.getInstance().getSDKVersion(homePath);
+    String moduleGroovyHomePath = LibrariesUtil.getGroovyHomePath(module);
+    boolean bundled = moduleGroovyHomePath == null || !hasGroovyAll(module);
+    String homePathToUse = bundled ? GroovyUtils.getBundledGroovyJar().getParentFile().getParent() : moduleGroovyHomePath;
+
+    String version = GroovyConfigUtils.getInstance().getSDKVersion(homePathToUse);
     return version == AbstractConfigUtils.UNDEFINED_VERSION ? "" : " (" + (bundled ? "Bundled " : "") + "Groovy " + version + ")";
   }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellAction.java
index 835687a..085cce5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellAction.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellAction.java
@@ -22,6 +22,11 @@
  * @author peter
  */
 public class GroovyShellAction extends GroovyShellActionBase {
+  @Override
+  protected boolean isSuitableModule(Module module) {
+    return super.isSuitableModule(module) && DefaultGroovyShellRunner.hasGroovyWithNeededJars(module);
+  }
+
   protected GroovyShellRunner getRunner(Module module) {
     return new DefaultGroovyShellRunner();
   }
@@ -33,31 +38,6 @@
 
   @Override
   protected GroovyShellConsoleImpl createConsole(Project project, String title) {
-    final GroovyShellConsoleImpl console = new GroovyShellConsoleImpl(project, title);
-
-    /*UiNotifyConnector.doWhenFirstShown(console.getComponent(), new Runnable() {
-      @Override
-      public void run() {
-        final String key = "groovy.shell.is.really.groovy.shell";
-        if (!PropertiesComponent.getInstance().isTrueValue(key)) {
-          final Alarm alarm = new Alarm();
-          alarm.addRequest(new Runnable() {
-            @Override
-            public void run() {
-              GotItMessage.createMessage("Groovy Shell & Groovy Console", "<html><div align='left'>Use 'Groovy Console' action (Tools | Groovy Console...) to run <a href='http://'>Groovy Console</a><br>Use 'Groovy Shell' action (Tools | Groovy Shell...) to invoke <a href=\"http://groovy.codehaus.org/Groovy+Shell\">Groovy Shell</a></div></html>")
-                .setDisposable(console)
-                .show(new RelativePoint(console.getComponent(), new Point(10, 0)), Balloon.Position.above);
-
-              PropertiesComponent.getInstance().setValue(key, String.valueOf(true));
-              Disposer.dispose(alarm);
-            }
-          }, 2000);
-        }
-
-      }
-    })*/;
-
-
-    return console;
+    return new GroovyShellConsoleImpl(project, title);
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellActionBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellActionBase.java
index 54f8d51..f39da22 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellActionBase.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/console/GroovyShellActionBase.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,9 @@
 
 import com.intellij.execution.ExecutionException;
 import com.intellij.execution.configurations.JavaParameters;
-import com.intellij.execution.console.ConsoleHistoryController;
-import com.intellij.execution.console.LanguageConsoleImpl;
-import com.intellij.execution.console.LanguageConsoleView;
-import com.intellij.execution.console.LanguageConsoleViewImpl;
+import com.intellij.execution.console.*;
 import com.intellij.execution.process.OSProcessHandler;
 import com.intellij.execution.runners.AbstractConsoleRunnerWithHistory;
-import com.intellij.execution.runners.ConsoleExecuteActionHandler;
 import com.intellij.ide.util.PropertiesComponent;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
@@ -45,8 +41,10 @@
 import com.intellij.openapi.ui.popup.JBPopupFactory;
 import com.intellij.openapi.ui.popup.PopupStep;
 import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
+import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.Key;
 import com.intellij.util.PlatformIcons;
+import com.intellij.util.containers.ContainerUtil;
 import icons.JetgroovyIcons;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl;
@@ -60,13 +58,14 @@
 public abstract class GroovyShellActionBase extends DumbAwareAction {
   private static final Logger LOG = Logger.getInstance(GroovyShellActionBase.class);
 
+  public static final String GROOVY_SHELL_EXECUTE = "Groovy.Shell.Execute";
   public static final Key<Boolean> GROOVY_SHELL_FILE = Key.create("GROOVY_SHELL_FILE");
   private static final String GROOVY_SHELL_LAST_MODULE = "Groovy.Shell.LastModule";
 
-  private static List<Module> getGroovyCompatibleModules(Project project) {
+  private List<Module> getGroovyCompatibleModules(Project project) {
     ArrayList<Module> result = new ArrayList<Module>();
     for (Module module : ModuleManager.getInstance(project).getModules()) {
-      if (GroovyUtils.isSuitableModule(module)) {
+      if (isSuitableModule(module)) {
         Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
         if (sdk != null && sdk.getSdkType() instanceof JavaSdkType) {
           result.add(module);
@@ -76,6 +75,10 @@
     return result;
   }
 
+  protected boolean isSuitableModule(Module module) {
+    return GroovyUtils.isSuitableModule(module);
+  }
+
   @Override
   public void update(AnActionEvent e) {
     final Project project = e.getData(CommonDataKeys.PROJECT);
@@ -112,7 +115,7 @@
     final Map<Module, String> versions = new HashMap<Module, String>();
 
     for (Module module : getGroovyCompatibleModules(project)) {
-      GroovyShellRunner runner = GroovyShellRunner.getAppropriateRunner(module);
+      GroovyShellRunner runner = getRunner(module);
       if (runner != null) {
         modules.add(module);
         versions.put(module, runner.getTitle(module));
@@ -152,13 +155,19 @@
         }
       };
 
-    for (int i = 0; i < modules.size(); i++) {
-      Module module = modules.get(i);
-      if (module.getName().equals(PropertiesComponent.getInstance(project).getValue(GROOVY_SHELL_LAST_MODULE))) {
-        step.setDefaultOptionIndex(i);
-        break;
+    final String lastModuleName = PropertiesComponent.getInstance(project).getValue(GROOVY_SHELL_LAST_MODULE);
+    if (lastModuleName != null) {
+      int defaultOption = ContainerUtil.indexOf(modules, new Condition<Module>() {
+        @Override
+        public boolean value(Module module) {
+          return module.getName().equals(lastModuleName);
+        }
+      });
+      if (defaultOption >= 0) {
+        step.setDefaultOptionIndex(defaultOption);
       }
     }
+
     JBPopupFactory.getInstance().createListPopup(step).showCenteredInCurrentWindow(project);
   }
 
@@ -166,7 +175,7 @@
     final GroovyShellRunner shellRunner = getRunner(module);
     if (shellRunner == null) return;
 
-    AbstractConsoleRunnerWithHistory<LanguageConsoleView> runner = new GroovyConsoleRunner(getTitle(), shellRunner, module, "Groovy.Shell.Execute");
+    AbstractConsoleRunnerWithHistory<LanguageConsoleView> runner = new GroovyConsoleRunner(getTitle(), shellRunner, module);
     try {
       runner.initAndRun();
     }
@@ -183,18 +192,15 @@
   protected abstract LanguageConsoleImpl createConsole(Project project, String title);
 
   private class GroovyConsoleRunner extends AbstractConsoleRunnerWithHistory<LanguageConsoleView> {
-    private final String myEmptyExecuteAction;
     private GroovyShellRunner myShellRunner;
     private Module myModule;
 
     private GroovyConsoleRunner(@NotNull String consoleTitle,
                                 @NotNull GroovyShellRunner shellRunner,
-                                @NotNull Module module,
-                                @NotNull String emptyExecuteAction) {
+                                @NotNull Module module) {
       super(module.getProject(), consoleTitle, shellRunner.getWorkingDirectory(module));
       myShellRunner = shellRunner;
       myModule = module;
-      myEmptyExecuteAction = emptyExecuteAction;
     }
 
     @Override
@@ -230,16 +236,16 @@
 
     @NotNull
     @Override
-    protected ConsoleExecuteActionHandler createConsoleExecuteActionHandler() {
-      ConsoleExecuteActionHandler handler = new ConsoleExecuteActionHandler(getProcessHandler(), false) {
+    protected ProcessBackedConsoleExecuteActionHandler createExecuteActionHandler() {
+      ProcessBackedConsoleExecuteActionHandler handler = new ProcessBackedConsoleExecuteActionHandler(getProcessHandler(), false) {
         @Override
-        public void processLine(String line) {
+        public void processLine(@NotNull String line) {
           super.processLine(myShellRunner.transformUserInput(line));
         }
 
         @Override
         public String getEmptyExecuteAction() {
-          return myEmptyExecuteAction;
+          return GROOVY_SHELL_EXECUTE;
         }
       };
       new ConsoleHistoryController(getConsoleTitle(), null, getLanguageConsole(), handler.getConsoleHistoryModel()).install();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java
index 81d24d3..bea2383 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyCodeFragmentFactory.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -45,6 +45,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.ClosureSyntheticParameter;
+import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrBindingVariable;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightVariable;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 
@@ -69,10 +70,7 @@
   }
 
   public JavaCodeFragment createCodeFragment(TextWithImports textWithImports, PsiElement context, Project project) {
-    String text = textWithImports.getText();
-    String imports = textWithImports.getImports();
-
-    final Pair<Map<String, String>, GroovyFile> pair = externalParameters(text, context);
+    final Pair<Map<String, String>, GroovyFile> pair = externalParameters(textWithImports.getText(), context);
     GroovyFile toEval = pair.second;
     final Map<String, String> parameters = pair.first;
 
@@ -83,8 +81,7 @@
       }
     });
 
-
-    text = toEval.getText();
+    String text = toEval.getText();
     final String groovyText = StringUtil.join(names, ", ") + "->" + stripImports(text, toEval);
 
     PsiClass contextClass = PsiUtil.getContextClass(context);
@@ -97,41 +94,32 @@
     if (!isStatic) {
       javaText.append("java.lang.Object |thiz0;\n");
 
-      String fileName;
+      PsiFile containingFile = context.getContainingFile();
 
-      PsiElement originalContext = context.getContainingFile().getContext();
-      if (originalContext == null) {
-        fileName = null; // The class is not reloaded by springloaded if context is in physical file.
-      }
-      else {
-        fileName = originalContext.getContainingFile().getOriginalFile().getName();
+      if (containingFile.getContext() != null) {
+        containingFile = containingFile.getContext().getContainingFile();
       }
 
-      if (fileName == null) {
-        // The class could not be reloaded by springloaded
-        javaText.append("|thiz0 = this;\n");
-      }
-      else {
-        // Class could be reloaded by springloaded
+      String fileName = containingFile.getOriginalFile().getName();
 
-        String s = StringUtil.escapeStringCharacters(Pattern.quote(fileName));
-        // We believe what class is reloaded if stacktrace matches one of two patterns:
-        // 1.) [com.package.Foo$$ENLbVXwm.methodName(FileName.groovy:12), com.package.Foo$$DNLbVXwm.methodName(Unknown Source), *
-        // 2.) [com.package.Foo$$ENLbVXwm.methodName(FileName.groovy:12), * com.springsource.loaded. *
-        // Pattern below test this.
+      String s = StringUtil.escapeStringCharacters(Pattern.quote(fileName));
+      // We believe what class is reloaded if stacktrace matches one of two patterns:
+      // 1.) [com.package.Foo$$ENLbVXwm.methodName(FileName.groovy:12), com.package.Foo$$DNLbVXwm.methodName(Unknown Source), *
+      // 2.) [com.package.Foo$$ENLbVXwm.methodName(FileName.groovy:12), * com.springsource.loaded. *
+      // Pattern below test this.
 
-        //javaText.append("System.out.println(java.util.Arrays.toString(new Exception().getStackTrace()));\n");
-        //javaText.append("System.out.println(\"\\\\[([^,()]+\\\\$\\\\$)[A-Za-z0-9]{8}(\\\\.[^,()]+)\\\\(" + s + ":\\\\d+\\\\), (\\\\1[A-Za-z0-9]{8}\\\\2\\\\(Unknown Source\\\\), |.+(?:com|org)\\\\.springsource\\\\.loaded\\\\.).+\")\n");
+      //javaText.append("System.out.println(java.util.Arrays.toString(new Exception().getStackTrace()));\n");
+      //javaText.append("System.out.println(\"\\\\[([^,()]+\\\\$\\\\$)[A-Za-z0-9]{8}(\\\\.[^,()]+)\\\\(" + s + ":\\\\d+\\\\), (\\\\1[A-Za-z0-9]{8}\\\\2\\\\(Unknown Source\\\\), |.+(?:com|org)\\\\.springsource\\\\.loaded\\\\.).+\")\n");
 
-        javaText.append(
-          "if (java.util.Arrays.toString(new Exception().getStackTrace()).matches(\"\\\\[([^,()]+\\\\$\\\\$)[A-Za-z0-9]{8}(\\\\.[^,()]+)\\\\(")
-          .append(s)
-          .append(":\\\\d+\\\\), (\\\\1[A-Za-z0-9]{8}\\\\2\\\\(Unknown Source\\\\), $OR$.+(?:com$OR$org)\\\\.springsource\\\\.loaded\\\\.).+\")) {\n");
-        javaText.append("  |thiz0 = thiz;\n");
-        javaText.append(" } else {\n");
-        javaText.append("  |thiz0 = this;\n");
-        javaText.append(" }\n");
-      }
+      javaText.append(
+        "if (java.util.Arrays.toString(new Exception().getStackTrace()).matches(\"\\\\[([^,()]+\\\\$\\\\$)[A-Za-z0-9]{8}(\\\\.[^,()]+)\\\\(")
+        .append(s)
+        .append(
+          ":\\\\d+\\\\), (\\\\1[A-Za-z0-9]{8}\\\\2\\\\(Unknown Source\\\\), $OR$.+(?:com$OR$org)\\\\.springsource\\\\.loaded\\\\.).+\")) {\n");
+      javaText.append("  |thiz0 = thiz;\n");
+      javaText.append(" } else {\n");
+      javaText.append("  |thiz0 = this;\n");
+      javaText.append(" }\n");
     }
 
     if (!isStatic) {
@@ -175,7 +163,7 @@
 
     String hiddenJavaVars = StringUtil.replace(javaText.toString(), "|", "_$_" + new Random().nextInt(42));
     hiddenJavaVars = hiddenJavaVars.replaceAll("\\$OR\\$", "|");
-    final String finalText = StringUtil.replace(StringUtil.replace(hiddenJavaVars, TEXT, groovyText), IMPORTS, imports);
+    final String finalText = StringUtil.replace(StringUtil.replace(hiddenJavaVars, TEXT, groovyText), IMPORTS, textWithImports.getImports());
     JavaCodeFragment result = JavaCodeFragmentFactory.getInstance(project).createCodeBlockCodeFragment(finalText, null, true);
     if (contextClass != null) {
       result.setThisType(factory.createType(contextClass));
@@ -218,6 +206,11 @@
           if (resolved instanceof ClosureSyntheticParameter && PsiTreeUtil.isAncestor(toEval, ((ClosureSyntheticParameter) resolved).getClosure(), false)) {
             return;
           }
+
+          if (resolved instanceof GrBindingVariable && !PsiTreeUtil.isAncestor(resolved.getContainingFile(), toEval, false)) {
+            return;
+          }
+
           String value;
           if (closure != null &&
               PsiTreeUtil.findCommonParent(resolved, closure) != closure &&
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java
index c4e8fad..583cbaa 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/GroovyHotSwapper.java
@@ -18,17 +18,18 @@
 import com.intellij.openapi.roots.LanguageLevelProjectExtension;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.pom.java.LanguageLevel;
-import com.intellij.psi.search.FilenameIndex;
+import com.intellij.psi.search.FileTypeIndex;
 import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.util.CachedValueProvider;
+import com.intellij.psi.util.CachedValuesManager;
+import com.intellij.psi.util.PsiModificationTracker;
 import com.intellij.util.PathUtil;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.GroovyFileTypeLoader;
+import org.jetbrains.plugins.groovy.GroovyFileType;
 import org.jetbrains.plugins.groovy.debugger.filters.GroovyDebuggerSettings;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
 import java.util.jar.Attributes;
 import java.util.regex.Pattern;
 
@@ -42,29 +43,15 @@
 
   private static final Pattern SPRING_LOADED_PATTERN = Pattern.compile("-javaagent:.+springloaded-core-[^/\\\\]+\\.jar");
   
-  private static boolean endsWithAny(String s, List<String> endings) {
-    for (String extension : endings) {
-      if (s.endsWith(extension)) {
-        return true;
+  private static boolean containsGroovyClasses(final Project project) {
+    return CachedValuesManager.getManager(project).getCachedValue(project, new CachedValueProvider<Boolean>() {
+      @Nullable
+      @Override
+      public Result<Boolean> compute() {
+        return Result.create(FileTypeIndex.containsFileOfType(GroovyFileType.GROOVY_FILE_TYPE, GlobalSearchScope.projectScope(project)), 
+                             PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
       }
-    }
-    return false;
-  }
-
-  private static boolean containsGroovyClasses(Project project) {
-    final List<String> extensions = new ArrayList<String>();
-    for (String extension : GroovyFileTypeLoader.getAllGroovyExtensions()) {
-      extensions.add("." + extension);
-    }
-    final GlobalSearchScope scope = GlobalSearchScope.projectScope(project);
-    for (String fileName : FilenameIndex.getAllFilenames(project)) {
-      if (endsWithAny(fileName, extensions)) {
-        if (!FilenameIndex.getVirtualFilesByName(project, fileName, scope).isEmpty()) {
-          return true;
-        }
-      }
-    }
-    return false;
+    });
   }
 
   private static boolean hasSpringLoadedReloader(JavaParameters javaParameters) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/filters/GroovyDebuggerClassFilterProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/filters/GroovyDebuggerClassFilterProvider.java
index f8ae680..77cbbb1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/filters/GroovyDebuggerClassFilterProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/filters/GroovyDebuggerClassFilterProvider.java
@@ -17,7 +17,6 @@
 
 import com.intellij.ui.classFilter.ClassFilter;
 import com.intellij.ui.classFilter.DebuggerClassFilterProvider;
-import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
 
 import java.util.Arrays;
 import java.util.Collections;
@@ -38,18 +37,4 @@
     return Collections.emptyList();
   }
 
-  public boolean isAuxiliaryFrame(String className, String methodName) {
-    if (className.equals(GroovyCommonClassNames.DEFAULT_GROOVY_METHODS) ||
-        className.equals("org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport")) {
-      return false;
-    }
-
-    for (ClassFilter filter : FILTERS) {
-      final String pattern = filter.getPattern();
-      if (className.startsWith(pattern.substring(0, pattern.length() - 1))) {
-        return true;
-      }
-    }
-    return false;
-  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/fragments/GroovyCodeFragment.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/fragments/GroovyCodeFragment.java
index 45d37ed..5a75a0d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/fragments/GroovyCodeFragment.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/debugger/fragments/GroovyCodeFragment.java
@@ -16,6 +16,7 @@
 package org.jetbrains.plugins.groovy.debugger.fragments;
 
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.PsiManagerEx;
 import com.intellij.psi.impl.file.impl.FileManager;
@@ -59,7 +60,7 @@
     this(project, new LightVirtualFile("Dummy.groovy", GroovyFileType.GROOVY_FILE_TYPE, text));
   }
 
-  public GroovyCodeFragment(Project project, LightVirtualFile virtualFile) {
+  public GroovyCodeFragment(Project project, VirtualFile virtualFile) {
     super(new SingleRootFileViewProvider(PsiManager.getInstance(project), virtualFile, true));
     ((SingleRootFileViewProvider)getViewProvider()).forceCachedPsi(this);
   }
@@ -151,7 +152,7 @@
     return myExceptionChecker;
   }
 
-  public void setIntentionActionsFilter(IntentionActionsFilter filter) {
+  public void setIntentionActionsFilter(@NotNull IntentionActionsFilter filter) {
     myFilter = filter;
   }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/dgm/DGMMemberContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/dgm/DGMMemberContributor.java
index a210716..224c5b4 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/dgm/DGMMemberContributor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/dgm/DGMMemberContributor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,10 +17,14 @@
 
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Pair;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiType;
+import com.intellij.psi.ResolveState;
 import com.intellij.psi.scope.PsiScopeProcessor;
 import com.intellij.psi.search.GlobalSearchScope;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager;
 import org.jetbrains.plugins.groovy.lang.resolve.NonCodeMembersContributor;
 
 import java.util.List;
@@ -37,15 +41,15 @@
                                      ResolveState state) {
     Project project = place.getProject();
     GlobalSearchScope resolveScope = place.getResolveScope();
-    JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
+    GroovyPsiManager groovyPsiManager = GroovyPsiManager.getInstance(project);
 
     Pair<List<String>, List<String>> extensions = GroovyExtensionProvider.getInstance(project).collectExtensions(resolveScope);
 
     List<String> instanceCategories = extensions.getFirst();
     List<String> staticCategories = extensions.getSecond();
 
-    if (!processCategories(qualifierType, processor, state, project, resolveScope, facade, instanceCategories, false)) return;
-    if (!processCategories(qualifierType, processor, state, project, resolveScope, facade, staticCategories, true)) return;
+    if (!processCategories(qualifierType, processor, state, project, resolveScope, groovyPsiManager, instanceCategories, false)) return;
+    if (!processCategories(qualifierType, processor, state, project, resolveScope, groovyPsiManager, staticCategories, true)) return;
   }
 
   private static boolean processCategories(PsiType qualifierType,
@@ -53,11 +57,10 @@
                                            ResolveState state,
                                            Project project,
                                            GlobalSearchScope resolveScope,
-                                           JavaPsiFacade facade,
-                                           List<String> instanceCategories,
+                                           GroovyPsiManager groovyPsiManager, List<String> instanceCategories,
                                            boolean isStatic) {
     for (String category : instanceCategories) {
-      PsiClass clazz = facade.findClass(category, resolveScope);
+      PsiClass clazz = groovyPsiManager.findClassWithCache(category, resolveScope);
       if (clazz != null) {
         if (!GdkMethodHolder.getHolderForClass(clazz, isStatic, resolveScope).processMethods(processor, state, qualifierType, project)) {
           return false;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GenerateGroovyDocDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GenerateGroovyDocDialog.java
index cf71abd..2d87f0a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GenerateGroovyDocDialog.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GenerateGroovyDocDialog.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,12 +54,6 @@
     }
   }
 
-  @Override
-  protected void dispose() {
-    super.dispose();
-    //Disposer.dispose(myPanel);
-  }
-
   @Nullable
   @Override
   protected String getHelpId() {
@@ -84,7 +78,7 @@
       int choice = Messages.showOkCancelDialog(myProject,
                                                GroovyDocBundle.message("groovydoc.generate.directory.not.exists", dirName),
                                                GroovyDocBundle.message("groovydoc.generate.message.title"), Messages.getWarningIcon());
-      if (choice != 0) return false;
+      if (choice != Messages.OK) return false;
       if (!dir.mkdirs()) {
         showError(GroovyDocBundle.message("groovydoc.generate.directory.creation.failed", dirName));
         return false;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocBundle.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocBundle.java
index b0d8df1..4a403bc 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocBundle.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocBundle.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 
 import com.intellij.CommonBundle;
 import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.PropertyKey;
 
 import java.lang.ref.Reference;
@@ -26,19 +27,16 @@
 
 public class GroovyDocBundle {
 
-  private static Reference<ResourceBundle> ourBundle;
-
-  @NonNls
-  private static final String BUNDLE = "org.jetbrains.plugins.groovy.doc.GroovyDocBundle";
-
-  public static String message(@PropertyKey(resourceBundle = BUNDLE) String key, Object... params) {
+  public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
     return CommonBundle.message(getBundle(), key, params);
   }
 
-  private static ResourceBundle getBundle() {
-    ResourceBundle bundle = null;
+  private static Reference<ResourceBundle> ourBundle;
+  @NonNls
+  private static final String BUNDLE = "org.jetbrains.plugins.groovy.doc.GroovyDocBundle";
 
-    if (ourBundle != null) bundle = ourBundle.get();
+  private static ResourceBundle getBundle() {
+    ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
 
     if (bundle == null) {
       bundle = ResourceBundle.getBundle(BUNDLE);
@@ -46,6 +44,5 @@
     }
     return bundle;
   }
-
 }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocGenerationPanel.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocGenerationPanel.java
index 5f9cec8..3973a8d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocGenerationPanel.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/doc/GroovyDocGenerationPanel.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@
 import java.util.HashSet;
 import java.util.Set;
 
-public final class GroovyDocGenerationPanel extends JPanel/* implements Disposable*/ {
+public final class GroovyDocGenerationPanel extends JPanel {
   JPanel myPanel;
   TextFieldWithBrowseButton myOutputDir;
   NonFocusableCheckBox myIsUse;
@@ -54,9 +54,6 @@
   private final DefaultListModel myDataModel;
 
   GroovyDocGenerationPanel() {
-    //Disposer.register(this, myInputDir);
-    //Disposer.register(this, myOutputDir);
-
     myInputDir.addBrowseFolderListener(GroovyDocBundle.message("groovydoc.generate.directory.browse"), null, null,
                                        FileChooserDescriptorFactory.createSingleFolderDescriptor());
 
@@ -161,8 +158,4 @@
   public JPanel getPanel() {
     return myPanel;
   }
-
-  //@Override
-  public void dispose() {
-  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/CustomMembersGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/CustomMembersGenerator.java
index b35fb5a..8f9958b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/CustomMembersGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/CustomMembersGenerator.java
@@ -23,6 +23,7 @@
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.util.Function;
 import com.intellij.util.containers.ContainerUtil;
+import com.intellij.util.containers.FList;
 import groovy.lang.Closure;
 import groovy.lang.GroovyObjectSupport;
 import groovy.lang.MetaMethod;
@@ -53,7 +54,7 @@
   private static final Logger LOG = Logger.getInstance("#org.jetbrains.plugins.groovy.dsl.CustomMembersGenerator");
   private static final GdslMembersProvider[] PROVIDERS = GdslMembersProvider.EP_NAME.getExtensions();
   public static final String THROWS = "throws";
-  private final List<Map> myDeclarations = ContainerUtil.newArrayList();
+  private FList<Map> myDeclarations = FList.emptyList();
   private final Project myProject;
   private final CompoundMembersHolder myDepot = new CompoundMembersHolder();
   private final GroovyClassDescriptor myDescriptor;
@@ -101,7 +102,8 @@
       addMemberHolder(new CustomMembersHolder() {
         @Override
         public boolean processMembers(GroovyClassDescriptor descriptor, PsiScopeProcessor processor, ResolveState state) {
-          return NonCodeMembersHolder.generateMembers(myDeclarations, descriptor.justGetPlaceFile()).processMembers(descriptor, processor, state);
+          return NonCodeMembersHolder.generateMembers(ContainerUtil.reverse(myDeclarations), descriptor.justGetPlaceFile()).processMembers(
+            descriptor, processor, state);
         }
       });
     }
@@ -166,9 +168,10 @@
   public void method(Map<Object, Object> args) {
     if (args == null) return;
 
+    args = ContainerUtil.newLinkedHashMap(args);
     parseMethod(args);
     args.put("declarationType", DeclarationType.METHOD);
-    myDeclarations.add(args);
+    myDeclarations = myDeclarations.prepend(args);
   }
 
   public void methodCall(Closure<Map<Object, Object>> generator) {
@@ -253,23 +256,25 @@
   public void closureInMethod(Map<Object, Object> args) {
     if (args == null) return;
 
+    args = ContainerUtil.newLinkedHashMap(args);
     parseMethod(args);
     final Object method = args.get("method");
     if (method instanceof Map) {
       parseMethod((Map)method);
     }
     args.put("declarationType", DeclarationType.CLOSURE);
-    myDeclarations.add(args);
+    myDeclarations = myDeclarations.prepend(args);
   }
 
   public void variable(Map<Object, Object> args) {
     if (args == null) return;
 
+    args = ContainerUtil.newLinkedHashMap(args);
     parseVariable(args);
-    myDeclarations.add(args);
+    myDeclarations = myDeclarations.prepend(args);
   }
 
-  private void parseVariable(Map<Object, Object> args) {
+  private static void parseVariable(Map<Object, Object> args) {
     String type = stringifyType(args.get("type"));
     args.put("type", type);
     args.put("declarationType", DeclarationType.VARIABLE);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java
index 73d9621..82cfe11 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslFileIndex.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -110,7 +110,7 @@
     VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() {
 
       @Override
-      public void contentsChanged(VirtualFileEvent event) {
+      public void contentsChanged(@NotNull VirtualFileEvent event) {
         if (event.getFileName().endsWith(".gdsl")) {
           disableFile(event.getFile(), MODIFIED);
         }
@@ -343,8 +343,7 @@
 
   @Nullable
   private static List<Pair<File, GroovyDslExecutor>> derefStandardScripts() {
-    SoftReference<List<Pair<File, GroovyDslExecutor>>> ref = ourStandardScripts;
-    return ref == null ? null : ref.get();
+    return SoftReference.dereference(ourStandardScripts);
   }
 
   private static List<Pair<File, GroovyDslExecutor>> getStandardScripts() {
@@ -406,7 +405,7 @@
           ref.set(new ArrayList<Pair<File, GroovyDslExecutor>>());
           //noinspection InstanceofCatchParameter
           if (e instanceof Error) {
-            stopGdsl = true;
+            stopGdsl();
           }
           LOG.error(e);
         }
@@ -419,7 +418,7 @@
     while (true) {
       ProgressManager.checkCanceled();
 
-      if (stopGdsl) {
+      if (ourGdslStopped) {
         return Collections.emptyList();
       }
       if (ref.get() != null || semaphore.waitFor(20)) {
@@ -428,12 +427,17 @@
     }
   }
 
+  static void stopGdsl() {
+    ourGdslStopped = true;
+  }
+
   private static final Key<CachedValue<List<GroovyDslScript>>> SCRIPTS_CACHE = Key.create("GdslScriptCache");
+
   private static List<GroovyDslScript> getDslScripts(final Project project) {
     return CachedValuesManager.getManager(project).getCachedValue(project, SCRIPTS_CACHE, new CachedValueProvider<List<GroovyDslScript>>() {
       @Override
       public Result<List<GroovyDslScript>> compute() {
-        if (stopGdsl) {
+        if (ourGdslStopped) {
           return Result.create(Collections.<GroovyDslScript>emptyList(), Collections.emptyList());
         }
 
@@ -442,9 +446,6 @@
         List<GroovyDslScript> result = new ArrayList<GroovyDslScript>();
 
         List<Pair<File, GroovyDslExecutor>> standardScripts = getStandardScripts();
-        if (stopGdsl) {
-          return Result.create(Collections.<GroovyDslScript>emptyList(), Collections.emptyList());
-        }
         assert standardScripts != null;
         for (Pair<File, GroovyDslExecutor> pair : standardScripts) {
           result.add(new GroovyDslScript(project, null, pair.second, pair.first.getPath()));
@@ -454,7 +455,8 @@
           new LinkedBlockingQueue<Pair<VirtualFile, GroovyDslExecutor>>();
 
         final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
-        for (VirtualFile vfile : FileBasedIndex.getInstance().getContainingFiles(NAME, OUR_KEY, GlobalSearchScope.allScope(project))) {
+        final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
+        for (VirtualFile vfile : FileBasedIndex.getInstance().getContainingFiles(NAME, OUR_KEY, scope)) {
           if (!vfile.isValid()) {
             continue;
           }
@@ -476,7 +478,7 @@
         }
 
         try {
-          while (count > 0 && !stopGdsl) {
+          while (count > 0 && !ourGdslStopped) {
             ProgressManager.checkCanceled();
             final Pair<VirtualFile, GroovyDslExecutor> pair = queue.poll(20, TimeUnit.MILLISECONDS);
             if (pair != null) {
@@ -562,11 +564,11 @@
     }
   }
 
-  private static volatile boolean stopGdsl = false;
+  private static volatile boolean ourGdslStopped = false;
 
   @Nullable
   private static GroovyDslExecutor createExecutor(String text, VirtualFile vfile, final Project project) {
-    if (stopGdsl) {
+    if (ourGdslStopped) {
       return null;
     }
 
@@ -587,12 +589,12 @@
 
       //noinspection InstanceofCatchParameter
       if (e instanceof OutOfMemoryError) {
-        stopGdsl = true;
+        stopGdsl();
         throw (Error)e;
       }
       //noinspection InstanceofCatchParameter
       if (e instanceof NoClassDefFoundError) {
-        stopGdsl = true;
+        stopGdsl();
         throw (NoClassDefFoundError) e;
       }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslScript.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslScript.java
index 2ae6f07..6508533 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslScript.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/dsl/GroovyDslScript.java
@@ -27,7 +27,6 @@
 import com.intellij.psi.PsiType;
 import com.intellij.psi.ResolveState;
 import com.intellij.psi.scope.PsiScopeProcessor;
-import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.ProcessingContext;
 import com.intellij.util.containers.MultiMap;
 import groovy.lang.Closure;
@@ -77,7 +76,10 @@
 
       return holder.processMembers(descriptor, processor, state);
     }
-    catch (IncorrectOperationException e) {
+    catch (ProcessCanceledException e) {
+      throw e;
+    }
+    catch (Throwable e) {
       handleDslError(e);
       return true;
     }
@@ -136,6 +138,9 @@
     }
     if (file != null) {
       GroovyDslFileIndex.invokeDslErrorPopup(e, project, file);
+    } else {
+      LOG.info("Error when executing internal GDSL " + myPath, e);
+      GroovyDslFileIndex.stopGdsl();
     }
     return false;
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyImportHelper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyImportHelper.java
index 2b0dc1f..d6a3214 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyImportHelper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyImportHelper.java
@@ -23,6 +23,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
 import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
+import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager;
 import org.jetbrains.plugins.groovy.lang.resolve.DefaultImportContributor;
 import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
 
@@ -106,8 +107,9 @@
       }
     }
 
+    GroovyPsiManager groovyPsiManager = GroovyPsiManager.getInstance(file.getProject());
     for (String implicitlyImportedClass : GroovyFileBase.IMPLICITLY_IMPORTED_CLASSES) {
-      PsiClass clazz = facade.findClass(implicitlyImportedClass, file.getResolveScope());
+      PsiClass clazz = groovyPsiManager.findClassWithCache(implicitlyImportedClass, file.getResolveScope());
       if (clazz != null && !ResolveUtil.processElement(processor, clazz, state)) return false;
     }
     return true;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyImportOptimizer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyImportOptimizer.java
index fc7bbff..a909733 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyImportOptimizer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyImportOptimizer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
+import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.HashSet;
 import gnu.trove.TObjectIntHashMap;
@@ -56,7 +57,7 @@
 
   public static Set<GrImportStatement> findUsedImports(GroovyFile file) {
     Set<GrImportStatement> usedImports = new HashSet<GrImportStatement>();
-    processFile(file, null, null, usedImports, null, null, null, null);
+    processFile(file, null, null, usedImports, null, null, null, null, null);
     return usedImports;
   }
 
@@ -68,12 +69,15 @@
                                   @Nullable final Set<String> importedClasses,
                                   @Nullable final Set<String> staticallyImportedMembers,
                                   @Nullable final Set<GrImportStatement> usedImports,
+                                  @Nullable final Set<GrImportStatement> unresolvedOnDemandImports,
                                   @Nullable final Set<String> implicitlyImported,
                                   @Nullable final Set<String> innerClasses,
                                   @Nullable final Map<String, String> aliased,
                                   @Nullable final Map<String, String> annotations) {
     if (!(file instanceof GroovyFile)) return;
 
+    final Set<String> unresolvedReferenceNames = ContainerUtil.newLinkedHashSet();
+
     file.accept(new PsiRecursiveElementWalkingVisitor() {
       @Override
       public void visitElement(PsiElement element) {
@@ -84,22 +88,30 @@
       }
 
       private void visitRefElement(GrReferenceElement refElement) {
-        if ("super".equals(refElement.getReferenceName())) return;
+        final String refName = refElement.getReferenceName();
+
+        if ("super".equals(refName)) return;
 
         final GroovyResolveResult[] resolveResults = refElement.multiResolve(false);
+        if (resolveResults.length == 0 && refName != null) {
+          if (PsiTreeUtil.getParentOfType(refElement, GrImportStatement.class) == null) {
+            unresolvedReferenceNames.add(refName);
+          }
+        }
+
         for (GroovyResolveResult resolveResult : resolveResults) {
           final PsiElement context = resolveResult.getCurrentFileResolveContext();
-          final PsiElement element = resolveResult.getElement();
-          if (element == null) return;
+          final PsiElement resolved = resolveResult.getElement();
+          if (resolved == null) return;
 
           if (context instanceof GrImportStatement) {
             final GrImportStatement importStatement = (GrImportStatement)context;
 
-            if (usedImports != null && isImportUsed(refElement, element)) {
+            if (usedImports != null && isImportUsed(refElement, resolved)) {
               usedImports.add(importStatement);
             }
-            if (isImplicitlyImported(element, refElement.getReferenceName(), (GroovyFile)file)) {
-              addImplicitClass(element);
+            if (isImplicitlyImported(resolved, refName, (GroovyFile)file)) {
+              addImplicitClass(resolved);
             }
 
             if (!importStatement.isAliasedImport() && !isAnnotatedImport(importStatement)) {
@@ -107,8 +119,8 @@
               if (importStatement.isOnDemand()) {
 
                 if (importStatement.isStatic()) {
-                  if (element instanceof PsiMember) {
-                    final PsiMember member = (PsiMember)element;
+                  if (resolved instanceof PsiMember) {
+                    final PsiMember member = (PsiMember)resolved;
                     final PsiClass clazz = member.getContainingClass();
                     if (clazz != null) {
                       final String classQName = clazz.getQualifiedName();
@@ -122,7 +134,7 @@
                   }
                 }
                 else {
-                  importedName = getTargetQualifiedName(element);
+                  importedName = getTargetQualifiedName(resolved);
                 }
               }
               else {
@@ -152,14 +164,14 @@
                 if (importedClasses != null) {
                   importedClasses.add(importedName);
                 }
-                if (element instanceof PsiClass && ((PsiClass)element).getContainingClass() != null && innerClasses != null) {
+                if (resolved instanceof PsiClass && ((PsiClass)resolved).getContainingClass() != null && innerClasses != null) {
                   innerClasses.add(importedName);
                 }
               }
             }
           }
           else if (context == null && !(refElement.getParent() instanceof GrImportStatement) && refElement.getQualifier() == null) {
-            addImplicitClass(element);
+            addImplicitClass(resolved);
           }
         }
       }
@@ -179,8 +191,8 @@
       /**
        * checks if import for implicitly imported class is needed
        */
-      private boolean isImportUsed(GrReferenceElement refElement, PsiElement element) {
-        if (isImplicitlyImported(element, refElement.getReferenceName(), (GroovyFile)file)) {
+      private boolean isImportUsed(GrReferenceElement refElement, PsiElement resolved) {
+        if (isImplicitlyImported(resolved, refElement.getReferenceName(), (GroovyFile)file)) {
           final ClassResolverProcessor processor =
             new ClassResolverProcessor(refElement.getReferenceName(), refElement, ResolverProcessor.RESOLVE_KINDS_CLASS);
           processImports(ResolveState.initial(), null, refElement, processor, ((GroovyFile)file).getImportStatements(), true);
@@ -192,6 +204,53 @@
       }
     });
 
+    final Set<GrImportStatement> importsToCheck = ContainerUtil.newLinkedHashSet(PsiUtil.getValidImportStatements((GroovyFile)file));
+    for (GrImportStatement anImport : importsToCheck) {
+      if (usedImports != null && usedImports.contains(anImport)) continue;
+
+      final GrCodeReferenceElement ref = anImport.getImportReference();
+      assert ref != null : "invalid import!";
+
+      if (ref.resolve() == null) {
+        if (anImport.isOnDemand()) {
+          if (usedImports != null) {
+            usedImports.add(anImport);
+          }
+          if (unresolvedOnDemandImports != null) {
+            unresolvedOnDemandImports.add(anImport);
+          }
+        }
+        else {
+          String importedName = anImport.getImportedName();
+          if (importedName != null && unresolvedReferenceNames.contains(importedName)) {
+            if (usedImports != null) {
+              usedImports.add(anImport);
+            }
+
+            final String symbolName = getImportReferenceText(anImport);
+
+            if (anImport.isAliasedImport()) {
+              if (aliased != null) {
+                aliased.put(symbolName, importedName);
+              }
+            }
+            else {
+              if (anImport.isStatic()) {
+                if (staticallyImportedMembers != null) {
+                  staticallyImportedMembers.add(symbolName);
+                }
+              }
+              else {
+                if (importedClasses != null) {
+                  importedClasses.add(symbolName);
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+
     if (annotations != null) {
       ((GroovyFile)file).acceptChildren(new GroovyElementVisitor() {
         @Override
@@ -238,12 +297,13 @@
       final Set<String> simplyImportedClasses = new LinkedHashSet<String>();
       final Set<String> staticallyImportedMembers = new LinkedHashSet<String>();
       final Set<GrImportStatement> usedImports = new HashSet<GrImportStatement>();
+      final Set<GrImportStatement> unresolvedOnDemandImports = new HashSet<GrImportStatement>();
       final Set<String> implicitlyImportedClasses = new LinkedHashSet<String>();
       final Set<String> innerClasses = new HashSet<String>();
       Map<String, String> aliasImported = ContainerUtil.newHashMap();
       Map<String, String> annotatedImports = ContainerUtil.newHashMap();
 
-      processFile(myFile, simplyImportedClasses, staticallyImportedMembers, usedImports, implicitlyImportedClasses, innerClasses,
+      processFile(myFile, simplyImportedClasses, staticallyImportedMembers, usedImports, unresolvedOnDemandImports ,implicitlyImportedClasses, innerClasses,
                   aliasImported, annotatedImports);
       final List<GrImportStatement> oldImports = PsiUtil.getValidImportStatements(file);
       if (myRemoveUnusedOnly) {
@@ -258,7 +318,7 @@
       // Add new import statements
       GrImportStatement[] newImports =
         prepare(usedImports, simplyImportedClasses, staticallyImportedMembers, implicitlyImportedClasses, innerClasses, aliasImported,
-                annotatedImports);
+                annotatedImports, unresolvedOnDemandImports);
       if (oldImports.isEmpty() && newImports.length == 0 && aliasImported.isEmpty()) {
         return;
       }
@@ -295,7 +355,8 @@
                                         Set<String> implicitlyImported,
                                         Set<String> innerClasses,
                                         Map<String, String> aliased,
-                                        final Map<String, String> annotations) {
+                                        final Map<String, String> annotations,
+                                        Set<GrImportStatement> unresolvedOnDemandImports) {
       final Project project = myFile.getProject();
       final GroovyCodeStyleSettings settings =
         CodeStyleSettingsManager.getSettings(project).getCustomSettings(GroovyCodeStyleSettings.class);
@@ -432,6 +493,10 @@
         first.getAnnotationList().replace(factory.createModifierList(allSkippedAnnotations));
       }
 
+      for (GrImportStatement anImport : unresolvedOnDemandImports) {
+        explicated.add(anImport);
+      }
+
       return explicated.toArray(new GrImportStatement[explicated.size()]);
     }
   }
@@ -463,7 +528,7 @@
   private static String getImportReferenceText(GrImportStatement statement) {
     GrCodeReferenceElement importReference = statement.getImportReference();
     if (importReference != null) {
-      return statement.getText().substring(importReference.getStartOffsetInParent());
+      return importReference.getClassNameText();
     }
     return null;
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java
index d6b80d3..17b8339 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/GroovyReferenceCopyPasteProcessor.java
@@ -22,6 +22,7 @@
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.*;
 import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
@@ -125,9 +126,10 @@
           }
           else {
             LOG.assertTrue(reference instanceof GrReferenceExpression);
-            PsiMethod[] members = refClass.findMethodsByName(refData.staticMemberName, true);
-            if (members.length == 0) return;
-            ((GrReferenceExpression)reference).bindToElementViaStaticImport(members[0]);
+            PsiMember member = findMember(refData, refClass);
+            if (member != null) {
+              ((GrReferenceExpression)reference).bindToElementViaStaticImport(member);
+            }
           }
         }
       }
@@ -137,5 +139,19 @@
     }
   }
 
-  
+
+  @Nullable
+  private static PsiMember findMember(ReferenceData refData, PsiClass refClass) {
+    PsiField field = refClass.findFieldByName(refData.staticMemberName, true);
+    if (field != null) {
+      return field;
+    }
+
+    PsiMethod[] methods = refClass.findMethodsByName(refData.staticMemberName, true);
+    if (methods.length != 0) {
+      return methods[0];
+    }
+
+    return null;
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/actions/GroovyEnterHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/actions/GroovyEnterHandler.java
index c31b59b..aecc2dd 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/actions/GroovyEnterHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/actions/GroovyEnterHandler.java
@@ -21,7 +21,6 @@
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.openapi.actionSystem.DataContext;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
 import com.intellij.openapi.editor.CaretModel;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
@@ -130,18 +129,18 @@
     Project project = file.getProject();
     CaretModel caretModel = editor.getCaretModel();
 
-    String text = document.getText();
-    if (StringUtil.isEmpty(text)) {
+    if (!(file instanceof GroovyFileBase)) {
       return Result.Continue;
     }
 
-    if (!(file instanceof GroovyFileBase)) {
+    int docLength = document.getTextLength();
+    if (docLength == 0) {
       return Result.Continue;
     }
 
     final int caret = caretModel.getOffset();
     final EditorHighlighter highlighter = ((EditorEx)editor).getHighlighter();
-    if (caret >= 1 && caret < text.length() && CodeInsightSettings.getInstance().SMART_INDENT_ON_ENTER) {
+    if (caret >= 1 && caret < docLength && CodeInsightSettings.getInstance().SMART_INDENT_ON_ENTER) {
       HighlighterIterator iterator = highlighter.createIterator(caret);
       iterator.retreat();
       while (!iterator.atEnd() && TokenType.WHITE_SPACE == iterator.getTokenType()) {
@@ -164,7 +163,7 @@
         if (element != null &&
             element.getNode().getElementType() == mRCURLY &&
             element.getParent() instanceof GrClosableBlock &&
-            text.length() > caret && afterArrow) {
+            docLength > caret && afterArrow) {
           return Result.DefaultForceIndent;
         }
       }
@@ -298,7 +297,7 @@
 
     boolean isInsertIndent = isInsertIndent(caretOffset, stringElement.getTextRange().getStartOffset(), fileText);
 
-    // For simple String literals like 'abcdef'
+    // For simple String literals like 'abc'
     CaretModel caretModel = editor.getCaretModel();
     if (nodeElementType == mSTRING_LITERAL) {
       if (isSingleQuoteString(stringElement)) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyBlockStatementsSelectioner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyBlockStatementsSelectioner.java
index eb023ac..545e0ec 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyBlockStatementsSelectioner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyBlockStatementsSelectioner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -51,7 +51,7 @@
     PsiElement lbrace = block.getLBrace();
     if (lbrace == null) return block.getTextRange().getStartOffset();
 
-    while (PsiImplUtil.isWhiteSpace(lbrace.getNextSibling())) {
+    while (PsiImplUtil.isWhiteSpaceOrNls(lbrace.getNextSibling())) {
       lbrace = lbrace.getNextSibling();
     }
     return lbrace.getTextRange().getEndOffset();
@@ -61,7 +61,7 @@
     PsiElement rbrace = block.getRBrace();
     if (rbrace == null) return block.getTextRange().getEndOffset();
 
-    while (PsiImplUtil.isWhiteSpace(rbrace.getPrevSibling()) && rbrace.getPrevSibling().getTextRange().getStartOffset() > startOffset) {
+    while (PsiImplUtil.isWhiteSpaceOrNls(rbrace.getPrevSibling()) && rbrace.getPrevSibling().getTextRange().getStartOffset() > startOffset) {
       rbrace = rbrace.getPrevSibling();
     }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyStatementSelectioner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyStatementSelectioner.java
index 12df73c..257ac99 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyStatementSelectioner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyStatementSelectioner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,9 +21,9 @@
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiWhiteSpace;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
-import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 
 import java.util.List;
@@ -130,7 +130,7 @@
 
   private static boolean isOneLineFeed(PsiElement e) {
     if (e == null) return false;
-    if (!TokenSets.WHITE_SPACES_SET.contains(e.getNode().getElementType())) return false;
+    if (!PsiImplUtil.isWhiteSpaceOrNls(e)) return false;
 
     final String text = e.getText();
     final int i = text.indexOf('\n');
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyTypeDefinitionBodySelectioner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyTypeDefinitionBodySelectioner.java
index 3125606..ba5d061 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyTypeDefinitionBodySelectioner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/editor/selection/GroovyTypeDefinitionBodySelectioner.java
@@ -49,7 +49,7 @@
     PsiElement lbrace = block.getLBrace();
     if (lbrace == null) return block.getTextRange().getStartOffset();
 
-    while (PsiImplUtil.isWhiteSpace(lbrace.getNextSibling())) {
+    while (PsiImplUtil.isWhiteSpaceOrNls(lbrace.getNextSibling())) {
       lbrace = lbrace.getNextSibling();
     }
     return lbrace.getTextRange().getEndOffset();
@@ -59,7 +59,7 @@
     PsiElement rbrace = block.getRBrace();
     if (rbrace == null) return block.getTextRange().getEndOffset();
 
-    while (PsiImplUtil.isWhiteSpace(rbrace.getPrevSibling()) && rbrace.getPrevSibling().getTextRange().getStartOffset() > startOffset) {
+    while (PsiImplUtil.isWhiteSpaceOrNls(rbrace.getPrevSibling()) && rbrace.getPrevSibling().getTextRange().getStartOffset() > startOffset) {
       rbrace = rbrace.getPrevSibling();
     }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodDescriptor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodDescriptor.java
index 4f06c15..64767e0 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodDescriptor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodDescriptor.java
@@ -80,6 +80,19 @@
     }
   }
 
+  @Property(surroundWithTag = false)
+  @AbstractCollection(surroundWithTag = false)
+  public ClosureArgument[] myClosureArguments;
+
+  @Tag("closureArgument")
+  public static class ClosureArgument {
+    @Attribute("index")
+    public int index;
+
+    @Attribute("methodContributor")
+    public String methodContributor;
+  }
+
   @Nullable
   public List<String> getParams() {
     if (params != null) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java
index 7730c6f..8365a38 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/GroovyMethodInfo.java
@@ -11,6 +11,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder;
+import org.jetbrains.plugins.groovy.lang.resolve.ClosureMissingMethodContributor;
 import org.jetbrains.plugins.groovy.refactoring.GroovyNamesUtil;
 import org.jetbrains.plugins.groovy.util.FixedValuesReferenceProvider;
 
@@ -40,6 +41,8 @@
 
   private Map<String, NamedArgumentReference> myNamedArgReferenceProviders;
 
+  private final GroovyMethodDescriptor myDescriptor;
+
   private static void ensureInit() {
     if (METHOD_INFOS != null) return;
 
@@ -131,6 +134,8 @@
 
   private GroovyMethodInfo(GroovyMethodDescriptor method, @NotNull ClassLoader classLoader) {
     myClassLoader = classLoader;
+    myDescriptor = method;
+
     myParams = method.getParams();
     myReturnType = method.returnType;
     myReturnTypeCalculatorClassName = method.returnTypeCalculator;
@@ -153,6 +158,12 @@
       for (NamedArgumentReference r : myNamedArgReferenceProviders.values()) {
         assertClassExists(r.myProviderClassName, PsiReferenceProvider.class, GroovyNamedArgumentReferenceProvider.class);
       }
+
+      if (method.myClosureArguments != null) {
+        for (GroovyMethodDescriptor.ClosureArgument argument : method.myClosureArguments) {
+          assertClassExists(argument.methodContributor, ClosureMissingMethodContributor.class);
+        }
+      }
     }
   }
 
@@ -174,6 +185,10 @@
     }
   }
 
+  public GroovyMethodDescriptor getDescriptor() {
+    return myDescriptor;
+  }
+
   private static Map<String, NamedArgumentReference> getNamedArgumentsReferenceProviders(GroovyMethodDescriptor methodDescriptor) {
     if (methodDescriptor.myArguments == null) return Collections.emptyMap();
 
@@ -293,6 +308,10 @@
     return myNamedArgProviderInstance;
   }
 
+  public ClassLoader getPluginClassLoader() {
+    return myClassLoader;
+  }
+
   public boolean isApplicable(@NotNull PsiMethod method) {
     if (myParams == null) {
       return true;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/NamedArgumentDescriptor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/NamedArgumentDescriptor.java
index c870de6..910a3a9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/NamedArgumentDescriptor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/extensions/NamedArgumentDescriptor.java
@@ -142,7 +142,7 @@
     @NotNull
     @Override
     public GroovyResolveResult[] multiResolve(boolean incompleteCode) {
-      return new GroovyResolveResult[]{new GroovyResolveResultImpl(myNavigationElement, null, null, mySubstitutor, true, true, false)};
+      return new GroovyResolveResult[]{new GroovyResolveResultImpl(myNavigationElement, null, null, mySubstitutor, true, true)};
     }
   }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/AnnotatedMembersSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/AnnotatedMembersSearcher.java
index 86aec32..b8fe585 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/AnnotatedMembersSearcher.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/AnnotatedMembersSearcher.java
@@ -53,7 +53,7 @@
     final Collection<PsiElement> members = ApplicationManager.getApplication().runReadAction(new Computable<Collection<PsiElement>>() {
       @Override
       public Collection<PsiElement> compute() {
-        return StubIndex.getInstance().get(GrAnnotatedMemberIndex.KEY, name, clazz.getProject(), scope);
+        return StubIndex.getElements(GrAnnotatedMemberIndex.KEY, name, clazz.getProject(), scope, PsiElement.class);
       }
     });
     if (members.isEmpty()) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrFileItemPresentationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrFileItemPresentationProvider.java
index 33796ce5..b8e5898 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrFileItemPresentationProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GrFileItemPresentationProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 import com.intellij.navigation.ItemPresentationProviders;
 import com.intellij.openapi.util.Iconable;
 import com.intellij.psi.PsiDirectory;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.GroovyBundle;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
 
@@ -27,7 +28,7 @@
 
 public class GrFileItemPresentationProvider implements ItemPresentationProvider<GroovyFile> {
   @Override
-  public ItemPresentation getPresentation(final GroovyFile file) {
+  public ItemPresentation getPresentation(@NotNull final GroovyFile file) {
     return new ItemPresentation() {
       @Override
       public String getPresentableText() {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyFieldFindUsagesHandlerFactory.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyFieldFindUsagesHandlerFactory.java
index ed95d06..676770c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyFieldFindUsagesHandlerFactory.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/findUsages/GroovyFieldFindUsagesHandlerFactory.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,7 +22,6 @@
 import com.intellij.ide.util.SuperMethodWarningUtil;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiElement;
@@ -70,7 +69,7 @@
               if (ApplicationManager.getApplication().isUnitTestMode()) return PsiElement.EMPTY_ARRAY;
               doSearch = Messages.showYesNoDialog(FindBundle.message("find.field.accessors.prompt", field.getName()),
                                              FindBundle.message("find.field.accessors.title"),
-                                             Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE;
+                                             Messages.getQuestionIcon()) == Messages.YES;
             }
             else {
               doSearch = true;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/AlignmentProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/AlignmentProvider.java
index 8159008..5c052f4 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/AlignmentProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/AlignmentProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,40 +58,18 @@
       }
 
       if (myAlignments.containsKey(set2)) {
-        for (Iterator<PsiElement> iterator = set1.iterator(); iterator.hasNext(); ) {
-          PsiElement element = iterator.next();
-          iterator.remove();
-
-          addInternal(set2, element);
-        }
+        addSet(set1, set2);
       }
       else {
         set1.addAll(set2);
-        for (Iterator<PsiElement> iterator = set2.iterator(); iterator.hasNext(); ) {
-          PsiElement element = iterator.next();
-          iterator.remove();
-
-          addInternal(set1, element);
-        }
+        addSet(set2, set1);
       }
     }
     else if (set1 != null) {
-      if (allowBackwardShift != null) {
-        assert myAllowBackwardShift.get(set1).booleanValue() == allowBackwardShift.booleanValue();
-      }
-      if (anchor != null) {
-        assert myAnchor.get(set1) == anchor;
-      }
-      addInternal(set1, e2);
+      addElement(e2, allowBackwardShift, anchor, set1);
     }
     else if (set2 != null) {
-      if (allowBackwardShift != null) {
-        assert(myAllowBackwardShift.get(set2).booleanValue() == allowBackwardShift.booleanValue());
-      }
-      if (anchor != null) {
-        assert(myAnchor.get(set2) == anchor);
-      }
-      addInternal(set2, e1);
+      addElement(e1, allowBackwardShift, anchor, set2);
     }
     else {
       final HashSet<PsiElement> set = createHashSet();
@@ -102,6 +80,25 @@
     }
   }
 
+  private void addElement(PsiElement e, Boolean allowBackwardShift, Alignment.Anchor anchor, Set<PsiElement> set) {
+    if (allowBackwardShift != null) {
+      assert myAllowBackwardShift.get(set).booleanValue() == allowBackwardShift.booleanValue();
+    }
+    if (anchor != null) {
+      assert myAnchor.get(set) == anchor;
+    }
+    addInternal(set, e);
+  }
+
+  private void addSet(Set<PsiElement> set1, Set<PsiElement> set2) {
+    for (Iterator<PsiElement> iterator = set1.iterator(); iterator.hasNext(); ) {
+      PsiElement element = iterator.next();
+      iterator.remove();
+
+      addInternal(set2, element);
+    }
+  }
+
   private void addInternal(@NotNull Set<PsiElement> set, @NotNull PsiElement element) {
     myTree.put(element, set);
     set.add(element);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GeeseUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GeeseUtil.java
index 30115c2..667be21 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GeeseUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GeeseUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,10 +26,10 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 
 import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mRCURLY;
-import static org.jetbrains.plugins.groovy.lang.lexer.TokenSets.WHITE_SPACES_SET;
 import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.CLOSABLE_BLOCK;
 
 /**
@@ -50,7 +50,7 @@
     }
 
     ASTNode lastChild = node.getLastChildNode();
-    while (lastChild != null && WHITE_SPACES_SET.contains(lastChild.getElementType())) {
+    while (lastChild != null && PsiImplUtil.isWhiteSpaceOrNls(lastChild)) {
       lastChild = lastChild.getTreePrev();
     }
     if (lastChild == null) return null;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyFormattingModelBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyFormattingModelBuilder.java
index 226e23d..a095273 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyFormattingModelBuilder.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyFormattingModelBuilder.java
@@ -39,7 +39,7 @@
 import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
 import org.jetbrains.plugins.groovy.formatter.blocks.GroovyBlock;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
-import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 
 
 /**
@@ -94,12 +94,12 @@
     @Override
     protected String replaceWithPsiInLeaf(TextRange textRange, String whiteSpace, ASTNode leafElement) {
       if (!myCanModifyAllWhiteSpaces) {
-        if (TokenSets.WHITE_SPACES_SET.contains(leafElement.getElementType())) return null;
+        if (PsiImplUtil.isWhiteSpaceOrNls(leafElement)) return null;
       }
 
       IElementType elementTypeToUse = TokenType.WHITE_SPACE;
       ASTNode prevNode = TreeUtil.prevLeaf(leafElement);
-      if (prevNode != null && TokenSets.WHITE_SPACES_SET.contains(prevNode.getElementType())) {
+      if (prevNode != null && PsiImplUtil.isWhiteSpaceOrNls(prevNode)) {
         elementTypeToUse = prevNode.getElementType();
       }
       FormatterUtil.replaceWhiteSpace(whiteSpace, leafElement, elementTypeToUse, textRange);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java
index c2ac05a..bba1441 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/blocks/GroovyBlockGenerator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
 import com.intellij.psi.tree.TokenSet;
 import com.intellij.util.Function;
 import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.GroovyFileType;
 import org.jetbrains.plugins.groovy.formatter.AlignmentProvider;
@@ -40,6 +41,7 @@
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
 import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
 import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
+import org.jetbrains.plugins.groovy.lang.parser.GroovyParserDefinition;
 import org.jetbrains.plugins.groovy.lang.psi.GrQualifiedReference;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
@@ -301,12 +303,20 @@
       if (myContext.getSettings().ALIGN_MULTILINE_TERNARY_OPERATION) {
         final GrConditionalExpression conditional = (GrConditionalExpression)blockPsi;
 
-        final AlignmentProvider.Aligner aligner = myAlignmentProvider.createAligner(false);
-        aligner.append(conditional.getCondition());
+        final AlignmentProvider.Aligner exprAligner = myAlignmentProvider.createAligner(false);
+        exprAligner.append(conditional.getCondition());
         if (!(conditional instanceof GrElvisExpression)) {
-          aligner.append(conditional.getThenBranch());
+          exprAligner.append(conditional.getThenBranch());
         }
-        aligner.append(conditional.getElseBranch());
+        exprAligner.append(conditional.getElseBranch());
+
+        ASTNode question = conditional.getNode().findChildByType(GroovyTokenTypes.mQUESTION);
+        ASTNode colon = conditional.getNode().findChildByType(GroovyTokenTypes.mCOLON);
+        if (question != null && colon != null) {
+          AlignmentProvider.Aligner questionColonAligner = myAlignmentProvider.createAligner(false);
+          questionColonAligner.append(question.getPsi());
+          questionColonAligner.append(colon.getPsi());
+        }
       }
     }
 
@@ -319,25 +329,28 @@
   }
 
   private Wrap getChildWrap(ASTNode childNode) {
-    final Wrap wrap = myWrappingProcessor.getChildWrap(childNode);
-    return wrap;
+    return myWrappingProcessor.getChildWrap(childNode);
   }
 
+  @NotNull
   public List<Block> generateSubBlockForCodeBlocks(boolean classLevel, final List<ASTNode> children, boolean indentLabelBlocks) {
 
-    calculateAlignments(children, classLevel);
     final ArrayList<Block> subBlocks = new ArrayList<Block>();
 
-    if (indentLabelBlocks) {
-      for (int i = 0; i < children.size(); i++) {
-        ASTNode childNode = children.get(i);
+    if (indentLabelBlocks && isCodeBlock()) {
+      List<ASTNode> flattenChildren = flattenChildren(children);
+      calculateAlignments(flattenChildren, classLevel);
+      for (int i = 0; i < flattenChildren.size(); i++) {
+        ASTNode childNode = flattenChildren.get(i);
         if (childNode.getElementType() == LABELED_STATEMENT) {
-          int j = i;
+          int start = i;
           do {
             i++;
           }
-          while (i < children.size() && children.get(i).getElementType() != LABELED_STATEMENT && children.get(i).getElementType() != mRCURLY);
-          subBlocks.add(new GrLabelBlock(childNode, children.subList(j, i), classLevel, getIndent(childNode), getChildWrap(childNode), myContext));
+          while (i < flattenChildren.size() &&
+                 flattenChildren.get(i).getElementType() != LABELED_STATEMENT &&
+                 flattenChildren.get(i).getElementType() != mRCURLY);
+          subBlocks.add(new GrLabelBlock(childNode, flattenChildren.subList(start + 1, i), classLevel, getIndent(childNode), getChildWrap(childNode), myContext));
           i--;
         }
         else {
@@ -346,6 +359,8 @@
       }
     }
     else {
+      calculateAlignments(children, classLevel);
+
       for (ASTNode childNode : children) {
         subBlocks.add(new GroovyBlock(childNode, getIndent(childNode), getChildWrap(childNode), myContext));
       }
@@ -353,6 +368,31 @@
     return subBlocks;
   }
 
+  private boolean isCodeBlock() {
+    IElementType type = myNode.getElementType();
+    return type == OPEN_BLOCK ||
+           type == CLOSABLE_BLOCK ||
+           type == CONSTRUCTOR_BODY ||
+           type == GroovyParserDefinition.GROOVY_FILE;
+  }
+
+  private static List<ASTNode> flattenChildren(List<ASTNode> children) {
+    ArrayList<ASTNode> result = ContainerUtil.newArrayList();
+    for (ASTNode child : children) {
+      processNodeFlattening(result, child);
+    }
+    return result;
+  }
+
+  private static void processNodeFlattening(ArrayList<ASTNode> result, ASTNode child) {
+    result.add(child);
+    if (child.getElementType() == LABELED_STATEMENT) {
+      for (ASTNode node : visibleChildren(child)) {
+        processNodeFlattening(result, node);
+      }
+    }
+  }
+
   private Indent getIndent(ASTNode childNode) {
     return new GroovyIndentProcessor().getChildIndent(myBlock, childNode);
   }
@@ -365,7 +405,7 @@
       PsiElement psi = child.getPsi();
       if (psi instanceof GrLabeledStatement) {
         alignGroup(currentGroup, spock, classLevel);
-        currentGroup = ContainerUtil.newArrayList((GrStatement)psi);
+        currentGroup = ContainerUtil.newArrayList(/*(GrStatement)psi*/);
         spock = true;
       }
       else if (currentGroup != null && spock && isTablePart(psi)) {
@@ -383,18 +423,26 @@
         }
       }
       else {
-        if (psi instanceof PsiComment) {
-          PsiElement prev = psi.getPrevSibling();
-          if (prev != null && prev.getNode().getElementType() != mNLS || classLevel && !fieldGroupEnded(psi)) {
-            continue;
-          }
-        }
+        if (shouldSkip(classLevel, psi)) continue;
         alignGroup(currentGroup, spock, classLevel);
         currentGroup = null;
       }
     }
   }
 
+  private boolean shouldSkip(boolean classLevel, PsiElement psi) {
+    if (psi instanceof PsiComment) {
+      PsiElement prev = psi.getPrevSibling();
+      if (prev != null && prev.getNode().getElementType() != mNLS || classLevel && !fieldGroupEnded(psi)) {
+        return true;
+      }
+    }
+    if (psi.getParent() instanceof GrLabeledStatement && !(psi instanceof GrStatement)) {
+      return true;
+    }
+    return false;
+  }
+
   private void alignGroup(@Nullable List<GrStatement> group, boolean spock, boolean classLevel) {
     if (group == null) {
       return;
@@ -432,7 +480,7 @@
     if (group.size() < 2) {
       return;
     }
-    GrStatement inner = ((GrLabeledStatement)group.get(0)).getStatement();
+    GrStatement inner = group.get(0);
     boolean embedded = inner != null && isTablePart(inner);
 
     GrStatement first = embedded ? inner : group.get(1);
@@ -508,7 +556,6 @@
     return blockPsi instanceof GrParameterList && myContext.getSettings().ALIGN_MULTILINE_PARAMETERS ||
            blockPsi instanceof GrExtendsClause && myContext.getSettings().ALIGN_MULTILINE_EXTENDS_LIST ||
            blockPsi instanceof GrThrowsClause && myContext.getSettings().ALIGN_MULTILINE_THROWS_LIST ||
-           blockPsi instanceof GrConditionalExpression && myContext.getSettings().ALIGN_MULTILINE_TERNARY_OPERATION ||
            blockPsi instanceof GrListOrMap && myContext.getGroovySettings().ALIGN_MULTILINE_LIST_OR_MAP;
   }
 
@@ -516,7 +563,6 @@
     return blockPsi instanceof GrParameterList ||
         blockPsi instanceof GrArgumentList ||
         blockPsi instanceof GrAssignmentExpression ||
-        blockPsi instanceof GrConditionalExpression ||
         blockPsi instanceof GrExtendsClause ||
         blockPsi instanceof GrThrowsClause ||
         blockPsi instanceof GrListOrMap;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/models/spacing/SpacingTokens.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/models/spacing/SpacingTokens.java
index b630a9c..9dde8ff 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/models/spacing/SpacingTokens.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/models/spacing/SpacingTokens.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,9 +37,10 @@
 
   TokenSet LOGICAL_OPERATORS = TokenSet.create(mLAND, mLOR);
   TokenSet EQUALITY_OPERATORS = TokenSet.create(mEQUAL, mNOT_EQUAL);
-  TokenSet RELATIONAL_OPERATORS = TokenSet.create(mGT, mGE, mLT, mLE);
+  TokenSet RELATIONAL_OPERATORS = TokenSet.create(mGT, mGE, mLT, mLE, mCOMPARE_TO);
   TokenSet BITWISE_OPERATORS = TokenSet.create(mBAND, mBOR, mBXOR);
   TokenSet ADDITIVE_OPERATORS = TokenSet.create(mPLUS, mMINUS);
   TokenSet MULTIPLICATIVE_OPERATORS = TokenSet.create(mSTAR, mDIV, mMOD);
   TokenSet SHIFT_OPERATORS = TokenSet.create(COMPOSITE_LSHIFT_SIGN, COMPOSITE_RSHIFT_SIGN, COMPOSITE_TRIPLE_SHIFT_SIGN);
+  TokenSet REGEX_OPERATORS = TokenSet.create(mREGEX_FIND, mREGEX_MATCH);
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java
index 2cc72c3..c81df59c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,6 +38,8 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrThrowsClause;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationArrayInitializer;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationNameValuePair;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.*;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
@@ -45,15 +47,19 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrAssertStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrConditionalExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrParenthesizedExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForClause;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForInClause;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameterList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
+import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
+import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeParameterList;
+import org.jetbrains.plugins.groovy.lang.psi.api.types.GrWildcardTypeArgument;
 
 import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.*;
 
@@ -89,7 +95,8 @@
       }
     }
     if (parentBlock instanceof GrLabelBlock) {
-      return myChildType == LABELED_STATEMENT
+      ASTNode first = parentBlock.getNode().getFirstChildNode();
+      return child == first
              ? Indent.getNoneIndent()
              : Indent.getLabelIndent();
 
@@ -118,6 +125,13 @@
   }
 
   @Override
+  public void visitAnnotationArrayInitializer(GrAnnotationArrayInitializer arrayInitializer) {
+    if (myChildType != mLBRACK && myChildType != mRBRACK) {
+      myResult = Indent.getContinuationWithoutFirstIndent();
+    }
+  }
+
+  @Override
   public void visitListOrMap(GrListOrMap listOrMap) {
     if (myChildType != mLBRACK && myChildType != mRBRACK) {
       myResult = Indent.getContinuationWithoutFirstIndent();
@@ -212,9 +226,7 @@
 
   @Override
   public void visitVariable(GrVariable variable) {
-    if (myChild == variable.getInitializerGroovy()) {
-      myResult = Indent.getContinuationIndent();
-    }
+    myResult = Indent.getContinuationWithoutFirstIndent();
   }
 
   @Override
@@ -369,5 +381,67 @@
     myResult = Indent.getContinuationWithoutFirstIndent();
   }
 
+  @Override
+  public void visitArrayDeclaration(GrArrayDeclaration arrayDeclaration) {
+    myResult = Indent.getContinuationWithoutFirstIndent();
+  }
+
+  @Override
+  public void visitExpression(GrExpression expression) {
+    myResult = Indent.getContinuationWithoutFirstIndent();
+  }
+
+  @Override
+  public void visitTypeArgumentList(GrTypeArgumentList typeArgumentList) {
+    myResult = Indent.getContinuationWithoutFirstIndent();
+  }
+
+  @Override
+  public void visitCodeReferenceElement(GrCodeReferenceElement refElement) {
+    myResult = Indent.getContinuationWithoutFirstIndent();
+  }
+
+  @Override
+  public void visitWildcardTypeArgument(GrWildcardTypeArgument wildcardTypeArgument) {
+    myResult = Indent.getContinuationWithoutFirstIndent();
+  }
+
+  @Override
+  public void visitDefaultAnnotationValue(GrDefaultAnnotationValue defaultAnnotationValue) {
+    myResult = Indent.getContinuationIndent();
+  }
+
+  @Override
+  public void visitAnnotationNameValuePair(GrAnnotationNameValuePair nameValuePair) {
+    myResult = Indent.getContinuationWithoutFirstIndent();
+  }
+
+  @Override
+  public void visitForInClause(GrForInClause forInClause) {
+    myResult = Indent.getContinuationWithoutFirstIndent();
+  }
+
+  @Override
+  public void visitForClause(GrForClause forClause) {
+    myResult = Indent.getContinuationWithoutFirstIndent();
+  }
+
+  @Override
+  public void visitCatchClause(GrCatchClause catchClause) {
+    if (myChild == catchClause.getBody()) {
+      myResult = Indent.getNoneIndent();
+    }
+    else {
+      myResult = Indent.getContinuationWithoutFirstIndent();
+    }
+  }
+
+  @Override
+  public void visitTypeParameterList(GrTypeParameterList list) {
+    myResult = Indent.getContinuationWithoutFirstIndent();
+  }
+
+
+
 }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java
index ea559fa..e64154c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -45,6 +45,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.*;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrSpreadArgument;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForInClause;
@@ -63,6 +64,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrArrayTypeElement;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeParameterList;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 
 import static org.jetbrains.plugins.groovy.GroovyFileType.GROOVY_LANGUAGE;
 import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.*;
@@ -75,6 +77,7 @@
 import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.mGDOC_COMMENT_START;
 import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.mQUESTION;
 import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.mSEMI;
+import static org.jetbrains.plugins.groovy.formatter.models.spacing.SpacingTokens.mSTAR;
 import static org.jetbrains.plugins.groovy.lang.groovydoc.lexer.GroovyDocTokenTypes.mGDOC_ASTERISKS;
 import static org.jetbrains.plugins.groovy.lang.groovydoc.lexer.GroovyDocTokenTypes.mGDOC_INLINE_TAG_END;
 import static org.jetbrains.plugins.groovy.lang.groovydoc.lexer.GroovyDocTokenTypes.mGDOC_INLINE_TAG_START;
@@ -181,10 +184,11 @@
 
   private boolean manageComments() {
     if (mySettings.KEEP_FIRST_COLUMN_COMMENT && COMMENT_SET.contains(myType2)) {
-      if (myType1 != IMPORT_STATEMENT) {
+      if (!isAfterElementOrSemi(IMPORT_STATEMENT)) {
         myResult = Spacing.createKeepingFirstColumnSpacing(0, Integer.MAX_VALUE, true, 1);
+        return true;
       }
-      return true;
+      return false;
     }
 
     ASTNode prev = FormatterUtil.getPreviousNonWhitespaceLeaf(myChild2);
@@ -211,7 +215,7 @@
   @Override
   public void visitLabeledStatement(GrLabeledStatement labeledStatement) {
     if (myType1 == mCOLON) {
-      if (myGroovySettings.INDENT_LABEL_BLOCKS) {
+      if (myGroovySettings.INDENT_LABEL_BLOCKS && !(myType2 == LITERAL)) {
         createLF(true);
       }
       else {
@@ -357,29 +361,36 @@
   }
 
   @Override
+  public void visitSpreadArgument(GrSpreadArgument spreadArgument) {
+    if (myType1 == mSTAR) {
+      createSpaceInCode(mySettings.SPACE_AROUND_UNARY_OPERATOR);
+    }
+  }
+
+  @Override
   public void visitFile(GroovyFileBase file) {
     if (isAfterElementOrSemi(PACKAGE_DEFINITION)) {
-      myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_PACKAGE + 1, mySettings.KEEP_LINE_BREAKS, Integer.MAX_VALUE / 2);
+      myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_PACKAGE + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
     }
     else if (myType2 == PACKAGE_DEFINITION) {
-      myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_BEFORE_PACKAGE + 1, mySettings.KEEP_LINE_BREAKS, Integer.MAX_VALUE / 2);
+      myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_BEFORE_PACKAGE + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
     }
     else if (isLeftOrRight(TYPE_DEFINITION_TYPES)) {
       if (myType1 == GROOVY_DOC_COMMENT) {
         createLF(true);
       }
       else {
-        myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AROUND_CLASS + 1, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS);
+        myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AROUND_CLASS + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
       }
     }
     else if (isAfterElementOrSemi(IMPORT_STATEMENT) && myType2 != IMPORT_STATEMENT) { //after imports
-      myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_IMPORTS + 1, mySettings.KEEP_LINE_BREAKS, Integer.MAX_VALUE / 2);
+      myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_AFTER_IMPORTS + 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
     }
     else if (myType1 != IMPORT_STATEMENT && !isSemiAfter(IMPORT_STATEMENT) && myType2 == IMPORT_STATEMENT) { //before imports
-      myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_BEFORE_IMPORTS, mySettings.KEEP_LINE_BREAKS, Integer.MAX_VALUE / 2);
+      myResult = Spacing.createSpacing(0, 0, mySettings.BLANK_LINES_BEFORE_IMPORTS, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
     }
     else if (isAfterElementOrSemi(IMPORT_STATEMENT) && myType2 == IMPORT_STATEMENT) {
-      myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, Integer.MAX_VALUE / 2);
+      myResult = Spacing.createSpacing(0, 0, 1, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
     }
     else {
       processClassMembers(null);
@@ -387,7 +398,7 @@
   }
 
   private boolean isAfterElementOrSemi(final IElementType elementType) {
-    return myType1 == elementType && myType2 != mSEMI || isSemiAfter(PACKAGE_DEFINITION);
+    return myType1 == elementType && myType2 != mSEMI || isSemiAfter(elementType);
   }
 
   private boolean isSemiAfter(@NotNull IElementType statement) {
@@ -571,7 +582,7 @@
   @Override
   public void visitTypeArgumentList(GrTypeArgumentList typeArgumentList) {
     if (myType1 == mLT || myType2 == mGT) {
-      createSpaceProperty(false, true, 1);
+      createSpaceInCode(false);
     }
   }
 
@@ -775,6 +786,7 @@
                           isLeftOrRight(ADDITIVE_OPERATORS)       ? mySettings.SPACE_AROUND_ADDITIVE_OPERATORS :
                           isLeftOrRight(MULTIPLICATIVE_OPERATORS) ? mySettings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS :
                           isLeftOrRight(SHIFT_OPERATORS)          ? mySettings.SPACE_AROUND_SHIFT_OPERATORS :
+                          isLeftOrRight(REGEX_OPERATORS)          ? myGroovySettings.SPACE_AROUND_REGEX_OPERATORS :
                           isLeftOrRight(kIN);
     if (TokenSets.BINARY_OP_SET.contains(myType2)) {
       createDependentLFSpacing(mySettings.BINARY_OPERATION_SIGN_ON_NEXT_LINE, spaceAround, expression.getTextRange());
@@ -846,7 +858,7 @@
   }
 
   private void createLazySpace() {
-    myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
+    myResult = Spacing.createSpacing(0, Integer.MAX_VALUE, 0, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
   }
 
   public void visitDocTag(GrDocTag docTag) {
@@ -1009,11 +1021,7 @@
   }
 
   private void createSpaceInCode(final boolean space) {
-    createSpaceProperty(space, keepBlankLines());
-  }
-
-  private void createSpaceProperty(boolean space, int keepBlankLines) {
-    createSpaceProperty(space, mySettings.KEEP_LINE_BREAKS, keepBlankLines);
+    createSpaceProperty(space, mySettings.KEEP_LINE_BREAKS, keepBlankLines());
   }
 
   private void createSpaceProperty(boolean space, boolean keepLineBreaks, final int keepBlankLines) {
@@ -1072,7 +1080,7 @@
   }
 
   static boolean isWhiteSpace(final ASTNode node) {
-    return node != null && (TokenSets.WHITE_SPACES_SET.contains(node.getElementType()) || node.getTextLength() == 0);
+    return node != null && (PsiImplUtil.isWhiteSpaceOrNls(node) || node.getTextLength() == 0);
   }
 }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java
index fedbecb..98dbd90 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/GantRunner.java
@@ -61,7 +61,7 @@
       int result = Messages
         .showOkCancelDialog("Gant is not configured. Do you want to configure it?", "Configure Gant SDK",
                             JetgroovyIcons.Groovy.Gant_16x16);
-      if (result == 0) {
+      if (result == Messages.OK) {
         ShowSettingsUtil.getInstance().editConfigurable(project, new GantConfigurable(project));
       }
       if (!(GantUtils.getSDKInstallPath(module, project).length() > 0)) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/NewGantScriptAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/NewGantScriptAction.java
index 80902d1..0911b04 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/NewGantScriptAction.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gant/NewGantScriptAction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -80,7 +80,7 @@
                                                       String templateName,
                                                       @NonNls String... parameters) throws IncorrectOperationException {
     return GroovyTemplatesFactory
-      .createFromTemplate(directory, className, className + "." + GantScriptType.DEFAULT_EXTENSION, templateName, parameters);
+      .createFromTemplate(directory, className, className + "." + GantScriptType.DEFAULT_EXTENSION, templateName, true, parameters);
   }
 
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gotoclass/GroovyGoToSymbolContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gotoclass/GroovyGoToSymbolContributor.java
index ee517e9..b8b4e06 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gotoclass/GroovyGoToSymbolContributor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gotoclass/GroovyGoToSymbolContributor.java
@@ -22,6 +22,9 @@
 import com.intellij.psi.stubs.StubIndex;
 import com.intellij.util.ArrayUtil;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAnnotationMethod;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
 import org.jetbrains.plugins.groovy.lang.psi.stubs.index.GrAnnotationMethodNameIndex;
 import org.jetbrains.plugins.groovy.lang.psi.stubs.index.GrFieldNameIndex;
 import org.jetbrains.plugins.groovy.lang.psi.stubs.index.GrMethodNameIndex;
@@ -49,9 +52,9 @@
     GlobalSearchScope scope = includeNonProjectItems ? GlobalSearchScope.allScope(project) : GlobalSearchScope.projectScope(project);
 
     List<NavigationItem> symbols = new ArrayList<NavigationItem>();
-    symbols.addAll(StubIndex.getInstance().get(GrFieldNameIndex.KEY, name, project, scope));
-    symbols.addAll(StubIndex.getInstance().get(GrMethodNameIndex.KEY, name, project, scope));
-    symbols.addAll(StubIndex.getInstance().get(GrAnnotationMethodNameIndex.KEY, name, project, scope));
+    symbols.addAll(StubIndex.getElements(GrFieldNameIndex.KEY, name, project, scope, GrField.class));
+    symbols.addAll(StubIndex.getElements(GrMethodNameIndex.KEY, name, project, scope, GrMethod.class));
+    symbols.addAll(StubIndex.getElements(GrAnnotationMethodNameIndex.KEY, name, project, scope, GrAnnotationMethod.class));
 
     return symbols.toArray(new NavigationItem[symbols.size()]);
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppClosureParameterTypeProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppClosureParameterTypeProvider.java
index 457c9840..1000a7b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppClosureParameterTypeProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppClosureParameterTypeProvider.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.jetbrains.plugins.groovy.gpp;
 
 import com.intellij.codeInsight.generation.OverrideImplementUtil;
@@ -18,7 +33,9 @@
 import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.GroovyExpectedTypesProvider;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType;
 import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
 import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.AbstractClosureParameterEnhancer;
+import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 
 import java.util.*;
@@ -124,7 +141,7 @@
 
   @Nullable
   public static PsiType[] findSingleAbstractMethodSignature(@Nullable PsiType type) {
-    if (type instanceof PsiClassType) {
+    if (type instanceof PsiClassType && !(TypesUtil.isClassType(type, GroovyCommonClassNames.GROOVY_LANG_CLOSURE))) {
       List<Pair<PsiMethod, PsiSubstitutor>> result = getMethodsToOverrideImplementInInheritor((PsiClassType)type, true);
       if (result.size() == 1) {
         return getParameterTypes(result.get(0));
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppTypeConverter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppTypeConverter.java
index 7c87148..0b4e639 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppTypeConverter.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/gpp/GppTypeConverter.java
@@ -73,10 +73,13 @@
 
       final PsiType expectedComponent = PsiUtil.extractIterableTypeParameter(lType, false);
       if (expectedComponent != null && isMethodCallConversion(context)) {
-        PsiType tupleComponent = tupleType.getParameters()[0];
-        if (tupleComponent != null &&
-            TypesUtil.isAssignable(expectedComponent, tupleComponent, context) && hasDefaultConstructor(lType)) {
-          return true;
+        PsiType[] parameters = tupleType.getParameters();
+        if (parameters.length == 1) {
+          PsiType tupleComponent = parameters[0];
+          if (tupleComponent != null &&
+              TypesUtil.isAssignable(expectedComponent, tupleComponent, context) && hasDefaultConstructor(lType)) {
+            return true;
+          }
         }
       }
 
@@ -88,10 +91,10 @@
       final PsiType lKeyType = PsiUtil.substituteTypeParameter(lType, CommonClassNames.JAVA_UTIL_MAP, 0, false);
       final PsiType lValueType = PsiUtil.substituteTypeParameter(lType, CommonClassNames.JAVA_UTIL_MAP, 1, false);
       final PsiType[] parameters = ((GrMapType)rType).getParameters();
-      if (lKeyType != null && lValueType != null &&
+      if (parameters.length == 2 && lKeyType != null && lValueType != null &&
           parameters[0] != null && parameters[1] != null &&
-          (!TypesUtil.isAssignable(lKeyType, parameters[0], context) || !TypesUtil
-            .isAssignable(lValueType, parameters[1], context))) {
+          (!TypesUtil.isAssignable(lKeyType, parameters[0], context) ||
+           !TypesUtil.isAssignable(lValueType, parameters[1], context))) {
         return null;
       }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java
index 0499c68..faa4955 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/griffon/GriffonFramework.java
@@ -202,15 +202,18 @@
   }
 
   @Override
+  protected boolean isCoreJar(@NotNull VirtualFile localFile) {
+    return GriffonLibraryPresentationProvider.isGriffonCoreJar(localFile);
+  }
+
+  @Override
   public VirtualFile getSdkRoot(@Nullable Module module) {
     VirtualFile coreJar = findCoreJar(module);
     if (coreJar == null) return null;
 
-    if (GriffonLibraryPresentationProvider.isGriffonCoreJar(coreJar)) {
-      final VirtualFile parent = coreJar.getParent();
-      if (parent != null) {
-        return parent.getParent();
-      }
+    final VirtualFile parent = coreJar.getParent();
+    if (parent != null) {
+      return parent.getParent();
     }
     return null;
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.java
index 64b47c7..74bcfea 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 
 import com.intellij.CommonBundle;
 import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.PropertyKey;
 
 import java.lang.ref.Reference;
@@ -29,19 +30,16 @@
  */
 public class GroovyIntentionsBundle {
 
-  private static Reference<ResourceBundle> ourBundle;
-
-  @NonNls
-  private static final String BUNDLE = "org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle";
-
-  public static String message(@PropertyKey(resourceBundle = BUNDLE)String key, Object... params) {
+  public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
     return CommonBundle.message(getBundle(), key, params);
   }
 
-  private static ResourceBundle getBundle() {
-    ResourceBundle bundle = null;
+  private static Reference<ResourceBundle> ourBundle;
+  @NonNls
+  private static final String BUNDLE = "org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle";
 
-    if (ourBundle != null) bundle = ourBundle.get();
+  private static ResourceBundle getBundle() {
+    ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
 
     if (bundle == null) {
       bundle = ResourceBundle.getBundle(BUNDLE);
@@ -49,5 +47,4 @@
     }
     return bundle;
   }
-
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties
index ae83a8a..846eea7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/GroovyIntentionsBundle.properties
@@ -1,12 +1,12 @@
 # suppress inspection "UnusedProperty" for whole file
 intention.category.groovy=Groovy
-intention.category.conversions=Expression conversions
-intention.category.closures=Closures
-intention.category.comments=Comments
-intention.category.groovy.style=Groovy-style
-intention.category.control.flow=Control Flow
-intention.category.groovy.declaration=Declaration
-intention.category.groovy.other=Other
+intention.category.conversions=Groovy/Expression conversions
+intention.category.closures=Groovy/Closures
+intention.category.comments=Groovy/Comments
+intention.category.groovy.style=Groovy/Groovy-style
+intention.category.control.flow=Groovy/Control Flow
+intention.category.groovy.declaration=Groovy/Declaration
+intention.category.groovy.other=Groovy/Other
 demorgans.law.intention.family.name=DeMorgan's Law
 demorgans.intention.name1=Replace '\\&\\&' with '||'
 demorgans.intention.name2=Replace '||' with '\\&\\&'
@@ -208,4 +208,9 @@
 convert.to.dollar.slash.regex.intention.name=Convert to Dollar-Slashy String
 convert.to.dollar.slash.regex.intention.family.name=Convert string literal to dollar-slashy string
 gr.remove.explicit.type.declaration.intention.name=Remove explicit type
-gr.remove.explicit.type.declaration.intention.family.name=Remove explicit type declaration
\ No newline at end of file
+gr.remove.explicit.type.declaration.intention.family.name=Remove explicit type declaration
+rename.file.to.0=Rename file to ''{0}''
+gr.sort.map.keys.intention.name=Sort alphabetically
+gr.sort.map.keys.intention.family.name=Sort map entries alphabetically
+gr.remove.annotation.intention.name=Remove
+gr.remove.annotation.intention.family.name=Remove annotation
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/base/Intention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/base/Intention.java
index c1df8e1..103546f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/base/Intention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/base/Intention.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -89,13 +89,17 @@
     }
 
     SelectionModel selectionModel = editor.getSelectionModel();
-    if (selectionModel.hasSelection()) {
-      TextRange selectionRange = new TextRange(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd());
-      PsiElement element = GroovyRefactoringUtil
-        .findElementInRange(file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd(), PsiElement.class);
-      while (element != null && element.getTextRange() != null && selectionRange.contains(element.getTextRange())) {
-        if (predicate.satisfiedBy(element)) return element;
-        element = element.getParent();
+    if (selectionModel.hasSelection() && !selectionModel.hasBlockSelection()) {
+      int start = selectionModel.getSelectionStart();
+      int end = selectionModel.getSelectionEnd();
+
+      if (0 <= start && start <= end) {
+        TextRange selectionRange = new TextRange(start, end);
+        PsiElement element = GroovyRefactoringUtil.findElementInRange(file, start, end, PsiElement.class);
+        while (element != null && element.getTextRange() != null && selectionRange.contains(element.getTextRange())) {
+          if (predicate.satisfiedBy(element)) return element;
+          element = element.getParent();
+        }
       }
     }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ClassNameDiffersFromFileNamePredicate.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ClassNameDiffersFromFileNamePredicate.java
index a108c93..41454ce 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ClassNameDiffersFromFileNamePredicate.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ClassNameDiffersFromFileNamePredicate.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
+import com.intellij.util.Consumer;
+import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
@@ -26,14 +28,16 @@
 * @author Maxim.Medvedev
 */
 class ClassNameDiffersFromFileNamePredicate implements PsiElementPredicate {
+  private final Consumer<GrTypeDefinition> myClassConsumer;
   private final boolean mySearchForClassInMultiClassFile;
 
-  ClassNameDiffersFromFileNamePredicate(boolean searchForClassInMultiClassFile) {
+  ClassNameDiffersFromFileNamePredicate(@Nullable Consumer<GrTypeDefinition> classConsumer, boolean searchForClassInMultiClassFile) {
+    myClassConsumer = classConsumer;
     mySearchForClassInMultiClassFile = searchForClassInMultiClassFile;
   }
 
-  ClassNameDiffersFromFileNamePredicate() {
-    this(false);
+  ClassNameDiffersFromFileNamePredicate(@Nullable Consumer<GrTypeDefinition> classConsumer) {
+    this(classConsumer, false);
   }
 
   @Override
@@ -44,6 +48,7 @@
 
     final String name = ((GrTypeDefinition)parent).getName();
     if (name == null || name.length() == 0) return false;
+    if (myClassConsumer != null) myClassConsumer.consume(((GrTypeDefinition)parent));
     final PsiFile file = element.getContainingFile();
     if (!(file instanceof GroovyFile)) return false;
     if (!file.isPhysical()) return false;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertMapToClassIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertMapToClassIntention.java
index 121e946..a69bc7c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertMapToClassIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/ConvertMapToClassIntention.java
@@ -95,7 +95,7 @@
 
     final GrTypeDefinition typeDefinition = createClass(project, namedArguments, selectedPackageName, shortName);
     final PsiClass generatedClass = CreateClassActionBase.createClassByType(
-      dialog.getTargetDirectory(), typeDefinition.getName(), PsiManager.getInstance(project), map, GroovyTemplates.GROOVY_CLASS);
+      dialog.getTargetDirectory(), typeDefinition.getName(), PsiManager.getInstance(project), map, GroovyTemplates.GROOVY_CLASS, true);
     final PsiClass replaced = (PsiClass)generatedClass.replace(typeDefinition);
     replaceMapWithClass(project, map, replaced, replaceReturnType, variableDeclaration, methodParameter);
   }
@@ -154,7 +154,7 @@
                                                                                                GroovyIntentionsBundle
                                                                                                  .message(
                                                                                                    "convert.map.to.class.intention.name"),
-                                                                                               Messages.getQuestionIcon()) != 0);
+                                                                                               Messages.getQuestionIcon()) != Messages.YES);
   }
 
   public static boolean checkForVariableDeclaration(GrExpression replacedNewExpression) {
@@ -171,7 +171,7 @@
                                                                                             GroovyIntentionsBundle.message(
                                                                                               "convert.map.to.class.intention.name"),
                                                                                             Messages.getQuestionIcon()) ==
-                                                                   0) {
+                                                                  Messages.YES) {
         return true;
       }
     }
@@ -215,7 +215,7 @@
     if (ApplicationManager.getApplication().isUnitTestMode() ||
            Messages.showYesNoDialog(map.getProject(), GroovyIntentionsBundle
              .message("do.you.want.to.change.type.of.parameter.in.method", parameter.getName(), method.getName()),
-                                    GroovyIntentionsBundle.message("convert.map.to.class.intention.name"), Messages.getQuestionIcon()) == 0) {
+                                    GroovyIntentionsBundle.message("convert.map.to.class.intention.name"), Messages.getQuestionIcon()) == Messages.YES) {
       return parameter;
     }
     return null;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/MoveClassToNewFileIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/MoveClassToNewFileIntention.java
index 9c0ec2a..ff8dbf8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/MoveClassToNewFileIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/MoveClassToNewFileIntention.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.refactoring.util.CommonRefactoringUtil;
+import com.intellij.util.Consumer;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.actions.GroovyTemplates;
@@ -59,7 +60,8 @@
       }
     }
 
-    final GroovyFile newFile = (GroovyFile)GroovyTemplatesFactory.createFromTemplate(dir, name, newFileName, GroovyTemplates.GROOVY_CLASS);
+    final GroovyFile newFile = (GroovyFile)GroovyTemplatesFactory.createFromTemplate(dir, name, newFileName, GroovyTemplates.GROOVY_CLASS,
+                                                                                     true);
     final GrTypeDefinition template = newFile.getTypeDefinitions()[0];
     final PsiElement newClass = template.replace(psiClass);
     final GrDocComment docComment = psiClass.getDocComment();
@@ -83,6 +85,6 @@
   @NotNull
   @Override
   protected PsiElementPredicate getElementPredicate() {
-    return new ClassNameDiffersFromFileNamePredicate(true);
+    return new ClassNameDiffersFromFileNamePredicate(null, true);
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/RenameFileWithClassIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/RenameFileWithClassIntention.java
index 8a3f5ee..2d93149 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/RenameFileWithClassIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/RenameFileWithClassIntention.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,8 +21,10 @@
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.refactoring.openapi.impl.RenameRefactoringImpl;
+import com.intellij.util.Consumer;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.intentions.GroovyIntentionsBundle;
 import org.jetbrains.plugins.groovy.intentions.base.Intention;
 import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
@@ -30,21 +32,32 @@
 /**
  * @author Maxim.Medvedev
  */
-public class RenameFileWithClassIntention extends Intention {
+public class RenameFileWithClassIntention extends Intention implements Consumer<GrTypeDefinition> {
+
+  private String myNewFileName = null;
 
   @Override
   protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
-    final GrTypeDefinition psiClass = (GrTypeDefinition)element.getParent();
-    final String name = psiClass.getName();
+    final PsiFile file = element.getContainingFile();
+    new RenameRefactoringImpl(project, file, myNewFileName, true, true).run();
+  }
 
-    final PsiFile file = psiClass.getContainingFile();
-    final String newFileName = name + "." + FileUtilRt.getExtension(file.getName());
-    new RenameRefactoringImpl(project, file, newFileName, true, true).run();
+  @NotNull
+  @Override
+  public String getText() {
+    return GroovyIntentionsBundle.message("rename.file.to.0", myNewFileName);
   }
 
   @NotNull
   @Override
   protected PsiElementPredicate getElementPredicate() {
-    return new ClassNameDiffersFromFileNamePredicate();
+    return new ClassNameDiffersFromFileNamePredicate(this);
+  }
+
+  @Override
+  public void consume(GrTypeDefinition def) {
+    final String name = def.getName();
+    final PsiFile file = def.getContainingFile();
+    myNewFileName = name + "." + FileUtilRt.getExtension(file.getName());
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertConcatenationToGstringIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertConcatenationToGstringIntention.java
index 6e98bad..1d33099 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertConcatenationToGstringIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertConcatenationToGstringIntention.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -196,13 +196,12 @@
 
   private static void getOperandText(@Nullable GrExpression operand, StringBuilder builder, boolean multiline) {
     if (operand instanceof GrRegex) {
-      boolean isDollarSlashy = GrStringUtil.isDollarSlashyString((GrLiteral)operand);
       for (GroovyPsiElement element : ((GrRegex)operand).getAllContentParts()) {
         if (element instanceof GrStringInjection) {
           builder.append(element.getText());
         }
         else if (element instanceof GrStringContent) {
-          if (isDollarSlashy) {
+          if (GrStringUtil.isDollarSlashyString((GrLiteral)operand)) {
             processDollarSlashyContent(builder, multiline, element.getText());
           }
           else {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertMultilineStringToSingleLineIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertMultilineStringToSingleLineIntention.java
index 60de8b6..d5dfc6ff 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertMultilineStringToSingleLineIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/conversions/strings/ConvertMultilineStringToSingleLineIntention.java
@@ -119,7 +119,12 @@
     return new PsiElementPredicate() {
       @Override
       public boolean satisfiedBy(PsiElement element) {
-        return element instanceof GrLiteral && GrStringUtil.isMultilineStringLiteral((GrLiteral)element);
+        if (!(element instanceof GrLiteral)) return false;
+
+        String text = element.getText();
+        String quote = GrStringUtil.getStartQuote(text);
+        return GrStringUtil.TRIPLE_QUOTES.equals(quote) ||
+               GrStringUtil.TRIPLE_DOUBLE_QUOTES.equals(quote);
       }
     };
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrCreateFieldForParameterIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrCreateFieldForParameterIntention.java
index c8b8731..6c56814 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrCreateFieldForParameterIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrCreateFieldForParameterIntention.java
@@ -59,7 +59,7 @@
   }
 
   private static boolean checkAssignmentToFieldExists(PsiParameter parameter) {
-    for (PsiReference reference : ReferencesSearch.search(parameter)) {
+    for (PsiReference reference : ReferencesSearch.search(parameter).findAll()) {
       PsiElement element = reference.getElement();
       if (element instanceof GrReferenceExpression &&
           element.getParent() instanceof GrAssignmentExpression &&
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrCreateSubclassAction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrCreateSubclassAction.java
index 198adf0..a4cc490 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrCreateSubclassAction.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrCreateSubclassAction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,24 +29,26 @@
 import com.intellij.openapi.command.WriteCommandAction;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.RangeMarker;
 import com.intellij.openapi.fileEditor.ex.IdeDocumentHistory;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.GroovyFileType;
 import org.jetbrains.plugins.groovy.actions.GroovyTemplates;
 import org.jetbrains.plugins.groovy.annotator.intentions.CreateClassActionBase;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
+import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeParameterList;
 
 /**
@@ -75,14 +77,13 @@
 
     new WriteCommandAction(project, getTitle(psiClass), getTitle(psiClass)) {
       @Override
-      protected void run(Result result) throws Throwable {
+      protected void run(@NotNull Result result) throws Throwable {
         IdeDocumentHistory.getInstance(project).includeCurrentPlaceAsChangePlace();
 
         final GrTypeParameterList oldTypeParameterList = psiClass.getTypeParameterList();
 
         try {
-          targetClass.set(CreateClassActionBase.createClassByType(targetDirectory, className, PsiManager.getInstance(project), psiClass,
-                                                                  GroovyTemplates.GROOVY_CLASS));
+          targetClass.set(CreateClassActionBase.createClassByType(targetDirectory, className, PsiManager.getInstance(project), psiClass, GroovyTemplates.GROOVY_CLASS, true));
         }
         catch (final IncorrectOperationException e) {
           ApplicationManager.getApplication().invokeLater(new Runnable() {
@@ -96,10 +97,9 @@
           return;
         }
         startTemplate(oldTypeParameterList, project, psiClass, targetClass.get(), false);
-        PsiElement element = targetClass.get();
-        JavaCodeStyleManager.getInstance(project).shortenClassReferences(element);
       }
     }.execute();
+
     if (targetClass.get() == null) return null;
     if (!ApplicationManager.getApplication().isUnitTestMode() && !psiClass.hasTypeParameters()) {
 
@@ -118,22 +118,15 @@
                                     boolean includeClassName) {
     PsiElementFactory jfactory = JavaPsiFacade.getElementFactory(project);
     final GroovyPsiElementFactory elementFactory = GroovyPsiElementFactory.getInstance(project);
-    GrCodeReferenceElement ref = elementFactory.createCodeReferenceElementFromClass(psiClass);
+    GrCodeReferenceElement stubRef = elementFactory.createCodeReferenceElementFromClass(psiClass);
     try {
-      if (psiClass.isInterface()) {
-        GrImplementsClause clause = targetClass.getImplementsClause();
-        if (clause == null) {
-          clause = (GrImplementsClause)targetClass.addAfter(elementFactory.createImplementsClause(), targetClass.getNameIdentifierGroovy());
-        }
-        ref = (GrCodeReferenceElement)clause.add(ref);
+      GrReferenceList clause = psiClass.isInterface() ? targetClass.getImplementsClause() : targetClass.getExtendsClause();
+      if (clause == null) {
+        GrReferenceList stubRefList = psiClass.isInterface() ? elementFactory.createImplementsClause() : elementFactory.createExtendsClause();
+        clause = (GrExtendsClause)targetClass.addAfter(stubRefList, targetClass.getNameIdentifierGroovy());
       }
-      else {
-        GrExtendsClause clause = targetClass.getExtendsClause();
-        if (clause == null) {
-          clause = (GrExtendsClause)targetClass.addAfter(elementFactory.createExtendsClause(), targetClass.getNameIdentifierGroovy());
-        }
-        ref = (GrCodeReferenceElement)clause.add(ref);
-      }
+      GrCodeReferenceElement ref = (GrCodeReferenceElement)clause.add(stubRef);
+
       if (psiClass.hasTypeParameters() || includeClassName) {
         final Editor editor = CodeInsightUtil.positionCursor(project, targetClass.getContainingFile(), targetClass.getLBrace());
         final TemplateBuilderImpl templateBuilder = editor == null || ApplicationManager.getApplication().isUnitTestMode() ? null
@@ -143,19 +136,31 @@
           templateBuilder.replaceElement(targetClass.getNameIdentifier(), targetClass.getName());
         }
 
-        if (oldTypeParameterList != null) {
+        if (oldTypeParameterList != null && oldTypeParameterList.getTypeParameters().length > 0) {
+          GrTypeArgumentList existingList = ref.getTypeArgumentList();
+          final GrTypeParameterList typeParameterList =
+            (GrTypeParameterList)targetClass.addAfter(elementFactory.createTypeParameterList(), targetClass.getNameIdentifierGroovy());
+
+          GrTypeArgumentList argList;
+          if (existingList == null) {
+            GrCodeReferenceElement codeRef = elementFactory.createCodeReferenceElementFromText("A<T>");
+            argList = ((GrTypeArgumentList)ref.add(codeRef.getTypeArgumentList()));
+            argList.getTypeArgumentElements()[0].delete();
+          }
+          else {
+            argList = existingList;
+          }
+
           for (PsiTypeParameter parameter : oldTypeParameterList.getTypeParameters()) {
-            final PsiElement param = ref.getTypeArgumentList().add(elementFactory.createTypeElement(jfactory.createType(parameter)));
+            final PsiElement param = argList.add(elementFactory.createTypeElement(jfactory.createType(parameter)));
             if (templateBuilder != null) {
               templateBuilder.replaceElement(param, param.getText());
             }
+
+            typeParameterList.add(elementFactory.createTypeParameter(parameter.getName(), parameter.getExtendsListTypes()));
           }
         }
 
-        final GrTypeParameterList typeParameterList = targetClass.getTypeParameterList();
-        assert typeParameterList != null;
-        typeParameterList.replace(oldTypeParameterList);
-
         if (templateBuilder != null) {
           templateBuilder.setEndVariableBefore(ref);
           final Template template = templateBuilder.buildTemplate();
@@ -166,12 +171,14 @@
           PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
 
           final TextRange textRange = targetClass.getTextRange();
-          final int startClassOffset = textRange.getStartOffset();
+          final RangeMarker startClassOffset = editor.getDocument().createRangeMarker(textRange.getStartOffset(), textRange.getEndOffset());
+          startClassOffset.setGreedyToLeft(true);
+          startClassOffset.setGreedyToRight(true);
           editor.getDocument().deleteString(textRange.getStartOffset(), textRange.getEndOffset());
           CreateFromUsageBaseFix.startTemplate(editor, template, project, new TemplateEditingAdapter() {
             @Override
             public void templateFinished(Template template, boolean brokenOff) {
-              chooseAndImplement(psiClass, project,PsiTreeUtil.getParentOfType(containingFile.findElementAt(startClassOffset), GrTypeDefinition.class),editor);
+              chooseAndImplement(psiClass, project,PsiTreeUtil.getParentOfType(containingFile.findElementAt(startClassOffset.getStartOffset()), GrTypeDefinition.class),editor);
             }
           }, getTitle(psiClass));
         }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrIntroduceLocalVariableIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrIntroduceLocalVariableIntention.java
index ac459d0..d4e3c2d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrIntroduceLocalVariableIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrIntroduceLocalVariableIntention.java
@@ -1,8 +1,25 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.jetbrains.plugins.groovy.intentions.declaration;
 
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiType;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.IncorrectOperationException;
@@ -47,9 +64,15 @@
   }
 
   @Override
-  protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
+  protected void processIntention(@NotNull final PsiElement element, final Project project, final Editor editor) throws IncorrectOperationException {
     setSelection(editor, getTargetExpression(element));
-    new GrIntroduceVariableHandler().invoke(project, editor, element.getContainingFile(), null);
+    final PsiFile file = element.getContainingFile();
+    ApplicationManager.getApplication().invokeLater(new Runnable() {
+      @Override
+      public void run() {
+        new GrIntroduceVariableHandler().invoke(project, editor, file, null);
+      }
+    });
   }
 
   @NotNull
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrRemoveExplicitTypeDeclarationIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrRemoveExplicitTypeDeclarationIntention.java
index 5f530705..74bdd87 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrRemoveExplicitTypeDeclarationIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/declaration/GrRemoveExplicitTypeDeclarationIntention.java
@@ -65,7 +65,7 @@
             return ((GrVariable)parent).getTypeElementGroovy() != null;
           }
 
-          if (parent instanceof GrMethod) {
+          if (parent instanceof GrMethod && ((GrMethod)parent).findSuperMethods().length == 0 ) {
             return ((GrMethod)parent).getReturnTypeElementGroovy() != null;
           }
         }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/other/GrSortMapKeysIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/other/GrSortMapKeysIntention.java
new file mode 100644
index 0000000..ce1a8fb
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/other/GrSortMapKeysIntention.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.intentions.other;
+
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiElement;
+import com.intellij.util.IncorrectOperationException;
+import groovy.lang.Closure;
+import org.codehaus.groovy.runtime.DefaultGroovyMethods;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.intentions.base.ErrorUtil;
+import org.jetbrains.plugins.groovy.intentions.base.Intention;
+import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
+
+import java.util.Arrays;
+import java.util.Comparator;
+
+/**
+ * Created by Max Medvedev on 10/01/14
+ */
+public class GrSortMapKeysIntention extends Intention {
+
+  @Override
+  protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
+    PsiElement parent = element.getParent();
+
+    if (parent instanceof GrArgumentLabel) {
+      PsiElement pparent = parent.getParent().getParent();
+      if (pparent instanceof GrListOrMap && !ErrorUtil.containsError(pparent)) {
+        GrListOrMap map = (GrListOrMap)pparent;
+        if (map.getInitializers().length == 0) {
+          GrNamedArgument[] namedArgs = map.getNamedArguments();
+          if (isLiteralKeys(namedArgs)) {
+            GrListOrMap newMap = constructNewMap(namedArgs, project);
+            map.replace(newMap);
+          }
+        }
+      }
+    }
+  }
+
+  @NotNull
+  private static GrListOrMap constructNewMap(@NotNull GrNamedArgument[] args, Project project) {
+    StringBuilder builder = new StringBuilder();
+
+    builder.append("[");
+
+    Arrays.sort(args, new Comparator<GrNamedArgument>() {
+      @Override
+      public int compare(GrNamedArgument o1, GrNamedArgument o2) {
+        final String l1 = o1.getLabelName();
+        final String l2 = o2.getLabelName();
+        assert l1 != null && l2 != null;
+
+        return l1.compareTo(l2);
+      }
+    });
+
+    for (GrNamedArgument arg : args) {
+      builder.append(arg.getText()).append(",\n");
+    }
+
+
+    builder.replace(builder.length() - 2, builder.length(), "]");
+
+    return (GrListOrMap)GroovyPsiElementFactory.getInstance(project).createExpressionFromText(builder);
+  }
+
+  @NotNull
+  @Override
+  protected PsiElementPredicate getElementPredicate() {
+    return new PsiElementPredicate() {
+      @Override
+      public boolean satisfiedBy(PsiElement element) {
+        PsiElement parent = element.getParent();
+        if (parent instanceof GrArgumentLabel &&
+            ((GrArgumentLabel)parent).getNameElement().equals(element) &&
+            parent.getParent() != null &&
+            parent.getParent().getParent() instanceof GrListOrMap) {
+          GrListOrMap map = DefaultGroovyMethods.asType(parent.getParent().getParent(), GrListOrMap.class);
+          if (!ErrorUtil.containsError(map) && map.getInitializers().length == 0 && isLiteralKeys(map.getNamedArguments())) {
+            return true;
+          }
+        }
+
+
+        return false;
+      }
+    };
+  }
+
+  private static boolean isLiteralKeys(GrNamedArgument[] args) {
+    return DefaultGroovyMethods.find(args, new Closure<Boolean>(null, null) {
+      public Boolean doCall(GrNamedArgument it) {
+        return it.getLabel().getNameElement() == null;
+      }
+
+      public Boolean doCall() {
+        return doCall(null);
+      }
+    }) == null;
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ConvertFromGeeseBracesIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ConvertFromGeeseBracesIntention.java
index 1f9417f..ce1b552 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ConvertFromGeeseBracesIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ConvertFromGeeseBracesIntention.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
-import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
@@ -37,7 +36,7 @@
 import org.jetbrains.plugins.groovy.intentions.base.Intention;
 import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
-import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 
 /**
  * @author Max Medvedev
@@ -54,8 +53,7 @@
         return false;
       }
 
-      IElementType elementType = element.getNode().getElementType();
-      if (TokenSets.WHITE_SPACES_SET.contains(elementType)) {
+      if (PsiImplUtil.isWhiteSpaceOrNls(element)) {
         element = PsiTreeUtil.prevLeaf(element);
       }
 
@@ -97,8 +95,7 @@
 
   @Override
   protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
-    IElementType elementType = element.getNode().getElementType();
-    if (TokenSets.WHITE_SPACES_SET.contains(elementType)) {
+    if (PsiImplUtil.isWhiteSpaceOrNls(element)) {
       element = PsiTreeUtil.prevLeaf(element);
     }
     LOG.assertTrue(GeeseUtil.isClosureRBrace(element));
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ConvertToGeeseBracesIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ConvertToGeeseBracesIntention.java
index 81d9f33..963e9d9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ConvertToGeeseBracesIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/ConvertToGeeseBracesIntention.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,7 +27,6 @@
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
-import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
@@ -37,7 +36,7 @@
 import org.jetbrains.plugins.groovy.intentions.base.Intention;
 import org.jetbrains.plugins.groovy.intentions.base.PsiElementPredicate;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
-import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 
 import static org.jetbrains.plugins.groovy.formatter.GeeseUtil.*;
 
@@ -56,8 +55,7 @@
         return false;
       }
 
-      IElementType elementType = element.getNode().getElementType();
-      if (TokenSets.WHITE_SPACES_SET.contains(elementType)) {
+      if (PsiImplUtil.isWhiteSpaceOrNls(element)) {
         element = PsiTreeUtil.prevLeaf(element);
       }
 
@@ -87,8 +85,7 @@
 
   @Override
   protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
-    IElementType elementType = element.getNode().getElementType();
-    if (TokenSets.WHITE_SPACES_SET.contains(elementType)) {
+    if (PsiImplUtil.isWhiteSpaceOrNls(element)) {
       element = PsiTreeUtil.prevLeaf(element);
     }
     LOG.assertTrue(isClosureRBrace(element) && isClosureContainLF(element));
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java
index 48e774c..79eb885 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/intentions/style/parameterToEntry/ConvertParameterToMapEntryIntention.java
@@ -445,7 +445,6 @@
     final Task task = new Task.Modal(project, GroovyIntentionsBundle
       .message("find.method.ro.closure.usages.0", owner instanceof GrClosableBlock ? CLOSURE_CAPTION : METHOD_CAPTION), true) {
       public void run(@NotNull final ProgressIndicator indicator) {
-        final GlobalSearchScope projectScope = GlobalSearchScope.projectScope(getProject());
         final Collection<PsiReference> references = Collections.synchronizedSet(new HashSet<PsiReference>());
         final Processor<PsiReference> consumer = new Processor<PsiReference>() {
           @Override
@@ -454,7 +453,7 @@
             return true;
           }
         };
-        ReferencesSearch.search(namedElem, projectScope).forEach(consumer);
+        ReferencesSearch.search(namedElem).forEach(consumer);
         if (namedElem instanceof GrField && ((GrField)namedElem).isProperty()) {
           final GrAccessorMethod[] getters = ((GrField)namedElem).getGetters();
           for (GrAccessorMethod getter : getters) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyNamesValidator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyNamesValidator.java
index f345d84..7c23489 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyNamesValidator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/GroovyNamesValidator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
 
 import com.intellij.lang.refactoring.NamesValidator;
 import com.intellij.openapi.project.Project;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
 
 /**
@@ -24,12 +25,12 @@
  */
 public class GroovyNamesValidator implements NamesValidator {
   @Override
-  public boolean isKeyword(String name, Project project) {
+  public boolean isKeyword(@NotNull String name, Project project) {
     return GroovyRefactoringUtil.KEYWORDS.contains(name);
   }
 
   @Override
-  public boolean isIdentifier(String name, Project project) {
+  public boolean isIdentifier(@NotNull String name, Project project) {
     return GroovyRefactoringUtil.isCorrectReferenceName(name, project);
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java
index 5610d74..ce5d9c1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionContributor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
 import com.intellij.psi.codeStyle.SuggestedNameInfo;
 import com.intellij.psi.codeStyle.VariableKind;
 import com.intellij.psi.filters.FilterPositionUtil;
+import com.intellij.psi.impl.light.LightElement;
 import com.intellij.psi.impl.source.tree.LeafPsiElement;
 import com.intellij.psi.scope.PsiScopeProcessor;
 import com.intellij.psi.util.InheritanceUtil;
@@ -77,6 +78,7 @@
 
 import static com.intellij.patterns.PlatformPatterns.psiElement;
 import static com.intellij.patterns.PsiJavaPatterns.elementType;
+import static com.intellij.patterns.StandardPatterns.alwaysFalse;
 import static com.intellij.util.containers.ContainerUtil.*;
 import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*;
 import static org.jetbrains.plugins.groovy.lang.lexer.TokenSets.SEPARATORS;
@@ -169,7 +171,8 @@
       ))
     );
 
-  private static final ElementPattern<PsiElement> AFTER_NUMBER_LITERAL = psiElement().afterLeaf(
+  private static final ElementPattern<PsiElement> AFTER_NUMBER_LITERAL = psiElement().afterLeafSkipping(
+    alwaysFalse(),
     psiElement().withElementType(elementType().oneOf(mNUM_DOUBLE, mNUM_INT, mNUM_LONG, mNUM_FLOAT, mNUM_BIG_INT, mNUM_BIG_DECIMAL)));
   public static final ElementPattern<PsiElement> AFTER_AT = psiElement().afterLeaf("@");
   public static final ElementPattern<PsiElement> IN_CATCH_TYPE = psiElement().afterLeaf(psiElement().withText("(").withParent(GrCatchClause.class));
@@ -450,6 +453,10 @@
           object = ((GroovyResolveResult)object).getElement();
         }
 
+        if (isLightElementDeclaredDuringCompletion(object)) {
+          return;
+        }
+
         if (!(lookupElement instanceof LookupElementBuilder) && inheritorsHolder.alreadyProcessed(lookupElement)) {
           return;
         }
@@ -490,6 +497,16 @@
     return EmptyRunnable.INSTANCE;
   }
 
+  private static boolean isLightElementDeclaredDuringCompletion(Object object) {
+    if (!(object instanceof LightElement && object instanceof PsiNamedElement)) return false;
+    final String name = ((PsiNamedElement)object).getName();
+    if (name == null) return false;
+
+    return name.contains(CompletionInitializationContext.DUMMY_IDENTIFIER_TRIMMED.trim()) ||
+           name.contains(DUMMY_IDENTIFIER_DECAPITALIZED.trim());
+  }
+
+
   private static Runnable addStaticMembers(CompletionParameters parameters,
                                        final PrefixMatcher matcher,
                                        final Map<PsiModifierListOwner, LookupElement> staticMembers, final Consumer<LookupElement> consumer) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionData.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionData.java
index aa24e61..fa8ea6d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionData.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionData.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -132,17 +132,16 @@
 
       registerControlCompletion(position, result);
 
-      if (parent instanceof GrExpression) {
+      if (parent instanceof GrExpression || isInfixOperatorPosition(position)) {
         addKeywords(result, false, PsiKeyword.TRUE, PsiKeyword.FALSE, PsiKeyword.NULL, PsiKeyword.SUPER, PsiKeyword.THIS);
         result.addElement(keyword(PsiKeyword.NEW, TailType.HUMBLE_SPACE_BEFORE_WORD));
-        result.addElement(keyword("as", TailType.HUMBLE_SPACE_BEFORE_WORD));
       }
 
       if (isAfterForParameter(position)) {
         result.addElement(keyword("in", TailType.HUMBLE_SPACE_BEFORE_WORD));
       }
       if (isInfixOperatorPosition(position)) {
-        addKeywords(result, true, "in", PsiKeyword.INSTANCEOF);
+        addKeywords(result, true, "as", "in", PsiKeyword.INSTANCEOF);
       }
       if (suggestPrimitiveTypes(position)) {
         final boolean addSpace = !IN_CAST_TYPE_ELEMENT.accepts(position) && !GroovySmartCompletionContributor.AFTER_NEW.accepts(position) && !isInExpression(position);
@@ -239,8 +238,11 @@
       elem = PsiUtil.skipWhitespacesAndComments(context.getPrevSibling(), false);
     }
     else {
-      if (elem.getParent() != null) {
-        elem = elem.getParent().getPrevSibling();
+      if (elem instanceof GrReferenceExpression && PsiUtil.skipWhitespacesAndComments(elem.getPrevSibling(), false) instanceof GrTypeDefinition) {
+        elem = PsiUtil.skipWhitespacesAndComments(elem.getPrevSibling(), false);
+      }
+      else if (elem.getParent() != null) {
+        elem = PsiUtil.skipWhitespacesAndComments(elem.getParent().getPrevSibling(), false);
       }
     }
 
@@ -591,7 +593,7 @@
       candidate = PsiUtil.skipWhitespacesAndComments(run.getPrevSibling(), false, skipNLs);
     }
     else {
-     candidate = PsiTreeUtil.prevLeaf(context);
+     candidate = PsiUtil.skipWhitespacesAndComments(PsiTreeUtil.prevLeaf(context), false);
     }
     if (candidate instanceof PsiErrorElement) candidate = candidate.getPrevSibling();
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java
index 4217e2f..e3b6fc6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovyCompletionUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -173,7 +173,7 @@
    * return true, if the element is first element after modifiers and there is no type element
    */
   public static boolean isFirstElementAfterPossibleModifiersInVariableDeclaration(PsiElement element, boolean acceptParameter) {
-    if (element.getParent() instanceof GrTypeDefinitionBody) {
+    if (element.getParent() instanceof GrTypeDefinitionBody && !(element instanceof PsiComment)) {
       //is first on the line?
       String text = element.getContainingFile().getText();
       int i = CharArrayUtil.shiftBackward(text, element.getTextRange().getStartOffset() - 1, " \t");
@@ -263,9 +263,9 @@
   }
 
 
-  public static List<? extends LookupElement> createLookupElements(GroovyResolveResult candidate,
+  public static List<? extends LookupElement> createLookupElements(@NotNull GroovyResolveResult candidate,
                                                                    boolean afterNew,
-                                                                   PrefixMatcher matcher,
+                                                                   @NotNull PrefixMatcher matcher,
                                                                    @Nullable PsiElement position) {
     final PsiElement element = candidate.getElement();
     final PsiElement context = candidate.getCurrentFileResolveContext();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovySmartCompletionContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovySmartCompletionContributor.java
index 7392520..4d1f239 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovySmartCompletionContributor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/GroovySmartCompletionContributor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -411,7 +411,9 @@
     }
 
     final LookupItem item = PsiTypeLookupItem.createLookupItem(GenericsUtil.eliminateWildcards(type), place, isDiamond, ChooseTypeExpression.IMPORT_FIXER);
-    JavaCompletionUtil.setShowFQN(item);
+    if (item.getObject() instanceof PsiClass) {
+      JavaCompletionUtil.setShowFQN(item);
+    }
     item.setInsertHandler(new AfterNewClassInsertHandler((PsiClassType)type, true));
     return item;
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/closureParameters/ClosureDescriptor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/closureParameters/ClosureDescriptor.java
index 8ed7f39..53e941d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/closureParameters/ClosureDescriptor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/completion/closureParameters/ClosureDescriptor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -87,12 +87,12 @@
     }
     final boolean isConstructor = Boolean.TRUE.equals(myMethod.get("constructor"));
     final MethodSignature signature = MethodSignatureUtil
-      .createMethodSignature(name, types.toArray(new PsiType[types.size()]), method.getTypeParameters(), PsiSubstitutor.EMPTY, isConstructor);
+      .createMethodSignature(name, types.toArray(PsiType.createArray(types.size())), method.getTypeParameters(), PsiSubstitutor.EMPTY, isConstructor);
     final GrClosureSignature closureSignature = GrClosureSignatureUtil.createSignature(signature);
 
     if (method instanceof ClsMethodImpl) method = ((ClsMethodImpl)method).getSourceMirrorMethod();
     final PsiParameter[] parameters = method.getParameterList().getParameters();
-    final PsiType[] typeArray = new PsiType[parameters.length];
+    final PsiType[] typeArray = PsiType.createArray(parameters.length);
     ContainerUtil.map(parameters, new Function<PsiParameter, PsiType>() {
       @Override
       public PsiType fun(PsiParameter parameter) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java
index d56722d..f24d182 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/documentation/GroovyDocumentationProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,7 +48,6 @@
 import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner;
 import org.jetbrains.plugins.groovy.lang.groovydoc.psi.impl.GrDocCommentUtil;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
-import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
@@ -60,6 +59,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrPropertyForCompletion;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrImplicitVariable;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightVariable;
@@ -195,7 +195,7 @@
 
   private static void appendInferredType(PsiElement originalElement, GrVariable variable, StringBuilder buffer) {
     PsiType inferredType = null;
-    if (TokenSets.WHITE_SPACES_SET.contains(originalElement.getNode().getElementType())) {
+    if (PsiImplUtil.isWhiteSpaceOrNls(originalElement)) {
       originalElement = PsiTreeUtil.prevLeaf(originalElement);
     }
     if (originalElement != null && originalElement.getNode().getElementType() == GroovyTokenTypes.mIDENT) {
@@ -455,7 +455,7 @@
                         PsiFormatUtilBase.SHOW_TYPE);
         createElementLink(sb, element, str);
       }
-      return CodeInsightBundle.message("javadoc.candiates", text, sb);
+      return CodeInsightBundle.message("javadoc.candidates", text, sb);
     }
     return CodeInsightBundle.message("javadoc.candidates.not.found", text);
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java
index 4965af3..25b2e48 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/folding/GroovyFoldingBuilder.java
@@ -21,6 +21,7 @@
 import com.intellij.lang.ASTNode;
 import com.intellij.lang.folding.CustomFoldingBuilder;
 import com.intellij.lang.folding.FoldingDescriptor;
+import com.intellij.lang.folding.NamedFoldingDescriptor;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.FoldingGroup;
 import com.intellij.openapi.project.DumbAware;
@@ -41,6 +42,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
 import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
 
 import java.util.List;
@@ -82,15 +84,14 @@
       usedComments.add(element);
       PsiElement end = null;
       for (PsiElement current = element.getNextSibling(); current != null; current = current.getNextSibling()) {
+        if (PsiImplUtil.isWhiteSpaceOrNls(current)) continue;
+
         IElementType elementType = current.getNode().getElementType();
         if (elementType == mSL_COMMENT) {
           end = current;
           usedComments.add(current);
           continue;
         }
-        if (WHITE_SPACES_SET.contains(elementType)) {
-          continue;
-        }
         break;
       }
       if (end != null) {
@@ -121,11 +122,11 @@
         if (lbrace != null && rbrace != null) {
           final PsiElement next = lbrace.getNextSibling();
           final PsiElement prev = rbrace.getPrevSibling();
-          if (next != null && WHITE_SPACES_SET.contains(next.getNode().getElementType()) &&
-              prev != null && WHITE_SPACES_SET.contains(prev.getNode().getElementType())) {
+          if (next != null && PsiImplUtil.isWhiteSpaceOrNls(next) &&
+              prev != null && PsiImplUtil.isWhiteSpaceOrNls(prev)) {
             final FoldingGroup group = FoldingGroup.newGroup("block_group");
-            descriptors.add(new NamedFoldingDescriptor(psi.getNode(), lbrace.getTextRange().getStartOffset(), next.getTextRange().getEndOffset(), group, "{"));
-            descriptors.add(new NamedFoldingDescriptor(psi.getNode(), prev.getTextRange().getStartOffset(), rbrace.getTextRange().getEndOffset(), group, "}"));
+            descriptors.add(new NamedFoldingDescriptor(psi, lbrace.getTextRange().getStartOffset(), next.getTextRange().getEndOffset(), group, "{"));
+            descriptors.add(new NamedFoldingDescriptor(psi, prev.getTextRange().getStartOffset(), rbrace.getTextRange().getEndOffset(), group, "}"));
             return;
           }
         }
@@ -191,24 +192,6 @@
     }
   }
 
-  private static class NamedFoldingDescriptor extends FoldingDescriptor {
-    private final String myPlaceholderText;
-
-    private NamedFoldingDescriptor(@NotNull ASTNode node, int start, int end, @Nullable FoldingGroup group, @NotNull String placeholderText) {
-      this(node, new TextRange(start, end), group, placeholderText);
-    }
-
-    private NamedFoldingDescriptor(@NotNull ASTNode node, @NotNull final TextRange range, @Nullable FoldingGroup group, @NotNull String placeholderText) {
-      super(node, range, group);
-      myPlaceholderText = placeholderText;
-    }
-
-    @Override
-    public String getPlaceholderText() {
-      return myPlaceholderText;
-    }
-  }
-
   private static void processImports(final List<FoldingDescriptor> descriptors, GrImportStatement[] imports) {
     if (imports.length < 2) return;
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/parser/elements/GroovyDocTagValueTokenType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/parser/elements/GroovyDocTagValueTokenType.java
index a372cef..9bd58f2 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/parser/elements/GroovyDocTagValueTokenType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/parser/elements/GroovyDocTagValueTokenType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -120,7 +120,7 @@
     return builder.getTreeBuilt().getFirstChildNode();
   }
 
-  public static enum TagValueTokenType {
+  public enum TagValueTokenType {
     REFERENCE_ELEMENT, VALUE_TOKEN
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocMethodParamsImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocMethodParamsImpl.java
index 5051f08..fcc9d6d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocMethodParamsImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/impl/GrDocMethodParamsImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,7 +25,6 @@
 import com.intellij.psi.impl.PsiManagerEx;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.ReflectionCache;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.groovydoc.lexer.GroovyDocTokenTypes;
@@ -53,10 +52,12 @@
     return "GrDocMethodParameterList";
   }
 
+  @Override
   public void accept(GroovyElementVisitor visitor) {
     visitor.visitDocMethodParameterList(this);
   }
 
+  @Override
   public PsiType[] getParameterTypes() {
     ArrayList<PsiType> types = new ArrayList<PsiType>();
     PsiManagerEx manager = getManager();
@@ -73,17 +74,19 @@
         types.add(null);
       }
     }
-    return types.toArray(new PsiType[types.size()]);
+    return types.toArray(PsiType.createArray(types.size()));
   }
 
+  @Override
   public GrDocMethodParameter[] getParameters() {
     List<GrDocMethodParameter> result = new ArrayList<GrDocMethodParameter>();
     for (PsiElement cur = getFirstChild(); cur != null; cur = cur.getNextSibling()) {
-      if (ReflectionCache.isInstance(cur, GrDocMethodParameter.class)) result.add((GrDocMethodParameter)cur);
+      if (GrDocMethodParameter.class.isInstance(cur)) result.add((GrDocMethodParameter)cur);
     }
     return result.toArray(new GrDocMethodParameter[result.size()]);
   }
 
+  @Override
   @NotNull
   public PsiElement getLeftParen() {
     ASTNode paren = getNode().findChildByType(GroovyDocTokenTypes.mGDOC_TAG_VALUE_LPAREN);
@@ -91,6 +94,7 @@
     return paren.getPsi();
   }
 
+  @Override
   @Nullable
   public PsiElement getRightParen() {
     ASTNode paren = getNode().findChildByType(GroovyDocTokenTypes.mGDOC_TAG_VALUE_RPAREN);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyElementType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyElementType.java
index 923bbc7..d6dfc73 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyElementType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyElementType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,11 +16,11 @@
 
 package org.jetbrains.plugins.groovy.lang.lexer;
 
-import com.intellij.psi.tree.IElementType;
 import com.intellij.lang.ASTNode;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.GroovyFileType;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
-import org.jetbrains.annotations.NotNull;
 
 /**
  * Main classdef for Groovy element types, such as lexems or AST nodes
@@ -29,15 +29,26 @@
  */
 public class GroovyElementType extends IElementType {
 
-  private String debugName = null;
+  private final String myDebugName;
+  private final boolean myLeftBound;
 
   public GroovyElementType(String debugName) {
+    this(debugName, false);
+  }
+
+  public GroovyElementType(String debugName, boolean boundToLeft) {
     super(debugName, GroovyFileType.GROOVY_LANGUAGE);
-    this.debugName = debugName;
+    myDebugName = debugName;
+    myLeftBound = boundToLeft;
   }
 
   public String toString() {
-    return debugName;
+    return myDebugName;
+  }
+
+  @Override
+  public boolean isLeftBound() {
+    return myLeftBound;
   }
 
   public static abstract class PsiCreator extends GroovyElementType {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyLexer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyLexer.java
index 7812039..726fbb2 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyLexer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/GroovyLexer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,9 +33,7 @@
     mREGEX_CONTENT,
     mDOLLAR_SLASH_REGEX_CONTENT,
     WHITE_SPACE,
-    mGSTRING_CONTENT,
-    mDOLLAR_SLASH_REGEX_CONTENT,
-    mREGEX_CONTENT
+    mGSTRING_CONTENT
   );
 
   public GroovyLexer() {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java
index 72930dc..3fa6965 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -100,6 +100,8 @@
   public static final TokenSet REFERENCE_NAMES = TokenSet.orSet(KEYWORDS, PROPERTY_NAMES, NUMBERS);
   public static final TokenSet REFERENCE_NAMES_WITHOUT_NUMBERS = TokenSet.orSet(KEYWORDS, PROPERTY_NAMES);
 
+  public static final TokenSet REFERENCE_NAME_PREFIXES = TokenSet.orSet(NUMBERS, KEYWORDS, TokenSet.create(mIDENT, mSTRING_LITERAL, mGSTRING_LITERAL, mGSTRING_BEGIN, mREGEX_BEGIN, mDOLLAR_SLASH_REGEX_BEGIN, mAT));
+
 
   public static final TokenSet VISIBILITY_MODIFIERS = TokenSet.create(
       kPRIVATE,
@@ -172,6 +174,9 @@
                                                                COMPOSITE_LSHIFT_SIGN, COMPOSITE_RSHIFT_SIGN, COMPOSITE_TRIPLE_SHIFT_SIGN,
                                                                mREGEX_FIND, mREGEX_MATCH, mRANGE_INCLUSIVE, mRANGE_EXCLUSIVE);
 
+  public static final TokenSet ASSOCIATIVE_BINARY_OP_SET = TokenSet.create(mBAND, mBOR, mBXOR, mEQUAL, mLOR, mPLUS, mSTAR, mNOT_EQUAL, mLAND);
+
+
   public static final TokenSet BINARY_EXPRESSIONS = TokenSet.create(ADDITIVE_EXPRESSION, MULTIPLICATIVE_EXPRESSION, POWER_EXPRESSION,
                                                                     POWER_EXPRESSION_SIMPLE, LOGICAL_OR_EXPRESSION, LOGICAL_AND_EXPRESSION,
                                                                     INCLUSIVE_OR_EXPRESSION, EXCLUSIVE_OR_EXPRESSION, AND_EXPRESSION,
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/_GroovyLexer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/_GroovyLexer.java
index 707e80f..4768006 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/_GroovyLexer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/_GroovyLexer.java
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-/* The following code was generated by JFlex 1.4.3 on 10/22/13 5:15 PM */
+/* The following code was generated by JFlex 1.4.3 on 11/12/13 2:46 PM */
 
 package org.jetbrains.plugins.groovy.lang.lexer;
 
@@ -28,7 +28,7 @@
 /**
  * This class is a scanner generated by 
  * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
- * on 10/22/13 5:15 PM from the specification file
+ * on 11/12/13 2:46 PM from the specification file
  * <tt>/Users/maxmedvedev/work/IDEA/tools/lexer/../../community/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/groovy.flex</tt>
  */
 public class _GroovyLexer implements FlexLexer, GroovyTokenTypes, TokenType {
@@ -178,62 +178,86 @@
     "\1\41\20\42\1\43\1\44\20\45\1\46\1\47\1\50"+
     "\1\47\1\51\1\52\1\53\1\47\1\54\1\47\1\41"+
     "\1\44\1\55\1\56\1\57\1\60\1\61\1\62\1\61"+
-    "\1\63\1\61\1\64\1\65\2\66\1\67\1\70\2\71"+
-    "\1\72\1\73\2\74\1\75\2\76\1\77\1\3\2\77"+
-    "\2\100\2\101\5\0\1\3\1\102\1\103\1\104\1\105"+
-    "\1\106\1\107\1\110\1\111\1\112\1\113\1\114\1\10"+
-    "\1\115\3\0\5\7\1\116\1\7\1\117\1\7\1\120"+
-    "\3\7\1\121\1\122\1\123\1\124\1\125\2\0\3\7"+
-    "\1\126\1\127\1\130\1\14\1\0\1\14\2\0\1\131"+
-    "\4\7\1\132\21\7\1\133\1\134\1\135\1\136\1\137"+
-    "\1\0\1\140\1\0\1\141\1\142\1\143\1\144\1\145"+
-    "\1\146\5\42\1\116\1\42\1\117\1\42\1\120\12\42"+
-    "\1\132\21\42\5\45\1\116\1\45\1\117\1\45\1\120"+
-    "\12\45\1\132\21\45\1\0\4\47\1\147\1\150\1\0"+
-    "\1\62\1\151\1\0\1\152\1\153\2\0\1\154\2\155"+
-    "\1\156\3\0\1\103\1\157\1\160\1\111\1\161\1\0"+
-    "\1\161\3\7\1\162\3\7\1\163\1\164\4\7\2\10"+
-    "\3\7\1\165\1\166\4\14\1\131\2\0\1\167\23\7"+
-    "\1\170\3\7\1\171\5\7\1\135\1\172\1\173\1\174"+
-    "\1\175\1\0\3\42\1\162\3\42\1\163\1\164\32\42"+
-    "\1\170\3\42\1\171\5\42\3\45\1\162\3\45\1\163"+
-    "\1\164\32\45\1\170\3\45\1\171\5\45\1\47\2\0"+
-    "\1\47\1\176\1\0\1\103\2\157\1\161\1\0\3\7"+
-    "\1\177\6\7\1\200\1\7\1\201\2\0\2\7\1\202"+
-    "\3\0\1\14\7\0\7\7\1\203\2\7\1\204\6\7"+
-    "\1\205\1\7\1\206\2\7\1\207\2\7\1\210\1\7"+
-    "\1\211\3\42\1\177\6\42\1\200\1\42\1\201\2\42"+
-    "\1\202\7\42\1\203\2\42\1\204\6\42\1\205\1\42"+
-    "\1\206\2\42\1\207\2\42\1\210\1\42\3\45\1\177"+
-    "\6\45\1\200\1\45\1\201\2\45\1\202\7\45\1\203"+
-    "\2\45\1\204\6\45\1\205\1\45\1\206\2\45\1\207"+
-    "\2\45\1\210\1\45\1\47\1\0\1\53\1\103\1\0"+
-    "\1\157\1\212\1\213\1\214\7\7\1\215\1\7\1\14"+
-    "\1\0\1\14\5\0\6\7\1\216\1\217\1\7\1\220"+
-    "\3\7\1\221\2\7\1\222\3\7\1\223\1\212\1\213"+
-    "\1\214\7\42\1\215\7\42\1\216\1\217\1\42\1\220"+
-    "\3\42\1\221\2\42\1\222\3\42\1\223\1\212\1\213"+
-    "\1\214\7\45\1\215\7\45\1\216\1\217\1\45\1\220"+
-    "\3\45\1\221\2\45\1\222\3\45\1\223\1\0\2\7"+
-    "\1\224\3\7\1\225\2\7\2\0\1\226\4\7\1\227"+
-    "\1\7\1\230\2\7\1\231\1\7\1\232\1\233\1\234"+
-    "\1\7\2\42\1\224\3\42\1\225\2\42\1\226\4\42"+
-    "\1\227\1\42\1\230\2\42\1\231\1\42\1\232\1\233"+
-    "\1\234\1\42\2\45\1\224\3\45\1\225\2\45\1\226"+
-    "\4\45\1\227\1\45\1\230\2\45\1\231\1\45\1\232"+
-    "\1\233\1\234\1\45\1\235\3\7\1\236\1\237\1\240"+
-    "\1\14\1\241\1\242\7\7\1\235\3\42\1\236\1\237"+
-    "\1\240\1\241\1\242\7\42\1\235\3\45\1\236\1\237"+
-    "\1\240\1\241\1\242\7\45\4\7\1\243\1\244\1\245"+
-    "\2\7\1\246\4\42\1\243\1\244\1\245\2\42\1\246"+
-    "\4\45\1\243\1\244\1\245\2\45\1\246\2\7\1\247"+
-    "\1\250\1\7\1\251\2\42\1\247\1\250\1\42\1\251"+
-    "\2\45\1\247\1\250\1\45\1\251\1\252\1\253\1\7"+
-    "\1\252\1\253\1\42\1\252\1\253\1\45\1\7\1\42"+
-    "\1\45\3\254";
+    "\1\63\1\61\1\64\20\65\1\66\2\67\1\70\1\71"+
+    "\1\64\1\72\20\73\1\74\2\75\1\76\2\77\1\100"+
+    "\1\3\2\100\2\101\2\102\5\0\1\3\1\103\1\104"+
+    "\1\105\1\106\1\107\1\110\1\111\1\112\1\113\1\114"+
+    "\1\115\1\10\1\116\3\0\5\7\1\117\1\7\1\120"+
+    "\1\7\1\121\3\7\1\122\1\123\1\124\1\125\1\126"+
+    "\2\0\3\7\1\127\1\130\1\131\1\14\1\0\1\14"+
+    "\2\0\1\132\4\7\1\133\21\7\1\134\1\135\1\136"+
+    "\1\137\1\140\1\0\1\141\1\0\1\142\1\143\1\144"+
+    "\1\145\1\146\1\147\5\42\1\117\1\42\1\120\1\42"+
+    "\1\121\12\42\1\133\21\42\5\45\1\117\1\45\1\120"+
+    "\1\45\1\121\12\45\1\133\21\45\1\0\4\47\1\150"+
+    "\1\151\1\0\1\62\1\152\5\65\1\117\1\65\1\120"+
+    "\1\65\1\121\12\65\1\133\21\65\1\0\1\153\1\154"+
+    "\5\73\1\117\1\73\1\120\1\73\1\121\12\73\1\133"+
+    "\21\73\2\0\1\155\2\156\1\157\3\0\1\104\1\160"+
+    "\1\161\1\112\1\162\1\0\1\162\3\7\1\163\3\7"+
+    "\1\164\1\165\4\7\2\10\3\7\1\166\1\167\4\14"+
+    "\1\132\2\0\1\170\23\7\1\171\3\7\1\172\5\7"+
+    "\1\136\1\173\1\174\1\175\1\176\1\0\3\42\1\163"+
+    "\3\42\1\164\1\165\32\42\1\171\3\42\1\172\5\42"+
+    "\3\45\1\163\3\45\1\164\1\165\32\45\1\171\3\45"+
+    "\1\172\5\45\1\47\2\0\1\47\1\177\3\65\1\163"+
+    "\3\65\1\164\1\165\32\65\1\171\3\65\1\172\5\65"+
+    "\3\73\1\163\3\73\1\164\1\165\32\73\1\171\3\73"+
+    "\1\172\5\73\1\0\1\104\2\160\1\162\1\0\3\7"+
+    "\1\200\6\7\1\201\1\7\1\202\2\0\2\7\1\203"+
+    "\3\0\1\14\7\0\7\7\1\204\2\7\1\205\6\7"+
+    "\1\206\1\7\1\207\2\7\1\210\2\7\1\211\1\7"+
+    "\1\212\3\42\1\200\6\42\1\201\1\42\1\202\2\42"+
+    "\1\203\7\42\1\204\2\42\1\205\6\42\1\206\1\42"+
+    "\1\207\2\42\1\210\2\42\1\211\1\42\3\45\1\200"+
+    "\6\45\1\201\1\45\1\202\2\45\1\203\7\45\1\204"+
+    "\2\45\1\205\6\45\1\206\1\45\1\207\2\45\1\210"+
+    "\2\45\1\211\1\45\1\47\1\0\1\53\3\65\1\200"+
+    "\6\65\1\201\1\65\1\202\2\65\1\203\7\65\1\204"+
+    "\2\65\1\205\6\65\1\206\1\65\1\207\2\65\1\210"+
+    "\2\65\1\211\1\65\3\73\1\200\6\73\1\201\1\73"+
+    "\1\202\2\73\1\203\7\73\1\204\2\73\1\205\6\73"+
+    "\1\206\1\73\1\207\2\73\1\210\2\73\1\211\1\73"+
+    "\1\104\1\0\1\160\1\213\1\214\1\215\7\7\1\216"+
+    "\1\7\1\14\1\0\1\14\5\0\6\7\1\217\1\220"+
+    "\1\7\1\221\3\7\1\222\2\7\1\223\3\7\1\224"+
+    "\1\213\1\214\1\215\7\42\1\216\7\42\1\217\1\220"+
+    "\1\42\1\221\3\42\1\222\2\42\1\223\3\42\1\224"+
+    "\1\213\1\214\1\215\7\45\1\216\7\45\1\217\1\220"+
+    "\1\45\1\221\3\45\1\222\2\45\1\223\3\45\1\224"+
+    "\1\213\1\214\1\215\7\65\1\216\7\65\1\217\1\220"+
+    "\1\65\1\221\3\65\1\222\2\65\1\223\3\65\1\224"+
+    "\1\213\1\214\1\215\7\73\1\216\7\73\1\217\1\220"+
+    "\1\73\1\221\3\73\1\222\2\73\1\223\3\73\1\224"+
+    "\1\0\2\7\1\225\3\7\1\226\2\7\2\0\1\227"+
+    "\4\7\1\230\1\7\1\231\2\7\1\232\1\7\1\233"+
+    "\1\234\1\235\1\7\2\42\1\225\3\42\1\226\2\42"+
+    "\1\227\4\42\1\230\1\42\1\231\2\42\1\232\1\42"+
+    "\1\233\1\234\1\235\1\42\2\45\1\225\3\45\1\226"+
+    "\2\45\1\227\4\45\1\230\1\45\1\231\2\45\1\232"+
+    "\1\45\1\233\1\234\1\235\1\45\2\65\1\225\3\65"+
+    "\1\226\2\65\1\227\4\65\1\230\1\65\1\231\2\65"+
+    "\1\232\1\65\1\233\1\234\1\235\1\65\2\73\1\225"+
+    "\3\73\1\226\2\73\1\227\4\73\1\230\1\73\1\231"+
+    "\2\73\1\232\1\73\1\233\1\234\1\235\1\73\1\236"+
+    "\3\7\1\237\1\240\1\241\1\14\1\242\1\243\7\7"+
+    "\1\236\3\42\1\237\1\240\1\241\1\242\1\243\7\42"+
+    "\1\236\3\45\1\237\1\240\1\241\1\242\1\243\7\45"+
+    "\1\236\3\65\1\237\1\240\1\241\1\242\1\243\7\65"+
+    "\1\236\3\73\1\237\1\240\1\241\1\242\1\243\7\73"+
+    "\4\7\1\244\1\245\1\246\2\7\1\247\4\42\1\244"+
+    "\1\245\1\246\2\42\1\247\4\45\1\244\1\245\1\246"+
+    "\2\45\1\247\4\65\1\244\1\245\1\246\2\65\1\247"+
+    "\4\73\1\244\1\245\1\246\2\73\1\247\2\7\1\250"+
+    "\1\251\1\7\1\252\2\42\1\250\1\251\1\42\1\252"+
+    "\2\45\1\250\1\251\1\45\1\252\2\65\1\250\1\251"+
+    "\1\65\1\252\2\73\1\250\1\251\1\73\1\252\1\253"+
+    "\1\254\1\7\1\253\1\254\1\42\1\253\1\254\1\45"+
+    "\1\253\1\254\1\65\1\253\1\254\1\73\1\7\1\42"+
+    "\1\45\1\65\1\73\5\255";
 
   private static int [] zzUnpackAction() {
-    int [] result = new int[961];
+    int [] result = new int[1434];
     int offset = 0;
     offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
     return result;
@@ -274,114 +298,173 @@
     "\0\u1908\0\u1950\0\u1998\0\u19e0\0\u1a28\0\u1a70\0\u1ab8\0\u1b00"+
     "\0\u0750\0\u1b48\0\u1b90\0\u1bd8\0\u0750\0\u0750\0\u1c20\0\u1c68"+
     "\0\u0750\0\u1cb0\0\u1cf8\0\u1d40\0\u0750\0\u1d88\0\u0750\0\u0750"+
-    "\0\u0750\0\u0750\0\u1dd0\0\u1e18\0\u1e60\0\u1ea8\0\u0750\0\u1ef0"+
-    "\0\u1f38\0\u0750\0\u1f80\0\u0750\0\u1fc8\0\u2010\0\u0750\0\u2058"+
-    "\0\u20a0\0\u20e8\0\u0750\0\u2130\0\u0750\0\u2178\0\u21c0\0\u1e18"+
-    "\0\u0750\0\u21c0\0\u0750\0\u21c0\0\u06c0\0\u2208\0\u2250\0\u2298"+
-    "\0\u22e0\0\u2328\0\u2370\0\u23b8\0\u0750\0\u2400\0\u0750\0\u0750"+
-    "\0\u2448\0\u2490\0\u0750\0\u0750\0\u0750\0\u0750\0\u0750\0\u24d8"+
-    "\0\u2520\0\u2568\0\u25b0\0\u25f8\0\u2640\0\u2688\0\u26d0\0\u0948"+
-    "\0\u2718\0\u2760\0\u27a8\0\u27f0\0\u2838\0\u2880\0\u28c8\0\u0750"+
-    "\0\u0750\0\u0750\0\u0750\0\u0750\0\u2910\0\u2958\0\u29a0\0\u29e8"+
-    "\0\u2a30\0\u2a78\0\u0750\0\u0750\0\u2ac0\0\u2b08\0\u2b50\0\u2b98"+
-    "\0\u2be0\0\u2c28\0\u2c70\0\u2cb8\0\u2d00\0\u2d48\0\u2d90\0\u2dd8"+
-    "\0\u2e20\0\u2e68\0\u2eb0\0\u2ef8\0\u2f40\0\u2f88\0\u2fd0\0\u3018"+
-    "\0\u3060\0\u30a8\0\u30f0\0\u3138\0\u3180\0\u31c8\0\u3210\0\u3258"+
-    "\0\u0750\0\u0750\0\u32a0\0\u0750\0\u32e8\0\u3330\0\u0750\0\u3378"+
-    "\0\u0750\0\u0750\0\u0750\0\u0750\0\u0750\0\u0750\0\u33c0\0\u3408"+
-    "\0\u3450\0\u3498\0\u34e0\0\u1248\0\u3528\0\u3570\0\u35b8\0\u3600"+
-    "\0\u3648\0\u3690\0\u36d8\0\u3720\0\u3768\0\u37b0\0\u37f8\0\u3840"+
-    "\0\u3888\0\u38d0\0\u3918\0\u3960\0\u39a8\0\u39f0\0\u3a38\0\u3a80"+
-    "\0\u3ac8\0\u3b10\0\u3b58\0\u3ba0\0\u3be8\0\u3c30\0\u3c78\0\u3cc0"+
-    "\0\u3d08\0\u3d50\0\u3d98\0\u3de0\0\u3e28\0\u3e70\0\u3eb8\0\u3f00"+
-    "\0\u3f48\0\u16c8\0\u3f90\0\u3fd8\0\u4020\0\u4068\0\u40b0\0\u40f8"+
+    "\0\u0750\0\u0750\0\u1dd0\0\u1e18\0\u1e60\0\u0750\0\u1ea8\0\u1ef0"+
+    "\0\u1f38\0\u1f80\0\u1fc8\0\u2010\0\u2058\0\u20a0\0\u20e8\0\u2130"+
+    "\0\u2178\0\u21c0\0\u2208\0\u2250\0\u2298\0\u22e0\0\u0750\0\u2328"+
+    "\0\u2370\0\u0750\0\u23b8\0\u2400\0\u0750\0\u2448\0\u2490\0\u24d8"+
+    "\0\u2520\0\u2568\0\u25b0\0\u25f8\0\u2640\0\u2688\0\u26d0\0\u2718"+
+    "\0\u2760\0\u27a8\0\u27f0\0\u2838\0\u2880\0\u0750\0\u28c8\0\u2910"+
+    "\0\u2958\0\u0750\0\u29a0\0\u0750\0\u29e8\0\u2a30\0\u1e18\0\u0750"+
+    "\0\u2a30\0\u0750\0\u2a30\0\u06c0\0\u2a78\0\u2ac0\0\u2b08\0\u2b50"+
+    "\0\u2b98\0\u2be0\0\u2c28\0\u0750\0\u2c70\0\u0750\0\u0750\0\u2cb8"+
+    "\0\u2d00\0\u0750\0\u0750\0\u0750\0\u0750\0\u0750\0\u2d48\0\u2d90"+
+    "\0\u2dd8\0\u2e20\0\u2e68\0\u2eb0\0\u2ef8\0\u2f40\0\u0948\0\u2f88"+
+    "\0\u2fd0\0\u3018\0\u3060\0\u30a8\0\u30f0\0\u3138\0\u0750\0\u0750"+
+    "\0\u0750\0\u0750\0\u0750\0\u3180\0\u31c8\0\u3210\0\u3258\0\u32a0"+
+    "\0\u32e8\0\u0750\0\u0750\0\u3330\0\u3378\0\u33c0\0\u3408\0\u3450"+
+    "\0\u3498\0\u34e0\0\u3528\0\u3570\0\u35b8\0\u3600\0\u3648\0\u3690"+
+    "\0\u36d8\0\u3720\0\u3768\0\u37b0\0\u37f8\0\u3840\0\u3888\0\u38d0"+
+    "\0\u3918\0\u3960\0\u39a8\0\u39f0\0\u3a38\0\u3a80\0\u3ac8\0\u0750"+
+    "\0\u0750\0\u3b10\0\u0750\0\u3b58\0\u3ba0\0\u0750\0\u3be8\0\u0750"+
+    "\0\u0750\0\u0750\0\u0750\0\u0750\0\u0750\0\u3c30\0\u3c78\0\u3cc0"+
+    "\0\u3d08\0\u3d50\0\u1248\0\u3d98\0\u3de0\0\u3e28\0\u3e70\0\u3eb8"+
+    "\0\u3f00\0\u3f48\0\u3f90\0\u3fd8\0\u4020\0\u4068\0\u40b0\0\u40f8"+
     "\0\u4140\0\u4188\0\u41d0\0\u4218\0\u4260\0\u42a8\0\u42f0\0\u4338"+
     "\0\u4380\0\u43c8\0\u4410\0\u4458\0\u44a0\0\u44e8\0\u4530\0\u4578"+
     "\0\u45c0\0\u4608\0\u4650\0\u4698\0\u46e0\0\u4728\0\u4770\0\u47b8"+
-    "\0\u4800\0\u4848\0\u4890\0\u48d8\0\u4920\0\u4968\0\u49b0\0\u49f8"+
-    "\0\u4a40\0\u4a88\0\u4ad0\0\u0750\0\u1f80\0\u0750\0\u4b18\0\u4b60"+
-    "\0\u20e8\0\u0750\0\u0750\0\u2058\0\u4ba8\0\u21c0\0\u4bf0\0\u4c38"+
-    "\0\u4c80\0\u4cc8\0\u0750\0\u0750\0\u4d10\0\u4d58\0\u4da0\0\u4de8"+
-    "\0\u4e30\0\u4e78\0\u0948\0\u4ec0\0\u4f08\0\u4f50\0\u4f98\0\u4fe0"+
-    "\0\u5028\0\u5070\0\u50b8\0\u5100\0\u5148\0\u5190\0\u51d8\0\u5220"+
-    "\0\u5268\0\u0750\0\u0750\0\u0750\0\u52b0\0\u52f8\0\u5340\0\u0750"+
-    "\0\u5388\0\u53d0\0\u5418\0\u5460\0\u54a8\0\u54f0\0\u5538\0\u5580"+
-    "\0\u55c8\0\u5610\0\u5658\0\u56a0\0\u56e8\0\u5730\0\u5778\0\u57c0"+
-    "\0\u5808\0\u5850\0\u5898\0\u58e0\0\u5928\0\u5970\0\u0948\0\u59b8"+
-    "\0\u5a00\0\u5a48\0\u0948\0\u5a90\0\u5ad8\0\u5b20\0\u5b68\0\u5bb0"+
-    "\0\u0750\0\u0750\0\u0750\0\u0750\0\u0750\0\u5bf8\0\u5c40\0\u5c88"+
-    "\0\u5cd0\0\u1248\0\u5d18\0\u5d60\0\u5da8\0\u5df0\0\u5e38\0\u5e80"+
-    "\0\u5ec8\0\u5f10\0\u5f58\0\u5fa0\0\u5fe8\0\u6030\0\u6078\0\u60c0"+
-    "\0\u6108\0\u6150\0\u6198\0\u61e0\0\u6228\0\u6270\0\u62b8\0\u6300"+
-    "\0\u6348\0\u6390\0\u63d8\0\u6420\0\u6468\0\u64b0\0\u64f8\0\u6540"+
-    "\0\u6588\0\u1248\0\u65d0\0\u6618\0\u6660\0\u1248\0\u66a8\0\u66f0"+
-    "\0\u6738\0\u6780\0\u67c8\0\u6810\0\u6858\0\u68a0\0\u16c8\0\u68e8"+
-    "\0\u6930\0\u6978\0\u69c0\0\u6a08\0\u6a50\0\u6a98\0\u6ae0\0\u6b28"+
-    "\0\u6b70\0\u6bb8\0\u6c00\0\u6c48\0\u6c90\0\u6cd8\0\u6d20\0\u6d68"+
-    "\0\u6db0\0\u6df8\0\u6e40\0\u6e88\0\u6ed0\0\u6f18\0\u6f60\0\u6fa8"+
-    "\0\u6ff0\0\u7038\0\u7080\0\u70c8\0\u7110\0\u7158\0\u16c8\0\u71a0"+
-    "\0\u71e8\0\u7230\0\u16c8\0\u7278\0\u72c0\0\u7308\0\u7350\0\u7398"+
-    "\0\u73e0\0\u7428\0\u7470\0\u74b8\0\u0750\0\u0750\0\u7500\0\u7548"+
-    "\0\u0750\0\u0750\0\u7590\0\u75d8\0\u7620\0\u7668\0\u0948\0\u76b0"+
-    "\0\u76f8\0\u7740\0\u7788\0\u77d0\0\u7818\0\u0948\0\u7860\0\u0948"+
-    "\0\u78a8\0\u78f0\0\u7938\0\u7980\0\u0948\0\u79c8\0\u7a10\0\u7a58"+
-    "\0\u7aa0\0\u7ae8\0\u7b30\0\u7b78\0\u7bc0\0\u7c08\0\u7c50\0\u7c98"+
-    "\0\u7ce0\0\u7d28\0\u7d70\0\u7db8\0\u7e00\0\u7e48\0\u7e90\0\u0948"+
-    "\0\u7ed8\0\u7f20\0\u0948\0\u7f68\0\u7fb0\0\u7ff8\0\u8040\0\u8088"+
-    "\0\u80d0\0\u0948\0\u8118\0\u0948\0\u8160\0\u81a8\0\u0948\0\u81f0"+
-    "\0\u8238\0\u0948\0\u8280\0\u0750\0\u82c8\0\u8310\0\u8358\0\u1248"+
-    "\0\u83a0\0\u83e8\0\u8430\0\u8478\0\u84c0\0\u8508\0\u1248\0\u8550"+
-    "\0\u1248\0\u8598\0\u85e0\0\u1248\0\u8628\0\u8670\0\u86b8\0\u8700"+
-    "\0\u8748\0\u8790\0\u87d8\0\u1248\0\u8820\0\u8868\0\u1248\0\u88b0"+
-    "\0\u88f8\0\u8940\0\u8988\0\u89d0\0\u8a18\0\u1248\0\u8a60\0\u1248"+
-    "\0\u8aa8\0\u8af0\0\u1248\0\u8b38\0\u8b80\0\u1248\0\u8bc8\0\u8c10"+
-    "\0\u8c58\0\u8ca0\0\u16c8\0\u8ce8\0\u8d30\0\u8d78\0\u8dc0\0\u8e08"+
-    "\0\u8e50\0\u16c8\0\u8e98\0\u16c8\0\u8ee0\0\u8f28\0\u16c8\0\u8f70"+
-    "\0\u8fb8\0\u9000\0\u9048\0\u9090\0\u90d8\0\u9120\0\u16c8\0\u9168"+
-    "\0\u91b0\0\u16c8\0\u91f8\0\u9240\0\u9288\0\u92d0\0\u9318\0\u9360"+
-    "\0\u16c8\0\u93a8\0\u16c8\0\u93f0\0\u9438\0\u16c8\0\u9480\0\u94c8"+
-    "\0\u16c8\0\u9510\0\u9558\0\u95a0\0\u0750\0\u0750\0\u7500\0\u95e8"+
-    "\0\u0948\0\u9630\0\u0948\0\u9678\0\u96c0\0\u9708\0\u9750\0\u9798"+
-    "\0\u97e0\0\u9828\0\u0948\0\u9870\0\u98b8\0\u9900\0\u9948\0\u9990"+
-    "\0\u99d8\0\u9a20\0\u9a68\0\u9ab0\0\u9af8\0\u9b40\0\u9b88\0\u9bd0"+
-    "\0\u9c18\0\u9c60\0\u0948\0\u0948\0\u9ca8\0\u0948\0\u9cf0\0\u9d38"+
-    "\0\u9d80\0\u0948\0\u9dc8\0\u9e10\0\u9e58\0\u9ea0\0\u9ee8\0\u9f30"+
-    "\0\u0948\0\u1248\0\u9f78\0\u1248\0\u9fc0\0\ua008\0\ua050\0\ua098"+
-    "\0\ua0e0\0\ua128\0\ua170\0\u1248\0\ua1b8\0\ua200\0\ua248\0\ua290"+
-    "\0\ua2d8\0\ua320\0\ua368\0\u1248\0\u1248\0\ua3b0\0\u1248\0\ua3f8"+
-    "\0\ua440\0\ua488\0\u1248\0\ua4d0\0\ua518\0\ua560\0\ua5a8\0\ua5f0"+
-    "\0\ua638\0\u1248\0\u16c8\0\ua680\0\u16c8\0\ua6c8\0\ua710\0\ua758"+
-    "\0\ua7a0\0\ua7e8\0\ua830\0\ua878\0\u16c8\0\ua8c0\0\ua908\0\ua950"+
-    "\0\ua998\0\ua9e0\0\uaa28\0\uaa70\0\u16c8\0\u16c8\0\uaab8\0\u16c8"+
-    "\0\uab00\0\uab48\0\uab90\0\u16c8\0\uabd8\0\uac20\0\uac68\0\uacb0"+
-    "\0\uacf8\0\uad40\0\u16c8\0\u95e8\0\uad88\0\uadd0\0\u0948\0\uae18"+
-    "\0\uae60\0\uaea8\0\u0948\0\uaef0\0\uaf38\0\uaf80\0\uafc8\0\u0948"+
-    "\0\ub010\0\ub058\0\ub0a0\0\ub0e8\0\u0948\0\ub130\0\u0948\0\ub178"+
-    "\0\ub1c0\0\u0948\0\ub208\0\u0948\0\u0948\0\u0948\0\ub250\0\ub298"+
-    "\0\ub2e0\0\u1248\0\ub328\0\ub370\0\ub3b8\0\u1248\0\ub400\0\ub448"+
-    "\0\u1248\0\ub490\0\ub4d8\0\ub520\0\ub568\0\u1248\0\ub5b0\0\u1248"+
-    "\0\ub5f8\0\ub640\0\u1248\0\ub688\0\u1248\0\u1248\0\u1248\0\ub6d0"+
-    "\0\ub718\0\ub760\0\u16c8\0\ub7a8\0\ub7f0\0\ub838\0\u16c8\0\ub880"+
-    "\0\ub8c8\0\u16c8\0\ub910\0\ub958\0\ub9a0\0\ub9e8\0\u16c8\0\uba30"+
-    "\0\u16c8\0\uba78\0\ubac0\0\u16c8\0\ubb08\0\u16c8\0\u16c8\0\u16c8"+
-    "\0\ubb50\0\u0948\0\ubb98\0\ubbe0\0\ubc28\0\u0948\0\u0948\0\u0948"+
-    "\0\u9990\0\u0948\0\u0948\0\ubc70\0\ubcb8\0\ubd00\0\ubd48\0\ubd90"+
-    "\0\ubdd8\0\ube20\0\u1248\0\ube68\0\ubeb0\0\ubef8\0\u1248\0\u1248"+
-    "\0\u1248\0\u1248\0\u1248\0\ubf40\0\ubf88\0\ubfd0\0\uc018\0\uc060"+
-    "\0\uc0a8\0\uc0f0\0\u16c8\0\uc138\0\uc180\0\uc1c8\0\u16c8\0\u16c8"+
-    "\0\u16c8\0\u16c8\0\u16c8\0\uc210\0\uc258\0\uc2a0\0\uc2e8\0\uc330"+
-    "\0\uc378\0\uc3c0\0\uc408\0\uc450\0\uc498\0\uc4e0\0\u0948\0\u0948"+
-    "\0\u0948\0\uc528\0\uc570\0\u0948\0\uc5b8\0\uc600\0\uc648\0\uc690"+
-    "\0\u1248\0\u1248\0\u1248\0\uc6d8\0\uc720\0\u1248\0\uc768\0\uc7b0"+
-    "\0\uc7f8\0\uc840\0\u16c8\0\u16c8\0\u16c8\0\uc888\0\uc8d0\0\u16c8"+
-    "\0\uc918\0\uc960\0\u0948\0\u0948\0\uc9a8\0\u0948\0\uc9f0\0\uca38"+
-    "\0\u1248\0\u1248\0\uca80\0\u1248\0\ucac8\0\ucb10\0\u16c8\0\u16c8"+
-    "\0\ucb58\0\u16c8\0\u0948\0\u0948\0\ucba0\0\u1248\0\u1248\0\ucbe8"+
-    "\0\u16c8\0\u16c8\0\ucc30\0\ucc78\0\uccc0\0\ucd08\0\u0948\0\u1248"+
-    "\0\u16c8";
+    "\0\u16c8\0\u4800\0\u4848\0\u4890\0\u48d8\0\u4920\0\u4968\0\u49b0"+
+    "\0\u49f8\0\u4a40\0\u4a88\0\u4ad0\0\u4b18\0\u4b60\0\u4ba8\0\u4bf0"+
+    "\0\u4c38\0\u4c80\0\u4cc8\0\u4d10\0\u4d58\0\u4da0\0\u4de8\0\u4e30"+
+    "\0\u4e78\0\u4ec0\0\u4f08\0\u4f50\0\u4f98\0\u4fe0\0\u5028\0\u5070"+
+    "\0\u50b8\0\u5100\0\u5148\0\u5190\0\u51d8\0\u5220\0\u5268\0\u52b0"+
+    "\0\u52f8\0\u5340\0\u0750\0\u5388\0\u53d0\0\u5418\0\u5460\0\u54a8"+
+    "\0\u1ea8\0\u54f0\0\u5538\0\u5580\0\u55c8\0\u5610\0\u5658\0\u56a0"+
+    "\0\u56e8\0\u5730\0\u5778\0\u57c0\0\u5808\0\u5850\0\u5898\0\u58e0"+
+    "\0\u5928\0\u5970\0\u59b8\0\u5a00\0\u5a48\0\u5a90\0\u5ad8\0\u5b20"+
+    "\0\u5b68\0\u5bb0\0\u5bf8\0\u5c40\0\u5c88\0\u5cd0\0\u5d18\0\u5d60"+
+    "\0\u5da8\0\u23b8\0\u0750\0\u5df0\0\u5e38\0\u5e80\0\u5ec8\0\u5f10"+
+    "\0\u5f58\0\u2448\0\u5fa0\0\u5fe8\0\u6030\0\u6078\0\u60c0\0\u6108"+
+    "\0\u6150\0\u6198\0\u61e0\0\u6228\0\u6270\0\u62b8\0\u6300\0\u6348"+
+    "\0\u6390\0\u63d8\0\u6420\0\u6468\0\u64b0\0\u64f8\0\u6540\0\u6588"+
+    "\0\u65d0\0\u6618\0\u6660\0\u66a8\0\u66f0\0\u6738\0\u6780\0\u67c8"+
+    "\0\u6810\0\u6858\0\u68a0\0\u2958\0\u0750\0\u0750\0\u28c8\0\u68e8"+
+    "\0\u2a30\0\u6930\0\u6978\0\u69c0\0\u6a08\0\u0750\0\u0750\0\u6a50"+
+    "\0\u6a98\0\u6ae0\0\u6b28\0\u6b70\0\u6bb8\0\u0948\0\u6c00\0\u6c48"+
+    "\0\u6c90\0\u6cd8\0\u6d20\0\u6d68\0\u6db0\0\u6df8\0\u6e40\0\u6e88"+
+    "\0\u6ed0\0\u6f18\0\u6f60\0\u6fa8\0\u0750\0\u0750\0\u0750\0\u6ff0"+
+    "\0\u7038\0\u7080\0\u0750\0\u70c8\0\u7110\0\u7158\0\u71a0\0\u71e8"+
+    "\0\u7230\0\u7278\0\u72c0\0\u7308\0\u7350\0\u7398\0\u73e0\0\u7428"+
+    "\0\u7470\0\u74b8\0\u7500\0\u7548\0\u7590\0\u75d8\0\u7620\0\u7668"+
+    "\0\u76b0\0\u0948\0\u76f8\0\u7740\0\u7788\0\u0948\0\u77d0\0\u7818"+
+    "\0\u7860\0\u78a8\0\u78f0\0\u0750\0\u0750\0\u0750\0\u0750\0\u0750"+
+    "\0\u7938\0\u7980\0\u79c8\0\u7a10\0\u1248\0\u7a58\0\u7aa0\0\u7ae8"+
+    "\0\u7b30\0\u7b78\0\u7bc0\0\u7c08\0\u7c50\0\u7c98\0\u7ce0\0\u7d28"+
+    "\0\u7d70\0\u7db8\0\u7e00\0\u7e48\0\u7e90\0\u7ed8\0\u7f20\0\u7f68"+
+    "\0\u7fb0\0\u7ff8\0\u8040\0\u8088\0\u80d0\0\u8118\0\u8160\0\u81a8"+
+    "\0\u81f0\0\u8238\0\u8280\0\u82c8\0\u1248\0\u8310\0\u8358\0\u83a0"+
+    "\0\u1248\0\u83e8\0\u8430\0\u8478\0\u84c0\0\u8508\0\u8550\0\u8598"+
+    "\0\u85e0\0\u16c8\0\u8628\0\u8670\0\u86b8\0\u8700\0\u8748\0\u8790"+
+    "\0\u87d8\0\u8820\0\u8868\0\u88b0\0\u88f8\0\u8940\0\u8988\0\u89d0"+
+    "\0\u8a18\0\u8a60\0\u8aa8\0\u8af0\0\u8b38\0\u8b80\0\u8bc8\0\u8c10"+
+    "\0\u8c58\0\u8ca0\0\u8ce8\0\u8d30\0\u8d78\0\u8dc0\0\u8e08\0\u8e50"+
+    "\0\u8e98\0\u16c8\0\u8ee0\0\u8f28\0\u8f70\0\u16c8\0\u8fb8\0\u9000"+
+    "\0\u9048\0\u9090\0\u90d8\0\u9120\0\u9168\0\u91b0\0\u91f8\0\u0750"+
+    "\0\u9240\0\u9288\0\u92d0\0\u1ea8\0\u9318\0\u9360\0\u93a8\0\u93f0"+
+    "\0\u9438\0\u9480\0\u94c8\0\u9510\0\u9558\0\u95a0\0\u95e8\0\u9630"+
+    "\0\u9678\0\u96c0\0\u9708\0\u9750\0\u9798\0\u97e0\0\u9828\0\u9870"+
+    "\0\u98b8\0\u9900\0\u9948\0\u9990\0\u99d8\0\u9a20\0\u9a68\0\u9ab0"+
+    "\0\u9af8\0\u9b40\0\u9b88\0\u1ea8\0\u9bd0\0\u9c18\0\u9c60\0\u1ea8"+
+    "\0\u9ca8\0\u9cf0\0\u9d38\0\u9d80\0\u9dc8\0\u9e10\0\u9e58\0\u9ea0"+
+    "\0\u2448\0\u9ee8\0\u9f30\0\u9f78\0\u9fc0\0\ua008\0\ua050\0\ua098"+
+    "\0\ua0e0\0\ua128\0\ua170\0\ua1b8\0\ua200\0\ua248\0\ua290\0\ua2d8"+
+    "\0\ua320\0\ua368\0\ua3b0\0\ua3f8\0\ua440\0\ua488\0\ua4d0\0\ua518"+
+    "\0\ua560\0\ua5a8\0\ua5f0\0\ua638\0\ua680\0\ua6c8\0\ua710\0\ua758"+
+    "\0\u2448\0\ua7a0\0\ua7e8\0\ua830\0\u2448\0\ua878\0\ua8c0\0\ua908"+
+    "\0\ua950\0\ua998\0\u0750\0\ua9e0\0\uaa28\0\u0750\0\u0750\0\uaa70"+
+    "\0\uaab8\0\uab00\0\uab48\0\u0948\0\uab90\0\uabd8\0\uac20\0\uac68"+
+    "\0\uacb0\0\uacf8\0\u0948\0\uad40\0\u0948\0\uad88\0\uadd0\0\uae18"+
+    "\0\uae60\0\u0948\0\uaea8\0\uaef0\0\uaf38\0\uaf80\0\uafc8\0\ub010"+
+    "\0\ub058\0\ub0a0\0\ub0e8\0\ub130\0\ub178\0\ub1c0\0\ub208\0\ub250"+
+    "\0\ub298\0\ub2e0\0\ub328\0\ub370\0\u0948\0\ub3b8\0\ub400\0\u0948"+
+    "\0\ub448\0\ub490\0\ub4d8\0\ub520\0\ub568\0\ub5b0\0\u0948\0\ub5f8"+
+    "\0\u0948\0\ub640\0\ub688\0\u0948\0\ub6d0\0\ub718\0\u0948\0\ub760"+
+    "\0\u0750\0\ub7a8\0\ub7f0\0\ub838\0\u1248\0\ub880\0\ub8c8\0\ub910"+
+    "\0\ub958\0\ub9a0\0\ub9e8\0\u1248\0\uba30\0\u1248\0\uba78\0\ubac0"+
+    "\0\u1248\0\ubb08\0\ubb50\0\ubb98\0\ubbe0\0\ubc28\0\ubc70\0\ubcb8"+
+    "\0\u1248\0\ubd00\0\ubd48\0\u1248\0\ubd90\0\ubdd8\0\ube20\0\ube68"+
+    "\0\ubeb0\0\ubef8\0\u1248\0\ubf40\0\u1248\0\ubf88\0\ubfd0\0\u1248"+
+    "\0\uc018\0\uc060\0\u1248\0\uc0a8\0\uc0f0\0\uc138\0\uc180\0\u16c8"+
+    "\0\uc1c8\0\uc210\0\uc258\0\uc2a0\0\uc2e8\0\uc330\0\u16c8\0\uc378"+
+    "\0\u16c8\0\uc3c0\0\uc408\0\u16c8\0\uc450\0\uc498\0\uc4e0\0\uc528"+
+    "\0\uc570\0\uc5b8\0\uc600\0\u16c8\0\uc648\0\uc690\0\u16c8\0\uc6d8"+
+    "\0\uc720\0\uc768\0\uc7b0\0\uc7f8\0\uc840\0\u16c8\0\uc888\0\u16c8"+
+    "\0\uc8d0\0\uc918\0\u16c8\0\uc960\0\uc9a8\0\u16c8\0\uc9f0\0\uca38"+
+    "\0\uca80\0\u0750\0\ucac8\0\ucb10\0\ucb58\0\u1ea8\0\ucba0\0\ucbe8"+
+    "\0\ucc30\0\ucc78\0\uccc0\0\ucd08\0\u1ea8\0\ucd50\0\u1ea8\0\ucd98"+
+    "\0\ucde0\0\u1ea8\0\uce28\0\uce70\0\uceb8\0\ucf00\0\ucf48\0\ucf90"+
+    "\0\ucfd8\0\u1ea8\0\ud020\0\ud068\0\u1ea8\0\ud0b0\0\ud0f8\0\ud140"+
+    "\0\ud188\0\ud1d0\0\ud218\0\u1ea8\0\ud260\0\u1ea8\0\ud2a8\0\ud2f0"+
+    "\0\u1ea8\0\ud338\0\ud380\0\u1ea8\0\ud3c8\0\ud410\0\ud458\0\ud4a0"+
+    "\0\u2448\0\ud4e8\0\ud530\0\ud578\0\ud5c0\0\ud608\0\ud650\0\u2448"+
+    "\0\ud698\0\u2448\0\ud6e0\0\ud728\0\u2448\0\ud770\0\ud7b8\0\ud800"+
+    "\0\ud848\0\ud890\0\ud8d8\0\ud920\0\u2448\0\ud968\0\ud9b0\0\u2448"+
+    "\0\ud9f8\0\uda40\0\uda88\0\udad0\0\udb18\0\udb60\0\u2448\0\udba8"+
+    "\0\u2448\0\udbf0\0\udc38\0\u2448\0\udc80\0\udcc8\0\u2448\0\udd10"+
+    "\0\u0750\0\ua9e0\0\udd58\0\u0948\0\udda0\0\u0948\0\udde8\0\ude30"+
+    "\0\ude78\0\udec0\0\udf08\0\udf50\0\udf98\0\u0948\0\udfe0\0\ue028"+
+    "\0\ue070\0\ue0b8\0\ue100\0\ue148\0\ue190\0\ue1d8\0\ue220\0\ue268"+
+    "\0\ue2b0\0\ue2f8\0\ue340\0\ue388\0\ue3d0\0\u0948\0\u0948\0\ue418"+
+    "\0\u0948\0\ue460\0\ue4a8\0\ue4f0\0\u0948\0\ue538\0\ue580\0\ue5c8"+
+    "\0\ue610\0\ue658\0\ue6a0\0\u0948\0\u1248\0\ue6e8\0\u1248\0\ue730"+
+    "\0\ue778\0\ue7c0\0\ue808\0\ue850\0\ue898\0\ue8e0\0\u1248\0\ue928"+
+    "\0\ue970\0\ue9b8\0\uea00\0\uea48\0\uea90\0\uead8\0\u1248\0\u1248"+
+    "\0\ueb20\0\u1248\0\ueb68\0\uebb0\0\uebf8\0\u1248\0\uec40\0\uec88"+
+    "\0\uecd0\0\ued18\0\ued60\0\ueda8\0\u1248\0\u16c8\0\uedf0\0\u16c8"+
+    "\0\uee38\0\uee80\0\ueec8\0\uef10\0\uef58\0\uefa0\0\uefe8\0\u16c8"+
+    "\0\uf030\0\uf078\0\uf0c0\0\uf108\0\uf150\0\uf198\0\uf1e0\0\u16c8"+
+    "\0\u16c8\0\uf228\0\u16c8\0\uf270\0\uf2b8\0\uf300\0\u16c8\0\uf348"+
+    "\0\uf390\0\uf3d8\0\uf420\0\uf468\0\uf4b0\0\u16c8\0\u1ea8\0\uf4f8"+
+    "\0\u1ea8\0\uf540\0\uf588\0\uf5d0\0\uf618\0\uf660\0\uf6a8\0\uf6f0"+
+    "\0\u1ea8\0\uf738\0\uf780\0\uf7c8\0\uf810\0\uf858\0\uf8a0\0\uf8e8"+
+    "\0\u1ea8\0\u1ea8\0\uf930\0\u1ea8\0\uf978\0\uf9c0\0\ufa08\0\u1ea8"+
+    "\0\ufa50\0\ufa98\0\ufae0\0\ufb28\0\ufb70\0\ufbb8\0\u1ea8\0\u2448"+
+    "\0\ufc00\0\u2448\0\ufc48\0\ufc90\0\ufcd8\0\ufd20\0\ufd68\0\ufdb0"+
+    "\0\ufdf8\0\u2448\0\ufe40\0\ufe88\0\ufed0\0\uff18\0\uff60\0\uffa8"+
+    "\0\ufff0\0\u2448\0\u2448\1\70\0\u2448\1\200\1\310\1\u0110"+
+    "\0\u2448\1\u0158\1\u01a0\1\u01e8\1\u0230\1\u0278\1\u02c0\0\u2448"+
+    "\0\udd58\1\u0308\1\u0350\0\u0948\1\u0398\1\u03e0\1\u0428\0\u0948"+
+    "\1\u0470\1\u04b8\1\u0500\1\u0548\0\u0948\1\u0590\1\u05d8\1\u0620"+
+    "\1\u0668\0\u0948\1\u06b0\0\u0948\1\u06f8\1\u0740\0\u0948\1\u0788"+
+    "\0\u0948\0\u0948\0\u0948\1\u07d0\1\u0818\1\u0860\0\u1248\1\u08a8"+
+    "\1\u08f0\1\u0938\0\u1248\1\u0980\1\u09c8\0\u1248\1\u0a10\1\u0a58"+
+    "\1\u0aa0\1\u0ae8\0\u1248\1\u0b30\0\u1248\1\u0b78\1\u0bc0\0\u1248"+
+    "\1\u0c08\0\u1248\0\u1248\0\u1248\1\u0c50\1\u0c98\1\u0ce0\0\u16c8"+
+    "\1\u0d28\1\u0d70\1\u0db8\0\u16c8\1\u0e00\1\u0e48\0\u16c8\1\u0e90"+
+    "\1\u0ed8\1\u0f20\1\u0f68\0\u16c8\1\u0fb0\0\u16c8\1\u0ff8\1\u1040"+
+    "\0\u16c8\1\u1088\0\u16c8\0\u16c8\0\u16c8\1\u10d0\1\u1118\1\u1160"+
+    "\0\u1ea8\1\u11a8\1\u11f0\1\u1238\0\u1ea8\1\u1280\1\u12c8\0\u1ea8"+
+    "\1\u1310\1\u1358\1\u13a0\1\u13e8\0\u1ea8\1\u1430\0\u1ea8\1\u1478"+
+    "\1\u14c0\0\u1ea8\1\u1508\0\u1ea8\0\u1ea8\0\u1ea8\1\u1550\1\u1598"+
+    "\1\u15e0\0\u2448\1\u1628\1\u1670\1\u16b8\0\u2448\1\u1700\1\u1748"+
+    "\0\u2448\1\u1790\1\u17d8\1\u1820\1\u1868\0\u2448\1\u18b0\0\u2448"+
+    "\1\u18f8\1\u1940\0\u2448\1\u1988\0\u2448\0\u2448\0\u2448\1\u19d0"+
+    "\0\u0948\1\u1a18\1\u1a60\1\u1aa8\0\u0948\0\u0948\0\u0948\0\ue100"+
+    "\0\u0948\0\u0948\1\u1af0\1\u1b38\1\u1b80\1\u1bc8\1\u1c10\1\u1c58"+
+    "\1\u1ca0\0\u1248\1\u1ce8\1\u1d30\1\u1d78\0\u1248\0\u1248\0\u1248"+
+    "\0\u1248\0\u1248\1\u1dc0\1\u1e08\1\u1e50\1\u1e98\1\u1ee0\1\u1f28"+
+    "\1\u1f70\0\u16c8\1\u1fb8\1\u2000\1\u2048\0\u16c8\0\u16c8\0\u16c8"+
+    "\0\u16c8\0\u16c8\1\u2090\1\u20d8\1\u2120\1\u2168\1\u21b0\1\u21f8"+
+    "\1\u2240\0\u1ea8\1\u2288\1\u22d0\1\u2318\0\u1ea8\0\u1ea8\0\u1ea8"+
+    "\0\u1ea8\0\u1ea8\1\u2360\1\u23a8\1\u23f0\1\u2438\1\u2480\1\u24c8"+
+    "\1\u2510\0\u2448\1\u2558\1\u25a0\1\u25e8\0\u2448\0\u2448\0\u2448"+
+    "\0\u2448\0\u2448\1\u2630\1\u2678\1\u26c0\1\u2708\1\u2750\1\u2798"+
+    "\1\u27e0\1\u2828\1\u2870\1\u28b8\1\u2900\0\u0948\0\u0948\0\u0948"+
+    "\1\u2948\1\u2990\0\u0948\1\u29d8\1\u2a20\1\u2a68\1\u2ab0\0\u1248"+
+    "\0\u1248\0\u1248\1\u2af8\1\u2b40\0\u1248\1\u2b88\1\u2bd0\1\u2c18"+
+    "\1\u2c60\0\u16c8\0\u16c8\0\u16c8\1\u2ca8\1\u2cf0\0\u16c8\1\u2d38"+
+    "\1\u2d80\1\u2dc8\1\u2e10\0\u1ea8\0\u1ea8\0\u1ea8\1\u2e58\1\u2ea0"+
+    "\0\u1ea8\1\u2ee8\1\u2f30\1\u2f78\1\u2fc0\0\u2448\0\u2448\0\u2448"+
+    "\1\u3008\1\u3050\0\u2448\1\u3098\1\u30e0\0\u0948\0\u0948\1\u3128"+
+    "\0\u0948\1\u3170\1\u31b8\0\u1248\0\u1248\1\u3200\0\u1248\1\u3248"+
+    "\1\u3290\0\u16c8\0\u16c8\1\u32d8\0\u16c8\1\u3320\1\u3368\0\u1ea8"+
+    "\0\u1ea8\1\u33b0\0\u1ea8\1\u33f8\1\u3440\0\u2448\0\u2448\1\u3488"+
+    "\0\u2448\0\u0948\0\u0948\1\u34d0\0\u1248\0\u1248\1\u3518\0\u16c8"+
+    "\0\u16c8\1\u3560\0\u1ea8\0\u1ea8\1\u35a8\0\u2448\0\u2448\1\u35f0"+
+    "\1\u3638\1\u3680\1\u36c8\1\u3710\1\u3758\0\u0948\0\u1248\0\u16c8"+
+    "\0\u1ea8\0\u2448";
 
   private static int [] zzUnpackRowMap() {
-    int [] result = new int[961];
+    int [] result = new int[1434];
     int offset = 0;
     offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
     return result;
@@ -438,952 +521,1534 @@
     "\3\43\1\72\1\177\1\200\1\75\1\76\1\77\1\100"+
     "\1\101\1\102\1\103\1\104\1\105\1\106\1\107\1\110"+
     "\1\111\1\112\1\113\1\114\1\115\3\201\1\202\1\203"+
-    "\1\204\34\201\1\205\45\201\11\0\1\206\1\0\14\206"+
-    "\2\0\1\206\1\0\2\206\1\0\2\206\1\0\1\206"+
-    "\1\0\1\206\2\0\17\206\1\207\22\0\4\210\1\211"+
-    "\1\212\34\210\1\213\45\210\11\214\1\206\1\214\14\206"+
-    "\2\214\1\206\1\214\2\206\1\214\2\206\1\214\1\206"+
-    "\1\214\1\206\2\214\17\206\63\214\1\215\47\214\11\0"+
-    "\1\216\1\0\14\216\2\0\1\216\1\0\2\216\1\0"+
-    "\2\216\1\0\1\216\1\0\1\216\2\0\17\216\1\217"+
-    "\22\0\5\220\1\221\34\220\1\222\45\220\11\223\1\216"+
-    "\1\223\14\216\2\223\1\216\1\223\2\216\1\223\2\216"+
-    "\1\223\1\216\1\223\1\216\2\223\17\216\63\223\1\224"+
-    "\47\223\1\225\3\226\1\227\1\230\102\225\1\231\3\226"+
-    "\1\232\103\231\1\233\3\226\1\234\103\233\1\33\2\34"+
-    "\1\35\1\36\1\37\1\40\1\41\1\42\1\43\1\44"+
-    "\2\43\1\45\1\43\1\46\1\43\1\47\1\43\1\50"+
-    "\1\43\1\51\1\43\1\52\1\53\1\43\1\54\1\55"+
-    "\1\43\1\44\2\43\1\56\1\43\1\57\1\43\1\60"+
-    "\1\61\1\62\1\63\1\64\1\43\1\65\1\66\1\67"+
-    "\2\43\1\70\1\71\3\43\1\72\1\73\1\33\1\75"+
-    "\1\76\1\77\1\100\1\101\1\102\1\103\1\104\1\105"+
-    "\1\106\1\107\1\110\1\111\1\112\1\113\1\114\1\115"+
-    "\4\235\1\236\35\235\1\0\2\235\1\237\42\235\45\0"+
-    "\1\240\153\0\3\34\1\241\104\0\1\242\1\35\112\0"+
-    "\1\243\1\244\61\0\1\245\25\0\1\246\31\0\1\247"+
-    "\27\0\1\250\27\0\1\251\167\0\1\252\30\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\17\43\35\0\1\44"+
-    "\2\253\2\254\2\255\2\256\2\257\2\260\2\0\1\261"+
-    "\1\44\2\0\1\44\2\0\1\262\60\0\6\43\1\263"+
-    "\1\43\1\264\5\43\2\0\7\43\1\0\3\43\2\0"+
-    "\1\43\1\265\6\43\1\266\6\43\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\10\43\1\267\6\43\34\0"+
-    "\4\43\1\270\11\43\2\0\7\43\1\0\3\43\2\0"+
-    "\7\43\1\271\1\43\1\272\5\43\34\0\14\43\1\273"+
-    "\1\43\2\0\7\43\1\0\3\43\2\0\10\43\1\274"+
-    "\6\43\34\0\6\43\1\275\7\43\2\0\5\43\1\276"+
-    "\1\43\1\0\3\43\2\0\11\43\1\277\5\43\52\0"+
-    "\1\300\40\0\1\301\47\0\1\302\37\0\1\303\7\0"+
-    "\1\304\21\0\1\44\2\253\2\254\2\255\2\256\2\257"+
-    "\2\260\2\0\1\261\1\44\2\305\1\44\2\306\1\262"+
-    "\60\0\16\43\2\0\7\43\1\0\3\43\2\0\6\43"+
-    "\1\307\1\43\1\310\2\43\1\311\3\43\63\0\1\312"+
-    "\44\0\1\313\7\0\1\314\3\0\16\43\2\0\7\43"+
-    "\1\0\3\43\2\0\17\43\23\0\1\315\2\0\1\315"+
-    "\1\316\37\315\1\317\43\315\1\320\2\0\1\320\1\321"+
-    "\35\320\1\0\2\320\1\322\42\320\11\0\16\43\2\0"+
-    "\7\43\1\0\2\43\1\323\2\0\1\43\1\324\4\43"+
-    "\1\325\10\43\34\0\16\43\2\0\2\43\1\326\4\43"+
-    "\1\0\3\43\2\0\4\43\1\327\12\43\34\0\6\43"+
-    "\1\330\7\43\2\0\7\43\1\0\3\43\2\0\1\43"+
-    "\1\331\6\43\1\332\3\43\1\333\2\43\34\0\16\43"+
-    "\2\0\7\43\1\0\2\43\1\334\2\0\5\43\1\335"+
-    "\5\43\1\336\1\337\1\43\1\340\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\6\43\1\341\5\43\1\342"+
-    "\2\43\34\0\14\43\1\343\1\43\2\0\7\43\1\0"+
-    "\3\43\2\0\17\43\34\0\14\43\1\344\1\43\2\0"+
-    "\7\43\1\0\2\43\1\345\2\0\1\43\1\346\15\43"+
-    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\10\43"+
-    "\1\347\6\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\14\43\1\350\2\43\63\0\1\351\34\0\1\352"+
-    "\102\0\1\353\10\0\1\354\76\0\1\355\6\0\1\356"+
-    "\100\0\1\357\7\0\1\360\77\0\1\361\107\0\1\362"+
-    "\107\0\1\363\13\0\1\364\73\0\1\365\14\0\1\366"+
-    "\13\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\17\117\34\0\6\117\1\367\1\117\1\370\5\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\1\117"+
-    "\1\371\6\117\1\372\6\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\10\117\1\373\6\117"+
-    "\34\0\4\117\1\374\11\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\7\117\1\375\1\117\1\376\5\117"+
-    "\34\0\14\117\1\377\1\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\10\117\1\u0100\6\117\34\0\6\117"+
-    "\1\u0101\7\117\2\0\5\117\1\u0102\1\117\1\0\1\117"+
-    "\1\0\1\117\2\0\11\117\1\u0103\5\117\34\0\16\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\6\117"+
-    "\1\u0104\1\117\1\u0105\2\117\1\u0106\3\117\34\0\16\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\u0107\2\0\1\117"+
-    "\1\u0108\4\117\1\u0109\10\117\34\0\16\117\2\0\2\117"+
-    "\1\u010a\4\117\1\0\1\117\1\0\1\117\2\0\4\117"+
-    "\1\u010b\12\117\34\0\6\117\1\u010c\7\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\1\117\1\u010d\6\117"+
-    "\1\u010e\3\117\1\u010f\2\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\u0110\2\0\5\117\1\u0111\5\117"+
-    "\1\u0112\1\u0113\1\117\1\u0114\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\6\117\1\u0115\5\117"+
-    "\1\u0116\2\117\34\0\14\117\1\u0117\1\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\14\117"+
-    "\1\u0118\1\117\2\0\7\117\1\0\1\117\1\0\1\u0119"+
-    "\2\0\1\117\1\u011a\15\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\10\117\1\u011b\6\117"+
+    "\1\204\34\201\1\205\45\201\11\206\1\207\1\206\2\207"+
+    "\1\210\1\207\1\211\1\207\1\212\1\207\1\213\1\207"+
+    "\1\214\1\207\2\206\1\207\1\206\1\215\1\207\1\206"+
+    "\2\207\1\206\1\207\1\206\1\207\2\206\1\216\1\217"+
+    "\1\220\1\207\1\221\1\222\1\223\2\207\1\224\1\225"+
+    "\3\207\1\226\1\227\22\206\4\230\1\231\1\232\34\230"+
+    "\1\233\45\230\11\206\1\207\1\206\14\207\2\206\1\207"+
+    "\1\206\2\207\1\206\2\207\1\206\1\207\1\206\1\207"+
+    "\2\206\17\207\63\206\1\234\47\206\11\235\1\236\1\235"+
+    "\2\236\1\237\1\236\1\240\1\236\1\241\1\236\1\242"+
+    "\1\236\1\243\1\236\2\235\1\236\1\235\1\244\1\236"+
+    "\1\235\2\236\1\235\1\236\1\235\1\236\2\235\1\245"+
+    "\1\246\1\247\1\236\1\250\1\251\1\252\2\236\1\253"+
+    "\1\254\3\236\1\255\1\256\22\235\5\257\1\260\34\257"+
+    "\1\261\45\257\11\262\1\236\1\262\14\236\2\262\1\236"+
+    "\1\262\2\236\1\262\2\236\1\262\1\236\1\262\1\236"+
+    "\2\262\17\236\63\262\1\263\47\262\1\264\3\265\1\266"+
+    "\1\267\102\264\1\270\3\265\1\271\103\270\1\272\3\265"+
+    "\1\273\103\272\1\33\2\34\1\35\1\36\1\37\1\40"+
+    "\1\41\1\42\1\43\1\44\2\43\1\45\1\43\1\46"+
+    "\1\43\1\47\1\43\1\50\1\43\1\51\1\43\1\52"+
+    "\1\53\1\43\1\54\1\55\1\43\1\44\2\43\1\56"+
+    "\1\43\1\57\1\43\1\60\1\61\1\62\1\63\1\64"+
+    "\1\43\1\65\1\66\1\67\2\43\1\70\1\71\3\43"+
+    "\1\72\1\73\1\33\1\75\1\76\1\77\1\100\1\101"+
+    "\1\102\1\103\1\104\1\105\1\106\1\107\1\110\1\111"+
+    "\1\112\1\113\1\114\1\115\4\274\1\275\35\274\1\0"+
+    "\2\274\1\276\42\274\45\0\1\277\153\0\3\34\1\300"+
+    "\104\0\1\301\1\35\112\0\1\302\1\303\61\0\1\304"+
+    "\25\0\1\305\31\0\1\306\27\0\1\307\27\0\1\310"+
+    "\167\0\1\311\30\0\16\43\2\0\7\43\1\0\3\43"+
+    "\2\0\17\43\35\0\1\44\2\312\2\313\2\314\2\315"+
+    "\2\316\2\317\2\0\1\320\1\44\2\0\1\44\2\0"+
+    "\1\321\60\0\6\43\1\322\1\43\1\323\5\43\2\0"+
+    "\7\43\1\0\3\43\2\0\1\43\1\324\6\43\1\325"+
+    "\6\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
+    "\10\43\1\326\6\43\34\0\4\43\1\327\11\43\2\0"+
+    "\7\43\1\0\3\43\2\0\7\43\1\330\1\43\1\331"+
+    "\5\43\34\0\14\43\1\332\1\43\2\0\7\43\1\0"+
+    "\3\43\2\0\10\43\1\333\6\43\34\0\6\43\1\334"+
+    "\7\43\2\0\5\43\1\335\1\43\1\0\3\43\2\0"+
+    "\11\43\1\336\5\43\52\0\1\337\40\0\1\340\47\0"+
+    "\1\341\37\0\1\342\7\0\1\343\21\0\1\44\2\312"+
+    "\2\313\2\314\2\315\2\316\2\317\2\0\1\320\1\44"+
+    "\2\344\1\44\2\345\1\321\60\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\6\43\1\346\1\43\1\347\2\43"+
+    "\1\350\3\43\63\0\1\351\44\0\1\352\7\0\1\353"+
+    "\3\0\16\43\2\0\7\43\1\0\3\43\2\0\17\43"+
+    "\23\0\1\354\2\0\1\354\1\355\37\354\1\356\43\354"+
+    "\1\357\2\0\1\357\1\360\35\357\1\0\2\357\1\361"+
+    "\42\357\11\0\16\43\2\0\7\43\1\0\2\43\1\362"+
+    "\2\0\1\43\1\363\4\43\1\364\10\43\34\0\16\43"+
+    "\2\0\2\43\1\365\4\43\1\0\3\43\2\0\4\43"+
+    "\1\366\12\43\34\0\6\43\1\367\7\43\2\0\7\43"+
+    "\1\0\3\43\2\0\1\43\1\370\6\43\1\371\3\43"+
+    "\1\372\2\43\34\0\16\43\2\0\7\43\1\0\2\43"+
+    "\1\373\2\0\5\43\1\374\5\43\1\375\1\376\1\43"+
+    "\1\377\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
+    "\6\43\1\u0100\5\43\1\u0101\2\43\34\0\14\43\1\u0102"+
+    "\1\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
+    "\14\43\1\u0103\1\43\2\0\7\43\1\0\2\43\1\u0104"+
+    "\2\0\1\43\1\u0105\15\43\34\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\10\43\1\u0106\6\43\34\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\14\43\1\u0107\2\43"+
+    "\63\0\1\u0108\34\0\1\u0109\102\0\1\u010a\10\0\1\u010b"+
+    "\76\0\1\u010c\6\0\1\u010d\100\0\1\u010e\7\0\1\u010f"+
+    "\77\0\1\u0110\107\0\1\u0111\107\0\1\u0112\13\0\1\u0113"+
+    "\73\0\1\u0114\14\0\1\u0115\13\0\16\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\6\117"+
+    "\1\u0116\1\117\1\u0117\5\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\1\117\1\u0118\6\117\1\u0119\6\117"+
     "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\14\117\1\u011c\2\117\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\6\141"+
-    "\1\u011d\1\141\1\u011e\5\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\1\141\1\u011f\6\141\1\u0120\6\141"+
+    "\2\0\10\117\1\u011a\6\117\34\0\4\117\1\u011b\11\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\7\117"+
+    "\1\u011c\1\117\1\u011d\5\117\34\0\14\117\1\u011e\1\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\10\117"+
+    "\1\u011f\6\117\34\0\6\117\1\u0120\7\117\2\0\5\117"+
+    "\1\u0121\1\117\1\0\1\117\1\0\1\117\2\0\11\117"+
+    "\1\u0122\5\117\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\6\117\1\u0123\1\117\1\u0124\2\117"+
+    "\1\u0125\3\117\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\u0126\2\0\1\117\1\u0127\4\117\1\u0128\10\117"+
+    "\34\0\16\117\2\0\2\117\1\u0129\4\117\1\0\1\117"+
+    "\1\0\1\117\2\0\4\117\1\u012a\12\117\34\0\6\117"+
+    "\1\u012b\7\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\1\117\1\u012c\6\117\1\u012d\3\117\1\u012e\2\117"+
+    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\u012f"+
+    "\2\0\5\117\1\u0130\5\117\1\u0131\1\u0132\1\117\1\u0133"+
+    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\6\117\1\u0134\5\117\1\u0135\2\117\34\0\14\117"+
+    "\1\u0136\1\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\17\117\34\0\14\117\1\u0137\1\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\u0138\2\0\1\117\1\u0139\15\117"+
+    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\10\117\1\u013a\6\117\34\0\16\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\14\117\1\u013b\2\117"+
     "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\10\141\1\u0121\6\141\34\0\4\141\1\u0122\11\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\7\141"+
-    "\1\u0123\1\141\1\u0124\5\141\34\0\14\141\1\u0125\1\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\10\141"+
-    "\1\u0126\6\141\34\0\6\141\1\u0127\7\141\2\0\5\141"+
-    "\1\u0128\1\141\1\0\1\141\1\0\1\141\2\0\11\141"+
-    "\1\u0129\5\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\6\141\1\u012a\1\141\1\u012b\2\141"+
-    "\1\u012c\3\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\u012d\2\0\1\141\1\u012e\4\141\1\u012f\10\141"+
-    "\34\0\16\141\2\0\2\141\1\u0130\4\141\1\0\1\141"+
-    "\1\0\1\141\2\0\4\141\1\u0131\12\141\34\0\6\141"+
-    "\1\u0132\7\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\1\141\1\u0133\6\141\1\u0134\3\141\1\u0135\2\141"+
-    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\u0136"+
-    "\2\0\5\141\1\u0137\5\141\1\u0138\1\u0139\1\141\1\u013a"+
+    "\2\0\17\141\34\0\6\141\1\u013c\1\141\1\u013d\5\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\1\141"+
+    "\1\u013e\6\141\1\u013f\6\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\10\141\1\u0140\6\141"+
+    "\34\0\4\141\1\u0141\11\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\7\141\1\u0142\1\141\1\u0143\5\141"+
+    "\34\0\14\141\1\u0144\1\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\10\141\1\u0145\6\141\34\0\6\141"+
+    "\1\u0146\7\141\2\0\5\141\1\u0147\1\141\1\0\1\141"+
+    "\1\0\1\141\2\0\11\141\1\u0148\5\141\34\0\16\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\6\141"+
+    "\1\u0149\1\141\1\u014a\2\141\1\u014b\3\141\34\0\16\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\u014c\2\0\1\141"+
+    "\1\u014d\4\141\1\u014e\10\141\34\0\16\141\2\0\2\141"+
+    "\1\u014f\4\141\1\0\1\141\1\0\1\141\2\0\4\141"+
+    "\1\u0150\12\141\34\0\6\141\1\u0151\7\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\1\141\1\u0152\6\141"+
+    "\1\u0153\3\141\1\u0154\2\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\u0155\2\0\5\141\1\u0156\5\141"+
+    "\1\u0157\1\u0158\1\141\1\u0159\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\6\141\1\u015a\5\141"+
+    "\1\u015b\2\141\34\0\14\141\1\u015c\1\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\14\141"+
+    "\1\u015d\1\141\2\0\7\141\1\0\1\141\1\0\1\u015e"+
+    "\2\0\1\141\1\u015f\15\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\10\141\1\u0160\6\141"+
     "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\6\141\1\u013b\5\141\1\u013c\2\141\34\0\14\141"+
-    "\1\u013d\1\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\17\141\34\0\14\141\1\u013e\1\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\u013f\2\0\1\141\1\u0140\15\141"+
-    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\10\141\1\u0141\6\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\14\141\1\u0142\2\141"+
-    "\23\0\1\162\2\0\1\162\1\164\35\162\1\0\2\162"+
-    "\1\0\42\162\1\0\3\163\1\u0143\103\0\3\162\1\u0144"+
-    "\1\u0145\103\162\4\167\1\170\35\167\1\0\2\167\1\u0146"+
-    "\156\167\1\0\35\167\1\0\2\167\1\u0147\42\167\11\0"+
-    "\1\u0148\1\0\14\u0148\2\0\1\u0148\1\0\2\u0148\1\0"+
-    "\2\u0148\1\0\1\u0148\1\0\1\u0148\2\0\17\u0148\34\0"+
-    "\1\u0149\1\0\14\u0149\2\0\1\u0149\1\0\2\u0149\1\0"+
-    "\2\u0149\1\0\1\u0149\1\0\1\u0149\2\0\17\u0149\24\0"+
-    "\3\176\1\u014a\104\0\1\u014b\1\202\112\0\1\243\1\244"+
-    "\106\0\1\u014c\113\0\16\206\2\0\7\206\1\0\1\206"+
-    "\1\0\1\206\2\0\17\206\23\0\4\210\1\211\1\0"+
-    "\34\210\1\u014d\51\210\1\211\35\210\1\u014d\45\210\11\u014e"+
-    "\1\0\1\u014e\14\0\2\u014e\1\0\1\u014e\2\0\1\u014e"+
-    "\2\0\1\u014e\1\0\1\u014e\1\0\2\u014e\20\0\22\u014e"+
-    "\11\0\1\u014f\1\0\14\u014f\2\0\1\u014f\1\0\2\u014f"+
-    "\1\0\2\u014f\1\0\1\u014f\1\0\1\u014f\2\0\17\u014f"+
-    "\34\0\16\216\2\0\7\216\1\0\1\216\1\0\1\216"+
-    "\2\0\17\216\23\0\5\220\1\u0150\34\220\1\u0151\52\220"+
-    "\1\0\34\220\1\u0152\45\220\5\u0153\1\u0154\3\u0153\1\0"+
-    "\1\u0153\14\0\2\u0153\1\0\1\u0153\2\0\1\u0153\2\0"+
-    "\1\u0153\1\0\1\u0154\1\0\2\u0153\20\0\22\u0153\11\0"+
-    "\1\u0155\1\0\14\u0155\2\0\1\u0155\1\0\2\u0155\1\0"+
-    "\2\u0155\1\0\1\u0155\1\0\1\u0155\2\0\17\u0155\24\0"+
-    "\3\226\1\u0156\104\0\2\226\105\0\114\235\1\0\35\235"+
-    "\1\0\2\235\1\u0157\42\235\45\0\1\u0158\43\0\2\34"+
-    "\107\0\1\35\105\0\1\243\2\0\105\243\6\u0159\1\u015a"+
-    "\101\u0159\70\0\1\u015b\17\0\1\251\2\0\105\251\70\0"+
-    "\1\u015c\31\0\1\u015d\14\0\2\u015e\1\0\1\u015d\2\0"+
-    "\1\u015d\64\0\1\44\16\0\1\261\1\44\2\0\1\44"+
-    "\64\0\1\u015f\17\0\1\u015f\2\0\1\u015f\63\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\10\43\1\u0160\6\43"+
+    "\2\0\14\141\1\u0161\2\141\23\0\1\162\2\0\1\162"+
+    "\1\164\35\162\1\0\2\162\1\0\42\162\1\0\3\163"+
+    "\1\u0162\103\0\3\162\1\u0163\1\u0164\103\162\4\167\1\170"+
+    "\35\167\1\0\2\167\1\u0165\156\167\1\0\35\167\1\0"+
+    "\2\167\1\u0166\42\167\11\0\1\u0167\1\0\14\u0167\2\0"+
+    "\1\u0167\1\0\2\u0167\1\0\2\u0167\1\0\1\u0167\1\0"+
+    "\1\u0167\2\0\17\u0167\34\0\1\u0168\1\0\14\u0168\2\0"+
+    "\1\u0168\1\0\2\u0168\1\0\2\u0168\1\0\1\u0168\1\0"+
+    "\1\u0168\2\0\17\u0168\24\0\3\176\1\u0169\104\0\1\u016a"+
+    "\1\202\112\0\1\302\1\303\106\0\1\u016b\113\0\16\207"+
+    "\2\0\7\207\1\0\1\207\1\0\1\207\2\0\17\207"+
+    "\34\0\6\207\1\u016c\1\207\1\u016d\5\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\1\207\1\u016e\6\207"+
+    "\1\u016f\6\207\34\0\16\207\2\0\7\207\1\0\1\207"+
+    "\1\0\1\207\2\0\10\207\1\u0170\6\207\34\0\4\207"+
+    "\1\u0171\11\207\2\0\7\207\1\0\1\207\1\0\1\207"+
+    "\2\0\7\207\1\u0172\1\207\1\u0173\5\207\34\0\14\207"+
+    "\1\u0174\1\207\2\0\7\207\1\0\1\207\1\0\1\207"+
+    "\2\0\10\207\1\u0175\6\207\34\0\6\207\1\u0176\7\207"+
+    "\2\0\5\207\1\u0177\1\207\1\0\1\207\1\0\1\207"+
+    "\2\0\11\207\1\u0178\5\207\34\0\16\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\6\207\1\u0179\1\207"+
+    "\1\u017a\2\207\1\u017b\3\207\34\0\16\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\u017c\2\0\1\207\1\u017d\4\207"+
+    "\1\u017e\10\207\34\0\16\207\2\0\2\207\1\u017f\4\207"+
+    "\1\0\1\207\1\0\1\207\2\0\4\207\1\u0180\12\207"+
+    "\34\0\6\207\1\u0181\7\207\2\0\7\207\1\0\1\207"+
+    "\1\0\1\207\2\0\1\207\1\u0182\6\207\1\u0183\3\207"+
+    "\1\u0184\2\207\34\0\16\207\2\0\7\207\1\0\1\207"+
+    "\1\0\1\u0185\2\0\5\207\1\u0186\5\207\1\u0187\1\u0188"+
+    "\1\207\1\u0189\34\0\16\207\2\0\7\207\1\0\1\207"+
+    "\1\0\1\207\2\0\6\207\1\u018a\5\207\1\u018b\2\207"+
+    "\34\0\14\207\1\u018c\1\207\2\0\7\207\1\0\1\207"+
+    "\1\0\1\207\2\0\17\207\34\0\14\207\1\u018d\1\207"+
+    "\2\0\7\207\1\0\1\207\1\0\1\u018e\2\0\1\207"+
+    "\1\u018f\15\207\34\0\16\207\2\0\7\207\1\0\1\207"+
+    "\1\0\1\207\2\0\10\207\1\u0190\6\207\34\0\16\207"+
+    "\2\0\7\207\1\0\1\207\1\0\1\207\2\0\14\207"+
+    "\1\u0191\2\207\23\0\4\230\1\231\1\0\34\230\1\u0192"+
+    "\51\230\1\231\35\230\1\u0192\45\230\11\u0193\1\0\1\u0193"+
+    "\14\0\2\u0193\1\0\1\u0193\2\0\1\u0193\2\0\1\u0193"+
+    "\1\0\1\u0193\1\0\2\u0193\20\0\22\u0193\11\0\1\u0194"+
+    "\1\0\14\u0194\2\0\1\u0194\1\0\2\u0194\1\0\2\u0194"+
+    "\1\0\1\u0194\1\0\1\u0194\2\0\17\u0194\34\0\16\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\17\236"+
+    "\34\0\6\236\1\u0195\1\236\1\u0196\5\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\1\236\1\u0197\6\236"+
+    "\1\u0198\6\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\10\236\1\u0199\6\236\34\0\4\236"+
+    "\1\u019a\11\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\7\236\1\u019b\1\236\1\u019c\5\236\34\0\14\236"+
+    "\1\u019d\1\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\10\236\1\u019e\6\236\34\0\6\236\1\u019f\7\236"+
+    "\2\0\5\236\1\u01a0\1\236\1\0\1\236\1\0\1\236"+
+    "\2\0\11\236\1\u01a1\5\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\6\236\1\u01a2\1\236"+
+    "\1\u01a3\2\236\1\u01a4\3\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\u01a5\2\0\1\236\1\u01a6\4\236"+
+    "\1\u01a7\10\236\34\0\16\236\2\0\2\236\1\u01a8\4\236"+
+    "\1\0\1\236\1\0\1\236\2\0\4\236\1\u01a9\12\236"+
+    "\34\0\6\236\1\u01aa\7\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\1\236\1\u01ab\6\236\1\u01ac\3\236"+
+    "\1\u01ad\2\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\u01ae\2\0\5\236\1\u01af\5\236\1\u01b0\1\u01b1"+
+    "\1\236\1\u01b2\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\6\236\1\u01b3\5\236\1\u01b4\2\236"+
+    "\34\0\14\236\1\u01b5\1\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\17\236\34\0\14\236\1\u01b6\1\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\u01b7\2\0\1\236"+
+    "\1\u01b8\15\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\10\236\1\u01b9\6\236\34\0\16\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\14\236"+
+    "\1\u01ba\2\236\23\0\5\257\1\u01bb\34\257\1\u01bc\52\257"+
+    "\1\0\34\257\1\u01bd\45\257\5\u01be\1\u01bf\3\u01be\1\0"+
+    "\1\u01be\14\0\2\u01be\1\0\1\u01be\2\0\1\u01be\2\0"+
+    "\1\u01be\1\0\1\u01bf\1\0\2\u01be\20\0\22\u01be\11\0"+
+    "\1\u01c0\1\0\14\u01c0\2\0\1\u01c0\1\0\2\u01c0\1\0"+
+    "\2\u01c0\1\0\1\u01c0\1\0\1\u01c0\2\0\17\u01c0\24\0"+
+    "\3\265\1\u01c1\104\0\2\265\105\0\114\274\1\0\35\274"+
+    "\1\0\2\274\1\u01c2\42\274\45\0\1\u01c3\43\0\2\34"+
+    "\107\0\1\35\105\0\1\302\2\0\105\302\6\u01c4\1\u01c5"+
+    "\101\u01c4\70\0\1\u01c6\17\0\1\310\2\0\105\310\70\0"+
+    "\1\u01c7\31\0\1\u01c8\14\0\2\u01c9\1\0\1\u01c8\2\0"+
+    "\1\u01c8\64\0\1\44\16\0\1\320\1\44\2\0\1\44"+
+    "\64\0\1\u01ca\17\0\1\u01ca\2\0\1\u01ca\63\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\10\43\1\u01cb\6\43"+
     "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\11\43"+
-    "\1\u0161\5\43\34\0\6\43\1\u0162\7\43\2\0\7\43"+
+    "\1\u01cc\5\43\34\0\6\43\1\u01cd\7\43\2\0\7\43"+
     "\1\0\3\43\2\0\17\43\34\0\16\43\2\0\7\43"+
-    "\1\0\3\43\2\0\6\43\1\u0163\10\43\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\11\43\1\u0164\5\43"+
-    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\1\u0165"+
+    "\1\0\3\43\2\0\6\43\1\u01ce\10\43\34\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\11\43\1\u01cf\5\43"+
+    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\1\u01d0"+
     "\16\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
-    "\4\43\1\u0166\1\u0167\11\43\34\0\4\43\1\u0168\11\43"+
+    "\4\43\1\u01d1\1\u01d2\11\43\34\0\4\43\1\u01d3\11\43"+
     "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\16\43"+
-    "\2\0\7\43\1\0\2\43\1\u0169\2\0\17\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\4\43\1\u016a"+
+    "\2\0\7\43\1\0\2\43\1\u01d4\2\0\17\43\34\0"+
+    "\16\43\2\0\7\43\1\0\3\43\2\0\4\43\1\u01d5"+
     "\12\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
-    "\5\43\1\u016b\11\43\34\0\16\43\2\0\7\43\1\0"+
-    "\2\43\1\u016c\2\0\17\43\55\0\1\u016d\2\0\1\u016d"+
-    "\63\0\2\u016e\2\0\2\u016e\4\0\4\u016e\3\0\4\u016e"+
-    "\11\0\2\u016e\50\0\14\43\1\u016f\1\43\2\0\7\43"+
+    "\5\43\1\u01d6\11\43\34\0\16\43\2\0\7\43\1\0"+
+    "\2\43\1\u01d7\2\0\17\43\55\0\1\u01d8\2\0\1\u01d8"+
+    "\63\0\2\u01d9\2\0\2\u01d9\4\0\4\u01d9\3\0\4\u01d9"+
+    "\11\0\2\u01d9\50\0\14\43\1\u01da\1\43\2\0\7\43"+
     "\1\0\3\43\2\0\17\43\34\0\16\43\2\0\7\43"+
-    "\1\0\3\43\2\0\10\43\1\u0170\6\43\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\5\43\1\u0171\11\43"+
-    "\63\0\1\u0172\36\0\1\u0173\10\0\1\315\2\0\1\315"+
-    "\1\316\37\315\1\u0174\46\315\1\u0175\1\u0176\103\315\44\0"+
-    "\1\u0177\43\0\1\320\2\0\1\320\1\321\35\320\1\0"+
-    "\2\320\1\u0178\45\320\1\u0179\1\u017a\103\320\45\0\1\u017b"+
-    "\53\0\16\43\2\0\2\43\1\u017c\4\43\1\0\3\43"+
+    "\1\0\3\43\2\0\10\43\1\u01db\6\43\34\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\5\43\1\u01dc\11\43"+
+    "\63\0\1\u01dd\36\0\1\u01de\10\0\1\354\2\0\1\354"+
+    "\1\355\37\354\1\u01df\46\354\1\u01e0\1\u01e1\103\354\44\0"+
+    "\1\u01e2\43\0\1\357\2\0\1\357\1\360\35\357\1\0"+
+    "\2\357\1\u01e3\45\357\1\u01e4\1\u01e5\103\357\45\0\1\u01e6"+
+    "\53\0\16\43\2\0\2\43\1\u01e7\4\43\1\0\3\43"+
     "\2\0\17\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\2\43\1\u017d\14\43\34\0\10\43\1\u017e\5\43"+
-    "\2\0\7\43\1\0\3\43\2\0\10\43\1\u017f\6\43"+
+    "\2\0\2\43\1\u01e8\14\43\34\0\10\43\1\u01e9\5\43"+
+    "\2\0\7\43\1\0\3\43\2\0\10\43\1\u01ea\6\43"+
     "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\4\43"+
-    "\1\u0180\12\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\4\43\1\u0181\12\43\34\0\16\43\2\0\7\43"+
-    "\1\0\3\43\2\0\1\43\1\u0182\15\43\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\4\43\1\u0183\1\u0184"+
+    "\1\u01eb\12\43\34\0\16\43\2\0\7\43\1\0\3\43"+
+    "\2\0\4\43\1\u01ec\12\43\34\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\1\43\1\u01ed\15\43\34\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\4\43\1\u01ee\1\u01ef"+
     "\11\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
-    "\11\43\1\u0185\5\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\1\43\1\u0186\15\43\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\1\u0187\16\43\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\1\43\1\u0188\4\43"+
-    "\1\u0189\10\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\11\43\1\u018a\5\43\34\0\16\43\2\0\7\43"+
-    "\1\0\3\43\2\0\10\43\1\u018b\6\43\34\0\10\43"+
-    "\1\u018c\5\43\2\0\7\43\1\0\3\43\2\0\17\43"+
-    "\34\0\16\43\2\0\7\43\1\0\2\43\1\u018d\2\0"+
-    "\1\43\1\u018e\11\43\1\u018f\3\43\34\0\10\43\1\u0190"+
-    "\5\43\2\0\7\43\1\0\3\43\2\0\6\43\1\u0191"+
+    "\11\43\1\u01f0\5\43\34\0\16\43\2\0\7\43\1\0"+
+    "\3\43\2\0\1\43\1\u01f1\15\43\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\1\u01f2\16\43\34\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\1\43\1\u01f3\4\43"+
+    "\1\u01f4\10\43\34\0\16\43\2\0\7\43\1\0\3\43"+
+    "\2\0\11\43\1\u01f5\5\43\34\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\10\43\1\u01f6\6\43\34\0\10\43"+
+    "\1\u01f7\5\43\2\0\7\43\1\0\3\43\2\0\17\43"+
+    "\34\0\16\43\2\0\7\43\1\0\2\43\1\u01f8\2\0"+
+    "\1\43\1\u01f9\11\43\1\u01fa\3\43\34\0\10\43\1\u01fb"+
+    "\5\43\2\0\7\43\1\0\3\43\2\0\6\43\1\u01fc"+
     "\10\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
-    "\5\43\1\u0192\11\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\16\43\1\u0193\34\0\6\43\1\u0194\7\43"+
+    "\5\43\1\u01fd\11\43\34\0\16\43\2\0\7\43\1\0"+
+    "\3\43\2\0\16\43\1\u01fe\34\0\6\43\1\u01ff\7\43"+
     "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\5\43\1\u0195\11\43"+
-    "\34\0\6\43\1\u0196\1\43\1\u0197\5\43\2\0\7\43"+
-    "\1\0\3\43\2\0\17\43\34\0\10\43\1\u0198\5\43"+
-    "\2\0\7\43\1\0\3\43\2\0\17\43\113\0\1\u0199"+
-    "\10\0\1\u019a\106\0\1\u019b\77\0\1\u019c\107\0\1\u019d"+
-    "\7\0\1\u019e\20\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\10\117\1\u019f\6\117\34\0\16\117"+
+    "\2\0\7\43\1\0\3\43\2\0\5\43\1\u0200\11\43"+
+    "\34\0\6\43\1\u0201\1\43\1\u0202\5\43\2\0\7\43"+
+    "\1\0\3\43\2\0\17\43\34\0\10\43\1\u0203\5\43"+
+    "\2\0\7\43\1\0\3\43\2\0\17\43\113\0\1\u0204"+
+    "\10\0\1\u0205\106\0\1\u0206\77\0\1\u0207\107\0\1\u0208"+
+    "\7\0\1\u0209\20\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\10\117\1\u020a\6\117\34\0\16\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\11\117"+
-    "\1\u01a0\5\117\34\0\6\117\1\u01a1\7\117\2\0\7\117"+
+    "\1\u020b\5\117\34\0\6\117\1\u020c\7\117\2\0\7\117"+
     "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\6\117"+
-    "\1\u01a2\10\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\11\117\1\u01a3\5\117\34\0\16\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\1\u01a4"+
+    "\1\u020d\10\117\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\11\117\1\u020e\5\117\34\0\16\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\1\u020f"+
     "\16\117\34\0\16\117\2\0\7\117\1\0\1\117\1\0"+
-    "\1\117\2\0\4\117\1\u01a5\1\u01a6\11\117\34\0\4\117"+
-    "\1\u01a7\11\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\1\117\2\0\4\117\1\u0210\1\u0211\11\117\34\0\4\117"+
+    "\1\u0212\11\117\2\0\7\117\1\0\1\117\1\0\1\117"+
     "\2\0\17\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\u01a8\2\0\17\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\4\117\1\u01a9\12\117"+
+    "\1\0\1\u0213\2\0\17\117\34\0\16\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\4\117\1\u0214\12\117"+
     "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\5\117\1\u01aa\11\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\u01ab\2\0\17\117\34\0\14\117"+
-    "\1\u01ac\1\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\5\117\1\u0215\11\117\34\0\16\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\u0216\2\0\17\117\34\0\14\117"+
+    "\1\u0217\1\117\2\0\7\117\1\0\1\117\1\0\1\117"+
     "\2\0\17\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\10\117\1\u01ad\6\117\34\0\16\117"+
+    "\1\0\1\117\2\0\10\117\1\u0218\6\117\34\0\16\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\5\117"+
-    "\1\u01ae\11\117\34\0\16\117\2\0\2\117\1\u01af\4\117"+
+    "\1\u0219\11\117\34\0\16\117\2\0\2\117\1\u021a\4\117"+
     "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\2\117"+
-    "\1\u01b0\14\117\34\0\10\117\1\u01b1\5\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\10\117\1\u01b2\6\117"+
+    "\1\u021b\14\117\34\0\10\117\1\u021c\5\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\10\117\1\u021d\6\117"+
     "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\4\117\1\u01b3\12\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\4\117\1\u01b4\12\117"+
+    "\2\0\4\117\1\u021e\12\117\34\0\16\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\4\117\1\u021f\12\117"+
     "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\1\117\1\u01b5\15\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\4\117\1\u01b6\1\u01b7"+
+    "\2\0\1\117\1\u0220\15\117\34\0\16\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\4\117\1\u0221\1\u0222"+
     "\11\117\34\0\16\117\2\0\7\117\1\0\1\117\1\0"+
-    "\1\117\2\0\11\117\1\u01b8\5\117\34\0\16\117\2\0"+
-    "\7\117\1\0\1\117\1\0\1\117\2\0\1\117\1\u01b9"+
+    "\1\117\2\0\11\117\1\u0223\5\117\34\0\16\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\1\117\1\u0224"+
     "\15\117\34\0\16\117\2\0\7\117\1\0\1\117\1\0"+
-    "\1\117\2\0\1\u01ba\16\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\1\117\1\u01bb\4\117"+
-    "\1\u01bc\10\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\11\117\1\u01bd\5\117\34\0\16\117"+
+    "\1\117\2\0\1\u0225\16\117\34\0\16\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\1\117\1\u0226\4\117"+
+    "\1\u0227\10\117\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\11\117\1\u0228\5\117\34\0\16\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\10\117"+
-    "\1\u01be\6\117\34\0\10\117\1\u01bf\5\117\2\0\7\117"+
+    "\1\u0229\6\117\34\0\10\117\1\u022a\5\117\2\0\7\117"+
     "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\u01c0\2\0\1\117"+
-    "\1\u01c1\11\117\1\u01c2\3\117\34\0\10\117\1\u01c3\5\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\u022b\2\0\1\117"+
+    "\1\u022c\11\117\1\u022d\3\117\34\0\10\117\1\u022e\5\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\6\117"+
-    "\1\u01c4\10\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\5\117\1\u01c5\11\117\34\0\16\117"+
+    "\1\u022f\10\117\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\5\117\1\u0230\11\117\34\0\16\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\16\117"+
-    "\1\u01c6\34\0\6\117\1\u01c7\7\117\2\0\7\117\1\0"+
+    "\1\u0231\34\0\6\117\1\u0232\7\117\2\0\7\117\1\0"+
     "\1\117\1\0\1\117\2\0\17\117\34\0\16\117\2\0"+
-    "\7\117\1\0\1\117\1\0\1\117\2\0\5\117\1\u01c8"+
-    "\11\117\34\0\6\117\1\u01c9\1\117\1\u01ca\5\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\5\117\1\u0233"+
+    "\11\117\34\0\6\117\1\u0234\1\117\1\u0235\5\117\2\0"+
     "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
-    "\10\117\1\u01cb\5\117\2\0\7\117\1\0\1\117\1\0"+
+    "\10\117\1\u0236\5\117\2\0\7\117\1\0\1\117\1\0"+
     "\1\117\2\0\17\117\34\0\16\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\10\141\1\u01cc\6\141\34\0"+
+    "\1\141\1\0\1\141\2\0\10\141\1\u0237\6\141\34\0"+
     "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\11\141\1\u01cd\5\141\34\0\6\141\1\u01ce\7\141\2\0"+
+    "\11\141\1\u0238\5\141\34\0\6\141\1\u0239\7\141\2\0"+
     "\7\141\1\0\1\141\1\0\1\141\2\0\17\141\34\0"+
     "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\6\141\1\u01cf\10\141\34\0\16\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\11\141\1\u01d0\5\141\34\0"+
+    "\6\141\1\u023a\10\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\11\141\1\u023b\5\141\34\0"+
     "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\1\u01d1\16\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\4\141\1\u01d2\1\u01d3\11\141\34\0"+
-    "\4\141\1\u01d4\11\141\2\0\7\141\1\0\1\141\1\0"+
+    "\1\u023c\16\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\4\141\1\u023d\1\u023e\11\141\34\0"+
+    "\4\141\1\u023f\11\141\2\0\7\141\1\0\1\141\1\0"+
     "\1\141\2\0\17\141\34\0\16\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\u01d5\2\0\17\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\4\141\1\u01d6"+
+    "\1\141\1\0\1\u0240\2\0\17\141\34\0\16\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\4\141\1\u0241"+
     "\12\141\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\5\141\1\u01d7\11\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\u01d8\2\0\17\141\34\0"+
-    "\14\141\1\u01d9\1\141\2\0\7\141\1\0\1\141\1\0"+
+    "\1\141\2\0\5\141\1\u0242\11\141\34\0\16\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\u0243\2\0\17\141\34\0"+
+    "\14\141\1\u0244\1\141\2\0\7\141\1\0\1\141\1\0"+
     "\1\141\2\0\17\141\34\0\16\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\10\141\1\u01da\6\141\34\0"+
+    "\1\141\1\0\1\141\2\0\10\141\1\u0245\6\141\34\0"+
     "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\5\141\1\u01db\11\141\34\0\16\141\2\0\2\141\1\u01dc"+
+    "\5\141\1\u0246\11\141\34\0\16\141\2\0\2\141\1\u0247"+
     "\4\141\1\0\1\141\1\0\1\141\2\0\17\141\34\0"+
     "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\2\141\1\u01dd\14\141\34\0\10\141\1\u01de\5\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\10\141\1\u01df"+
+    "\2\141\1\u0248\14\141\34\0\10\141\1\u0249\5\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\10\141\1\u024a"+
     "\6\141\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\4\141\1\u01e0\12\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\4\141\1\u01e1"+
+    "\1\141\2\0\4\141\1\u024b\12\141\34\0\16\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\4\141\1\u024c"+
     "\12\141\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\1\141\1\u01e2\15\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\4\141\1\u01e3"+
-    "\1\u01e4\11\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\11\141\1\u01e5\5\141\34\0\16\141"+
+    "\1\141\2\0\1\141\1\u024d\15\141\34\0\16\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\4\141\1\u024e"+
+    "\1\u024f\11\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\11\141\1\u0250\5\141\34\0\16\141"+
     "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\1\141"+
-    "\1\u01e6\15\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\1\u01e7\16\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\1\141\1\u01e8"+
-    "\4\141\1\u01e9\10\141\34\0\16\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\11\141\1\u01ea\5\141\34\0"+
+    "\1\u0251\15\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\1\u0252\16\141\34\0\16\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\1\141\1\u0253"+
+    "\4\141\1\u0254\10\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\11\141\1\u0255\5\141\34\0"+
     "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\10\141\1\u01eb\6\141\34\0\10\141\1\u01ec\5\141\2\0"+
+    "\10\141\1\u0256\6\141\34\0\10\141\1\u0257\5\141\2\0"+
     "\7\141\1\0\1\141\1\0\1\141\2\0\17\141\34\0"+
-    "\16\141\2\0\7\141\1\0\1\141\1\0\1\u01ed\2\0"+
-    "\1\141\1\u01ee\11\141\1\u01ef\3\141\34\0\10\141\1\u01f0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\u0258\2\0"+
+    "\1\141\1\u0259\11\141\1\u025a\3\141\34\0\10\141\1\u025b"+
     "\5\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\6\141\1\u01f1\10\141\34\0\16\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\5\141\1\u01f2\11\141\34\0"+
+    "\6\141\1\u025c\10\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\5\141\1\u025d\11\141\34\0"+
     "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\16\141\1\u01f3\34\0\6\141\1\u01f4\7\141\2\0\7\141"+
+    "\16\141\1\u025e\34\0\6\141\1\u025f\7\141\2\0\7\141"+
     "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\141"+
     "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\5\141"+
-    "\1\u01f5\11\141\34\0\6\141\1\u01f6\1\141\1\u01f7\5\141"+
+    "\1\u0260\11\141\34\0\6\141\1\u0261\1\141\1\u0262\5\141"+
     "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
-    "\34\0\10\141\1\u01f8\5\141\2\0\7\141\1\0\1\141"+
+    "\34\0\10\141\1\u0263\5\141\2\0\7\141\1\0\1\141"+
     "\1\0\1\141\2\0\17\141\24\0\2\163\105\0\3\162"+
-    "\1\u0144\1\u01f9\35\162\1\0\2\162\1\0\43\162\1\u01fa"+
-    "\1\u01fb\1\162\1\164\35\162\1\0\2\162\1\0\42\162"+
-    "\4\167\1\0\35\167\1\0\2\167\1\u01fc\46\167\1\0"+
-    "\35\167\1\0\2\167\1\u01fd\42\167\11\0\16\u0148\2\0"+
-    "\7\u0148\1\0\1\u0148\1\0\1\u0148\2\0\17\u0148\34\0"+
-    "\16\u0149\2\0\7\u0149\1\0\1\u0149\1\0\1\u0149\2\0"+
-    "\17\u0149\24\0\2\176\107\0\1\202\116\0\16\u014f\2\0"+
-    "\7\u014f\1\0\1\u014f\1\0\1\u014f\2\0\17\u014f\23\0"+
-    "\5\220\1\0\34\220\1\0\45\220\11\0\16\u0155\2\0"+
-    "\7\u0155\1\0\1\u0155\1\0\1\u0155\2\0\17\u0155\23\0"+
-    "\4\235\1\0\35\235\1\0\2\235\1\0\42\235\45\0"+
-    "\1\u01fe\42\0\6\u0159\1\u01ff\101\u0159\5\u0200\1\u0201\1\u015a"+
-    "\101\u0200\12\0\1\u015d\2\u0202\2\254\4\0\2\257\4\0"+
-    "\1\u015e\1\u015d\2\0\1\u015d\64\0\1\u015d\17\0\1\u015d"+
-    "\2\0\1\u015d\64\0\1\u015f\2\u0202\2\254\4\0\2\257"+
-    "\2\260\2\0\1\u0203\1\u015f\2\0\1\u015f\63\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\1\43\1\u0204\15\43"+
+    "\1\u0163\1\u0264\35\162\1\0\2\162\1\0\43\162\1\u0265"+
+    "\1\u0266\1\162\1\164\35\162\1\0\2\162\1\0\42\162"+
+    "\4\167\1\0\35\167\1\0\2\167\1\u0267\46\167\1\0"+
+    "\35\167\1\0\2\167\1\u0268\42\167\11\0\16\u0167\2\0"+
+    "\7\u0167\1\0\1\u0167\1\0\1\u0167\2\0\17\u0167\34\0"+
+    "\16\u0168\2\0\7\u0168\1\0\1\u0168\1\0\1\u0168\2\0"+
+    "\17\u0168\24\0\2\176\107\0\1\202\116\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\10\207\1\u0269"+
+    "\6\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\11\207\1\u026a\5\207\34\0\6\207\1\u026b"+
+    "\7\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\17\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\6\207\1\u026c\10\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\11\207\1\u026d"+
+    "\5\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\1\u026e\16\207\34\0\16\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\4\207\1\u026f\1\u0270"+
+    "\11\207\34\0\4\207\1\u0271\11\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\u0272\2\0\17\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\4\207\1\u0273\12\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\5\207\1\u0274\11\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\u0275\2\0"+
+    "\17\207\34\0\14\207\1\u0276\1\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\10\207\1\u0277"+
+    "\6\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\5\207\1\u0278\11\207\34\0\16\207\2\0"+
+    "\2\207\1\u0279\4\207\1\0\1\207\1\0\1\207\2\0"+
+    "\17\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\2\207\1\u027a\14\207\34\0\10\207\1\u027b"+
+    "\5\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\10\207\1\u027c\6\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\4\207\1\u027d\12\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\4\207\1\u027e\12\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\1\207\1\u027f\15\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\4\207\1\u0280\1\u0281\11\207\34\0\16\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\11\207\1\u0282\5\207"+
+    "\34\0\16\207\2\0\7\207\1\0\1\207\1\0\1\207"+
+    "\2\0\1\207\1\u0283\15\207\34\0\16\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\1\u0284\16\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\1\207\1\u0285\4\207\1\u0286\10\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\11\207\1\u0287"+
+    "\5\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\10\207\1\u0288\6\207\34\0\10\207\1\u0289"+
+    "\5\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\17\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\u028a\2\0\1\207\1\u028b\11\207\1\u028c\3\207\34\0"+
+    "\10\207\1\u028d\5\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\6\207\1\u028e\10\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\5\207\1\u028f"+
+    "\11\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\16\207\1\u0290\34\0\6\207\1\u0291\7\207"+
+    "\2\0\7\207\1\0\1\207\1\0\1\207\2\0\17\207"+
+    "\34\0\16\207\2\0\7\207\1\0\1\207\1\0\1\207"+
+    "\2\0\5\207\1\u0292\11\207\34\0\6\207\1\u0293\1\207"+
+    "\1\u0294\5\207\2\0\7\207\1\0\1\207\1\0\1\207"+
+    "\2\0\17\207\34\0\10\207\1\u0295\5\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\17\207\34\0\16\u0194"+
+    "\2\0\7\u0194\1\0\1\u0194\1\0\1\u0194\2\0\17\u0194"+
+    "\34\0\16\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\10\236\1\u0296\6\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\11\236\1\u0297\5\236"+
+    "\34\0\6\236\1\u0298\7\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\17\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\6\236\1\u0299\10\236"+
+    "\34\0\16\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\11\236\1\u029a\5\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\1\u029b\16\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\4\236\1\u029c\1\u029d\11\236\34\0\4\236\1\u029e\11\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\17\236"+
+    "\34\0\16\236\2\0\7\236\1\0\1\236\1\0\1\u029f"+
+    "\2\0\17\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\4\236\1\u02a0\12\236\34\0\16\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\5\236"+
+    "\1\u02a1\11\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\u02a2\2\0\17\236\34\0\14\236\1\u02a3\1\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\17\236"+
+    "\34\0\16\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\10\236\1\u02a4\6\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\5\236\1\u02a5\11\236"+
+    "\34\0\16\236\2\0\2\236\1\u02a6\4\236\1\0\1\236"+
+    "\1\0\1\236\2\0\17\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\2\236\1\u02a7\14\236"+
+    "\34\0\10\236\1\u02a8\5\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\10\236\1\u02a9\6\236\34\0\16\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\4\236"+
+    "\1\u02aa\12\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\4\236\1\u02ab\12\236\34\0\16\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\1\236"+
+    "\1\u02ac\15\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\4\236\1\u02ad\1\u02ae\11\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\11\236\1\u02af\5\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\1\236\1\u02b0\15\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\1\u02b1\16\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\1\236\1\u02b2\4\236\1\u02b3\10\236"+
+    "\34\0\16\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\11\236\1\u02b4\5\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\10\236\1\u02b5\6\236"+
+    "\34\0\10\236\1\u02b6\5\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\17\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\u02b7\2\0\1\236\1\u02b8\11\236"+
+    "\1\u02b9\3\236\34\0\10\236\1\u02ba\5\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\6\236\1\u02bb\10\236"+
+    "\34\0\16\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\5\236\1\u02bc\11\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\16\236\1\u02bd\34\0"+
+    "\6\236\1\u02be\7\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\17\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\5\236\1\u02bf\11\236\34\0"+
+    "\6\236\1\u02c0\1\236\1\u02c1\5\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\10\236\1\u02c2"+
+    "\5\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\17\236\23\0\5\257\1\0\34\257\1\0\45\257\11\0"+
+    "\16\u01c0\2\0\7\u01c0\1\0\1\u01c0\1\0\1\u01c0\2\0"+
+    "\17\u01c0\23\0\4\274\1\0\35\274\1\0\2\274\1\0"+
+    "\42\274\45\0\1\u02c3\42\0\6\u01c4\1\u02c4\101\u01c4\5\u02c5"+
+    "\1\u02c6\1\u01c5\101\u02c5\12\0\1\u01c8\2\u02c7\2\313\4\0"+
+    "\2\316\4\0\1\u01c9\1\u01c8\2\0\1\u01c8\64\0\1\u01c8"+
+    "\17\0\1\u01c8\2\0\1\u01c8\64\0\1\u01ca\2\u02c7\2\313"+
+    "\4\0\2\316\2\317\2\0\1\u02c8\1\u01ca\2\0\1\u01ca"+
+    "\63\0\16\43\2\0\7\43\1\0\3\43\2\0\1\43"+
+    "\1\u02c9\15\43\34\0\16\43\2\0\7\43\1\0\3\43"+
+    "\2\0\1\43\1\u02ca\15\43\34\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\4\43\1\u02cb\12\43\34\0\2\43"+
+    "\1\u02cc\13\43\2\0\7\43\1\0\3\43\2\0\17\43"+
+    "\34\0\6\43\1\u02cd\7\43\2\0\7\43\1\0\3\43"+
+    "\2\0\10\43\1\u02ce\6\43\34\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\5\43\1\u02cf\11\43\34\0\14\43"+
+    "\1\u02d0\1\43\2\0\7\43\1\0\3\43\2\0\17\43"+
     "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\1\43"+
-    "\1\u0205\15\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\4\43\1\u0206\12\43\34\0\2\43\1\u0207\13\43"+
-    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\6\43"+
-    "\1\u0208\7\43\2\0\7\43\1\0\3\43\2\0\10\43"+
-    "\1\u0209\6\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\5\43\1\u020a\11\43\34\0\14\43\1\u020b\1\43"+
-    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\1\43\1\u020c\15\43"+
-    "\34\0\16\43\2\0\2\43\1\u020d\4\43\1\0\3\43"+
-    "\2\0\17\43\34\0\14\43\1\u020e\1\43\2\0\7\43"+
-    "\1\0\3\43\2\0\17\43\34\0\14\43\1\u020f\1\43"+
-    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\7\43\1\u0210\7\43"+
-    "\36\0\2\253\2\0\2\255\2\256\6\0\1\u0211\1\u016d"+
-    "\2\0\1\u016d\63\0\2\u016e\2\253\2\u016e\2\255\2\256"+
-    "\4\u016e\2\0\1\u0212\4\u016e\11\0\2\u016e\50\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\1\43\1\u0213\15\43"+
-    "\34\0\6\43\1\u0214\7\43\2\0\7\43\1\0\3\43"+
-    "\2\0\17\43\34\0\14\43\1\u0215\1\43\2\0\7\43"+
-    "\1\0\3\43\2\0\17\43\23\0\3\315\1\u0175\1\u0216"+
-    "\37\315\1\u0174\44\315\1\u0217\1\u0218\1\315\1\316\37\315"+
-    "\1\u0174\43\315\4\u0177\1\u0219\37\u0177\1\u021a\43\u0177\3\320"+
-    "\1\u0179\1\u021b\35\320\1\0\2\320\1\u0178\43\320\1\u021c"+
-    "\1\u021d\1\320\1\321\35\320\1\0\2\320\1\u0178\42\320"+
-    "\4\u021e\1\u021f\35\u021e\1\0\2\u021e\1\u0220\42\u021e\11\0"+
-    "\6\43\1\u0221\7\43\2\0\7\43\1\0\3\43\2\0"+
-    "\17\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
-    "\3\43\1\u0222\13\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\12\43\1\u0223\4\43\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\5\43\1\u0224\11\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\5\43\1\u0225"+
-    "\11\43\34\0\14\43\1\u0226\1\43\2\0\7\43\1\0"+
+    "\1\u02d1\15\43\34\0\16\43\2\0\2\43\1\u02d2\4\43"+
+    "\1\0\3\43\2\0\17\43\34\0\14\43\1\u02d3\1\43"+
+    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\14\43"+
+    "\1\u02d4\1\43\2\0\7\43\1\0\3\43\2\0\17\43"+
+    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\7\43"+
+    "\1\u02d5\7\43\36\0\2\312\2\0\2\314\2\315\6\0"+
+    "\1\u02d6\1\u01d8\2\0\1\u01d8\63\0\2\u01d9\2\312\2\u01d9"+
+    "\2\314\2\315\4\u01d9\2\0\1\u02d7\4\u01d9\11\0\2\u01d9"+
+    "\50\0\16\43\2\0\7\43\1\0\3\43\2\0\1\43"+
+    "\1\u02d8\15\43\34\0\6\43\1\u02d9\7\43\2\0\7\43"+
+    "\1\0\3\43\2\0\17\43\34\0\14\43\1\u02da\1\43"+
+    "\2\0\7\43\1\0\3\43\2\0\17\43\23\0\3\354"+
+    "\1\u01e0\1\u02db\37\354\1\u01df\44\354\1\u02dc\1\u02dd\1\354"+
+    "\1\355\37\354\1\u01df\43\354\4\u01e2\1\u02de\37\u01e2\1\u02df"+
+    "\43\u01e2\3\357\1\u01e4\1\u02e0\35\357\1\0\2\357\1\u01e3"+
+    "\43\357\1\u02e1\1\u02e2\1\357\1\360\35\357\1\0\2\357"+
+    "\1\u01e3\42\357\4\u02e3\1\u02e4\35\u02e3\1\0\2\u02e3\1\u02e5"+
+    "\42\u02e3\11\0\6\43\1\u02e6\7\43\2\0\7\43\1\0"+
     "\3\43\2\0\17\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\4\43\1\u0227\12\43\34\0\14\43\1\u0228"+
-    "\1\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\2\43\1\u0229"+
-    "\14\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
-    "\5\43\1\u022a\11\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\6\43\1\u022b\10\43\34\0\14\43\1\u022c"+
-    "\1\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\5\43\1\u022d"+
-    "\11\43\34\0\10\43\1\u022e\5\43\2\0\7\43\1\0"+
-    "\3\43\2\0\17\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\2\43\1\u022f\14\43\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\6\43\1\u0230\10\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\5\43\1\u0231"+
-    "\11\43\34\0\14\43\1\u0232\1\43\2\0\7\43\1\0"+
-    "\3\43\2\0\17\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\11\43\1\u0233\5\43\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\4\43\1\u0234\12\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\10\43\1\u0235"+
-    "\6\43\34\0\16\43\2\0\7\43\1\0\2\43\1\u0236"+
-    "\2\0\17\43\34\0\6\43\1\u0237\7\43\2\0\7\43"+
-    "\1\0\3\43\2\0\17\43\34\0\10\43\1\u0238\5\43"+
-    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\1\43\1\u0239\15\43"+
-    "\34\0\12\43\1\u023a\3\43\2\0\7\43\1\0\3\43"+
-    "\2\0\17\43\34\0\6\43\1\u023b\7\43\2\0\7\43"+
-    "\1\0\3\43\2\0\17\43\113\0\1\u023c\30\0\16\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\1\117"+
-    "\1\u023d\15\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\1\117\1\u023e\15\117\34\0\16\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\4\117"+
-    "\1\u023f\12\117\34\0\2\117\1\u0240\13\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\6\117"+
-    "\1\u0241\7\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\10\117\1\u0242\6\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\5\117\1\u0243\11\117"+
-    "\34\0\14\117\1\u0244\1\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\17\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\1\117\1\u0245\15\117"+
-    "\34\0\16\117\2\0\2\117\1\u0246\4\117\1\0\1\117"+
-    "\1\0\1\117\2\0\17\117\34\0\14\117\1\u0247\1\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
-    "\34\0\14\117\1\u0248\1\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\17\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\7\117\1\u0249\7\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\1\117\1\u024a\15\117\34\0\6\117\1\u024b\7\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
-    "\34\0\14\117\1\u024c\1\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\17\117\34\0\6\117\1\u024d\7\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\3\117\1\u024e\13\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\12\117\1\u024f\4\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\5\117\1\u0250\11\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\5\117\1\u0251\11\117"+
-    "\34\0\14\117\1\u0252\1\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\17\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\4\117\1\u0253\12\117"+
-    "\34\0\14\117\1\u0254\1\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\17\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\2\117\1\u0255\14\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\5\117\1\u0256\11\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\6\117\1\u0257\10\117"+
-    "\34\0\14\117\1\u0258\1\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\17\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\5\117\1\u0259\11\117"+
-    "\34\0\10\117\1\u025a\5\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\17\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\2\117\1\u025b\14\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\6\117\1\u025c\10\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\5\117\1\u025d\11\117"+
-    "\34\0\14\117\1\u025e\1\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\17\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\11\117\1\u025f\5\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\4\117\1\u0260\12\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\10\117\1\u0261\6\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\u0262"+
-    "\2\0\17\117\34\0\6\117\1\u0263\7\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\10\117"+
-    "\1\u0264\5\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\17\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\1\117\1\u0265\15\117\34\0\12\117"+
-    "\1\u0266\3\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\17\117\34\0\6\117\1\u0267\7\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\1\141"+
-    "\1\u0268\15\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\1\141\1\u0269\15\141\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\4\141"+
-    "\1\u026a\12\141\34\0\2\141\1\u026b\13\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\6\141"+
-    "\1\u026c\7\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\10\141\1\u026d\6\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\5\141\1\u026e\11\141"+
-    "\34\0\14\141\1\u026f\1\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\1\141\1\u0270\15\141"+
-    "\34\0\16\141\2\0\2\141\1\u0271\4\141\1\0\1\141"+
-    "\1\0\1\141\2\0\17\141\34\0\14\141\1\u0272\1\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
-    "\34\0\14\141\1\u0273\1\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\7\141\1\u0274\7\141"+
-    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\1\141\1\u0275\15\141\34\0\6\141\1\u0276\7\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
-    "\34\0\14\141\1\u0277\1\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\17\141\34\0\6\141\1\u0278\7\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
-    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\3\141\1\u0279\13\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\12\141\1\u027a\4\141"+
-    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\5\141\1\u027b\11\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\5\141\1\u027c\11\141"+
-    "\34\0\14\141\1\u027d\1\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\4\141\1\u027e\12\141"+
-    "\34\0\14\141\1\u027f\1\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\2\141\1\u0280\14\141"+
-    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\5\141\1\u0281\11\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\6\141\1\u0282\10\141"+
-    "\34\0\14\141\1\u0283\1\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\5\141\1\u0284\11\141"+
-    "\34\0\10\141\1\u0285\5\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\2\141\1\u0286\14\141"+
-    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\6\141\1\u0287\10\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\5\141\1\u0288\11\141"+
-    "\34\0\14\141\1\u0289\1\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\11\141\1\u028a\5\141"+
-    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\4\141\1\u028b\12\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\10\141\1\u028c\6\141"+
-    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\u028d"+
-    "\2\0\17\141\34\0\6\141\1\u028e\7\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\10\141"+
-    "\1\u028f\5\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\17\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\1\141\1\u0290\15\141\34\0\12\141"+
-    "\1\u0291\3\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\17\141\34\0\6\141\1\u0292\7\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\17\141\23\0\1\162"+
-    "\1\u0293\2\u0144\1\u0145\103\162\1\0\1\162\1\u0144\1\u01fb"+
-    "\1\u0294\104\0\2\162\1\u01fb\1\u0294\103\0\4\167\1\0"+
-    "\35\167\1\0\2\167\1\u0295\42\167\5\u0159\1\u0296\1\u0297"+
-    "\101\u0159\6\u0200\1\u0298\101\u0200\12\0\1\u015f\16\0\1\u0203"+
-    "\1\u015f\2\0\1\u015f\63\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\5\43\1\u0299\11\43\34\0\6\43\1\u029a"+
-    "\7\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
-    "\14\43\1\u029b\1\43\2\0\7\43\1\0\3\43\2\0"+
-    "\17\43\34\0\14\43\1\u029c\1\43\2\0\7\43\1\0"+
-    "\3\43\2\0\17\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\6\43\1\u029d\10\43\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\1\43\1\u029e\15\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\6\43\1\u029f"+
-    "\10\43\34\0\16\43\2\0\7\43\1\0\2\43\1\u02a0"+
-    "\2\0\17\43\34\0\6\43\1\u02a1\7\43\2\0\7\43"+
-    "\1\0\3\43\2\0\17\43\34\0\16\43\2\0\7\43"+
-    "\1\0\3\43\2\0\11\43\1\u02a2\5\43\54\0\1\u0211"+
-    "\1\u016d\2\0\1\u016d\63\0\2\u016e\2\0\2\u016e\4\0"+
-    "\4\u016e\2\0\1\u0212\4\u016e\11\0\2\u016e\50\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\3\43\1\u02a3\13\43"+
-    "\34\0\14\43\1\u02a4\1\43\2\0\7\43\1\0\3\43"+
-    "\2\0\17\43\23\0\1\315\1\u02a5\2\u0175\1\u0176\103\315"+
-    "\1\0\1\315\1\u0175\1\u0218\1\u02a6\104\0\2\315\1\u0218"+
-    "\1\u02a6\103\0\4\u0177\1\u0219\37\u0177\1\u02a7\107\u0177\1\u02a8"+
-    "\43\u0177\1\320\1\u02a9\2\u0179\1\u017a\103\320\1\0\1\320"+
-    "\1\u0179\1\u021d\1\u02aa\104\0\2\320\1\u021d\1\u02aa\103\0"+
-    "\4\u021e\1\u021f\35\u021e\1\0\2\u021e\1\u02ab\156\u021e\1\0"+
-    "\35\u021e\1\0\2\u021e\1\u02ac\42\u021e\11\0\10\43\1\u02ad"+
-    "\5\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\1\43\1\u02ae"+
-    "\15\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
-    "\1\43\1\u02af\15\43\34\0\14\43\1\u02b0\1\43\2\0"+
-    "\7\43\1\0\3\43\2\0\17\43\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\6\43\1\u02b1\10\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\6\43\1\u02b2"+
-    "\10\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
-    "\4\43\1\u02b3\12\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\14\43\1\u02b4\2\43\34\0\10\43\1\u02b5"+
-    "\5\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\6\43\1\u02b6"+
-    "\10\43\34\0\10\43\1\u02b7\5\43\2\0\7\43\1\0"+
-    "\3\43\2\0\17\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\2\43\1\u02b8\14\43\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\14\43\1\u02b9\2\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\5\43\1\u02ba"+
+    "\3\43\2\0\3\43\1\u02e7\13\43\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\12\43\1\u02e8\4\43\34\0"+
+    "\16\43\2\0\7\43\1\0\3\43\2\0\5\43\1\u02e9"+
     "\11\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
-    "\2\43\1\u02bb\14\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\4\43\1\u02bc\12\43\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\16\43\1\u02bd\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\6\43\1\u02be\10\43"+
-    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\12\43"+
-    "\1\u02bf\4\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\5\43\1\u02c0\11\43\34\0\14\43\1\u02c1\1\43"+
-    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\16\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\5\117"+
-    "\1\u02c2\11\117\34\0\6\117\1\u02c3\7\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\14\117"+
-    "\1\u02c4\1\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\17\117\34\0\14\117\1\u02c5\1\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\6\117"+
-    "\1\u02c6\10\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\1\117\1\u02c7\15\117\34\0\16\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\6\117"+
-    "\1\u02c8\10\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\u02c9\2\0\17\117\34\0\6\117\1\u02ca\7\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\11\117\1\u02cb\5\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\3\117\1\u02cc\13\117"+
-    "\34\0\14\117\1\u02cd\1\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\17\117\34\0\10\117\1\u02ce\5\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\1\117\1\u02cf\15\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\1\117\1\u02d0\15\117"+
-    "\34\0\14\117\1\u02d1\1\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\17\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\6\117\1\u02d2\10\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\6\117\1\u02d3\10\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\4\117\1\u02d4\12\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\14\117\1\u02d5\2\117\34\0\10\117\1\u02d6\5\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\6\117\1\u02d7\10\117\34\0\10\117\1\u02d8\5\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\2\117\1\u02d9\14\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\14\117\1\u02da\2\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\5\117\1\u02db\11\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\2\117\1\u02dc\14\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\4\117\1\u02dd\12\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\16\117\1\u02de\34\0"+
-    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
-    "\6\117\1\u02df\10\117\34\0\16\117\2\0\7\117\1\0"+
-    "\1\117\1\0\1\117\2\0\12\117\1\u02e0\4\117\34\0"+
-    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
-    "\5\117\1\u02e1\11\117\34\0\14\117\1\u02e2\1\117\2\0"+
-    "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
-    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\5\141\1\u02e3\11\141\34\0\6\141\1\u02e4\7\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\17\141\34\0"+
-    "\14\141\1\u02e5\1\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\17\141\34\0\14\141\1\u02e6\1\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\17\141\34\0"+
-    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\6\141\1\u02e7\10\141\34\0\16\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\1\141\1\u02e8\15\141\34\0"+
-    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\6\141\1\u02e9\10\141\34\0\16\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\u02ea\2\0\17\141\34\0\6\141\1\u02eb"+
-    "\7\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\17\141\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\11\141\1\u02ec\5\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\3\141\1\u02ed"+
-    "\13\141\34\0\14\141\1\u02ee\1\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\17\141\34\0\10\141\1\u02ef"+
-    "\5\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\17\141\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\1\141\1\u02f0\15\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\1\141\1\u02f1"+
-    "\15\141\34\0\14\141\1\u02f2\1\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\17\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\6\141\1\u02f3"+
-    "\10\141\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\6\141\1\u02f4\10\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\4\141\1\u02f5"+
-    "\12\141\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\14\141\1\u02f6\2\141\34\0\10\141\1\u02f7"+
-    "\5\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\17\141\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\6\141\1\u02f8\10\141\34\0\10\141\1\u02f9"+
-    "\5\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\17\141\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\2\141\1\u02fa\14\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\14\141\1\u02fb"+
-    "\2\141\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\5\141\1\u02fc\11\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\2\141\1\u02fd"+
-    "\14\141\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\4\141\1\u02fe\12\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\16\141\1\u02ff"+
-    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\6\141\1\u0300\10\141\34\0\16\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\12\141\1\u0301\4\141"+
-    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\5\141\1\u0302\11\141\34\0\14\141\1\u0303\1\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
-    "\23\0\2\162\2\u0144\1\u01f9\35\162\1\0\2\162\1\0"+
-    "\42\162\1\0\1\u01fa\1\u01fb\105\0\5\u0200\1\u0201\1\u0304"+
-    "\101\u0200\11\0\6\43\1\u0305\7\43\2\0\7\43\1\0"+
-    "\3\43\2\0\17\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\7\43\1\u0306\7\43\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\5\43\1\u0307\11\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\11\43\1\u0308"+
-    "\5\43\34\0\4\43\1\u0309\11\43\2\0\7\43\1\0"+
-    "\3\43\2\0\17\43\34\0\6\43\1\u030a\7\43\2\0"+
-    "\7\43\1\0\3\43\2\0\17\43\34\0\14\43\1\u030b"+
-    "\1\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
-    "\12\43\1\u030c\3\43\2\0\7\43\1\0\3\43\2\0"+
+    "\5\43\1\u02ea\11\43\34\0\14\43\1\u02eb\1\43\2\0"+
+    "\7\43\1\0\3\43\2\0\17\43\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\4\43\1\u02ec\12\43\34\0"+
+    "\14\43\1\u02ed\1\43\2\0\7\43\1\0\3\43\2\0"+
     "\17\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
-    "\1\43\1\u030d\15\43\23\0\2\315\2\u0175\1\u0216\37\315"+
-    "\1\u0174\43\315\1\0\1\u0217\1\u0218\105\0\4\u0177\1\u0219"+
-    "\37\u0177\1\u030e\107\u0177\1\u0174\43\u0177\2\320\2\u0179\1\u021b"+
-    "\35\320\1\0\2\320\1\u0178\42\320\1\0\1\u021c\1\u021d"+
-    "\105\0\4\u021e\1\0\35\u021e\1\0\2\u021e\1\u030f\46\u021e"+
-    "\1\0\35\u021e\1\0\2\u021e\1\0\42\u021e\11\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\2\43\1\u0310\14\43"+
-    "\34\0\2\43\1\u0311\13\43\2\0\7\43\1\0\3\43"+
-    "\2\0\17\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\5\43\1\u0312\11\43\34\0\16\43\2\0\7\43"+
-    "\1\0\3\43\2\0\2\43\1\u0313\14\43\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\1\43\1\u0314\15\43"+
-    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\5\43"+
-    "\1\u0315\11\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\11\43\1\u0316\5\43\34\0\16\43\2\0\7\43"+
-    "\1\0\3\43\2\0\2\43\1\u0317\14\43\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\5\43\1\u0318\11\43"+
-    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\6\43"+
-    "\1\u0319\10\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\14\43\1\u031a\2\43\34\0\10\43\1\u031b\5\43"+
-    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\4\43\1\u031c\12\43"+
-    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\11\43"+
-    "\1\u031d\5\43\34\0\14\43\1\u031e\1\43\2\0\7\43"+
-    "\1\0\3\43\2\0\17\43\34\0\10\43\1\u031f\5\43"+
-    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\6\117"+
-    "\1\u0320\7\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\17\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\7\117\1\u0321\7\117\34\0\16\117"+
+    "\2\43\1\u02ee\14\43\34\0\16\43\2\0\7\43\1\0"+
+    "\3\43\2\0\5\43\1\u02ef\11\43\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\6\43\1\u02f0\10\43\34\0"+
+    "\14\43\1\u02f1\1\43\2\0\7\43\1\0\3\43\2\0"+
+    "\17\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
+    "\5\43\1\u02f2\11\43\34\0\10\43\1\u02f3\5\43\2\0"+
+    "\7\43\1\0\3\43\2\0\17\43\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\2\43\1\u02f4\14\43\34\0"+
+    "\16\43\2\0\7\43\1\0\3\43\2\0\6\43\1\u02f5"+
+    "\10\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
+    "\5\43\1\u02f6\11\43\34\0\14\43\1\u02f7\1\43\2\0"+
+    "\7\43\1\0\3\43\2\0\17\43\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\11\43\1\u02f8\5\43\34\0"+
+    "\16\43\2\0\7\43\1\0\3\43\2\0\4\43\1\u02f9"+
+    "\12\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
+    "\10\43\1\u02fa\6\43\34\0\16\43\2\0\7\43\1\0"+
+    "\2\43\1\u02fb\2\0\17\43\34\0\6\43\1\u02fc\7\43"+
+    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\10\43"+
+    "\1\u02fd\5\43\2\0\7\43\1\0\3\43\2\0\17\43"+
+    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\1\43"+
+    "\1\u02fe\15\43\34\0\12\43\1\u02ff\3\43\2\0\7\43"+
+    "\1\0\3\43\2\0\17\43\34\0\6\43\1\u0300\7\43"+
+    "\2\0\7\43\1\0\3\43\2\0\17\43\113\0\1\u0301"+
+    "\30\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\1\117\1\u0302\15\117\34\0\16\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\1\117\1\u0303\15\117"+
+    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\4\117\1\u0304\12\117\34\0\2\117\1\u0305\13\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
+    "\34\0\6\117\1\u0306\7\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\10\117\1\u0307\6\117\34\0\16\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\5\117"+
-    "\1\u0322\11\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\11\117\1\u0323\5\117\34\0\4\117"+
-    "\1\u0324\11\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\17\117\34\0\6\117\1\u0325\7\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\14\117"+
-    "\1\u0326\1\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\17\117\34\0\12\117\1\u0327\3\117\2\0\7\117"+
+    "\1\u0308\11\117\34\0\14\117\1\u0309\1\117\2\0\7\117"+
     "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\1\117"+
-    "\1\u0328\15\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\2\117\1\u0329\14\117\34\0\2\117"+
-    "\1\u032a\13\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\1\u030a\15\117\34\0\16\117\2\0\2\117\1\u030b\4\117"+
+    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\14\117"+
+    "\1\u030c\1\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\17\117\34\0\14\117\1\u030d\1\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\7\117"+
+    "\1\u030e\7\117\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\1\117\1\u030f\15\117\34\0\6\117"+
+    "\1\u0310\7\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\17\117\34\0\14\117\1\u0311\1\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\6\117"+
+    "\1\u0312\7\117\2\0\7\117\1\0\1\117\1\0\1\117"+
     "\2\0\17\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\5\117\1\u032b\11\117\34\0\16\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\2\117"+
-    "\1\u032c\14\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\1\117\1\u032d\15\117\34\0\16\117"+
+    "\1\0\1\117\2\0\3\117\1\u0313\13\117\34\0\16\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\12\117"+
+    "\1\u0314\4\117\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\5\117\1\u0315\11\117\34\0\16\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\5\117"+
-    "\1\u032e\11\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\11\117\1\u032f\5\117\34\0\16\117"+
+    "\1\u0316\11\117\34\0\14\117\1\u0317\1\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\4\117"+
+    "\1\u0318\12\117\34\0\14\117\1\u0319\1\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\2\117"+
-    "\1\u0330\14\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\5\117\1\u0331\11\117\34\0\16\117"+
+    "\1\u031a\14\117\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\5\117\1\u031b\11\117\34\0\16\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\6\117"+
-    "\1\u0332\10\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\14\117\1\u0333\2\117\34\0\10\117"+
-    "\1\u0334\5\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\17\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\4\117\1\u0335\12\117\34\0\16\117"+
+    "\1\u031c\10\117\34\0\14\117\1\u031d\1\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\5\117"+
+    "\1\u031e\11\117\34\0\10\117\1\u031f\5\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\2\117"+
+    "\1\u0320\14\117\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\6\117\1\u0321\10\117\34\0\16\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\5\117"+
+    "\1\u0322\11\117\34\0\14\117\1\u0323\1\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\117"+
     "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\11\117"+
-    "\1\u0336\5\117\34\0\14\117\1\u0337\1\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\10\117"+
-    "\1\u0338\5\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\17\117\34\0\6\141\1\u0339\7\141\2\0\7\141"+
+    "\1\u0324\5\117\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\4\117\1\u0325\12\117\34\0\16\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\10\117"+
+    "\1\u0326\6\117\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\u0327\2\0\17\117\34\0\6\117\1\u0328\7\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
+    "\34\0\10\117\1\u0329\5\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\17\117\34\0\16\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\1\117\1\u032a\15\117"+
+    "\34\0\12\117\1\u032b\3\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\17\117\34\0\6\117\1\u032c\7\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
+    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\1\141\1\u032d\15\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\1\141\1\u032e\15\141"+
+    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\4\141\1\u032f\12\141\34\0\2\141\1\u0330\13\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
+    "\34\0\6\141\1\u0331\7\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\10\141\1\u0332\6\141\34\0\16\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\5\141"+
+    "\1\u0333\11\141\34\0\14\141\1\u0334\1\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\1\141"+
+    "\1\u0335\15\141\34\0\16\141\2\0\2\141\1\u0336\4\141"+
+    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\14\141"+
+    "\1\u0337\1\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\17\141\34\0\14\141\1\u0338\1\141\2\0\7\141"+
     "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\141"+
     "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\7\141"+
-    "\1\u033a\7\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\5\141\1\u033b\11\141\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\11\141"+
-    "\1\u033c\5\141\34\0\4\141\1\u033d\11\141\2\0\7\141"+
+    "\1\u0339\7\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\1\141\1\u033a\15\141\34\0\6\141"+
+    "\1\u033b\7\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\17\141\34\0\14\141\1\u033c\1\141\2\0\7\141"+
     "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\6\141"+
-    "\1\u033e\7\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\17\141\34\0\14\141\1\u033f\1\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\12\141"+
-    "\1\u0340\3\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\1\u033d\7\141\2\0\7\141\1\0\1\141\1\0\1\141"+
     "\2\0\17\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\1\141\1\u0341\15\141\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\2\141"+
-    "\1\u0342\14\141\34\0\2\141\1\u0343\13\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\141"+
+    "\1\0\1\141\2\0\3\141\1\u033e\13\141\34\0\16\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\12\141"+
+    "\1\u033f\4\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\5\141\1\u0340\11\141\34\0\16\141"+
     "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\5\141"+
-    "\1\u0344\11\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\2\141\1\u0345\14\141\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\1\141"+
-    "\1\u0346\15\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\5\141\1\u0347\11\141\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\11\141"+
-    "\1\u0348\5\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\2\141\1\u0349\14\141\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\5\141"+
-    "\1\u034a\11\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\6\141\1\u034b\10\141\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\14\141"+
-    "\1\u034c\2\141\34\0\10\141\1\u034d\5\141\2\0\7\141"+
+    "\1\u0341\11\141\34\0\14\141\1\u0342\1\141\2\0\7\141"+
     "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\141"+
     "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\4\141"+
-    "\1\u034e\12\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\11\141\1\u034f\5\141\34\0\14\141"+
-    "\1\u0350\1\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\17\141\34\0\10\141\1\u0351\5\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\13\43\1\u0352\3\43"+
-    "\34\0\14\43\1\u0353\1\43\2\0\7\43\1\0\3\43"+
-    "\2\0\17\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\2\43\1\u0354\14\43\34\0\16\43\2\0\7\43"+
-    "\1\0\3\43\2\0\1\43\1\u0355\15\43\34\0\16\43"+
-    "\2\0\7\43\1\0\3\43\2\0\5\43\1\u0356\11\43"+
-    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\4\43"+
-    "\1\u0357\12\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\11\43\1\u0358\5\43\23\0\44\u0177\1\u0359\43\u0177"+
-    "\4\u021e\1\0\35\u021e\1\0\2\u021e\1\u0178\42\u021e\11\0"+
-    "\14\43\1\u035a\1\43\2\0\7\43\1\0\3\43\2\0"+
-    "\17\43\34\0\14\43\1\u035b\1\43\2\0\7\43\1\0"+
-    "\3\43\2\0\17\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\5\43\1\u035c\11\43\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\2\43\1\u035d\14\43\34\0"+
-    "\16\43\2\0\7\43\1\0\2\43\1\u035e\2\0\17\43"+
-    "\34\0\4\43\1\u035f\11\43\2\0\7\43\1\0\3\43"+
-    "\2\0\17\43\34\0\16\43\2\0\7\43\1\0\3\43"+
-    "\2\0\10\43\1\u0360\6\43\34\0\14\43\1\u0361\1\43"+
-    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\6\43"+
-    "\1\u0362\7\43\2\0\7\43\1\0\3\43\2\0\17\43"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\13\117\1\u0363\3\117\34\0\14\117\1\u0364\1\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\2\117\1\u0365\14\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\1\117\1\u0366\15\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\5\117\1\u0367\11\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\4\117\1\u0368\12\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\11\117\1\u0369\5\117\34\0\14\117\1\u036a\1\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
-    "\34\0\14\117\1\u036b\1\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\17\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\5\117\1\u036c\11\117"+
-    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\2\117\1\u036d\14\117\34\0\16\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\u036e\2\0\17\117\34\0\4\117"+
-    "\1\u036f\11\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\17\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\10\117\1\u0370\6\117\34\0\14\117"+
-    "\1\u0371\1\117\2\0\7\117\1\0\1\117\1\0\1\117"+
-    "\2\0\17\117\34\0\6\117\1\u0372\7\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\13\141"+
-    "\1\u0373\3\141\34\0\14\141\1\u0374\1\141\2\0\7\141"+
+    "\1\u0343\12\141\34\0\14\141\1\u0344\1\141\2\0\7\141"+
     "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\141"+
     "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\2\141"+
-    "\1\u0375\14\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\1\141\1\u0376\15\141\34\0\16\141"+
+    "\1\u0345\14\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\5\141\1\u0346\11\141\34\0\16\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\6\141"+
+    "\1\u0347\10\141\34\0\14\141\1\u0348\1\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\141"+
     "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\5\141"+
-    "\1\u0377\11\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\4\141\1\u0378\12\141\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\11\141"+
-    "\1\u0379\5\141\34\0\14\141\1\u037a\1\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\14\141"+
-    "\1\u037b\1\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\17\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\5\141\1\u037c\11\141\34\0\16\141"+
+    "\1\u0349\11\141\34\0\10\141\1\u034a\5\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\141"+
     "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\2\141"+
-    "\1\u037d\14\141\34\0\16\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\u037e\2\0\17\141\34\0\4\141\1\u037f\11\141"+
+    "\1\u034b\14\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\6\141\1\u034c\10\141\34\0\16\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\5\141"+
+    "\1\u034d\11\141\34\0\14\141\1\u034e\1\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\11\141"+
+    "\1\u034f\5\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\4\141\1\u0350\12\141\34\0\16\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\10\141"+
+    "\1\u0351\6\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\u0352\2\0\17\141\34\0\6\141\1\u0353\7\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
+    "\34\0\10\141\1\u0354\5\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\1\141\1\u0355\15\141"+
+    "\34\0\12\141\1\u0356\3\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\17\141\34\0\6\141\1\u0357\7\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
+    "\23\0\1\162\1\u0358\2\u0163\1\u0164\103\162\1\0\1\162"+
+    "\1\u0163\1\u0266\1\u0359\104\0\2\162\1\u0266\1\u0359\103\0"+
+    "\4\167\1\0\35\167\1\0\2\167\1\u035a\42\167\11\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\1\207\1\u035b\15\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\1\207\1\u035c\15\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\4\207\1\u035d\12\207\34\0\2\207\1\u035e\13\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\17\207\34\0"+
+    "\6\207\1\u035f\7\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\10\207\1\u0360\6\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\5\207\1\u0361"+
+    "\11\207\34\0\14\207\1\u0362\1\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\1\207\1\u0363"+
+    "\15\207\34\0\16\207\2\0\2\207\1\u0364\4\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\14\207\1\u0365"+
+    "\1\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\17\207\34\0\14\207\1\u0366\1\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\7\207\1\u0367"+
+    "\7\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\1\207\1\u0368\15\207\34\0\6\207\1\u0369"+
+    "\7\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\17\207\34\0\14\207\1\u036a\1\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\6\207\1\u036b"+
+    "\7\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\17\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\3\207\1\u036c\13\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\12\207\1\u036d"+
+    "\4\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\5\207\1\u036e\11\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\5\207\1\u036f"+
+    "\11\207\34\0\14\207\1\u0370\1\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\4\207\1\u0371"+
+    "\12\207\34\0\14\207\1\u0372\1\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\2\207\1\u0373"+
+    "\14\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\5\207\1\u0374\11\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\6\207\1\u0375"+
+    "\10\207\34\0\14\207\1\u0376\1\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\5\207\1\u0377"+
+    "\11\207\34\0\10\207\1\u0378\5\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\2\207\1\u0379"+
+    "\14\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\6\207\1\u037a\10\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\5\207\1\u037b"+
+    "\11\207\34\0\14\207\1\u037c\1\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\11\207\1\u037d"+
+    "\5\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\4\207\1\u037e\12\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\10\207\1\u037f"+
+    "\6\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\u0380\2\0\17\207\34\0\6\207\1\u0381\7\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\17\207\34\0"+
+    "\10\207\1\u0382\5\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\17\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\1\207\1\u0383\15\207\34\0"+
+    "\12\207\1\u0384\3\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\17\207\34\0\6\207\1\u0385\7\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\17\207\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\1\236\1\u0386\15\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\1\236\1\u0387\15\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\4\236\1\u0388\12\236\34\0\2\236\1\u0389\13\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\17\236\34\0"+
+    "\6\236\1\u038a\7\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\10\236\1\u038b\6\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\5\236\1\u038c"+
+    "\11\236\34\0\14\236\1\u038d\1\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\1\236\1\u038e"+
+    "\15\236\34\0\16\236\2\0\2\236\1\u038f\4\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\14\236\1\u0390"+
+    "\1\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\17\236\34\0\14\236\1\u0391\1\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\7\236\1\u0392"+
+    "\7\236\34\0\16\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\1\236\1\u0393\15\236\34\0\6\236\1\u0394"+
+    "\7\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\17\236\34\0\14\236\1\u0395\1\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\6\236\1\u0396"+
+    "\7\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\17\236\34\0\16\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\3\236\1\u0397\13\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\12\236\1\u0398"+
+    "\4\236\34\0\16\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\5\236\1\u0399\11\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\5\236\1\u039a"+
+    "\11\236\34\0\14\236\1\u039b\1\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\4\236\1\u039c"+
+    "\12\236\34\0\14\236\1\u039d\1\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\2\236\1\u039e"+
+    "\14\236\34\0\16\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\5\236\1\u039f\11\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\6\236\1\u03a0"+
+    "\10\236\34\0\14\236\1\u03a1\1\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\5\236\1\u03a2"+
+    "\11\236\34\0\10\236\1\u03a3\5\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\2\236\1\u03a4"+
+    "\14\236\34\0\16\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\6\236\1\u03a5\10\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\5\236\1\u03a6"+
+    "\11\236\34\0\14\236\1\u03a7\1\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\11\236\1\u03a8"+
+    "\5\236\34\0\16\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\4\236\1\u03a9\12\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\10\236\1\u03aa"+
+    "\6\236\34\0\16\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\u03ab\2\0\17\236\34\0\6\236\1\u03ac\7\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\17\236\34\0"+
+    "\10\236\1\u03ad\5\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\17\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\1\236\1\u03ae\15\236\34\0"+
+    "\12\236\1\u03af\3\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\17\236\34\0\6\236\1\u03b0\7\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\17\236\23\0"+
+    "\5\u01c4\1\u03b1\1\u03b2\101\u01c4\6\u02c5\1\u03b3\101\u02c5\12\0"+
+    "\1\u01ca\16\0\1\u02c8\1\u01ca\2\0\1\u01ca\63\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\5\43\1\u03b4\11\43"+
+    "\34\0\6\43\1\u03b5\7\43\2\0\7\43\1\0\3\43"+
+    "\2\0\17\43\34\0\14\43\1\u03b6\1\43\2\0\7\43"+
+    "\1\0\3\43\2\0\17\43\34\0\14\43\1\u03b7\1\43"+
+    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\6\43\1\u03b8\10\43"+
+    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\1\43"+
+    "\1\u03b9\15\43\34\0\16\43\2\0\7\43\1\0\3\43"+
+    "\2\0\6\43\1\u03ba\10\43\34\0\16\43\2\0\7\43"+
+    "\1\0\2\43\1\u03bb\2\0\17\43\34\0\6\43\1\u03bc"+
+    "\7\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
+    "\16\43\2\0\7\43\1\0\3\43\2\0\11\43\1\u03bd"+
+    "\5\43\54\0\1\u02d6\1\u01d8\2\0\1\u01d8\63\0\2\u01d9"+
+    "\2\0\2\u01d9\4\0\4\u01d9\2\0\1\u02d7\4\u01d9\11\0"+
+    "\2\u01d9\50\0\16\43\2\0\7\43\1\0\3\43\2\0"+
+    "\3\43\1\u03be\13\43\34\0\14\43\1\u03bf\1\43\2\0"+
+    "\7\43\1\0\3\43\2\0\17\43\23\0\1\354\1\u03c0"+
+    "\2\u01e0\1\u01e1\103\354\1\0\1\354\1\u01e0\1\u02dd\1\u03c1"+
+    "\104\0\2\354\1\u02dd\1\u03c1\103\0\4\u01e2\1\u02de\37\u01e2"+
+    "\1\u03c2\107\u01e2\1\u03c3\43\u01e2\1\357\1\u03c4\2\u01e4\1\u01e5"+
+    "\103\357\1\0\1\357\1\u01e4\1\u02e2\1\u03c5\104\0\2\357"+
+    "\1\u02e2\1\u03c5\103\0\4\u02e3\1\u02e4\35\u02e3\1\0\2\u02e3"+
+    "\1\u03c6\156\u02e3\1\0\35\u02e3\1\0\2\u02e3\1\u03c7\42\u02e3"+
+    "\11\0\10\43\1\u03c8\5\43\2\0\7\43\1\0\3\43"+
+    "\2\0\17\43\34\0\16\43\2\0\7\43\1\0\3\43"+
+    "\2\0\1\43\1\u03c9\15\43\34\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\1\43\1\u03ca\15\43\34\0\14\43"+
+    "\1\u03cb\1\43\2\0\7\43\1\0\3\43\2\0\17\43"+
+    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\6\43"+
+    "\1\u03cc\10\43\34\0\16\43\2\0\7\43\1\0\3\43"+
+    "\2\0\6\43\1\u03cd\10\43\34\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\4\43\1\u03ce\12\43\34\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\14\43\1\u03cf\2\43"+
+    "\34\0\10\43\1\u03d0\5\43\2\0\7\43\1\0\3\43"+
+    "\2\0\17\43\34\0\16\43\2\0\7\43\1\0\3\43"+
+    "\2\0\6\43\1\u03d1\10\43\34\0\10\43\1\u03d2\5\43"+
+    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\2\43\1\u03d3\14\43"+
+    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\14\43"+
+    "\1\u03d4\2\43\34\0\16\43\2\0\7\43\1\0\3\43"+
+    "\2\0\5\43\1\u03d5\11\43\34\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\2\43\1\u03d6\14\43\34\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\4\43\1\u03d7\12\43"+
+    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\16\43"+
+    "\1\u03d8\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
+    "\6\43\1\u03d9\10\43\34\0\16\43\2\0\7\43\1\0"+
+    "\3\43\2\0\12\43\1\u03da\4\43\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\5\43\1\u03db\11\43\34\0"+
+    "\14\43\1\u03dc\1\43\2\0\7\43\1\0\3\43\2\0"+
+    "\17\43\34\0\16\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\5\117\1\u03dd\11\117\34\0\6\117\1\u03de"+
+    "\7\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\17\117\34\0\14\117\1\u03df\1\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\17\117\34\0\14\117\1\u03e0"+
+    "\1\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\17\117\34\0\16\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\6\117\1\u03e1\10\117\34\0\16\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\1\117\1\u03e2"+
+    "\15\117\34\0\16\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\6\117\1\u03e3\10\117\34\0\16\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\u03e4\2\0\17\117\34\0"+
+    "\6\117\1\u03e5\7\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\17\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\11\117\1\u03e6\5\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\3\117\1\u03e7\13\117\34\0\14\117\1\u03e8\1\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
+    "\10\117\1\u03e9\5\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\17\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\1\117\1\u03ea\15\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\1\117\1\u03eb\15\117\34\0\14\117\1\u03ec\1\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\6\117\1\u03ed\10\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\6\117\1\u03ee\10\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\4\117\1\u03ef\12\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\14\117\1\u03f0\2\117\34\0"+
+    "\10\117\1\u03f1\5\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\17\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\6\117\1\u03f2\10\117\34\0"+
+    "\10\117\1\u03f3\5\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\17\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\2\117\1\u03f4\14\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\14\117\1\u03f5\2\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\5\117\1\u03f6\11\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\2\117\1\u03f7\14\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\4\117\1\u03f8\12\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\16\117\1\u03f9\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\6\117\1\u03fa\10\117\34\0\16\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\12\117"+
+    "\1\u03fb\4\117\34\0\16\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\5\117\1\u03fc\11\117\34\0\14\117"+
+    "\1\u03fd\1\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\17\117\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\5\141\1\u03fe\11\141\34\0\6\141"+
+    "\1\u03ff\7\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\17\141\34\0\14\141\1\u0400\1\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\14\141"+
+    "\1\u0401\1\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\17\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\6\141\1\u0402\10\141\34\0\16\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\1\141"+
+    "\1\u0403\15\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\6\141\1\u0404\10\141\34\0\16\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\u0405\2\0\17\141"+
+    "\34\0\6\141\1\u0406\7\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\11\141\1\u0407\5\141"+
+    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\3\141\1\u0408\13\141\34\0\14\141\1\u0409\1\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
+    "\34\0\10\141\1\u040a\5\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\1\141\1\u040b\15\141"+
+    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\1\141\1\u040c\15\141\34\0\14\141\1\u040d\1\141"+
     "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
     "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
-    "\2\0\10\141\1\u0380\6\141\34\0\14\141\1\u0381\1\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
-    "\34\0\6\141\1\u0382\7\141\2\0\7\141\1\0\1\141"+
-    "\1\0\1\141\2\0\17\141\34\0\16\43\2\0\7\43"+
-    "\1\0\3\43\2\0\11\43\1\u0383\5\43\34\0\14\43"+
-    "\1\u0384\1\43\2\0\7\43\1\0\3\43\2\0\17\43"+
-    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\2\43"+
-    "\1\u0385\14\43\34\0\14\43\1\u0386\1\43\2\0\7\43"+
-    "\1\0\3\43\2\0\17\43\34\0\16\43\2\0\7\43"+
-    "\1\0\3\43\2\0\5\43\1\u0387\11\43\34\0\14\43"+
-    "\1\u0388\1\43\2\0\7\43\1\0\3\43\2\0\17\43"+
-    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\1\u0389"+
-    "\16\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
-    "\11\43\1\u038a\5\43\34\0\16\43\2\0\7\43\1\0"+
-    "\3\43\2\0\11\43\1\u038b\5\43\34\0\14\43\1\u038c"+
-    "\1\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
-    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
-    "\11\117\1\u038d\5\117\34\0\14\117\1\u038e\1\117\2\0"+
+    "\2\0\6\141\1\u040e\10\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\6\141\1\u040f\10\141"+
+    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\4\141\1\u0410\12\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\14\141\1\u0411\2\141"+
+    "\34\0\10\141\1\u0412\5\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\6\141\1\u0413\10\141"+
+    "\34\0\10\141\1\u0414\5\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\2\141\1\u0415\14\141"+
+    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\14\141\1\u0416\2\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\5\141\1\u0417\11\141"+
+    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\2\141\1\u0418\14\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\4\141\1\u0419\12\141"+
+    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\16\141\1\u041a\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\6\141\1\u041b\10\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\12\141\1\u041c\4\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\5\141\1\u041d\11\141\34\0"+
+    "\14\141\1\u041e\1\141\2\0\7\141\1\0\1\141\1\0"+
+    "\1\141\2\0\17\141\23\0\2\162\2\u0163\1\u0264\35\162"+
+    "\1\0\2\162\1\0\42\162\1\0\1\u0265\1\u0266\116\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\5\207\1\u041f\11\207\34\0\6\207\1\u0420\7\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\17\207\34\0"+
+    "\14\207\1\u0421\1\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\17\207\34\0\14\207\1\u0422\1\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\17\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\6\207\1\u0423\10\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\1\207\1\u0424\15\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\6\207\1\u0425\10\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\u0426\2\0\17\207\34\0\6\207\1\u0427"+
+    "\7\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\17\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\11\207\1\u0428\5\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\3\207\1\u0429"+
+    "\13\207\34\0\14\207\1\u042a\1\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\10\207\1\u042b"+
+    "\5\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\17\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\1\207\1\u042c\15\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\1\207\1\u042d"+
+    "\15\207\34\0\14\207\1\u042e\1\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\6\207\1\u042f"+
+    "\10\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\6\207\1\u0430\10\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\4\207\1\u0431"+
+    "\12\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\14\207\1\u0432\2\207\34\0\10\207\1\u0433"+
+    "\5\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\17\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\6\207\1\u0434\10\207\34\0\10\207\1\u0435"+
+    "\5\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\17\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\2\207\1\u0436\14\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\14\207\1\u0437"+
+    "\2\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\5\207\1\u0438\11\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\2\207\1\u0439"+
+    "\14\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\4\207\1\u043a\12\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\16\207\1\u043b"+
+    "\34\0\16\207\2\0\7\207\1\0\1\207\1\0\1\207"+
+    "\2\0\6\207\1\u043c\10\207\34\0\16\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\12\207\1\u043d\4\207"+
+    "\34\0\16\207\2\0\7\207\1\0\1\207\1\0\1\207"+
+    "\2\0\5\207\1\u043e\11\207\34\0\14\207\1\u043f\1\207"+
+    "\2\0\7\207\1\0\1\207\1\0\1\207\2\0\17\207"+
+    "\34\0\16\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\5\236\1\u0440\11\236\34\0\6\236\1\u0441\7\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\17\236"+
+    "\34\0\14\236\1\u0442\1\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\17\236\34\0\14\236\1\u0443\1\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\17\236"+
+    "\34\0\16\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\6\236\1\u0444\10\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\1\236\1\u0445\15\236"+
+    "\34\0\16\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\6\236\1\u0446\10\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\u0447\2\0\17\236\34\0\6\236"+
+    "\1\u0448\7\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\17\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\11\236\1\u0449\5\236\34\0\16\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\3\236"+
+    "\1\u044a\13\236\34\0\14\236\1\u044b\1\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\17\236\34\0\10\236"+
+    "\1\u044c\5\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\17\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\1\236\1\u044d\15\236\34\0\16\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\1\236"+
+    "\1\u044e\15\236\34\0\14\236\1\u044f\1\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\17\236\34\0\16\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\6\236"+
+    "\1\u0450\10\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\6\236\1\u0451\10\236\34\0\16\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\4\236"+
+    "\1\u0452\12\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\14\236\1\u0453\2\236\34\0\10\236"+
+    "\1\u0454\5\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\17\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\6\236\1\u0455\10\236\34\0\10\236"+
+    "\1\u0456\5\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\17\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\2\236\1\u0457\14\236\34\0\16\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\14\236"+
+    "\1\u0458\2\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\5\236\1\u0459\11\236\34\0\16\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\2\236"+
+    "\1\u045a\14\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\4\236\1\u045b\12\236\34\0\16\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\16\236"+
+    "\1\u045c\34\0\16\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\6\236\1\u045d\10\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\12\236\1\u045e"+
+    "\4\236\34\0\16\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\5\236\1\u045f\11\236\34\0\14\236\1\u0460"+
+    "\1\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\17\236\23\0\5\u02c5\1\u02c6\1\u0461\101\u02c5\11\0\6\43"+
+    "\1\u0462\7\43\2\0\7\43\1\0\3\43\2\0\17\43"+
+    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\7\43"+
+    "\1\u0463\7\43\34\0\16\43\2\0\7\43\1\0\3\43"+
+    "\2\0\5\43\1\u0464\11\43\34\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\11\43\1\u0465\5\43\34\0\4\43"+
+    "\1\u0466\11\43\2\0\7\43\1\0\3\43\2\0\17\43"+
+    "\34\0\6\43\1\u0467\7\43\2\0\7\43\1\0\3\43"+
+    "\2\0\17\43\34\0\14\43\1\u0468\1\43\2\0\7\43"+
+    "\1\0\3\43\2\0\17\43\34\0\12\43\1\u0469\3\43"+
+    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\1\43\1\u046a\15\43"+
+    "\23\0\2\354\2\u01e0\1\u02db\37\354\1\u01df\43\354\1\0"+
+    "\1\u02dc\1\u02dd\105\0\4\u01e2\1\u02de\37\u01e2\1\u046b\107\u01e2"+
+    "\1\u01df\43\u01e2\2\357\2\u01e4\1\u02e0\35\357\1\0\2\357"+
+    "\1\u01e3\42\357\1\0\1\u02e1\1\u02e2\105\0\4\u02e3\1\0"+
+    "\35\u02e3\1\0\2\u02e3\1\u046c\46\u02e3\1\0\35\u02e3\1\0"+
+    "\2\u02e3\1\0\42\u02e3\11\0\16\43\2\0\7\43\1\0"+
+    "\3\43\2\0\2\43\1\u046d\14\43\34\0\2\43\1\u046e"+
+    "\13\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
+    "\16\43\2\0\7\43\1\0\3\43\2\0\5\43\1\u046f"+
+    "\11\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
+    "\2\43\1\u0470\14\43\34\0\16\43\2\0\7\43\1\0"+
+    "\3\43\2\0\1\43\1\u0471\15\43\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\5\43\1\u0472\11\43\34\0"+
+    "\16\43\2\0\7\43\1\0\3\43\2\0\11\43\1\u0473"+
+    "\5\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
+    "\2\43\1\u0474\14\43\34\0\16\43\2\0\7\43\1\0"+
+    "\3\43\2\0\5\43\1\u0475\11\43\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\6\43\1\u0476\10\43\34\0"+
+    "\16\43\2\0\7\43\1\0\3\43\2\0\14\43\1\u0477"+
+    "\2\43\34\0\10\43\1\u0478\5\43\2\0\7\43\1\0"+
+    "\3\43\2\0\17\43\34\0\16\43\2\0\7\43\1\0"+
+    "\3\43\2\0\4\43\1\u0479\12\43\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\11\43\1\u047a\5\43\34\0"+
+    "\14\43\1\u047b\1\43\2\0\7\43\1\0\3\43\2\0"+
+    "\17\43\34\0\10\43\1\u047c\5\43\2\0\7\43\1\0"+
+    "\3\43\2\0\17\43\34\0\6\117\1\u047d\7\117\2\0"+
     "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
     "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
-    "\2\117\1\u038f\14\117\34\0\14\117\1\u0390\1\117\2\0"+
+    "\7\117\1\u047e\7\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\5\117\1\u047f\11\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\11\117\1\u0480\5\117\34\0\4\117\1\u0481\11\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
+    "\6\117\1\u0482\7\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\17\117\34\0\14\117\1\u0483\1\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
+    "\12\117\1\u0484\3\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\17\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\1\117\1\u0485\15\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\2\117\1\u0486\14\117\34\0\2\117\1\u0487\13\117\2\0"+
     "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
     "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
-    "\5\117\1\u0391\11\117\34\0\14\117\1\u0392\1\117\2\0"+
+    "\5\117\1\u0488\11\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\2\117\1\u0489\14\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\1\117\1\u048a\15\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\5\117\1\u048b\11\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\11\117\1\u048c\5\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\2\117\1\u048d\14\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\5\117\1\u048e\11\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\6\117\1\u048f\10\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\14\117\1\u0490\2\117\34\0\10\117\1\u0491\5\117\2\0"+
     "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
     "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
-    "\1\u0393\16\117\34\0\16\117\2\0\7\117\1\0\1\117"+
-    "\1\0\1\117\2\0\11\117\1\u0394\5\117\34\0\16\117"+
-    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\11\117"+
-    "\1\u0395\5\117\34\0\14\117\1\u0396\1\117\2\0\7\117"+
-    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\11\141"+
-    "\1\u0397\5\141\34\0\14\141\1\u0398\1\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\2\141"+
-    "\1\u0399\14\141\34\0\14\141\1\u039a\1\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\5\141"+
-    "\1\u039b\11\141\34\0\14\141\1\u039c\1\141\2\0\7\141"+
-    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\141"+
-    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\1\u039d"+
-    "\16\141\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\11\141\1\u039e\5\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\11\141\1\u039f"+
-    "\5\141\34\0\14\141\1\u03a0\1\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\17\141\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\5\43\1\u03a1\11\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\10\43\1\u03a2"+
-    "\6\43\34\0\14\43\1\u03a3\1\43\2\0\7\43\1\0"+
-    "\3\43\2\0\17\43\34\0\12\43\1\u03a4\3\43\2\0"+
-    "\7\43\1\0\3\43\2\0\17\43\34\0\10\43\1\u03a5"+
-    "\5\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
-    "\16\43\2\0\7\43\1\0\3\43\2\0\5\43\1\u03a6"+
-    "\11\43\34\0\16\117\2\0\7\117\1\0\1\117\1\0"+
-    "\1\117\2\0\5\117\1\u03a7\11\117\34\0\16\117\2\0"+
-    "\7\117\1\0\1\117\1\0\1\117\2\0\10\117\1\u03a8"+
-    "\6\117\34\0\14\117\1\u03a9\1\117\2\0\7\117\1\0"+
-    "\1\117\1\0\1\117\2\0\17\117\34\0\12\117\1\u03aa"+
-    "\3\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
-    "\17\117\34\0\10\117\1\u03ab\5\117\2\0\7\117\1\0"+
-    "\1\117\1\0\1\117\2\0\17\117\34\0\16\117\2\0"+
-    "\7\117\1\0\1\117\1\0\1\117\2\0\5\117\1\u03ac"+
-    "\11\117\34\0\16\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\5\141\1\u03ad\11\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\10\141\1\u03ae"+
-    "\6\141\34\0\14\141\1\u03af\1\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\17\141\34\0\12\141\1\u03b0"+
-    "\3\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\17\141\34\0\10\141\1\u03b1\5\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\17\141\34\0\16\141\2\0"+
-    "\7\141\1\0\1\141\1\0\1\141\2\0\5\141\1\u03b2"+
-    "\11\141\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
-    "\4\43\1\u03b3\12\43\34\0\4\43\1\u03b4\11\43\2\0"+
-    "\7\43\1\0\3\43\2\0\17\43\34\0\16\43\2\0"+
-    "\7\43\1\0\3\43\2\0\15\43\1\u03b5\1\43\34\0"+
-    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
-    "\4\117\1\u03b6\12\117\34\0\4\117\1\u03b7\11\117\2\0"+
+    "\4\117\1\u0492\12\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\11\117\1\u0493\5\117\34\0"+
+    "\14\117\1\u0494\1\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\17\117\34\0\10\117\1\u0495\5\117\2\0"+
     "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
-    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
-    "\15\117\1\u03b8\1\117\34\0\16\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\4\141\1\u03b9\12\141\34\0"+
-    "\4\141\1\u03ba\11\141\2\0\7\141\1\0\1\141\1\0"+
+    "\6\141\1\u0496\7\141\2\0\7\141\1\0\1\141\1\0"+
     "\1\141\2\0\17\141\34\0\16\141\2\0\7\141\1\0"+
-    "\1\141\1\0\1\141\2\0\15\141\1\u03bb\1\141\34\0"+
-    "\14\43\1\u03bc\1\43\2\0\7\43\1\0\3\43\2\0"+
-    "\17\43\34\0\14\117\1\u03bd\1\117\2\0\7\117\1\0"+
-    "\1\117\1\0\1\117\2\0\17\117\34\0\14\141\1\u03be"+
-    "\1\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
-    "\17\141\34\0\12\43\1\u03bf\3\43\2\0\7\43\1\0"+
-    "\3\43\2\0\17\43\34\0\12\117\1\u03c0\3\117\2\0"+
+    "\1\141\1\0\1\141\2\0\7\141\1\u0497\7\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\5\141\1\u0498\11\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\11\141\1\u0499\5\141\34\0"+
+    "\4\141\1\u049a\11\141\2\0\7\141\1\0\1\141\1\0"+
+    "\1\141\2\0\17\141\34\0\6\141\1\u049b\7\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\17\141\34\0"+
+    "\14\141\1\u049c\1\141\2\0\7\141\1\0\1\141\1\0"+
+    "\1\141\2\0\17\141\34\0\12\141\1\u049d\3\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\17\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\1\141\1\u049e\15\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\2\141\1\u049f\14\141\34\0"+
+    "\2\141\1\u04a0\13\141\2\0\7\141\1\0\1\141\1\0"+
+    "\1\141\2\0\17\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\5\141\1\u04a1\11\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\2\141\1\u04a2\14\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\1\141\1\u04a3\15\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\5\141\1\u04a4\11\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\11\141\1\u04a5\5\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\2\141\1\u04a6\14\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\5\141\1\u04a7\11\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\6\141\1\u04a8\10\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\14\141\1\u04a9\2\141\34\0"+
+    "\10\141\1\u04aa\5\141\2\0\7\141\1\0\1\141\1\0"+
+    "\1\141\2\0\17\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\4\141\1\u04ab\12\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\11\141\1\u04ac\5\141\34\0\14\141\1\u04ad\1\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\17\141\34\0"+
+    "\10\141\1\u04ae\5\141\2\0\7\141\1\0\1\141\1\0"+
+    "\1\141\2\0\17\141\34\0\6\207\1\u04af\7\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\17\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\7\207\1\u04b0\7\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\5\207\1\u04b1\11\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\11\207\1\u04b2\5\207\34\0\4\207\1\u04b3\11\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\17\207\34\0"+
+    "\6\207\1\u04b4\7\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\17\207\34\0\14\207\1\u04b5\1\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\17\207\34\0"+
+    "\12\207\1\u04b6\3\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\17\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\1\207\1\u04b7\15\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\2\207\1\u04b8\14\207\34\0\2\207\1\u04b9\13\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\17\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\5\207\1\u04ba\11\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\2\207\1\u04bb\14\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\1\207\1\u04bc\15\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\5\207\1\u04bd\11\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\11\207\1\u04be\5\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\2\207\1\u04bf\14\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\5\207\1\u04c0\11\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\6\207\1\u04c1\10\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\14\207\1\u04c2\2\207\34\0\10\207\1\u04c3\5\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\17\207\34\0"+
+    "\16\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\4\207\1\u04c4\12\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\11\207\1\u04c5\5\207\34\0"+
+    "\14\207\1\u04c6\1\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\17\207\34\0\10\207\1\u04c7\5\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\17\207\34\0"+
+    "\6\236\1\u04c8\7\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\17\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\7\236\1\u04c9\7\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\5\236\1\u04ca\11\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\11\236\1\u04cb\5\236\34\0"+
+    "\4\236\1\u04cc\11\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\17\236\34\0\6\236\1\u04cd\7\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\17\236\34\0"+
+    "\14\236\1\u04ce\1\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\17\236\34\0\12\236\1\u04cf\3\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\17\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\1\236\1\u04d0\15\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\2\236\1\u04d1\14\236\34\0"+
+    "\2\236\1\u04d2\13\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\17\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\5\236\1\u04d3\11\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\2\236\1\u04d4\14\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\1\236\1\u04d5\15\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\5\236\1\u04d6\11\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\11\236\1\u04d7\5\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\2\236\1\u04d8\14\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\5\236\1\u04d9\11\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\6\236\1\u04da\10\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\14\236\1\u04db\2\236\34\0"+
+    "\10\236\1\u04dc\5\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\17\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\4\236\1\u04dd\12\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\11\236\1\u04de\5\236\34\0\14\236\1\u04df\1\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\17\236\34\0"+
+    "\10\236\1\u04e0\5\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\17\236\34\0\16\43\2\0\7\43\1\0"+
+    "\3\43\2\0\13\43\1\u04e1\3\43\34\0\14\43\1\u04e2"+
+    "\1\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
+    "\16\43\2\0\7\43\1\0\3\43\2\0\2\43\1\u04e3"+
+    "\14\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
+    "\1\43\1\u04e4\15\43\34\0\16\43\2\0\7\43\1\0"+
+    "\3\43\2\0\5\43\1\u04e5\11\43\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\4\43\1\u04e6\12\43\34\0"+
+    "\16\43\2\0\7\43\1\0\3\43\2\0\11\43\1\u04e7"+
+    "\5\43\23\0\44\u01e2\1\u04e8\43\u01e2\4\u02e3\1\0\35\u02e3"+
+    "\1\0\2\u02e3\1\u01e3\42\u02e3\11\0\14\43\1\u04e9\1\43"+
+    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\14\43"+
+    "\1\u04ea\1\43\2\0\7\43\1\0\3\43\2\0\17\43"+
+    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\5\43"+
+    "\1\u04eb\11\43\34\0\16\43\2\0\7\43\1\0\3\43"+
+    "\2\0\2\43\1\u04ec\14\43\34\0\16\43\2\0\7\43"+
+    "\1\0\2\43\1\u04ed\2\0\17\43\34\0\4\43\1\u04ee"+
+    "\11\43\2\0\7\43\1\0\3\43\2\0\17\43\34\0"+
+    "\16\43\2\0\7\43\1\0\3\43\2\0\10\43\1\u04ef"+
+    "\6\43\34\0\14\43\1\u04f0\1\43\2\0\7\43\1\0"+
+    "\3\43\2\0\17\43\34\0\6\43\1\u04f1\7\43\2\0"+
+    "\7\43\1\0\3\43\2\0\17\43\34\0\16\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\13\117\1\u04f2"+
+    "\3\117\34\0\14\117\1\u04f3\1\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\17\117\34\0\16\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\2\117\1\u04f4"+
+    "\14\117\34\0\16\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\1\117\1\u04f5\15\117\34\0\16\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\5\117\1\u04f6"+
+    "\11\117\34\0\16\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\4\117\1\u04f7\12\117\34\0\16\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\11\117\1\u04f8"+
+    "\5\117\34\0\14\117\1\u04f9\1\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\17\117\34\0\14\117\1\u04fa"+
+    "\1\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\17\117\34\0\16\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\5\117\1\u04fb\11\117\34\0\16\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\2\117\1\u04fc"+
+    "\14\117\34\0\16\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\u04fd\2\0\17\117\34\0\4\117\1\u04fe\11\117\2\0"+
     "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
-    "\12\141\1\u03c1\3\141\2\0\7\141\1\0\1\141\1\0"+
-    "\1\141\2\0\17\141\23\0";
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\10\117\1\u04ff\6\117\34\0\14\117\1\u0500\1\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
+    "\6\117\1\u0501\7\117\2\0\7\117\1\0\1\117\1\0"+
+    "\1\117\2\0\17\117\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\13\141\1\u0502\3\141\34\0"+
+    "\14\141\1\u0503\1\141\2\0\7\141\1\0\1\141\1\0"+
+    "\1\141\2\0\17\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\2\141\1\u0504\14\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\1\141\1\u0505\15\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\5\141\1\u0506\11\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\4\141\1\u0507\12\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\11\141\1\u0508\5\141\34\0"+
+    "\14\141\1\u0509\1\141\2\0\7\141\1\0\1\141\1\0"+
+    "\1\141\2\0\17\141\34\0\14\141\1\u050a\1\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\17\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\5\141\1\u050b\11\141\34\0\16\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\2\141\1\u050c\14\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\u050d\2\0"+
+    "\17\141\34\0\4\141\1\u050e\11\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\17\141\34\0\16\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\10\141\1\u050f"+
+    "\6\141\34\0\14\141\1\u0510\1\141\2\0\7\141\1\0"+
+    "\1\141\1\0\1\141\2\0\17\141\34\0\6\141\1\u0511"+
+    "\7\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\17\141\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\13\207\1\u0512\3\207\34\0\14\207\1\u0513"+
+    "\1\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\17\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\2\207\1\u0514\14\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\1\207\1\u0515"+
+    "\15\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\5\207\1\u0516\11\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\4\207\1\u0517"+
+    "\12\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\11\207\1\u0518\5\207\34\0\14\207\1\u0519"+
+    "\1\207\2\0\7\207\1\0\1\207\1\0\1\207\2\0"+
+    "\17\207\34\0\14\207\1\u051a\1\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\5\207\1\u051b"+
+    "\11\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\2\207\1\u051c\14\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\u051d\2\0\17\207\34\0"+
+    "\4\207\1\u051e\11\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\17\207\34\0\16\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\10\207\1\u051f\6\207\34\0"+
+    "\14\207\1\u0520\1\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\17\207\34\0\6\207\1\u0521\7\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\17\207\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\13\236\1\u0522\3\236\34\0\14\236\1\u0523\1\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\17\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\2\236\1\u0524\14\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\1\236\1\u0525\15\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\5\236\1\u0526\11\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\4\236\1\u0527\12\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\11\236\1\u0528\5\236\34\0\14\236\1\u0529\1\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\17\236\34\0"+
+    "\14\236\1\u052a\1\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\17\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\5\236\1\u052b\11\236\34\0"+
+    "\16\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\2\236\1\u052c\14\236\34\0\16\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\u052d\2\0\17\236\34\0\4\236\1\u052e"+
+    "\11\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\17\236\34\0\16\236\2\0\7\236\1\0\1\236\1\0"+
+    "\1\236\2\0\10\236\1\u052f\6\236\34\0\14\236\1\u0530"+
+    "\1\236\2\0\7\236\1\0\1\236\1\0\1\236\2\0"+
+    "\17\236\34\0\6\236\1\u0531\7\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\11\43\1\u0532\5\43\34\0"+
+    "\14\43\1\u0533\1\43\2\0\7\43\1\0\3\43\2\0"+
+    "\17\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
+    "\2\43\1\u0534\14\43\34\0\14\43\1\u0535\1\43\2\0"+
+    "\7\43\1\0\3\43\2\0\17\43\34\0\16\43\2\0"+
+    "\7\43\1\0\3\43\2\0\5\43\1\u0536\11\43\34\0"+
+    "\14\43\1\u0537\1\43\2\0\7\43\1\0\3\43\2\0"+
+    "\17\43\34\0\16\43\2\0\7\43\1\0\3\43\2\0"+
+    "\1\u0538\16\43\34\0\16\43\2\0\7\43\1\0\3\43"+
+    "\2\0\11\43\1\u0539\5\43\34\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\11\43\1\u053a\5\43\34\0\14\43"+
+    "\1\u053b\1\43\2\0\7\43\1\0\3\43\2\0\17\43"+
+    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\11\117\1\u053c\5\117\34\0\14\117\1\u053d\1\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
+    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\2\117\1\u053e\14\117\34\0\14\117\1\u053f\1\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
+    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\5\117\1\u0540\11\117\34\0\14\117\1\u0541\1\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
+    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\1\u0542\16\117\34\0\16\117\2\0\7\117\1\0"+
+    "\1\117\1\0\1\117\2\0\11\117\1\u0543\5\117\34\0"+
+    "\16\117\2\0\7\117\1\0\1\117\1\0\1\117\2\0"+
+    "\11\117\1\u0544\5\117\34\0\14\117\1\u0545\1\117\2\0"+
+    "\7\117\1\0\1\117\1\0\1\117\2\0\17\117\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\11\141\1\u0546\5\141\34\0\14\141\1\u0547\1\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\17\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\2\141\1\u0548\14\141\34\0\14\141\1\u0549\1\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\17\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\5\141\1\u054a\11\141\34\0\14\141\1\u054b\1\141\2\0"+
+    "\7\141\1\0\1\141\1\0\1\141\2\0\17\141\34\0"+
+    "\16\141\2\0\7\141\1\0\1\141\1\0\1\141\2\0"+
+    "\1\u054c\16\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\11\141\1\u054d\5\141\34\0\16\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\11\141"+
+    "\1\u054e\5\141\34\0\14\141\1\u054f\1\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\17\141\34\0\16\207"+
+    "\2\0\7\207\1\0\1\207\1\0\1\207\2\0\11\207"+
+    "\1\u0550\5\207\34\0\14\207\1\u0551\1\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\17\207\34\0\16\207"+
+    "\2\0\7\207\1\0\1\207\1\0\1\207\2\0\2\207"+
+    "\1\u0552\14\207\34\0\14\207\1\u0553\1\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\17\207\34\0\16\207"+
+    "\2\0\7\207\1\0\1\207\1\0\1\207\2\0\5\207"+
+    "\1\u0554\11\207\34\0\14\207\1\u0555\1\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\17\207\34\0\16\207"+
+    "\2\0\7\207\1\0\1\207\1\0\1\207\2\0\1\u0556"+
+    "\16\207\34\0\16\207\2\0\7\207\1\0\1\207\1\0"+
+    "\1\207\2\0\11\207\1\u0557\5\207\34\0\16\207\2\0"+
+    "\7\207\1\0\1\207\1\0\1\207\2\0\11\207\1\u0558"+
+    "\5\207\34\0\14\207\1\u0559\1\207\2\0\7\207\1\0"+
+    "\1\207\1\0\1\207\2\0\17\207\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\11\236\1\u055a"+
+    "\5\236\34\0\14\236\1\u055b\1\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\2\236\1\u055c"+
+    "\14\236\34\0\14\236\1\u055d\1\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\5\236\1\u055e"+
+    "\11\236\34\0\14\236\1\u055f\1\236\2\0\7\236\1\0"+
+    "\1\236\1\0\1\236\2\0\17\236\34\0\16\236\2\0"+
+    "\7\236\1\0\1\236\1\0\1\236\2\0\1\u0560\16\236"+
+    "\34\0\16\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\11\236\1\u0561\5\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\11\236\1\u0562\5\236"+
+    "\34\0\14\236\1\u0563\1\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\17\236\34\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\5\43\1\u0564\11\43\34\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\10\43\1\u0565\6\43"+
+    "\34\0\14\43\1\u0566\1\43\2\0\7\43\1\0\3\43"+
+    "\2\0\17\43\34\0\12\43\1\u0567\3\43\2\0\7\43"+
+    "\1\0\3\43\2\0\17\43\34\0\10\43\1\u0568\5\43"+
+    "\2\0\7\43\1\0\3\43\2\0\17\43\34\0\16\43"+
+    "\2\0\7\43\1\0\3\43\2\0\5\43\1\u0569\11\43"+
+    "\34\0\16\117\2\0\7\117\1\0\1\117\1\0\1\117"+
+    "\2\0\5\117\1\u056a\11\117\34\0\16\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\10\117\1\u056b\6\117"+
+    "\34\0\14\117\1\u056c\1\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\17\117\34\0\12\117\1\u056d\3\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\17\117"+
+    "\34\0\10\117\1\u056e\5\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\17\117\34\0\16\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\5\117\1\u056f\11\117"+
+    "\34\0\16\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\5\141\1\u0570\11\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\10\141\1\u0571\6\141"+
+    "\34\0\14\141\1\u0572\1\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\17\141\34\0\12\141\1\u0573\3\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
+    "\34\0\10\141\1\u0574\5\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\17\141\34\0\16\141\2\0\7\141"+
+    "\1\0\1\141\1\0\1\141\2\0\5\141\1\u0575\11\141"+
+    "\34\0\16\207\2\0\7\207\1\0\1\207\1\0\1\207"+
+    "\2\0\5\207\1\u0576\11\207\34\0\16\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\10\207\1\u0577\6\207"+
+    "\34\0\14\207\1\u0578\1\207\2\0\7\207\1\0\1\207"+
+    "\1\0\1\207\2\0\17\207\34\0\12\207\1\u0579\3\207"+
+    "\2\0\7\207\1\0\1\207\1\0\1\207\2\0\17\207"+
+    "\34\0\10\207\1\u057a\5\207\2\0\7\207\1\0\1\207"+
+    "\1\0\1\207\2\0\17\207\34\0\16\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\5\207\1\u057b\11\207"+
+    "\34\0\16\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\5\236\1\u057c\11\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\10\236\1\u057d\6\236"+
+    "\34\0\14\236\1\u057e\1\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\17\236\34\0\12\236\1\u057f\3\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\17\236"+
+    "\34\0\10\236\1\u0580\5\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\17\236\34\0\16\236\2\0\7\236"+
+    "\1\0\1\236\1\0\1\236\2\0\5\236\1\u0581\11\236"+
+    "\34\0\16\43\2\0\7\43\1\0\3\43\2\0\4\43"+
+    "\1\u0582\12\43\34\0\4\43\1\u0583\11\43\2\0\7\43"+
+    "\1\0\3\43\2\0\17\43\34\0\16\43\2\0\7\43"+
+    "\1\0\3\43\2\0\15\43\1\u0584\1\43\34\0\16\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\4\117"+
+    "\1\u0585\12\117\34\0\4\117\1\u0586\11\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\16\117"+
+    "\2\0\7\117\1\0\1\117\1\0\1\117\2\0\15\117"+
+    "\1\u0587\1\117\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\4\141\1\u0588\12\141\34\0\4\141"+
+    "\1\u0589\11\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\17\141\34\0\16\141\2\0\7\141\1\0\1\141"+
+    "\1\0\1\141\2\0\15\141\1\u058a\1\141\34\0\16\207"+
+    "\2\0\7\207\1\0\1\207\1\0\1\207\2\0\4\207"+
+    "\1\u058b\12\207\34\0\4\207\1\u058c\11\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\17\207\34\0\16\207"+
+    "\2\0\7\207\1\0\1\207\1\0\1\207\2\0\15\207"+
+    "\1\u058d\1\207\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\4\236\1\u058e\12\236\34\0\4\236"+
+    "\1\u058f\11\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\17\236\34\0\16\236\2\0\7\236\1\0\1\236"+
+    "\1\0\1\236\2\0\15\236\1\u0590\1\236\34\0\14\43"+
+    "\1\u0591\1\43\2\0\7\43\1\0\3\43\2\0\17\43"+
+    "\34\0\14\117\1\u0592\1\117\2\0\7\117\1\0\1\117"+
+    "\1\0\1\117\2\0\17\117\34\0\14\141\1\u0593\1\141"+
+    "\2\0\7\141\1\0\1\141\1\0\1\141\2\0\17\141"+
+    "\34\0\14\207\1\u0594\1\207\2\0\7\207\1\0\1\207"+
+    "\1\0\1\207\2\0\17\207\34\0\14\236\1\u0595\1\236"+
+    "\2\0\7\236\1\0\1\236\1\0\1\236\2\0\17\236"+
+    "\34\0\12\43\1\u0596\3\43\2\0\7\43\1\0\3\43"+
+    "\2\0\17\43\34\0\12\117\1\u0597\3\117\2\0\7\117"+
+    "\1\0\1\117\1\0\1\117\2\0\17\117\34\0\12\141"+
+    "\1\u0598\3\141\2\0\7\141\1\0\1\141\1\0\1\141"+
+    "\2\0\17\141\34\0\12\207\1\u0599\3\207\2\0\7\207"+
+    "\1\0\1\207\1\0\1\207\2\0\17\207\34\0\12\236"+
+    "\1\u059a\3\236\2\0\7\236\1\0\1\236\1\0\1\236"+
+    "\2\0\17\236\23\0";
 
   private static int [] zzUnpackTrans() {
-    int [] result = new int[52560];
+    int [] result = new int[79776];
     int offset = 0;
     offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
     return result;
@@ -1426,22 +2091,22 @@
     "\31\0\1\1\1\11\1\1\1\11\35\1\2\11\2\1"+
     "\6\11\2\1\1\11\4\1\3\11\20\1\2\11\20\1"+
     "\1\11\3\1\2\11\2\1\1\11\3\1\1\11\1\1"+
-    "\4\11\4\1\1\11\2\1\1\11\1\1\1\11\2\1"+
-    "\1\11\3\1\1\11\1\1\1\11\3\1\1\11\1\1"+
-    "\1\11\2\1\4\0\3\1\1\11\1\1\2\11\2\1"+
-    "\5\11\3\0\15\1\5\11\2\0\4\1\2\11\1\1"+
-    "\1\0\1\1\2\0\27\1\2\11\1\1\1\11\1\1"+
-    "\1\0\1\11\1\0\6\11\114\1\1\0\6\1\1\0"+
-    "\1\1\1\11\1\0\1\11\1\1\2\0\2\11\2\1"+
-    "\3\0\2\1\2\11\1\1\1\0\23\1\3\11\3\1"+
-    "\1\11\2\0\36\1\5\11\1\0\133\1\2\0\1\1"+
-    "\2\11\2\1\2\11\1\0\15\1\2\0\3\1\3\0"+
-    "\1\1\7\0\33\1\1\11\127\1\1\0\2\11\1\0"+
-    "\16\1\1\0\1\1\5\0\127\1\1\0\11\1\2\0"+
-    "\262\1";
+    "\4\11\3\1\1\11\20\1\1\11\2\1\1\11\2\1"+
+    "\1\11\20\1\1\11\3\1\1\11\1\1\1\11\3\1"+
+    "\1\11\1\1\1\11\2\1\4\0\3\1\1\11\1\1"+
+    "\2\11\2\1\5\11\3\0\15\1\5\11\2\0\4\1"+
+    "\2\11\1\1\1\0\1\1\2\0\27\1\2\11\1\1"+
+    "\1\11\1\1\1\0\1\11\1\0\6\11\114\1\1\0"+
+    "\6\1\1\0\1\1\1\11\46\1\1\0\1\11\47\1"+
+    "\2\0\2\11\2\1\3\0\2\1\2\11\1\1\1\0"+
+    "\23\1\3\11\3\1\1\11\2\0\36\1\5\11\1\0"+
+    "\133\1\2\0\1\1\1\11\132\1\1\11\2\1\2\11"+
+    "\1\0\15\1\2\0\3\1\3\0\1\1\7\0\33\1"+
+    "\1\11\127\1\1\0\1\11\126\1\1\11\1\0\16\1"+
+    "\1\0\1\1\5\0\231\1\1\0\11\1\2\0\u012e\1";
 
   private static int [] zzUnpackAttribute() {
-    int [] result = new int[961];
+    int [] result = new int[1434];
     int offset = 0;
     offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
     return result;
@@ -1770,84 +2435,84 @@
       zzMarkedPos = zzMarkedPosL;
 
       switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
-        case 58: 
+        case 59: 
           { yybegin(IN_DOLLAR_SLASH_REGEX_DOT);
                                              return mIDENT;
           }
-        case 173: break;
+        case 174: break;
         case 5: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mSTAR);
           }
-        case 174: break;
-        case 73: 
+        case 175: break;
+        case 74: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mNOT_EQUAL);
           }
-        case 175: break;
+        case 176: break;
         case 47: 
           { blockStack.push(mLCURLY);
                                              braceCount.push(mLCURLY);
                                              yybegin(NLS_AFTER_LBRACE);
                                              return(mLCURLY);
           }
-        case 176: break;
-        case 133: 
+        case 177: break;
+        case 134: 
           { return( kTRUE );
           }
-        case 177: break;
-        case 135: 
+        case 178: break;
+        case 136: 
           { return( kNULL );
           }
-        case 178: break;
+        case 179: break;
         case 23: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mCOMMA);
           }
-        case 179: break;
-        case 129: 
+        case 180: break;
+        case 130: 
           { return( kENUM );
           }
-        case 180: break;
-        case 61: 
+        case 181: break;
+        case 62: 
           { yybegin(IN_DOLLAR_SLASH_REGEX_DOLLAR);
                                              return mDOLLAR;
           }
-        case 181: break;
-        case 83: 
+        case 182: break;
+        case 84: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mDEC);
           }
-        case 182: break;
-        case 80: 
+        case 183: break;
+        case 81: 
           { return( kDO );
           }
-        case 183: break;
-        case 86: 
+        case 184: break;
+        case 87: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mRANGE_INCLUSIVE);
           }
-        case 184: break;
-        case 72: 
+        case 185: break;
+        case 73: 
           { return mSH_COMMENT;
           }
-        case 185: break;
-        case 125: 
+        case 186: break;
+        case 126: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mSR_ASSIGN);
           }
-        case 186: break;
-        case 52: 
+        case 187: break;
+        case 53: 
           { yybegin(IN_REGEX_DOT);
                                              return mIDENT;
           }
-        case 187: break;
-        case 105: 
+        case 188: break;
+        case 106: 
           { yybegin(IN_DOLLAR_SLASH_REGEX);
                                              gStringStack.push(mDOLLAR);
                                              return mDOLLAR_SLASH_REGEX_BEGIN;
           }
-        case 188: break;
+        case 189: break;
         case 49: 
           { yypushback(1);
                                              if (blockStack.isEmpty()){
@@ -1856,114 +2521,114 @@
                                                yybegin(IN_INNER_BLOCK);
                                              }
           }
-        case 189: break;
+        case 190: break;
         case 7: 
           { return mIDENT;
           }
-        case 190: break;
+        case 191: break;
         case 25: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mGT);
           }
-        case 191: break;
-        case 144: 
+        case 192: break;
+        case 145: 
           { return( kSUPER );
           }
-        case 192: break;
-        case 119: 
+        case 193: break;
+        case 120: 
           { yybegin(IN_TRIPLE_GSTRING);
                                                               gStringStack.push(mLBRACK);
                                                               return mGSTRING_BEGIN;
           }
-        case 193: break;
-        case 68: 
+        case 194: break;
+        case 69: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mDIV_ASSIGN);
           }
-        case 194: break;
-        case 171: 
+        case 195: break;
+        case 172: 
           { return( kINSTANCEOF );
           }
-        case 195: break;
-        case 93: 
+        case 196: break;
+        case 94: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mEQUAL);
           }
-        case 196: break;
+        case 197: break;
         case 18: 
           { yybegin(WAIT_FOR_REGEX);
                                              braceCount.push(mLPAREN);
                                              return(mLPAREN);
           }
-        case 197: break;
+        case 198: break;
         case 22: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mCOLON);
           }
-        case 198: break;
-        case 152: 
+        case 199: break;
+        case 153: 
           { return( kSTATIC );
           }
-        case 199: break;
-        case 143: 
+        case 200: break;
+        case 144: 
           { return( kCATCH );
           }
-        case 200: break;
+        case 201: break;
         case 29: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mBOR);
           }
-        case 201: break;
-        case 54: 
+        case 202: break;
+        case 55: 
           { return mREGEX_CONTENT;
           }
-        case 202: break;
-        case 106: 
+        case 203: break;
+        case 107: 
           // lookahead expression with fixed lookahead length
           yypushback(1);
           { return mREGEX_CONTENT;
           }
-        case 203: break;
+        case 204: break;
         case 27: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mMOD);
           }
-        case 204: break;
+        case 205: break;
         case 24: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mLT);
           }
-        case 205: break;
-        case 168: 
+        case 206: break;
+        case 169: 
           { return( kPROTECTED );
           }
-        case 206: break;
-        case 113: 
+        case 207: break;
+        case 114: 
           { return mNUM_BIG_DECIMAL;
           }
-        case 207: break;
-        case 70: 
+        case 208: break;
+        case 71: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mSPREAD_DOT);
           }
-        case 208: break;
-        case 149: 
+        case 209: break;
+        case 150: 
           { return( kDOUBLE );
           }
-        case 209: break;
+        case 210: break;
         case 37: 
           { yybegin(IN_TRIPLE_DOT);
                                              return mIDENT;
           }
-        case 210: break;
+        case 211: break;
         case 35: 
           { blockStack.push(mLPAREN);
                                              braceCount.push(mLCURLY);
                                              yybegin(NLS_AFTER_LBRACE);
                                              return mLCURLY;
           }
-        case 211: break;
-        case 126: 
+        case 212: break;
+        case 127: 
           { if (!gStringStack.isEmpty()){
                                                gStringStack.pop();
                                              }
@@ -1974,54 +2639,54 @@
                                              }
                                              return mGSTRING_END;
           }
-        case 212: break;
-        case 121: 
+        case 213: break;
+        case 122: 
           { return( kNEW );
           }
-        case 213: break;
-        case 156: 
+        case 214: break;
+        case 157: 
           { return( kNATIVE );
           }
-        case 214: break;
-        case 87: 
+        case 215: break;
+        case 88: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mMEMBER_POINTER);
           }
-        case 215: break;
+        case 216: break;
         case 19: 
           { if (!braceCount.isEmpty() && mLPAREN == braceCount.peek()) {
                                                braceCount.pop();
                                              }
                                              return(mRPAREN);
           }
-        case 216: break;
-        case 64: 
+        case 217: break;
+        case 65: 
           { yypushback(1);
                                               yybegin(WAIT_FOR_REGEX);
           }
-        case 217: break;
-        case 114: 
+        case 218: break;
+        case 115: 
           { return( kFOR );
           }
-        case 218: break;
-        case 132: 
+        case 219: break;
+        case 133: 
           { return( kCHAR );
           }
-        case 219: break;
-        case 148: 
+        case 220: break;
+        case 149: 
           { return( kIMPORT );
           }
-        case 220: break;
-        case 91: 
+        case 221: break;
+        case 92: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mOPTIONAL_DOT);
           }
-        case 221: break;
-        case 101: 
+        case 222: break;
+        case 102: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mBAND_ASSIGN);
           }
-        case 222: break;
+        case 223: break;
         case 48: 
           { if (!blockStack.isEmpty()) {
                                                IElementType br = blockStack.pop();
@@ -2038,17 +2703,17 @@
                                              }
                                              return mRCURLY;
           }
-        case 223: break;
-        case 159: 
+        case 224: break;
+        case 160: 
           { return( kEXTENDS );
           }
-        case 224: break;
+        case 225: break;
         case 9: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mPLUS);
           }
-        case 225: break;
-        case 108: 
+        case 226: break;
+        case 109: 
           { if (!gStringStack.isEmpty()) {
                                                gStringStack.pop();
                                              }
@@ -2059,70 +2724,75 @@
                                              }
                                              return mDOLLAR_SLASH_REGEX_END;
           }
-        case 226: break;
-        case 94: 
+        case 227: break;
+        case 95: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mREGEX_FIND);
           }
-        case 227: break;
+        case 228: break;
         case 26: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mBNOT);
           }
-        case 228: break;
-        case 60: 
+        case 229: break;
+        case 61: 
           { return mDOLLAR_SLASH_REGEX_CONTENT;
           }
-        case 229: break;
-        case 109: 
+        case 230: break;
+        case 110: 
           // lookahead expression with fixed lookahead length
           yypushback(1);
           { return mDOLLAR_SLASH_REGEX_CONTENT;
           }
-        case 230: break;
-        case 99: 
+        case 231: break;
+        case 100: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mBOR_ASSIGN);
           }
-        case 231: break;
-        case 157: 
+        case 232: break;
+        case 158: 
           { return( kFINALLY );
           }
-        case 232: break;
-        case 100: 
+        case 233: break;
+        case 101: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mLOR);
           }
-        case 233: break;
-        case 71: 
+        case 234: break;
+        case 72: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mSTAR_ASSIGN);
           }
-        case 234: break;
-        case 136: 
+        case 235: break;
+        case 137: 
           { return( kVOID );
           }
-        case 235: break;
-        case 150: 
+        case 236: break;
+        case 151: 
           { return( kPUBLIC );
           }
-        case 236: break;
-        case 128: 
+        case 237: break;
+        case 129: 
           { return( kELSE );
           }
-        case 237: break;
+        case 238: break;
+        case 58: 
+          { yypushback(1);
+                                           yybegin(IN_DOLLAR_SLASH_REGEX);
+          }
+        case 239: break;
         case 38: 
           { blockStack.push(mLBRACK);
                                              braceCount.push(mLCURLY);
                                              yybegin(NLS_AFTER_LBRACE);
                                              return mLCURLY;
           }
-        case 238: break;
+        case 240: break;
         case 12: 
           { return mSTRING_LITERAL;
           }
-        case 239: break;
-        case 88: 
+        case 241: break;
+        case 89: 
           { if (zzStartRead == 0 ||
                                                zzBuffer.subSequence(0, zzStartRead).toString().trim().length() == 0) {
                                                yypushback(2);
@@ -2132,21 +2802,21 @@
                                                return(mDOLLAR);
                                              }
           }
-        case 240: break;
-        case 84: 
+        case 242: break;
+        case 85: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mMINUS_ASSIGN);
           }
-        case 241: break;
-        case 85: 
+        case 243: break;
+        case 86: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mCLOSABLE_BLOCK_OP);
           }
-        case 242: break;
-        case 170: 
+        case 244: break;
+        case 171: 
           { return( kIMPLEMENTS );
           }
-        case 243: break;
+        case 245: break;
         case 42: 
           { if (!gStringStack.isEmpty()) {
                                                gStringStack.pop();
@@ -2158,179 +2828,179 @@
                                              }
                                              return mGSTRING_END;
           }
-        case 244: break;
-        case 97: 
+        case 246: break;
+        case 98: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mMOD_ASSIGN);
           }
-        case 245: break;
+        case 247: break;
         case 16: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mQUESTION);
           }
-        case 246: break;
+        case 248: break;
         case 8: 
           { return mNUM_INT;
           }
-        case 247: break;
-        case 167: 
+        case 249: break;
+        case 168: 
           { return( kINTERFACE );
           }
-        case 248: break;
+        case 250: break;
         case 31: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mSEMI);
           }
-        case 249: break;
-        case 161: 
+        case 251: break;
+        case 162: 
           { return( kPACKAGE );
           }
-        case 250: break;
-        case 146: 
+        case 252: break;
+        case 147: 
           { return( kTHROW );
           }
-        case 251: break;
+        case 253: break;
         case 17: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mASSIGN);
           }
-        case 252: break;
-        case 79: 
+        case 254: break;
+        case 80: 
           { return( kIN );
           }
-        case 253: break;
-        case 66: 
+        case 255: break;
+        case 67: 
           { return mSL_COMMENT;
           }
-        case 254: break;
+        case 256: break;
         case 13: 
           { yybegin(IN_SINGLE_GSTRING);
                                                               gStringStack.push(mLPAREN);
                                                               return mGSTRING_BEGIN;
           }
-        case 255: break;
-        case 130: 
+        case 257: break;
+        case 131: 
           { return( kBYTE );
           }
-        case 256: break;
-        case 102: 
+        case 258: break;
+        case 103: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mLAND);
           }
-        case 257: break;
+        case 259: break;
         case 33: 
           { yypushback(1);
                                              yybegin(IN_SINGLE_GSTRING);
           }
-        case 258: break;
+        case 260: break;
         case 28: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mBXOR);
           }
-        case 259: break;
-        case 57: 
+        case 261: break;
+        case 52: 
           { yypushback(1);
                                              yybegin(IN_REGEX);
           }
-        case 260: break;
-        case 63: 
+        case 262: break;
+        case 64: 
           { yypushback(1);
                                               yybegin(afterComment);
           }
-        case 261: break;
-        case 172: 
+        case 263: break;
+        case 173: 
           { return( kSYNCHRONIZED );
           }
-        case 262: break;
-        case 124: 
+        case 264: break;
+        case 125: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mSL_ASSIGN);
           }
-        case 263: break;
-        case 56: 
+        case 265: break;
+        case 57: 
           { yybegin(IN_REGEX_DOLLAR);
                                              return mDOLLAR;
           }
-        case 264: break;
+        case 266: break;
         case 36: 
           { yypushback(1);
                                              yybegin(IN_TRIPLE_GSTRING);
           }
-        case 265: break;
-        case 120: 
+        case 267: break;
+        case 121: 
           { return( kTRY );
           }
-        case 266: break;
+        case 268: break;
         case 10: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mMINUS);
           }
-        case 267: break;
+        case 269: break;
         case 11: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mDOT);
           }
-        case 268: break;
-        case 131: 
+        case 270: break;
+        case 132: 
           { return( kCASE );
           }
-        case 269: break;
-        case 103: 
+        case 271: break;
+        case 104: 
           // lookahead expression with fixed base length
           zzMarkedPos = zzStartRead + 1;
           { yybegin(IN_SINGLE_IDENT);
                                              return mDOT;
           }
-        case 270: break;
-        case 77: 
+        case 272: break;
+        case 78: 
           { return mNUM_DOUBLE;
           }
-        case 271: break;
-        case 158: 
+        case 273: break;
+        case 159: 
           { return( kDEFAULT );
           }
-        case 272: break;
-        case 122: 
+        case 274: break;
+        case 123: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mREGEX_MATCH);
           }
-        case 273: break;
+        case 275: break;
         case 50: 
           { afterComment = YYINITIAL;
                                            return(WHITE_SPACE);
           }
-        case 274: break;
-        case 169: 
+        case 276: break;
+        case 170: 
           { return( kTRANSIENT );
           }
-        case 275: break;
-        case 81: 
+        case 277: break;
+        case 82: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mINC);
           }
-        case 276: break;
-        case 111: 
+        case 278: break;
+        case 112: 
           { return GROOVY_DOC_COMMENT;
           }
-        case 277: break;
+        case 279: break;
         case 2: 
           { yybegin(NLS_AFTER_NLS);
                                              afterComment = WAIT_FOR_REGEX;
                                              return !braceCount.isEmpty() &&
                                                  mLPAREN == braceCount.peek() ? WHITE_SPACE : mNLS;
           }
-        case 278: break;
-        case 59: 
+        case 280: break;
+        case 60: 
           { blockStack.push(mDOLLAR);
                                              braceCount.push(mLCURLY);
                                              yybegin(NLS_AFTER_LBRACE);
                                              return mLCURLY;
           }
-        case 279: break;
-        case 153: 
+        case 281: break;
+        case 154: 
           { return( kSWITCH );
           }
-        case 280: break;
+        case 282: break;
         case 15: 
           { while (!braceCount.isEmpty() && mLCURLY != braceCount.peek()) {
                                                braceCount.pop();
@@ -2340,7 +3010,7 @@
                                              }
                                              return mRCURLY;
           }
-        case 281: break;
+        case 283: break;
         case 4: 
           { if (zzStartRead == 0 ||
                                                zzBuffer.subSequence(0, zzStartRead).toString().trim().length() == 0) {
@@ -2350,217 +3020,217 @@
                                                return(mDIV);
                                              }
           }
-        case 282: break;
-        case 89: 
+        case 284: break;
+        case 90: 
           { return mGSTRING_LITERAL;
           }
-        case 283: break;
+        case 285: break;
         case 20: 
           { yybegin(WAIT_FOR_REGEX);
                                              braceCount.push(mLPAREN);
                                              return(mLBRACK);
           }
-        case 284: break;
+        case 286: break;
         case 45: 
           { yypushback(1);
                                              yybegin(IN_TRIPLE_IDENT);
           }
-        case 285: break;
-        case 138: 
+        case 287: break;
+        case 139: 
           { return( kFLOAT );
           }
-        case 286: break;
-        case 137: 
+        case 288: break;
+        case 138: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mBSR_ASSIGN);
           }
-        case 287: break;
-        case 78: 
+        case 289: break;
+        case 79: 
           { return( kIF );
           }
-        case 288: break;
-        case 92: 
+        case 290: break;
+        case 93: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mELVIS);
           }
-        case 289: break;
-        case 139: 
+        case 291: break;
+        case 140: 
           { return( kFINAL );
           }
-        case 290: break;
+        case 292: break;
         case 34: 
           { yybegin(IN_SINGLE_DOT);
                                              return mIDENT;
           }
-        case 291: break;
-        case 96: 
+        case 293: break;
+        case 97: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mGE);
           }
-        case 292: break;
-        case 154: 
+        case 294: break;
+        case 155: 
           { return( kTHROWS );
           }
-        case 293: break;
-        case 110: 
+        case 295: break;
+        case 111: 
           // lookahead expression with fixed base length
           zzMarkedPos = zzStartRead + 1;
           { yybegin(IN_DOLLAR_SLASH_REGEX_IDENT);
                                              return mDOT;
           }
-        case 294: break;
-        case 75: 
+        case 296: break;
+        case 76: 
           { return mNUM_FLOAT;
           }
-        case 295: break;
-        case 117: 
+        case 297: break;
+        case 118: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mTRIPLE_DOT);
           }
-        case 296: break;
-        case 115: 
+        case 298: break;
+        case 116: 
           { return( kINT );
           }
-        case 297: break;
-        case 165: 
+        case 299: break;
+        case 166: 
           { return( kSTRICTFP );
           }
-        case 298: break;
-        case 65: 
+        case 300: break;
+        case 66: 
           { yypushback(1);
                                               yybegin(NLS_AFTER_COMMENT);
           }
-        case 299: break;
-        case 163: 
+        case 301: break;
+        case 164: 
           { return( kABSTRACT );
           }
-        case 300: break;
-        case 140: 
+        case 302: break;
+        case 141: 
           { return( kFALSE );
           }
-        case 301: break;
-        case 90: 
+        case 303: break;
+        case 91: 
           { return( kAS );
           }
-        case 302: break;
+        case 304: break;
         case 46: 
           { yybegin(NLS_AFTER_NLS);
                                              afterComment = IN_TRIPLE_IDENT;
                                              return mNLS;
           }
-        case 303: break;
-        case 118: 
+        case 305: break;
+        case 119: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mRANGE_EXCLUSIVE);
           }
-        case 304: break;
-        case 164: 
+        case 306: break;
+        case 165: 
           { return( kCONTINUE );
           }
-        case 305: break;
+        case 307: break;
         case 32: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mAT);
           }
-        case 306: break;
-        case 127: 
+        case 308: break;
+        case 128: 
           { return( kLONG );
           }
-        case 307: break;
-        case 76: 
+        case 309: break;
+        case 77: 
           { return mNUM_LONG;
           }
-        case 308: break;
-        case 141: 
+        case 310: break;
+        case 142: 
           { return( kBREAK );
           }
-        case 309: break;
-        case 95: 
+        case 311: break;
+        case 96: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mLE);
           }
-        case 310: break;
-        case 160: 
+        case 312: break;
+        case 161: 
           { return( kBOOLEAN );
           }
-        case 311: break;
-        case 151: 
+        case 313: break;
+        case 152: 
           { return( kASSERT );
           }
-        case 312: break;
-        case 107: 
+        case 314: break;
+        case 108: 
           // lookahead expression with fixed base length
           zzMarkedPos = zzStartRead + 1;
           { yybegin(IN_REGEX_IDENT);
                                              return mDOT;
           }
-        case 313: break;
+        case 315: break;
         case 3: 
           { return WHITE_SPACE;
           }
-        case 314: break;
-        case 134: 
+        case 316: break;
+        case 135: 
           { return( kTHIS );
           }
-        case 315: break;
+        case 317: break;
         case 51: 
           { yybegin(IN_REGEX);
                                              gStringStack.push(mDIV);
                                              return mREGEX_BEGIN;
           }
-        case 316: break;
-        case 162: 
+        case 318: break;
+        case 163: 
           { return( kPRIVATE );
           }
-        case 317: break;
+        case 319: break;
         case 44: 
           { yybegin(IN_TRIPLE_GSTRING_DOLLAR);
                                              return mDOLLAR;
           }
-        case 318: break;
-        case 145: 
+        case 320: break;
+        case 146: 
           { return( kSHORT );
           }
-        case 319: break;
+        case 321: break;
         case 21: 
           { if (!braceCount.isEmpty() && mLPAREN == braceCount.peek()) {
                                                braceCount.pop();
                                              }
                                              return(mRBRACK);
           }
-        case 320: break;
+        case 322: break;
         case 14: 
           { yybegin(NLS_AFTER_LBRACE);
                                              braceCount.push(mLCURLY);
                                              return(mLCURLY);
           }
-        case 321: break;
-        case 166: 
+        case 323: break;
+        case 167: 
           { return( kVOLATILE );
           }
-        case 322: break;
-        case 104: 
+        case 324: break;
+        case 105: 
           // lookahead expression with fixed base length
           zzMarkedPos = zzStartRead + 1;
           { yybegin(IN_TRIPLE_NLS);
                                              return mDOT;
           }
-        case 323: break;
+        case 325: break;
         case 6: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mLNOT);
           }
-        case 324: break;
-        case 69: 
+        case 326: break;
+        case 70: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mSTAR_STAR);
           }
-        case 325: break;
-        case 74: 
+        case 327: break;
+        case 75: 
           { return mNUM_BIG_INT;
           }
-        case 326: break;
-        case 55: 
+        case 328: break;
+        case 56: 
           { if (!gStringStack.isEmpty()) {
                                                gStringStack.pop();
                                              }
@@ -2571,40 +3241,40 @@
                                              }
                                              return mREGEX_END;
           }
-        case 327: break;
-        case 142: 
+        case 329: break;
+        case 143: 
           { return( kCLASS );
           }
-        case 328: break;
-        case 82: 
+        case 330: break;
+        case 83: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mPLUS_ASSIGN);
           }
-        case 329: break;
+        case 331: break;
         case 30: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mBAND);
           }
-        case 330: break;
-        case 62: 
+        case 332: break;
+        case 63: 
           { yypushback(1);
                                              yybegin(IN_DOLLAR_SLASH_REGEX);
           }
-        case 331: break;
-        case 123: 
+        case 333: break;
+        case 124: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mCOMPARE_TO);
           }
-        case 332: break;
-        case 98: 
+        case 334: break;
+        case 99: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mBXOR_ASSIGN);
           }
-        case 333: break;
-        case 155: 
+        case 335: break;
+        case 156: 
           { return( kRETURN );
           }
-        case 334: break;
+        case 336: break;
         case 43: 
           // general lookahead, find correct zzMarkedPos
           { int zzFState = 24;
@@ -2628,51 +3298,51 @@
           }
           { return mGSTRING_CONTENT;
           }
-        case 335: break;
+        case 337: break;
         case 39: 
           { return mGSTRING_CONTENT;
           }
-        case 336: break;
-        case 112: 
+        case 338: break;
+        case 113: 
           { yybegin(WAIT_FOR_REGEX);
                                              return(mSTAR_STAR_ASSIGN);
           }
-        case 337: break;
-        case 116: 
+        case 339: break;
+        case 117: 
           { return( kDEF );
           }
-        case 338: break;
+        case 340: break;
         case 41: 
           { yybegin(IN_SINGLE_GSTRING_DOLLAR);
                                              return mDOLLAR;
           }
-        case 339: break;
+        case 341: break;
         case 40: 
           { clearStacks();
                                              yybegin(NLS_AFTER_NLS);
                                              afterComment = YYINITIAL;
                                              return mNLS;
           }
-        case 340: break;
-        case 53: 
+        case 342: break;
+        case 54: 
           { blockStack.push(mDIV);
                                              braceCount.push(mLCURLY);
                                              yybegin(NLS_AFTER_LBRACE);
                                              return mLCURLY;
           }
-        case 341: break;
-        case 147: 
+        case 343: break;
+        case 148: 
           { return( kWHILE );
           }
-        case 342: break;
+        case 344: break;
         case 1: 
           { return mWRONG;
           }
-        case 343: break;
-        case 67: 
+        case 345: break;
+        case 68: 
           { return mML_COMMENT;
           }
-        case 344: break;
+        case 346: break;
         default:
           if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
             zzAtEOF = true;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/groovy.flex b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/groovy.flex
index 6979286..0e520a6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/groovy.flex
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/groovy.flex
@@ -529,12 +529,69 @@
 
 <IN_REGEX_DOLLAR> {
 
+  "package"                               {  return( kPACKAGE );  }
+  "strictfp"                              {  return( kSTRICTFP );  }
+  "import"                                {  return( kIMPORT );  }
+  "static"                                {  return( kSTATIC );  }
+  "def"                                   {  return( kDEF );  }
+  "class"                                 {  return( kCLASS );  }
+  "interface"                             {  return( kINTERFACE );  }
+  "enum"                                  {  return( kENUM );  }
+  "extends"                               {  return( kEXTENDS );  }
+  "super"                                 {  return( kSUPER );  }
+  "void"                                  {  return( kVOID );  }
+  "boolean"                               {  return( kBOOLEAN );  }
+  "byte"                                  {  return( kBYTE );  }
+  "char"                                  {  return( kCHAR );  }
+  "short"                                 {  return( kSHORT );  }
+  "int"                                   {  return( kINT );  }
+  "float"                                 {  return( kFLOAT );  }
+  "long"                                  {  return( kLONG );  }
+  "double"                                {  return( kDOUBLE );  }
+  "as"                                    {  return( kAS );  }
+  "private"                               {  return( kPRIVATE );  }
+  "abstract"                              {  return( kABSTRACT );  }
+  "public"                                {  return( kPUBLIC );  }
+  "protected"                             {  return( kPROTECTED );  }
+  "transient"                             {  return( kTRANSIENT );  }
+  "native"                                {  return( kNATIVE );  }
+  "synchronized"                          {  return( kSYNCHRONIZED );  }
+  "volatile"                              {  return( kVOLATILE );  }
+  "default"                               {  return( kDEFAULT );  }
+  "do"                                    {  return( kDO );  }
+  "throws"                                {  return( kTHROWS );  }
+  "implements"                            {  return( kIMPLEMENTS );  }
+  "this"                                  {  return( kTHIS );  }
+  "if"                                    {  return( kIF );  }
+  "else"                                  {  return( kELSE );  }
+  "while"                                 {  return( kWHILE );  }
+  "switch"                                {  return( kSWITCH );  }
+  "for"                                   {  return( kFOR );  }
+  "in"                                    {  return( kIN );  }
+  "return"                                {  return( kRETURN );  }
+  "break"                                 {  return( kBREAK );  }
+  "continue"                              {  return( kCONTINUE );  }
+  "throw"                                 {  return( kTHROW );  }
+  "assert"                                {  return( kASSERT );  }
+  "case"                                  {  return( kCASE );  }
+  "try"                                   {  return( kTRY );  }
+  "finally"                               {  return( kFINALLY );  }
+  "catch"                                 {  return( kCATCH );  }
+  "instanceof"                            {  return( kINSTANCEOF );  }
+  "new"                                   {  return( kNEW );  }
+  "true"                                  {  return( kTRUE );  }
+  "false"                                 {  return( kFALSE );  }
+  "null"                                  {  return( kNULL );  }
+  "final"                                 {  return( kFINAL );  }
+
   {mIDENT_NOBUCKS}                        {  yybegin(IN_REGEX_DOT);
                                              return mIDENT; }
   "{"                                     {  blockStack.push(mDIV);
                                              braceCount.push(mLCURLY);
                                              yybegin(NLS_AFTER_LBRACE);
                                              return mLCURLY; }
+  [^]                                     {  yypushback(1);
+                                             yybegin(IN_REGEX); }
 }
 
 <IN_REGEX_DOT>{
@@ -575,12 +632,70 @@
 
 <IN_DOLLAR_SLASH_REGEX_DOLLAR> {
 
+  "package"                               {  return( kPACKAGE );  }
+  "strictfp"                              {  return( kSTRICTFP );  }
+  "import"                                {  return( kIMPORT );  }
+  "static"                                {  return( kSTATIC );  }
+  "def"                                   {  return( kDEF );  }
+  "class"                                 {  return( kCLASS );  }
+  "interface"                             {  return( kINTERFACE );  }
+  "enum"                                  {  return( kENUM );  }
+  "extends"                               {  return( kEXTENDS );  }
+  "super"                                 {  return( kSUPER );  }
+  "void"                                  {  return( kVOID );  }
+  "boolean"                               {  return( kBOOLEAN );  }
+  "byte"                                  {  return( kBYTE );  }
+  "char"                                  {  return( kCHAR );  }
+  "short"                                 {  return( kSHORT );  }
+  "int"                                   {  return( kINT );  }
+  "float"                                 {  return( kFLOAT );  }
+  "long"                                  {  return( kLONG );  }
+  "double"                                {  return( kDOUBLE );  }
+  "as"                                    {  return( kAS );  }
+  "private"                               {  return( kPRIVATE );  }
+  "abstract"                              {  return( kABSTRACT );  }
+  "public"                                {  return( kPUBLIC );  }
+  "protected"                             {  return( kPROTECTED );  }
+  "transient"                             {  return( kTRANSIENT );  }
+  "native"                                {  return( kNATIVE );  }
+  "synchronized"                          {  return( kSYNCHRONIZED );  }
+  "volatile"                              {  return( kVOLATILE );  }
+  "default"                               {  return( kDEFAULT );  }
+  "do"                                    {  return( kDO );  }
+  "throws"                                {  return( kTHROWS );  }
+  "implements"                            {  return( kIMPLEMENTS );  }
+  "this"                                  {  return( kTHIS );  }
+  "if"                                    {  return( kIF );  }
+  "else"                                  {  return( kELSE );  }
+  "while"                                 {  return( kWHILE );  }
+  "switch"                                {  return( kSWITCH );  }
+  "for"                                   {  return( kFOR );  }
+  "in"                                    {  return( kIN );  }
+  "return"                                {  return( kRETURN );  }
+  "break"                                 {  return( kBREAK );  }
+  "continue"                              {  return( kCONTINUE );  }
+  "throw"                                 {  return( kTHROW );  }
+  "assert"                                {  return( kASSERT );  }
+  "case"                                  {  return( kCASE );  }
+  "try"                                   {  return( kTRY );  }
+  "finally"                               {  return( kFINALLY );  }
+  "catch"                                 {  return( kCATCH );  }
+  "instanceof"                            {  return( kINSTANCEOF );  }
+  "new"                                   {  return( kNEW );  }
+  "true"                                  {  return( kTRUE );  }
+  "false"                                 {  return( kFALSE );  }
+  "null"                                  {  return( kNULL );  }
+  "final"                                 {  return( kFINAL );  }
+
   {mIDENT_NOBUCKS}                        {  yybegin(IN_DOLLAR_SLASH_REGEX_DOT);
                                              return mIDENT; }
   "{"                                     {  blockStack.push(mDOLLAR);
                                              braceCount.push(mLCURLY);
                                              yybegin(NLS_AFTER_LBRACE);
                                              return mLCURLY; }
+
+[^]                                     {  yypushback(1);
+                                           yybegin(IN_DOLLAR_SLASH_REGEX); }
 }
 
 <IN_DOLLAR_SLASH_REGEX_DOT>{
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyAnnotationAttributeInfoHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyAnnotationAttributeInfoHandler.java
index 7a58e0d..8d67050 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyAnnotationAttributeInfoHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyAnnotationAttributeInfoHandler.java
@@ -154,7 +154,7 @@
   }
 
   @Override
-  public void updateParameterInfo(@NotNull GrAnnotationArgumentList o, @NotNull UpdateParameterInfoContext context) {
+  public void updateParameterInfo(@NotNull GrAnnotationArgumentList parameterOwner, @NotNull UpdateParameterInfoContext context) {
     context.setHighlightedParameter(findAnnotationMethod(context.getFile(), context.getEditor()));
   }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java
index 0df8cf1..10e5c0b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyParameterInfoHandler.java
@@ -62,6 +62,7 @@
 public class GroovyParameterInfoHandler implements ParameterInfoHandlerWithTabActionSupport<GroovyPsiElement, Object, GroovyPsiElement> {
   private static final Logger LOG = Logger.getInstance(GroovyParameterInfoHandler.class);
 
+  @Override
   public boolean couldShowInLookup() {
     return true;
   }
@@ -75,6 +76,7 @@
   }
 
 
+  @Override
   public Object[] getParametersForLookup(LookupElement item, ParameterInfoContext context) {
     List<? extends PsiElement> elements = JavaCompletionUtil.getAllPsiElements(item);
 
@@ -91,6 +93,7 @@
     return null;
   }
 
+  @Override
   public Object[] getParametersForDocumentation(Object resolveResult, ParameterInfoContext context) {
     if (resolveResult instanceof GroovyResolveResult) {
       final PsiElement element = ((GroovyResolveResult)resolveResult).getElement();
@@ -102,11 +105,13 @@
     return ArrayUtil.EMPTY_OBJECT_ARRAY;
   }
 
-  public GroovyPsiElement findElementForParameterInfo(CreateParameterInfoContext context) {
+  @Override
+  public GroovyPsiElement findElementForParameterInfo(@NotNull CreateParameterInfoContext context) {
     return findAnchorElement(context.getEditor().getCaretModel().getOffset(), context.getFile());
   }
 
-  public GroovyPsiElement findElementForUpdatingParameterInfo(UpdateParameterInfoContext context) {
+  @Override
+  public GroovyPsiElement findElementForUpdatingParameterInfo(@NotNull UpdateParameterInfoContext context) {
     return findAnchorElement(context.getEditor().getCaretModel().getOffset(), context.getFile());
   }
 
@@ -131,6 +136,7 @@
     return null;
   }
 
+  @Override
   @SuppressWarnings("unchecked")
   public void showParameterInfo(@NotNull GroovyPsiElement place, @NotNull CreateParameterInfoContext context) {
     GroovyResolveResult[] variants = ResolveUtil.getCallVariants(place);
@@ -210,7 +216,8 @@
     return resolveResult.isInvokedOnProperty() || resolveResult.getElement() instanceof PsiVariable;
   }
 
-  public void updateParameterInfo(@NotNull GroovyPsiElement place, UpdateParameterInfoContext context) {
+  @Override
+  public void updateParameterInfo(@NotNull GroovyPsiElement place, @NotNull UpdateParameterInfoContext context) {
     final PsiElement parameterOwner = context.getParameterOwner();
     if (parameterOwner != place) {
       context.removeHint();
@@ -243,7 +250,7 @@
           final PsiMethod method = (PsiMethod)namedElement;
           PsiParameter[] parameters = method.getParameterList().getParameters();
           parameters = updateConstructorParams(method, parameters, context.getParameterOwner());
-          parameterTypes = new PsiType[parameters.length];
+          parameterTypes = PsiType.createArray(parameters.length);
           for (int j = 0; j < parameters.length; j++) {
             parameterTypes[j] = parameters[j].getType();
           }
@@ -254,7 +261,7 @@
       else if (objects[i] instanceof GrClosureSignature) {
         final GrClosureSignature signature = (GrClosureSignature)objects[i];
         argTypes = PsiUtil.getArgumentTypes(place, false);
-        parameterTypes = new PsiType[signature.getParameterCount()];
+        parameterTypes = PsiType.createArray(signature.getParameterCount());
         int j = 0;
         for (GrClosureParameter parameter : signature.getParameters()) {
           parameterTypes[j++] = parameter.getType();
@@ -310,15 +317,18 @@
     return element != null && element.getNode().getElementType() == GroovyTokenTypes.mCOMMA;
   }
 
+  @Override
   public String getParameterCloseChars() {
     return ",){}";
   }
 
+  @Override
   public boolean tracksParameterIndex() {
     return true;
   }
 
-  public void updateUI(Object o, ParameterInfoUIContext context) {
+  @Override
+  public void updateUI(Object o, @NotNull ParameterInfoUIContext context) {
     CodeInsightSettings settings = CodeInsightSettings.getInstance();
 
     if (o == null) return;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyTypeParameterInfoHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyTypeParameterInfoHandler.java
index 63560d2..4924d01 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyTypeParameterInfoHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parameterInfo/GroovyTypeParameterInfoHandler.java
@@ -100,7 +100,7 @@
 
   @Nullable
   @Override
-  public GrTypeArgumentList findElementForParameterInfo(CreateParameterInfoContext context) {
+  public GrTypeArgumentList findElementForParameterInfo(@NotNull CreateParameterInfoContext context) {
     final GrTypeArgumentList parameterList = ParameterInfoUtils.findParentOfType(context.getFile(), context.getOffset(), GrTypeArgumentList.class);
 
     if (parameterList != null) {
@@ -121,19 +121,19 @@
   }
 
   @Override
-  public void showParameterInfo(@NotNull GrTypeArgumentList element, CreateParameterInfoContext context) {
+  public void showParameterInfo(@NotNull GrTypeArgumentList element, @NotNull CreateParameterInfoContext context) {
     context.showHint(element, element.getTextRange().getStartOffset() + 1, this);
   }
 
   @Nullable
   @Override
-  public GrTypeArgumentList findElementForUpdatingParameterInfo(UpdateParameterInfoContext context) {
+  public GrTypeArgumentList findElementForUpdatingParameterInfo(@NotNull UpdateParameterInfoContext context) {
     return ParameterInfoUtils.findParentOfType(context.getFile(), context.getOffset(), GrTypeArgumentList.class);
   }
 
   @Override
-  public void updateParameterInfo(@NotNull GrTypeArgumentList o, UpdateParameterInfoContext context) {
-    int index = ParameterInfoUtils.getCurrentParameterIndex(o.getNode(), context.getOffset(), getActualParameterDelimiterType());
+  public void updateParameterInfo(@NotNull GrTypeArgumentList parameterOwner, @NotNull UpdateParameterInfoContext context) {
+    int index = ParameterInfoUtils.getCurrentParameterIndex(parameterOwner.getNode(), context.getOffset(), getActualParameterDelimiterType());
     context.setCurrentParameter(index);
     final Object[] objectsToView = context.getObjectsToView();
     context.setHighlightedParameter(index < objectsToView.length && index >= 0 ? (PsiElement)objectsToView[index] : null);
@@ -151,7 +151,7 @@
   }
 
   @Override
-  public void updateUI(PsiTypeParameter p, ParameterInfoUIContext context) {
+  public void updateUI(PsiTypeParameter p, @NotNull ParameterInfoUIContext context) {
     @NonNls StringBuilder buffer = new StringBuilder();
     buffer.append(p.getName());
     int highlightEndOffset = buffer.length();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java
index 699393b..af5085f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyElementTypes.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,7 +37,6 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeParameter;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeParameterList;
-import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.annotation.GrAnnotationImpl;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.GrVariableDeclarationImpl;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.blocks.GrBlockImpl;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.blocks.GrClosableBlockImpl;
@@ -181,7 +180,7 @@
       return new GrEnumConstantListImpl(stub);
     }
   };
-  GroovyElementType IMPORT_STATEMENT = new GroovyElementType("Import statement");
+  GrImportStatementElementType IMPORT_STATEMENT = new GrImportStatementElementType("Import statement");
   //Branch statements
   GroovyElementType BREAK_STATEMENT = new GroovyElementType("Break statement");
   GroovyElementType CONTINUE_STATEMENT = new GroovyElementType("Continue statement");
@@ -257,7 +256,7 @@
   GroovyElementType REFERENCE_ELEMENT = new GroovyElementType("reference element");
   GroovyElementType ARRAY_DECLARATOR = new GroovyElementType("array declarator");
 
-  GroovyElementType TYPE_ARGUMENTS = new GroovyElementType("type arguments");
+  GroovyElementType TYPE_ARGUMENTS = new GroovyElementType("type arguments", true);
   GroovyElementType TYPE_ARGUMENT = new GroovyElementType("type argument");
   EmptyStubElementType<GrTypeParameterList> TYPE_PARAMETER_LIST = new EmptyStubElementType<GrTypeParameterList>("type parameter list", GroovyFileType.GROOVY_LANGUAGE) {
     @Override
@@ -302,35 +301,13 @@
   GroovyElementType EXPLICIT_CONSTRUCTOR = new GroovyElementType("explicit constructor invokation");
 
   //throws
-  GroovyElementType THROW_CLAUSE = new GroovyElementType("throw clause");
+  GroovyElementType THROW_CLAUSE = new GroovyElementType("throw clause", true);
   //annotation
   GroovyElementType ANNOTATION_ARRAY_INITIALIZER = new GroovyElementType("annotation array initializer");
-  GroovyElementType ANNOTATION_ARGUMENTS = new GroovyElementType("annotation arguments");
+  GroovyElementType ANNOTATION_ARGUMENTS = new GroovyElementType("annotation arguments", true);
   GroovyElementType ANNOTATION_MEMBER_VALUE_PAIR = new GroovyElementType("annotation member value pair");
 
-  GrStubElementType<GrAnnotationStub, GrAnnotation> ANNOTATION = new GrStubElementType<GrAnnotationStub, GrAnnotation>("annotation") {
-
-    @Override
-    public GrAnnotation createPsi(@NotNull GrAnnotationStub stub) {
-      return new GrAnnotationImpl(stub);
-    }
-
-    @Override
-    public GrAnnotationStub createStub(@NotNull GrAnnotation psi, StubElement parentStub) {
-      return new GrAnnotationStub(parentStub, psi);
-    }
-
-    @Override
-    public void serialize(@NotNull GrAnnotationStub stub, @NotNull StubOutputStream dataStream) throws IOException {
-      dataStream.writeName(stub.getAnnotationName());
-    }
-
-    @NotNull
-    @Override
-    public GrAnnotationStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
-      return new GrAnnotationStub(parentStub, dataStream.readName());
-    }
-  };
+  GrStubElementType<GrAnnotationStub, GrAnnotation> ANNOTATION = new GrAnnotationElementType("annotation");
   //parameters
   EmptyStubElementType<GrParameterList> PARAMETERS_LIST = new EmptyStubElementType<GrParameterList>("parameters list", GroovyFileType.GROOVY_LANGUAGE) {
     @Override
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyParser.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyParser.java
index 5c84fe4..e59463d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyParser.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/GroovyParser.java
@@ -34,7 +34,6 @@
 import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.AssignmentExpression;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.ConditionalExpression;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.ExpressionStatement;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.StrictContextExpression;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.imports.ImportStatement;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.TypeDefinition;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.toplevel.CompilationUnit;
@@ -192,7 +191,7 @@
       return true;
     }
 
-    if (!StrictContextExpression.parse(builder, this)) {
+    if (!ExpressionStatement.argParse(builder, this)) {
       builder.error(GroovyBundle.message("expression.expected"));
     }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/ThrowClause.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/ThrowClause.java
index e348966..13f99db 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/ThrowClause.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/ThrowClause.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,16 +39,16 @@
 
     ParserUtils.getToken(builder, mNLS);
 
-    if (ReferenceElement.parseReferenceElement(builder) == FAIL) {
-      throwClauseMarker.done(THROW_CLAUSE);
+    if (ReferenceElement.parse(builder, false, true, true, false, false) == FAIL) {
       builder.error(GroovyBundle.message("identifier.expected"));
+      throwClauseMarker.done(THROW_CLAUSE);
       return;
     }
 
     while (ParserUtils.getToken(builder, mCOMMA)) {
       ParserUtils.getToken(builder, mNLS);
 
-      if (ReferenceElement.parseReferenceElement(builder) == FAIL) {
+      if (ReferenceElement.parse(builder, false, true, true, false, false) == FAIL) {
         break;
       }
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/annotations/Annotation.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/annotations/Annotation.java
index 313fb60..c6b15d9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/annotations/Annotation.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/annotations/Annotation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,7 +48,7 @@
       return false;
     }
 
-    if (ReferenceElement.parseReferenceElement(builder) == FAIL) {
+    if (ReferenceElement.parse(builder, false, true, true, false, false) == FAIL) {
       builder.error("Annotation name expected");
       annMarker.drop();
       return false;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/parameters/ParameterDeclaration.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/parameters/ParameterDeclaration.java
index 8ffd2bb..2d4e4d4 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/parameters/ParameterDeclaration.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/auxiliary/parameters/ParameterDeclaration.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -32,6 +32,8 @@
 import java.util.HashSet;
 import java.util.Set;
 
+import static org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement.ReferenceElementResult.*;
+
 /**
  * @author: Dmitry.Krasilschikov, ilyas
  */
@@ -47,7 +49,7 @@
 
     final ReferenceElement.ReferenceElementResult result = TypeSpec.parseStrict(builder, true);
 
-    if (result == ReferenceElement.ReferenceElementResult.FAIL && !hasModifiers) {
+    if (result == FAIL && !hasModifiers) {
       rb.drop();
       pdMarker.rollbackTo();
       return false;
@@ -90,9 +92,10 @@
     if (mIDENT.equals(builder.getTokenType()) || (mTRIPLE_DOT.equals(builder.getTokenType()))) {
       rb.drop();
     }
-    else if (result == ReferenceElement.ReferenceElementResult.REF_WITH_TYPE_PARAMS) {
+    else if (result == REF_WITH_TYPE_PARAMS || result == PATH_REF) {
       rb.drop();
-      pdMarker.error(GroovyBundle.message("identifier.expected"));
+      pdMarker.drop();
+      builder.error(GroovyBundle.message("identifier.expected"));
       return true;
     }
     else  {
@@ -135,7 +138,7 @@
       rb.drop();
       rb = builder.mark();
       final ReferenceElement.ReferenceElementResult result = TypeSpec.parseStrict(builder, false);
-      if (result == ReferenceElement.ReferenceElementResult.FAIL && ParserUtils.lookAhead(builder, mBOR)) {
+      if (result == FAIL && ParserUtils.lookAhead(builder, mBOR)) {
         builder.error(GroovyBundle.message("type.expected"));
       }
       else {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/ForStatement.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/ForStatement.java
index 5fb6053..f8aea34 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/ForStatement.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/ForStatement.java
@@ -23,8 +23,8 @@
 import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.modifiers.Modifiers;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.parameters.ParameterDeclaration;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.StrictContextExpression;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.arithmetic.ShiftExpression;
+import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.ConditionalExpression;
+import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.ExpressionStatement;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.types.TypeSpec;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
 
@@ -44,15 +44,15 @@
     if (!ParameterDeclaration.parseTraditionalForParameter(builder, parser)) {
       marker.rollbackTo();
       marker = builder.mark();
-      StrictContextExpression.parse(builder, parser);
+      ExpressionStatement.argParse(builder, parser);
     }
 
     ParserUtils.getToken(builder, mSEMI, GroovyBundle.message("semi.expected"));
-    StrictContextExpression.parse(builder, parser);
+    ExpressionStatement.argParse(builder, parser);
     ParserUtils.getToken(builder, mSEMI, GroovyBundle.message("semi.expected"));
     ParserUtils.getToken(builder, mNLS);
     if (!mRPAREN.equals(builder.getTokenType())) {
-      StrictContextExpression.parse(builder, parser);
+      ExpressionStatement.argParse(builder, parser);
     }
     marker.done(FOR_TRADITIONAL_CLAUSE);
     return true;
@@ -99,7 +99,7 @@
       return false;
     }
 
-    if (!ShiftExpression.parse(builder, parser)) {
+    if (!ConditionalExpression.parse(builder, parser)) {
       builder.error(GroovyBundle.message("expression.expected"));
     }
     marker.done(FOR_IN_CLAUSE);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/SwitchStatement.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/SwitchStatement.java
index 7755763..ce16425 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/SwitchStatement.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/SwitchStatement.java
@@ -23,7 +23,7 @@
 import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
 import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.AssignmentExpression;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.StrictContextExpression;
+import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.ExpressionStatement;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
 
 /**
@@ -41,7 +41,7 @@
       marker.done(SWITCH_STATEMENT);
       return;
     }
-    if (!StrictContextExpression.parse(builder, parser)) {
+    if (!ExpressionStatement.argParse(builder, parser)) {
       builder.error(GroovyBundle.message("expression.expected"));
     }
     ParserUtils.getToken(builder, mNLS);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/SynchronizedStatement.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/SynchronizedStatement.java
index a1dfe32..88e5c94 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/SynchronizedStatement.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/SynchronizedStatement.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
 import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
 import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.blocks.OpenOrClosableBlock;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.StrictContextExpression;
+import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.ExpressionStatement;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
 
 /**
@@ -39,7 +39,7 @@
       return false;
     }
 
-    if (!StrictContextExpression.parse(builder, parser)) {
+    if (!ExpressionStatement.argParse(builder, parser)) {
       builder.error(GroovyBundle.message("expression.expected"));
     }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/AssignmentExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/AssignmentExpression.java
index b986090..ce73328 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/AssignmentExpression.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/AssignmentExpression.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,6 +47,9 @@
         marker.done(ASSIGNMENT_EXPRESSION);
       }
       else {
+        if (isTuple) {
+          builder.error(GroovyBundle.message("assign.expected"));
+        }
         marker.drop();
       }
       return true;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/StrictContextExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/StrictContextExpression.java
deleted file mode 100644
index c1c505c..0000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/StrictContextExpression.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions;
-
-import com.intellij.lang.PsiBuilder;
-import org.jetbrains.plugins.groovy.GroovyBundle;
-import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
-import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.VariableInitializer;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.annotations.Annotation;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.modifiers.Modifiers;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.BranchStatement;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.declaration.Declaration;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.types.TypeSpec;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
-
-import static org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement.ReferenceElementResult.FAIL;
-
-/**
- * @autor: Dmitry.Krasilschikov, ilyas
- */
-public class StrictContextExpression implements GroovyElementTypes {
-  public static boolean parse(PsiBuilder builder, GroovyParser parser) {
-
-    if (BranchStatement.BRANCH_KEYWORDS.contains(builder.getTokenType())) {
-      return BranchStatement.parse(builder, parser);
-    }
-    if (mAT.equals(builder.getTokenType())) {
-      return Annotation.parse(builder, parser);
-    }
-
-
-    PsiBuilder.Marker declStartMarker = builder.mark();
-
-    if (Declaration.parse(builder, false, false, null, parser)) {
-      declStartMarker.rollbackTo();
-      singleDeclarationParse(builder, parser);
-      return true;
-    }
-    else {
-      declStartMarker.rollbackTo();
-      return ExpressionStatement.argParse(builder, parser);
-    }
-  }
-
-  public static void singleDeclarationParse(PsiBuilder builder, GroovyParser parser) {
-
-    PsiBuilder.Marker marker = builder.mark();
-    if (Modifiers.parse(builder, parser)) {
-      PsiBuilder.Marker rb = builder.mark();
-      TypeSpec.parse(builder);
-      if (!mIDENT.equals(builder.getTokenType())) {
-        rb.rollbackTo();
-      } else {
-        rb.drop();
-      }
-      ParserUtils.getToken(builder, mIDENT, GroovyBundle.message("identifier.expected"));
-      if (mASSIGN.equals(builder.getTokenType())) {
-        VariableInitializer.parse(builder, parser);
-      }
-      marker.done(VARIABLE_DEFINITION);
-    } else {
-      if (TypeSpec.parse(builder) != FAIL) {
-        ParserUtils.getToken(builder, mIDENT, GroovyBundle.message("identifier.expected"));
-        if (mASSIGN.equals(builder.getTokenType())) {
-          VariableInitializer.parse(builder, parser);
-        }
-        marker.done(VARIABLE_DEFINITION);
-      } else {
-        builder.error(GroovyBundle.message("type.specification.expected"));
-      }
-    }
-  }
-}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PathExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PathExpression.java
index 65061b0..2a514c6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PathExpression.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PathExpression.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
 import com.intellij.lang.PsiBuilder;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.tree.TokenSet;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.GroovyBundle;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyElementType;
 import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
@@ -38,73 +39,65 @@
  */
 public class PathExpression implements GroovyElementTypes {
 
-  public static boolean parse(PsiBuilder builder, GroovyParser parser) {
+  public enum Result {INVOKED_EXPR, METHOD_CALL, WRONG_WAY, LITERAL}
+
+  private static final TokenSet DOTS = TokenSet.create(mSPREAD_DOT, mOPTIONAL_DOT, mMEMBER_POINTER, mDOT);
+  private static final TokenSet PATH_ELEMENT_START = TokenSet.create(mSPREAD_DOT, mOPTIONAL_DOT, mMEMBER_POINTER, mLBRACK, mLPAREN, mLCURLY, mDOT);
+
+  public static boolean parse(@NotNull PsiBuilder builder, @NotNull GroovyParser parser) {
     return parsePathExprQualifierForExprStatement(builder, parser) != WRONG_WAY;
   }
 
-  public enum Result {INVOKED_EXPR, METHOD_CALL, WRONG_WAY, LITERAL}
-
   /**
    * parses method calls with parentheses, property index access, etc
    */
-  public static Result parsePathExprQualifierForExprStatement(PsiBuilder builder, GroovyParser parser) {
+  @NotNull
+  public static Result parsePathExprQualifierForExprStatement(@NotNull PsiBuilder builder, @NotNull GroovyParser parser) {
     PsiBuilder.Marker marker = builder.mark();
-    final PsiBuilder.Marker marker1 = builder.mark();
     IElementType qualifierType = PrimaryExpression.parsePrimaryExpression(builder, parser);
     if (qualifierType != WRONGWAY) {
-      Result result;
-      if (isPathElementStart(builder)) {
-        if ((builder.getTokenType() == mLPAREN || builder.getTokenType() == mLCURLY) && qualifierType == LITERAL) {
-          marker1.rollbackTo();
-          qualifierType = PrimaryExpression.parsePrimaryExpression(builder, parser, true);
-          assert qualifierType != WRONGWAY;
-        }
-        else {
-          marker1.drop();
-        }
-        PsiBuilder.Marker newMarker = marker.precede();
-        marker.drop();
-        if (checkForLCurly(builder)) {
-          PsiBuilder.Marker argsMarker = builder.mark();
-          argsMarker.done(ARGUMENTS);
-          ParserUtils.getToken(builder, mNLS);
-          result = pathElementParse(builder, newMarker, parser, METHOD_CALL);
-        }
-        else {
-          result = pathElementParse(builder, newMarker, parser, INVOKED_EXPR);
-        }
-      }
-      else {
-        marker1.drop();
-        marker.drop();
-        if (qualifierType == LITERAL) return Result.LITERAL;
-        return INVOKED_EXPR;
-      }
-      return result;
+      return parseAfterQualifier(builder, parser, marker, qualifierType);
     }
     else {
-      marker1.drop();
       marker.drop();
       return WRONG_WAY;
     }
   }
 
-  /**
-   * Any path element parsing
-   *
-   * @param builder
-   * @param marker
-   * @return
-   */
+  @NotNull
+  private static Result parseAfterQualifier(@NotNull PsiBuilder builder,
+                                            @NotNull GroovyParser parser,
+                                            @NotNull PsiBuilder.Marker marker,
+                                            @NotNull IElementType qualifierType) {
+    if (isPathElementStart(builder)) {
+      if (isLParenthOrLCurlyAfterLiteral(builder, qualifierType)) {
+        marker.rollbackTo();
+        PsiBuilder.Marker newMarker = builder.mark();
+        IElementType newQualifierType = PrimaryExpression.parsePrimaryExpression(builder, parser, true);
+        assert newQualifierType != WRONGWAY;
+        return parseAfterReference(builder, parser, newMarker);
+      }
+      else {
+        return parseAfterReference(builder, parser, marker);
+      }
+    }
+    else {
+      marker.drop();
+      if (qualifierType == LITERAL) return Result.LITERAL;
+      return INVOKED_EXPR;
+    }
+  }
 
-  private static final TokenSet DOTS = TokenSet.create(mSPREAD_DOT, mOPTIONAL_DOT, mMEMBER_POINTER, mDOT);
+  private static boolean isLParenthOrLCurlyAfterLiteral(@NotNull PsiBuilder builder, @NotNull IElementType qualifierType) {
+    return qualifierType == LITERAL && (checkForLParenth(builder) || checkForLCurly(builder));
+  }
 
-  private static Result pathElementParse(PsiBuilder builder,
-                                         PsiBuilder.Marker marker,
-                                         GroovyParser parser,
-                                         Result result) {
+  @NotNull
+  private static Result pathElementParse(@NotNull PsiBuilder builder,
+                                         @NotNull PsiBuilder.Marker marker,
+                                         @NotNull GroovyParser parser,
+                                         @NotNull Result result) {
 
-    GroovyElementType res;
 
     // Property reference
     if (DOTS.contains(builder.getTokenType()) || ParserUtils.lookAhead(builder, mNLS, mDOT)) {
@@ -114,76 +107,75 @@
       ParserUtils.getToken(builder, DOTS);
       ParserUtils.getToken(builder, mNLS);
       TypeArguments.parseTypeArguments(builder, true);
-      res = namePartParse(builder, parser);
-      if (!res.equals(WRONGWAY)) {
+      GroovyElementType res = namePartParse(builder, parser);
+      if (res != WRONGWAY) {
         PsiBuilder.Marker newMarker = marker.precede();
         marker.done(res);
-        if (checkForLCurly(builder)) {
-          PsiBuilder.Marker argsMarker = builder.mark();
-          argsMarker.done(ARGUMENTS);
-          ParserUtils.getToken(builder, mNLS);
-          result = pathElementParse(builder, newMarker, parser, METHOD_CALL);
-        }
-        else {
-          result = pathElementParse(builder, newMarker, parser, INVOKED_EXPR);
-        }
+        return parseAfterReference(builder, parser, newMarker);
       }
       else {
         builder.error(GroovyBundle.message("path.selector.expected"));
         marker.drop();
+        return result;
       }
     }
-    else if (mLPAREN.equals(builder.getTokenType())) {
+    else if (checkForLParenth(builder)) {
       PrimaryExpression.methodCallArgsParse(builder, parser);
-      if (checkForLCurly(builder)) {
-        ParserUtils.getToken(builder, mNLS);
-        result = pathElementParse(builder, marker, parser, METHOD_CALL);
-      }
-      else {
-        PsiBuilder.Marker newMarker = marker.precede();
-        marker.done(PATH_METHOD_CALL);
-        result = pathElementParse(builder, newMarker, parser, METHOD_CALL);
-      }
+      return parseAfterArguments(builder, marker, parser);
     }
     else if (checkForLCurly(builder)) {
       ParserUtils.getToken(builder, mNLS);
       appendedBlockParse(builder, parser);
-      if (checkForLCurly(builder)) {
-        ParserUtils.getToken(builder, mNLS);
-        result = pathElementParse(builder, marker, parser, METHOD_CALL);
-      }
-      else {
-        PsiBuilder.Marker newMarker = marker.precede();
-        marker.done(PATH_METHOD_CALL);
-        result = pathElementParse(builder, newMarker, parser, METHOD_CALL);
-      }
+      return parseAfterArguments(builder, marker, parser);
     }
     else if (checkForArrayAccess(builder)) {
       indexPropertyArgsParse(builder, parser);
       PsiBuilder.Marker newMarker = marker.precede();
       marker.done(PATH_INDEX_PROPERTY);
-      if (checkForLCurly(builder)) {
-        PsiBuilder.Marker argsMarker = builder.mark();
-        argsMarker.done(ARGUMENTS);
-        ParserUtils.getToken(builder, mNLS);
-        result = pathElementParse(builder, newMarker, parser, METHOD_CALL);
-      }
-      else {
-        result = pathElementParse(builder, newMarker, parser, INVOKED_EXPR);
-      }
+      return parseAfterReference(builder, parser, newMarker);
     }
     else {
       marker.drop();
+      return result;
     }
-    return result;
   }
 
-  private static boolean checkForLCurly(PsiBuilder builder) {
+  @NotNull
+  private static Result parseAfterReference(@NotNull PsiBuilder builder, @NotNull GroovyParser parser, @NotNull PsiBuilder.Marker newMarker) {
+    if (checkForLCurly(builder)) {
+      PsiBuilder.Marker argsMarker = builder.mark();
+      argsMarker.done(ARGUMENTS);
+      ParserUtils.getToken(builder, mNLS);
+      return pathElementParse(builder, newMarker, parser, METHOD_CALL);
+    }
+    else {
+      return pathElementParse(builder, newMarker, parser, INVOKED_EXPR);
+    }
+  }
+
+  @NotNull
+  private static Result parseAfterArguments(@NotNull PsiBuilder builder, @NotNull PsiBuilder.Marker marker, @NotNull GroovyParser parser) {
+    if (checkForLCurly(builder)) {
+      ParserUtils.getToken(builder, mNLS);
+      return pathElementParse(builder, marker, parser, METHOD_CALL);
+    }
+    else {
+      PsiBuilder.Marker newMarker = marker.precede();
+      marker.done(PATH_METHOD_CALL);
+      return pathElementParse(builder, newMarker, parser, METHOD_CALL);
+    }
+  }
+
+  private static boolean checkForLCurly(@NotNull PsiBuilder builder) {
     return ParserUtils.lookAhead(builder, mLCURLY) || ParserUtils.lookAhead(builder, mNLS, mLCURLY);
   }
 
-  public static boolean checkForArrayAccess(PsiBuilder builder) {
-    return mLBRACK.equals(builder.getTokenType()) &&
+  private static boolean checkForLParenth(@NotNull PsiBuilder builder) {
+    return builder.getTokenType() == mLPAREN;
+  }
+
+  public static boolean checkForArrayAccess(@NotNull PsiBuilder builder) {
+    return builder.getTokenType() == mLBRACK &&
            !ParserUtils.lookAhead(builder, mLBRACK, mCOLON) &&
            !ParserUtils.lookAhead(builder, mLBRACK, mNLS, mCOLON);
   }
@@ -194,7 +186,8 @@
    * @param builder
    * @return
    */
-  public static GroovyElementType namePartParse(PsiBuilder builder, GroovyParser parser) {
+  @NotNull
+  public static GroovyElementType namePartParse(@NotNull PsiBuilder builder, @NotNull GroovyParser parser) {
     ParserUtils.getToken(builder, mAT);
     if (ParserUtils.getToken(builder, mIDENT) ||
         ParserUtils.getToken(builder, mSTRING_LITERAL) ||
@@ -203,29 +196,29 @@
     }
 
     final IElementType tokenType = builder.getTokenType();
-    if (mGSTRING_BEGIN.equals(tokenType)) {
+    if (tokenType == mGSTRING_BEGIN) {
       final boolean result = CompoundStringExpression.parse(builder, parser, true, mGSTRING_BEGIN, mGSTRING_CONTENT, mGSTRING_END, null,
                                                             GSTRING, GroovyBundle.message("string.end.expected"));
       return result ? PATH_PROPERTY_REFERENCE : REFERENCE_EXPRESSION;
     }
-    if (mREGEX_BEGIN.equals(tokenType)) {
+    if (tokenType == mREGEX_BEGIN) {
       final boolean result = CompoundStringExpression.parse(builder, parser, true,
                                                             mREGEX_BEGIN, mREGEX_CONTENT, mREGEX_END, mREGEX_LITERAL,
                                                             REGEX, GroovyBundle.message("regex.end.expected"));
       return result ? PATH_PROPERTY_REFERENCE : REFERENCE_EXPRESSION;
     }
-    if (mDOLLAR_SLASH_REGEX_BEGIN.equals(tokenType)) {
+    if (tokenType == mDOLLAR_SLASH_REGEX_BEGIN) {
       final boolean result = CompoundStringExpression.parse(builder, parser, true,
                                                             mDOLLAR_SLASH_REGEX_BEGIN, mDOLLAR_SLASH_REGEX_CONTENT, mDOLLAR_SLASH_REGEX_END,
                                                             mDOLLAR_SLASH_REGEX_LITERAL,
                                                             REGEX, GroovyBundle.message("dollar.slash.end.expected"));
       return result ? PATH_PROPERTY_REFERENCE : REFERENCE_EXPRESSION;
     }
-    if (mLCURLY.equals(tokenType)) {
+    if (tokenType == mLCURLY) {
       OpenOrClosableBlock.parseOpenBlock(builder, parser);
       return PATH_PROPERTY_REFERENCE;
     }
-    if (mLPAREN.equals(tokenType)) {
+    if (tokenType == mLPAREN) {
       PrimaryExpression.parenthesizedExprParse(builder, parser);
       return PATH_PROPERTY_REFERENCE;
     }
@@ -242,8 +235,9 @@
    * @param builder
    * @return
    */
-  public static GroovyElementType indexPropertyArgsParse(PsiBuilder builder, GroovyParser parser) {
-    assert mLBRACK.equals(builder.getTokenType());
+  @NotNull
+  public static GroovyElementType indexPropertyArgsParse(@NotNull PsiBuilder builder, @NotNull GroovyParser parser) {
+    assert builder.getTokenType() == mLBRACK;
 
     PsiBuilder.Marker marker = builder.mark();
     ParserUtils.getToken(builder, mLBRACK);
@@ -261,7 +255,8 @@
    * @param builder
    * @return
    */
-  private static IElementType appendedBlockParse(PsiBuilder builder, GroovyParser parser) {
+  @NotNull
+  private static IElementType appendedBlockParse(@NotNull PsiBuilder builder, @NotNull GroovyParser parser) {
     return OpenOrClosableBlock.parseClosableBlock(builder, parser);
   }
 
@@ -272,17 +267,10 @@
    * @param builder
    * @return
    */
-  private static boolean isPathElementStart(PsiBuilder builder) {
+  private static boolean isPathElementStart(@NotNull PsiBuilder builder) {
     return (PATH_ELEMENT_START.contains(builder.getTokenType()) ||
             ParserUtils.lookAhead(builder, mNLS, mDOT) ||
             ParserUtils.lookAhead(builder, mNLS, mLCURLY));
   }
 
-  /**
-   * FIRST(1) of PathElement
-   */
-  private static final TokenSet PATH_ELEMENT_START =
-    TokenSet.create(mSPREAD_DOT, mOPTIONAL_DOT, mMEMBER_POINTER, mLBRACK, mLPAREN, mLCURLY, mDOT);
-
-
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java
index f785fe6..e2fc55c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -118,9 +118,10 @@
     }
 
     PsiBuilder.Marker anonymousMarker = builder.mark();
-    String name = null;
+    String name;
     if (TokenSets.BUILT_IN_TYPES.contains(builder.getTokenType())) {
       ParserUtils.eatElement(builder, BUILT_IN_TYPE);
+      name = null;
     }
     else if (TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS.contains(builder.getTokenType())) {
       name = builder.getTokenText();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/imports/ImportReference.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/imports/ImportReference.java
index 62381a5..6bb48b3b9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/imports/ImportReference.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/imports/ImportReference.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,7 +36,9 @@
       return false;
     }
 
-    ReferenceElement.parseForImport(builder);
+    if (ReferenceElement.parseForImport(builder) == ReferenceElement.ReferenceElementResult.FAIL) {
+      return false;
+    }
 
     if (ParserUtils.getToken(builder, mDOT)) {
       ParserUtils.getToken(builder, mNLS);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/ReferenceElement.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/ReferenceElement.java
index 79763df..3d13f1e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/ReferenceElement.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/typeDefinitions/ReferenceElement.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 import com.intellij.psi.tree.IElementType;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.GroovyBundle;
 import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
 import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.types.TypeArguments;
@@ -98,10 +99,9 @@
   }
 
   public static ReferenceElementResult parseForPackage(@NotNull PsiBuilder builder) {
-    return parse(builder, false, false, false, false, false);
+    return parse(builder, false, false, true, false, false);
   }
 
-  
   //it doesn't important first letter of identifier of ThrowClause, of Annotation, of new Expression, of implements, extends, superclass clauses
   public static ReferenceElementResult parseReferenceElement(@NotNull PsiBuilder builder) {
     return parseReferenceElement(builder, false, true);
@@ -114,7 +114,7 @@
   public static ReferenceElementResult parse(@NotNull PsiBuilder builder,
                                              boolean checkUpperCase,
                                              boolean parseTypeArgs,
-                                             boolean forImport,
+                                             boolean lineFeedAllowed,
                                              boolean allowDiamond,
                                              boolean expressionPossible) {
     PsiBuilder.Marker internalTypeMarker = builder.mark();
@@ -127,8 +127,8 @@
     }
 
     boolean hasTypeArguments = false;
-    if (parseTypeArgs) {
-      hasTypeArguments = TypeArguments.parseTypeArguments(builder, expressionPossible, allowDiamond);
+    if (parseTypeArgs && TypeArguments.parseTypeArguments(builder, expressionPossible, allowDiamond)) {
+      hasTypeArguments = true;
     }
 
     internalTypeMarker.done(REFERENCE_ELEMENT);
@@ -138,26 +138,31 @@
 
     while (builder.getTokenType() == mDOT) {
 
-      if ((ParserUtils.lookAhead(builder, mDOT, mSTAR) || ParserUtils.lookAhead(builder, mDOT, mNLS, mSTAR)) && forImport) {
+      if ((ParserUtils.lookAhead(builder, mDOT, mSTAR) || ParserUtils.lookAhead(builder, mDOT, mNLS, mSTAR)) && lineFeedAllowed) {
         internalTypeMarker.drop();
         return PATH_REF;
       }
 
       ParserUtils.getToken(builder, mDOT);
 
-      if (forImport) {
+      if (lineFeedAllowed) {
         ParserUtils.getToken(builder, mNLS);
       }
 
       lastIdentifier = builder.getTokenText();
 
       if (!ParserUtils.getToken(builder, TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS)) {
-        internalTypeMarker.rollbackTo();
-        return FAIL;
+        if (TokenSets.REFERENCE_NAME_PREFIXES.contains(builder.getTokenType())) {
+          internalTypeMarker.rollbackTo();
+          return FAIL;
+        }
+        builder.error(GroovyBundle.message("identifier.expected"));
+        internalTypeMarker.done(REFERENCE_ELEMENT);
+        return PATH_REF;
       }
 
-      if (parseTypeArgs) {
-        hasTypeArguments = TypeArguments.parseTypeArguments(builder, expressionPossible, allowDiamond) || hasTypeArguments;
+      if (parseTypeArgs && TypeArguments.parseTypeArguments(builder, expressionPossible, allowDiamond)) {
+        hasTypeArguments = true;
       }
 
       internalTypeMarker.done(REFERENCE_ELEMENT);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/toplevel/packaging/PackageDefinition.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/toplevel/packaging/PackageDefinition.java
index f0e5a4a..fa432a8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/toplevel/packaging/PackageDefinition.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/toplevel/packaging/PackageDefinition.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,13 +19,13 @@
 import com.intellij.lang.PsiBuilder;
 import com.intellij.lang.PsiBuilder.Marker;
 import org.jetbrains.plugins.groovy.GroovyBundle;
-import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
 import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
 import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.modifiers.Modifiers;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
 
+import static org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.ReferenceElement.ReferenceElementResult.FAIL;
 
 /**
  * @author ilyas
@@ -42,8 +42,7 @@
       return false;
     }
 
-    if (!TokenSets.CODE_REFERENCE_ELEMENT_NAME_TOKENS.contains(builder.getTokenType()) ||
-        ReferenceElement.parseForPackage(builder) == ReferenceElement.ReferenceElementResult.FAIL) {
+    if (ReferenceElement.parseForPackage(builder) == FAIL) {
       builder.error(GroovyBundle.message("identifier.expected"));
     }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyElementVisitor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyElementVisitor.java
index 06b53a4..c548b56 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyElementVisitor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyElementVisitor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrSpreadArgument;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.*;
@@ -462,4 +463,8 @@
   public void visitTupleExpression(GrTupleExpression tupleExpression) {
     visitExpression(tupleExpression);
   }
+
+  public void visitSpreadArgument(GrSpreadArgument spreadArgument) {
+    visitExpression(spreadArgument);
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyPsiElementFactory.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyPsiElementFactory.java
index 749319c..21b0572 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyPsiElementFactory.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/GroovyPsiElementFactory.java
@@ -260,6 +260,14 @@
   public abstract GrMethod createMethod(@NotNull @NonNls String name, @Nullable PsiType returnType) throws IncorrectOperationException;
 
   @NotNull
+  @Override
+  public abstract GrMethod createConstructor();
+
+  @NotNull
+  @Override
   public abstract GrParameter createParameter(@NotNull @NonNls String name, @Nullable PsiType type) throws IncorrectOperationException;
 
+  @NotNull
+  @Override
+  public abstract GrField createField(@NotNull @NonNls String name, @NotNull PsiType type) throws IncorrectOperationException;
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/GroovyResolveResult.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/GroovyResolveResult.java
index d725cb6..e3ce5dd 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/GroovyResolveResult.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/GroovyResolveResult.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,6 +31,8 @@
 
   boolean isStaticsOK();
 
+  boolean isApplicable();
+
   @Nullable
   PsiElement getCurrentFileResolveContext();
 
@@ -55,6 +57,11 @@
       return true;
     }
 
+    @Override
+    public boolean isApplicable() {
+      return false;
+    }
+
     @NotNull
     public PsiSubstitutor getSubstitutor() {
       return PsiSubstitutor.EMPTY;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrMultiSignature.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrMultiSignature.java
index 8d59457..5bcf8b3 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrMultiSignature.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrMultiSignature.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,9 @@
  */
 package org.jetbrains.plugins.groovy.lang.psi.api.signatures;
 
+import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiType;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
 
 /**
  * @author Max Medvedev
@@ -37,7 +37,7 @@
     }
 
     @Override
-    public GrSignature curry(@NotNull PsiType[] args, int position, @NotNull GroovyPsiElement context) {
+    public GrSignature curry(@NotNull PsiType[] args, int position, @NotNull PsiElement context) {
       return this;
     }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrSignature.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrSignature.java
index d168f7d..92d2140 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrSignature.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/signatures/GrSignature.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,10 +15,10 @@
  */
 package org.jetbrains.plugins.groovy.lang.psi.api.signatures;
 
+import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiType;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
 
 /**
  * @author Max Medvedev
@@ -27,7 +27,7 @@
   boolean isValid();
 
   @Nullable
-  GrSignature curry(@NotNull PsiType[] args, int position, @NotNull GroovyPsiElement context);
+  GrSignature curry(@NotNull PsiType[] args, int position, @NotNull PsiElement context);
 
   void accept(GrSignatureVisitor visitor);
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrClassInitializer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrClassInitializer.java
index 0323d1e..3d69a57 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrClassInitializer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrClassInitializer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,11 +21,12 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration;
 
 /**
  * @author ilyas
  */
-public interface GrClassInitializer extends GrMember, PsiClassInitializer {
+public interface GrClassInitializer extends GrMember, PsiClassInitializer, GrMembersDeclaration {
 
   GrClassInitializer[] EMPTY_ARRAY = new GrClassInitializer[0];
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrConstructorInvocation.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrConstructorInvocation.java
index 922f5bb..e212db7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrConstructorInvocation.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrConstructorInvocation.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
 
   boolean isThisCall();
 
+  @NotNull
   GrReferenceExpression getInvokedExpression();
 
   @Nullable
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrWhileStatement.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrWhileStatement.java
index 527c7d2..824b039 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrWhileStatement.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/GrWhileStatement.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrCondition;
 import org.jetbrains.plugins.groovy.lang.psi.api.formatter.GrControlStatement;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 
 /**
  * @autor: Dmitry.Krasilschikov
@@ -28,7 +29,7 @@
 public interface GrWhileStatement extends GrStatement, GrControlStatement, GrLoopStatement {
 
   @Nullable
-  GrCondition getCondition();
+  GrExpression getCondition();
 
   @Nullable
   GrStatement getBody();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrAssignmentExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrAssignmentExpression.java
index b76ede2..9e90485 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrAssignmentExpression.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrAssignmentExpression.java
@@ -34,10 +34,12 @@
   @Nullable
   GrExpression getRValue();
 
+  @NotNull
   IElementType getOperationTokenType();
 
   @NotNull
   GroovyResolveResult[] multiResolve(boolean incompleteCode);
 
+  @NotNull
   PsiElement getOperationToken();
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrMethodCall.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrMethodCall.java
index 1e718ac..1d558bc 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrMethodCall.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrMethodCall.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,15 +16,20 @@
 package org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions;
 
 import com.intellij.navigation.NavigationItem;
-import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrCallExpression;
 
 /**
  * @author peter
  */
 public interface GrMethodCall extends GrCallExpression, NavigationItem {
-  @Nullable
+  @NotNull
   GrExpression getInvokedExpression();
 
+  @Override
+  @NotNull
+  GrArgumentList getArgumentList();
+
   boolean isCommandExpression();
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrUnaryExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrUnaryExpression.java
index 03900c9..ab33b08e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrUnaryExpression.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/statements/expressions/GrUnaryExpression.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,10 +27,14 @@
  * @author ilyas
  */
 public interface GrUnaryExpression extends GrExpression, PsiPolyVariantReference {
+  @NotNull
   IElementType getOperationTokenType();
+
+  @NotNull
   PsiElement getOperationToken();
 
-  @Nullable GrExpression getOperand();
+  @Nullable
+  GrExpression getOperand();
 
   @NotNull
   @Override
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/toplevel/imports/GrImportStatement.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/toplevel/imports/GrImportStatement.java
index 592f450..b656806 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/toplevel/imports/GrImportStatement.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/toplevel/imports/GrImportStatement.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiElement;
+import com.intellij.util.ArrayFactory;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
@@ -29,6 +30,15 @@
  */
 public interface GrImportStatement extends GrTopStatement {
   GrImportStatement[] EMPTY_ARRAY = new GrImportStatement[0];
+
+  ArrayFactory<GrImportStatement> ARRAY_FACTORY = new ArrayFactory<GrImportStatement>() {
+    @NotNull
+    @Override
+    public GrImportStatement[] create(int count) {
+      return new GrImportStatement[count];
+    }
+  };
+
   @Nullable
   GrCodeReferenceElement getImportReference();
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/types/GrTypeElement.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/types/GrTypeElement.java
index ff67312..683ba7c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/types/GrTypeElement.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/api/types/GrTypeElement.java
@@ -15,7 +15,6 @@
  */
 package org.jetbrains.plugins.groovy.lang.psi.api.types;
 
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiType;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
@@ -27,7 +26,4 @@
 public interface GrTypeElement extends GroovyPsiElement {
   @NotNull
   PsiType getType();
-
-  /** @deprecated use {@link #getType()} (to remove in IDEA 13) */
-  PsiType getTypeNoResolve(PsiElement context);
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java
index cd6e3fc..2934d09 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/ControlFlowBuilder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -60,9 +60,10 @@
  */
 public class ControlFlowBuilder extends GroovyRecursiveElementVisitor {
   private static final Logger LOG = Logger.getInstance(ControlFlowBuilder.class);
-  private List<InstructionImpl> myInstructions;
 
-  private Deque<InstructionImpl> myProcessingStack;
+  private final List<InstructionImpl> myInstructions = new ArrayList<InstructionImpl>();
+
+  private final Deque<InstructionImpl> myProcessingStack = new ArrayDeque<InstructionImpl>();
   private final PsiConstantEvaluationHelper myConstantEvaluator;
   private GroovyPsiElement myScope;
 
@@ -70,12 +71,12 @@
   /**
    * stack of current catch blocks
    */
-  private Deque<ExceptionInfo> myCaughtExceptionInfos;
+  private final Deque<ExceptionInfo> myCaughtExceptionInfos = new ArrayDeque<ExceptionInfo>();
 
   /**
    * stack of current conditions
    */
-  private Deque<ConditionInstruction> myConditions;
+  private final Deque<ConditionInstruction> myConditions = new ArrayDeque<ConditionInstruction>();
 
 
   /**
@@ -91,7 +92,7 @@
   /**
    * list of pending nodes and corresponding scopes sorted by scopes from the biggest to smallest.
    */
-  private List<Pair<InstructionImpl, GroovyPsiElement>> myPending;
+  private List<Pair<InstructionImpl, GroovyPsiElement>> myPending = new ArrayList<Pair<InstructionImpl, GroovyPsiElement>>();
 
   private int myInstructionNumber;
   private final GrControlFlowPolicy myPolicy;
@@ -135,20 +136,16 @@
   }
 
 
-  private void handlePossibleReturn(@NotNull GrStatement possibleReturn) {
+  @Nullable
+  private InstructionImpl handlePossibleReturn(@NotNull GrStatement possibleReturn) {
     if (possibleReturn instanceof GrExpression && ControlFlowBuilderUtil.isCertainlyReturnStatement(possibleReturn)) {
-      addNodeAndCheckPending(new MaybeReturnInstruction((GrExpression)possibleReturn));
+      return addNodeAndCheckPending(new MaybeReturnInstruction((GrExpression)possibleReturn));
     }
+    return null;
   }
 
   public Instruction[] buildControlFlow(GroovyPsiElement scope) {
-    myInstructions = new ArrayList<InstructionImpl>();
-    myProcessingStack = new ArrayDeque<InstructionImpl>();
-    myCaughtExceptionInfos = new ArrayDeque<ExceptionInfo>();
-    myConditions = new ArrayDeque<ConditionInstruction>();
-
     myFinallyCount = 0;
-    myPending = new ArrayList<Pair<InstructionImpl, GroovyPsiElement>>();
     myInstructionNumber = 0;
 
     myScope = scope;
@@ -411,8 +408,8 @@
     GrExpression rValue = expression.getRValue();
     if (rValue != null) {
       rValue.accept(this);
-      lValue.accept(this);
     }
+    lValue.accept(this);
   }
 
   @Override
@@ -617,12 +614,12 @@
     addNode(new InstanceOfInstruction(expression, cond));
     NegatingGotoInstruction negation = new NegatingGotoInstruction(expression, cond);
     addNode(negation);
-    handlePossibleReturn(expression);
-    addPendingEdge(expression, negation);
+    InstructionImpl possibleReturn = handlePossibleReturn(expression);
+    addPendingEdge(expression, possibleReturn != null ? possibleReturn : negation);
 
     myHead = cond;
     addNode(new InstanceOfInstruction(expression, cond));
-    handlePossibleReturn(expression);
+    //handlePossibleReturn(expression);
     myConditions.removeFirstOccurrence(cond);
   }
 
@@ -1123,7 +1120,9 @@
   private void finishNode(InstructionImpl instruction) {
     final InstructionImpl popped = myProcessingStack.pop();
     if (!instruction.equals(popped)) {
-      String description = "popped: " + popped.toString() + " : " + popped.hashCode() + "   ,  expected: " + instruction.toString() + " : " + instruction.hashCode();
+      String description = "popped: " + popped.toString() + " : " + popped.hashCode() +
+                           "   ,  expected: " + instruction.toString() + " : " + instruction.hashCode() +
+                           "same objects:" + (popped == instruction);
       error(description);
     }
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/MaybeReturnInstruction.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/MaybeReturnInstruction.java
index 7720041..bfb4a82 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/MaybeReturnInstruction.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/controlFlow/impl/MaybeReturnInstruction.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
 
 import com.intellij.psi.PsiType;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 
 /**
 * @author peter
@@ -35,7 +37,7 @@
     GrExpression expression = (GrExpression) getElement();
     assert expression != null;
     final PsiType type = expression.getType();
-    return type != PsiType.VOID;
+    return type != PsiType.VOID && !PsiUtil.isVoidMethodCall(expression);
   }
 
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/DFAType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/DFAType.java
index fe97437..6f512c30 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/DFAType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/DFAType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -132,7 +132,7 @@
 
   @Nullable
   public PsiType getResultType() {
-    if (mixins.size() == 0) return primary;
+    if (mixins.isEmpty()) return primary;
 
     List<PsiType> types = new ArrayList<PsiType>();
     if (primary != null) {
@@ -143,8 +143,8 @@
         types.add(mixin.myType);
       }
     }
-    if (types.size() == 0) return null;
-    return PsiIntersectionType.createIntersection(types.toArray(new PsiType[types.size()]));
+    if (types.isEmpty()) return null;
+    return PsiIntersectionType.createIntersection(types.toArray(PsiType.createArray(types.size())));
   }
 
   public static DFAType create(@Nullable PsiType type) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/types/TypeInferenceHelper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/types/TypeInferenceHelper.java
index b4d8d61..a113fd8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/types/TypeInferenceHelper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/dataFlow/types/TypeInferenceHelper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,8 +31,10 @@
 import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
 import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
 import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrIndexProperty;
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.InstanceOfInstruction;
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction;
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.MixinTypeInstruction;
@@ -224,7 +226,7 @@
   @Nullable
   public static PsiType getInitializerType(final PsiElement element) {
     if (element instanceof GrReferenceExpression && ((GrReferenceExpression) element).getQualifierExpression() == null) {
-      return getInitializerFor(element);
+      return getInitializerTypeFor(element);
     }
 
     if (element instanceof GrVariable) {
@@ -235,9 +237,13 @@
   }
 
   @Nullable
-  public static PsiType getInitializerFor(PsiElement element) {
+  public static PsiType getInitializerTypeFor(PsiElement element) {
     final PsiElement parent = element.getParent();
     if (parent instanceof GrAssignmentExpression) {
+      if (element instanceof GrIndexProperty) {
+        final GrExpression rvalue = ((GrAssignmentExpression)parent).getRValue();
+        return rvalue != null ? rvalue.getType() : null; //don't try to infer assignment type in case of index property because of infinite recursion (example: a[2]+=4)
+      }
       return ((GrAssignmentExpression)parent).getType();
     }
 
@@ -265,6 +271,25 @@
     return null;
   }
 
+  @Nullable
+  public static GrExpression getInitializerFor(GrExpression lValue) {
+    final PsiElement parent = lValue.getParent();
+    if (parent instanceof GrAssignmentExpression) return ((GrAssignmentExpression)parent).getRValue();
+    if (parent instanceof GrTupleExpression) {
+      final int i = ((GrTupleExpression)parent).indexOf(lValue);
+      final PsiElement pparent = parent.getParent();
+      org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.LOG.assertTrue(pparent instanceof GrAssignmentExpression);
+
+      final GrExpression rValue = ((GrAssignmentExpression)pparent).getRValue();
+      if (rValue instanceof GrListOrMap && !((GrListOrMap)rValue).isMap()) {
+        final GrExpression[] initializers = ((GrListOrMap)rValue).getInitializers();
+        if (initializers.length < i) return initializers[i];
+      }
+    }
+
+    return null;
+  }
+
   static class TypeDfaInstance implements DfaInstance<TypeDfaState> {
     private final GrControlFlowOwner myScope;
     private final Instruction[] myFlow;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/expectedTypes/GroovyExpectedTypesProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/expectedTypes/GroovyExpectedTypesProvider.java
index d03a710..09ce7cc 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/expectedTypes/GroovyExpectedTypesProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/expectedTypes/GroovyExpectedTypesProvider.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,12 +15,14 @@
  */
 package org.jetbrains.plugins.groovy.lang.psi.expectedTypes;
 
-import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.Pair;
 import com.intellij.psi.*;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
@@ -66,8 +68,6 @@
  */
 public class GroovyExpectedTypesProvider {
 
-  private static final Logger LOG = Logger.getInstance(GroovyExpectedTypesProvider.class);
-
   public static TypeConstraint[] calculateTypeConstraints(@NotNull final GrExpression expression) {
     return TypeInferenceHelper.getCurrentContext().getCachedValue(expression, new Computable<TypeConstraint[]>() {
       @Override
@@ -82,7 +82,7 @@
           }
           final TypeConstraint[] result = calculator.getResult();
 
-          List<TypeConstraint> custom = new ArrayList<TypeConstraint>();
+          List<TypeConstraint> custom = ContainerUtil.newArrayList();
           for (GroovyExpectedTypesContributor contributor : GroovyExpectedTypesContributor.EP_NAME.getExtensions()) {
             custom.addAll(contributor.calculateTypeConstraints(expression));
           }
@@ -105,32 +105,6 @@
     return result;
   }
 
-  @Nullable
-  public static PsiType getExpectedClosureReturnType(GrClosableBlock closure) {
-  final Set<PsiType> expectedTypes = getDefaultExpectedTypes(closure);
-
-  List<PsiType> expectedReturnTypes = new ArrayList<PsiType>();
-  for (PsiType expectedType : expectedTypes) {
-    if (!(expectedType instanceof PsiClassType)) return null;
-
-    final PsiClassType.ClassResolveResult resolveResult = ((PsiClassType)expectedType).resolveGenerics();
-    final PsiClass resolved = resolveResult.getElement();
-    if (resolved == null || !(GroovyCommonClassNames.GROOVY_LANG_CLOSURE.equals(resolved.getQualifiedName()))) return null;
-
-    final PsiTypeParameter[] typeParameters = resolved.getTypeParameters();
-    if (typeParameters.length != 1) return null;
-
-    final PsiTypeParameter expected = typeParameters[0];
-    final PsiType expectedReturnType = resolveResult.getSubstitutor().substitute(expected);
-    if (expectedReturnType == PsiType.VOID || expectedReturnType == null) return null;
-
-    expectedReturnTypes.add(expectedReturnType);
-  }
-
-  return TypesUtil.getLeastUpperBoundNullable(expectedReturnTypes, closure.getManager());
-}
-
-
   private static class MyCalculator extends GroovyElementVisitor {
     private TypeConstraint[] myResult;
     private final GrExpression myExpression;
@@ -166,19 +140,15 @@
         if (pparent instanceof GrCall && resolvesToDefaultConstructor(((GrCall)pparent))) {
           final GroovyResolveResult resolveResult = label.advancedResolve();
           PsiElement resolved = resolveResult.getElement();
-          PsiType type;
-          if (resolved instanceof PsiField) {
-            type = ((PsiField)resolved).getType();
-          }
-          else if (resolved instanceof PsiMethod && GroovyPropertyUtils.isSimplePropertySetter((PsiMethod)resolved)) {
-            type = ((PsiMethod)resolved).getParameterList().getParameters()[0].getType();
-          }
-          else {
-            type = null;
-          }
-          type = resolveResult.getSubstitutor().substitute(type);
-          if (type != null) {
-            myResult = createSimpleSubTypeResult(type);
+          PsiType type = resolved instanceof PsiField ?
+                            ((PsiField)resolved).getType() :
+                         resolved instanceof PsiMethod && GroovyPropertyUtils.isSimplePropertySetter((PsiMethod)resolved) ?
+                            ((PsiMethod)resolved).getParameterList().getParameters()[0].getType()
+                         : null;
+
+          PsiType substituted = resolveResult.getSubstitutor().substitute(type);
+          if (substituted != null) {
+            myResult = createSimpleSubTypeResult(substituted);
           }
         }
       }
@@ -204,27 +174,12 @@
       }
 
       final GrClosableBlock[] closureArgs = methodCall.getClosureArguments();
-      //noinspection SuspiciousMethodCalls
-      final int closureIndex = Arrays.asList(closureArgs).indexOf(myExpression);
-      if (closureIndex >= 0) {
-        List<TypeConstraint> constraints = new ArrayList<TypeConstraint>();
-        for (GroovyResolveResult variant : ResolveUtil.getCallVariants(myExpression)) {
-          final GrArgumentList argumentList = methodCall.getArgumentList();
-          final GrNamedArgument[] namedArgs = argumentList == null ? GrNamedArgument.EMPTY_ARRAY : argumentList.getNamedArguments();
-          final GrExpression[] expressionArgs = argumentList == null ? GrExpression.EMPTY_ARRAY : argumentList.getExpressionArguments();
-          try {
-            final Map<GrExpression, Pair<PsiParameter, PsiType>> map =
-              GrClosureSignatureUtil.mapArgumentsToParameters(variant, methodCall, true, true, namedArgs, expressionArgs, closureArgs);
-            addConstraintsFromMap(constraints, map);
-          }
-          catch (RuntimeException e) {
-            LOG.error("call: " + methodCall.getText() + "\nsymbol: " + variant.getElement().getText(), e);
-          }
-        }
-        if (!constraints.isEmpty()) {
-          myResult = constraints.toArray(new TypeConstraint[constraints.size()]);
-        }
-
+      if (ArrayUtil.contains(myExpression, closureArgs)) {
+        final GrArgumentList argumentList = methodCall.getArgumentList();
+        final GrNamedArgument[] namedArgs = argumentList == null ? GrNamedArgument.EMPTY_ARRAY : argumentList.getNamedArguments();
+        final GrExpression[] expressionArgs = argumentList == null ? GrExpression.EMPTY_ARRAY : argumentList.getExpressionArguments();
+        final GroovyResolveResult[] callVariants = ResolveUtil.getCallVariants(myExpression);
+        processCallVariants(methodCall, callVariants, namedArgs, expressionArgs, closureArgs);
       }
     }
 
@@ -266,14 +221,7 @@
         final String name = nameValuePair.getName();
         if (name == null) return;
 
-        final PsiMethod[] attrs = annot.findMethodsByName(name, false);
-        if (attrs.length > 0) {
-          PsiType type = attrs[0].getReturnType();
-          while (type instanceof PsiArrayType) type = ((PsiArrayType)type).getComponentType();
-          if (type != null && isAcceptableAnnotationValueType(type)) {
-            myResult = createSimpleSubTypeResult(type);
-          }
-        }
+        createResultFromAttrName(annot, name);
       }
       else {
         final GrAnnotationMethod method = PsiTreeUtil.getParentOfType(arrayInitializer, GrAnnotationMethod.class);
@@ -305,30 +253,21 @@
         if (annot != null) {
           final String name = nameValuePair.getName();
           if (name != null) {
-            final PsiMethod[] attrs = annot.findMethodsByName(name, false);
-            if (attrs.length > 0) {
-              PsiType type = attrs[0].getReturnType();
-              while (type instanceof PsiArrayType) type = ((PsiArrayType)type).getComponentType();
-              if (type != null && isAcceptableAnnotationValueType(type)) {
-                myResult = createSimpleSubTypeResult(type);
-              }
-            }
+            createResultFromAttrName(annot, name);
           }
           else {
             final PsiMethod[] valueAttr = annot.findMethodsByName("value", false);
-            boolean canHaveSimpleExpr = valueAttr.length > 0;
-            final PsiMethod[] methods = annot.getMethods();
-            for (PsiMethod method : methods) {
-              if (!("value".equals(method.getName()) || method instanceof PsiAnnotationMethod && ((PsiAnnotationMethod)method).getDefaultValue() != null)) {
-                canHaveSimpleExpr = false;
-              }
-            }
+            if (valueAttr.length > 0) {
+              boolean canHaveSimpleExpr = ContainerUtil.find(annot.getMethods(), new Condition<PsiMethod>() {
+                @Override
+                public boolean value(PsiMethod method) {
+                  return !("value".equals(method.getName()) || method instanceof PsiAnnotationMethod && ((PsiAnnotationMethod)method).getDefaultValue() != null);
+                }
+              }) == null;
 
-            if (canHaveSimpleExpr) {
-              PsiType type = valueAttr[0].getReturnType();
-              while (type instanceof PsiArrayType) type = ((PsiArrayType)type).getComponentType();
-              if (type != null && isAcceptableAnnotationValueType(type)) {
-                myResult = createSimpleSubTypeResult(type);
+
+              if (canHaveSimpleExpr) {
+                createResultFromAnnotationAttribute(valueAttr[0]);
               }
             }
           }
@@ -336,6 +275,21 @@
       }
     }
 
+    private void createResultFromAttrName(PsiClass annotation, String attrName) {
+      final PsiMethod[] attrs = annotation.findMethodsByName(attrName, false);
+      if (attrs.length > 0) {
+        createResultFromAnnotationAttribute(attrs[0]);
+      }
+    }
+
+    private void createResultFromAnnotationAttribute(PsiMethod attr) {
+      PsiType type = attr.getReturnType();
+      while (type instanceof PsiArrayType) type = ((PsiArrayType)type).getComponentType();
+      if (type != null && isAcceptableAnnotationValueType(type)) {
+        myResult = createSimpleSubTypeResult(type);
+      }
+    }
+
     private static boolean isAcceptableAnnotationValueType(PsiType type) {
       //noinspection ConstantConditions
       return type instanceof PsiPrimitiveType ||
@@ -382,10 +336,18 @@
     }
 
     public void visitArgumentList(GrArgumentList list) {
-      List<TypeConstraint> constraints = new ArrayList<TypeConstraint>();
-      for (GroovyResolveResult variant : ResolveUtil.getCallVariants(list)) {
+      processCallVariants(list, ResolveUtil.getCallVariants(list), list.getNamedArguments(), list.getExpressionArguments(), GrClosableBlock.EMPTY_ARRAY);
+    }
+
+    private void processCallVariants(@NotNull PsiElement place,
+                                     @NotNull GroovyResolveResult[] variants,
+                                     @NotNull GrNamedArgument[] namedArguments,
+                                     @NotNull GrExpression[] expressionArguments,
+                                     @NotNull GrClosableBlock[] closureArguments) {
+      List<TypeConstraint> constraints = ContainerUtil.newArrayList();
+      for (GroovyResolveResult variant : variants) {
         final Map<GrExpression, Pair<PsiParameter, PsiType>> map = GrClosureSignatureUtil.mapArgumentsToParameters(
-          variant, list, true, true, list.getNamedArguments(), list.getExpressionArguments(), GrClosableBlock.EMPTY_ARRAY
+          variant, place, true, true, namedArguments, expressionArguments, closureArguments
         );
         addConstraintsFromMap(constraints, map);
       }
@@ -400,25 +362,28 @@
       final GrExpression left = expression.getLeftOperand();
       final GrExpression right = expression.getRightOperand();
 
-
-      if (type == mREGEX_FIND || type == mREGEX_MATCH) {
-        final PsiClassType string = TypesUtil.createType(CommonClassNames.JAVA_LANG_STRING, expression);
-        myResult = createSimpleSubTypeResult(string);
-        return;
-      }
-
       final GrExpression other = myExpression == left ? right : left;
       final PsiType otherType = other != null ? other.getType() : null;
 
       if (otherType == null) return;
 
-      if (type== mPLUS && otherType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
-        final PsiClassType obj = TypesUtil.getJavaLangObject(expression);
-        myResult = createSimpleSubTypeResult(obj);
-        return;
+      final GroovyResolveResult[] callVariants = expression.multiResolve(true);
+      if (myExpression == left || callVariants.length == 0) {
+        if (type == mPLUS && otherType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
+          final PsiClassType obj = TypesUtil.getJavaLangObject(expression);
+          myResult = createSimpleSubTypeResult(obj);
+        }
+        else if (type == mREGEX_FIND || type == mREGEX_MATCH) {
+          final PsiClassType string = TypesUtil.createType(CommonClassNames.JAVA_LANG_STRING, expression);
+          myResult = createSimpleSubTypeResult(string);
+        }
+        else {
+          myResult = createSimpleSubTypeResult(otherType);
+        }
       }
-
-      myResult = createSimpleSubTypeResult(otherType);
+      else { //myExpression == right
+        processCallVariants(expression,  callVariants, GrNamedArgument.EMPTY_ARRAY, new GrExpression[]{myExpression}, GrClosableBlock.EMPTY_ARRAY);
+      }
     }
 
     @Override
@@ -548,7 +513,8 @@
     @Override
     public void visitCaseLabel(GrCaseLabel caseLabel) {
       final PsiElement parent = caseLabel.getParent().getParent();
-      assert parent instanceof GrSwitchStatement : parent + " of class " + parent.getClass();
+      if (!(parent instanceof GrSwitchStatement)) return;
+
       final GrExpression condition = ((GrSwitchStatement)parent).getCondition();
       if (condition == null) return;
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnnotationUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnnotationUtil.java
index eb1f818..387db84 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnnotationUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnnotationUtil.java
@@ -44,4 +44,14 @@
     }
     return null;
   }
+
+  @Nullable
+  public static Boolean inferBooleanAttribute(@NotNull PsiAnnotation annotation, @NotNull String attributeName) {
+    final PsiAnnotationMemberValue targetValue = annotation.findAttributeValue(attributeName);
+    if (targetValue instanceof PsiLiteral) {
+      final Object value = ((PsiLiteral)targetValue).getValue();
+      if (value instanceof Boolean) return (Boolean)value;
+    }
+    return null;
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnonymousClassType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnonymousClassType.java
index fd6ee28..529b060 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnonymousClassType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrAnonymousClassType.java
@@ -74,6 +74,7 @@
     return new GrAnonymousClassType(languageLevel, myScope, myFacade, myAnonymous);
   }
 
+  @NotNull
   @Override
   public String getInternalCanonicalText() {
     return getCanonicalText();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClassReferenceType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClassReferenceType.java
index 4c02980..67be74d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClassReferenceType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClassReferenceType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,22 +40,13 @@
     myReferenceElement = referenceElement;
   }
 
+  @Override
   @Nullable
   public PsiClass resolve() {
-    ResolveResult[] results = multiResolve();
-    if (results.length == 1) {
-      PsiElement only = results[0].getElement();
-      return only instanceof PsiClass ? (PsiClass) only : null;
-    }
-
-    return null;
+    return resolveGenerics().getElement();
   }
 
-  //reference resolve is cached
-  private GroovyResolveResult[] multiResolve() {
-    return myReferenceElement.multiResolve(false);
-  }
-
+  @Override
   @Nullable
   public String getClassName() {
     final PsiClass resolved = resolve();
@@ -63,47 +54,58 @@
     return myReferenceElement.getReferenceName();
   }
 
+  @Override
   @NotNull
   public PsiType[] getParameters() {
     return myReferenceElement.getTypeArguments();
   }
 
+  @Override
   @NotNull
   public ClassResolveResult resolveGenerics() {
     final GroovyResolveResult resolveResult = myReferenceElement.advancedResolve();
     return new ClassResolveResult() {
+      @Override
       public PsiClass getElement() {
         final PsiElement resolved = resolveResult.getElement();
         return resolved instanceof PsiClass ? (PsiClass)resolved : null;
       }
 
+      @Override
+      @NotNull
       public PsiSubstitutor getSubstitutor() {
         return resolveResult.getSubstitutor();
       }
 
+      @Override
       public boolean isPackagePrefixPackageReference() {
         return false;
       }
 
+      @Override
       public boolean isAccessible() {
         return resolveResult.isAccessible();
       }
 
+      @Override
       public boolean isStaticsScopeCorrect() {
         return resolveResult.isStaticsOK();
       }
 
+      @Override
       @Nullable
       public PsiElement getCurrentFileResolveScope() {
         return resolveResult.getCurrentFileResolveContext();
       }
 
+      @Override
       public boolean isValidResult() {
         return isStaticsScopeCorrect() && isAccessible();
       }
     };
   }
 
+  @Override
   @NotNull
   public PsiClassType rawType() {
     final PsiClass clazz = resolve();
@@ -115,38 +117,48 @@
     return this;
   }
 
+  @NotNull
+  @Override
   public String getPresentableText() {
     return PsiNameHelper.getPresentableText(myReferenceElement.getReferenceName(), PsiAnnotation.EMPTY_ARRAY, myReferenceElement.getTypeArguments());
   }
 
+  @Override
   @NotNull
   public String getCanonicalText() {
     return myReferenceElement.getCanonicalText();
   }
 
+  @NotNull
+  @Override
   public String getInternalCanonicalText() {
     return getCanonicalText();
   }
 
+  @Override
   public boolean isValid() {
     return myReferenceElement.isValid();
   }
 
-  public boolean equalsToText(@NonNls String text) {
+  @Override
+  public boolean equalsToText(@NotNull @NonNls String text) {
     return text.endsWith(getPresentableText()) && //optimization
         text.equals(getCanonicalText());
   }
 
+  @Override
   @NotNull
   public GlobalSearchScope getResolveScope() {
     return myReferenceElement.getResolveScope();
   }
 
+  @Override
   @NotNull
   public LanguageLevel getLanguageLevel() {
     return myLanguageLevel;
   }
 
+  @Override
   @NotNull
   public PsiClassType setLanguageLevel(@NotNull final LanguageLevel languageLevel) {
     return new GrClassReferenceType(myReferenceElement,languageLevel);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java
index 04db427..e2efdad 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrClosureType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,10 +39,10 @@
  * @author ven
  */
 public class GrClosureType extends GrLiteralClassType {
-  private final @NotNull GrSignature mySignature;
-  private PsiType[] myTypeArgs = null;
+  private final GrSignature mySignature;
+  private volatile PsiType[] myTypeArgs = null;
 
-  private GrClosureType(@NotNull LanguageLevel languageLevel,
+  private GrClosureType(LanguageLevel languageLevel,
                         @NotNull GlobalSearchScope scope,
                         @NotNull JavaPsiFacade facade,
                         @NotNull GrSignature closureSignature,
@@ -52,21 +52,24 @@
     if (!shouldInferTypeParameters) myTypeArgs = PsiType.EMPTY_ARRAY;
   }
 
+  private GrClosureType(LanguageLevel level,
+                        @NotNull GlobalSearchScope scope,
+                        @NotNull JavaPsiFacade facade,
+                        @NotNull GrSignature signature,
+                        @NotNull PsiType[] typeArgs) {
+    super(level, scope, facade);
+
+    mySignature = signature;
+    myTypeArgs = typeArgs;
+  }
+
+  @Override
   @NotNull
   public String getClassName() {
     return "Closure";
   }
 
   @Override
-  public int getParameterCount() {
-    if (myTypeArgs != null) {
-      return myTypeArgs.length;
-    }
-
-    final PsiClass psiClass = resolve();
-    return psiClass != null && psiClass.getTypeParameters().length == 1 ? 1 : 0;
-  }
-
   @NotNull
   public PsiType[] getParameters() {
     if (myTypeArgs == null) {
@@ -75,11 +78,12 @@
     return myTypeArgs;
   }
 
+  @NotNull
   private PsiType[] inferParameters() {
     final PsiClass psiClass = resolve();
     if (psiClass != null && psiClass.getTypeParameters().length == 1) {
       final PsiType type = GrClosureSignatureUtil.getReturnType(mySignature);
-      if (type == PsiType.NULL) {
+      if (type == PsiType.NULL || type == null) {
         return new PsiType[]{null};
       }
       else {
@@ -97,6 +101,7 @@
     return GroovyCommonClassNames.GROOVY_LANG_CLOSURE;
   }
 
+  @Override
   @NotNull
   public PsiClassType rawType() {
     if (myTypeArgs != null && myTypeArgs.length == 0) {
@@ -106,11 +111,13 @@
     return new GrClosureType(getLanguageLevel(), getResolveScope(), myFacade, mySignature, false);
   }
 
-  @Nullable
+  @Override
+  @NotNull
   public String getInternalCanonicalText() {
     return getCanonicalText();
   }
 
+  @Override
   public boolean isValid() {
     return mySignature.isValid();
   }
@@ -123,15 +130,15 @@
     return super.equals(obj);
   }
 
-  public boolean equalsToText(@NonNls String text) {
+  @Override
+  public boolean equalsToText(@NotNull @NonNls String text) {
     return text != null && text.equals(GroovyCommonClassNames.GROOVY_LANG_CLOSURE);
   }
 
+  @Override
   @NotNull
   public PsiClassType setLanguageLevel(@NotNull final LanguageLevel languageLevel) {
-    final GrClosureType result = create(mySignature, myScope, myFacade, languageLevel, true);
-    result.myTypeArgs = this.myTypeArgs;
-    return result;
+    return new GrClosureType(languageLevel, myScope, myFacade, mySignature, myTypeArgs);
   }
 
   public static GrClosureType create(GroovyResolveResult[] results, GroovyPsiElement context) {
@@ -187,9 +194,7 @@
   public PsiType curry(@NotNull PsiType[] args, int position, @NotNull GroovyPsiElement context) {
     final GrSignature newSignature = mySignature.curry(args, position, context);
     if (newSignature == null) return null;
-    final GrClosureType result = create(newSignature, myScope, myFacade, myLanguageLevel, true);
-    result.myTypeArgs = this.myTypeArgs;
-    return result;
+    return new GrClosureType(myLanguageLevel, myScope, myFacade, newSignature, myTypeArgs);
   }
 
   @NotNull
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrLiteralClassType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrLiteralClassType.java
index 55c8d34..8559f53 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrLiteralClassType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrLiteralClassType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@
   protected final JavaPsiFacade myFacade;
   private final GroovyPsiManager myGroovyPsiManager;
 
-  public GrLiteralClassType(@NotNull LanguageLevel languageLevel, @NotNull GlobalSearchScope scope, @NotNull JavaPsiFacade facade) {
+  public GrLiteralClassType(LanguageLevel languageLevel, @NotNull GlobalSearchScope scope, @NotNull JavaPsiFacade facade) {
     super(languageLevel);
     myScope = scope;
     myFacade = facade;
@@ -43,61 +43,75 @@
   @NotNull
   protected abstract String getJavaClassName();
 
+  @Override
   @NotNull
   public ClassResolveResult resolveGenerics() {
     final PsiClass myBaseClass = resolve();
-    final PsiSubstitutor substitutor;
-    if (myBaseClass != null) {
-      final PsiType[] typeArgs = getParameters();
-      final PsiTypeParameter[] typeParams = myBaseClass.getTypeParameters();
-      if (typeParams.length == typeArgs.length) {
-        substitutor = PsiSubstitutor.EMPTY.putAll(myBaseClass, typeArgs);
-      }
-      else {
-        substitutor = PsiSubstitutor.EMPTY;
-      }
-    }
-    else {
-      substitutor = PsiSubstitutor.EMPTY;
-    }
+    final PsiSubstitutor substitutor = inferSubstitutor(myBaseClass);
 
     return new ClassResolveResult() {
 
+      @Override
       public PsiClass getElement() {
         return myBaseClass;
       }
 
+      @Override
+      @NotNull
       public PsiSubstitutor getSubstitutor() {
         return substitutor;
       }
 
+      @Override
       public boolean isPackagePrefixPackageReference() {
         return false;
       }
 
+      @Override
       public boolean isAccessible() {
         return true;
       }
 
+      @Override
       public boolean isStaticsScopeCorrect() {
         return true;
       }
 
+      @Override
       @Nullable
       public PsiElement getCurrentFileResolveScope() {
         return null;
       }
 
+      @Override
       public boolean isValidResult() {
         return isStaticsScopeCorrect() && isAccessible();
       }
     };
   }
 
+  @NotNull
+  private PsiSubstitutor inferSubstitutor(@Nullable PsiClass myBaseClass) {
+    if (myBaseClass != null) {
+      final PsiType[] typeArgs = getParameters();
+      final PsiTypeParameter[] typeParams = myBaseClass.getTypeParameters();
+      if (typeParams.length == typeArgs.length) {
+        return PsiSubstitutor.EMPTY.putAll(myBaseClass, typeArgs);
+      }
+      else {
+        return PsiSubstitutor.EMPTY.putAll(myBaseClass, createArray(typeParams.length));
+      }
+    }
+    else {
+      return PsiSubstitutor.EMPTY;
+    }
+  }
+
   @Override
   @NotNull
   public abstract String getClassName() ;
 
+  @Override
   @NotNull
   public String getPresentableText() {
     String name = getClassName();
@@ -112,6 +126,7 @@
     }, ", ") + ">";
   }
 
+  @Override
   @NotNull
   public String getCanonicalText() {
     String name = getJavaClassName();
@@ -127,6 +142,7 @@
     return name + "<" + StringUtil.join(params, f, ", ") + ">";
   }
 
+  @Override
   @NotNull
   public LanguageLevel getLanguageLevel() {
     return myLanguageLevel;
@@ -137,20 +153,24 @@
     return myScope;
   }
 
+  @Override
   @Nullable
   public PsiClass resolve() {
     return myGroovyPsiManager.findClassWithCache(getJavaClassName(), getResolveScope());
   }
 
+  @Override
   @NotNull
   public PsiClassType rawType() {
     return myGroovyPsiManager.createTypeByFQClassName(getJavaClassName(), myScope);
   }
 
-  public boolean equalsToText(@NonNls String text) {
+  @Override
+  public boolean equalsToText(@NotNull @NonNls String text) {
     return text != null && text.equals(getJavaClassName());
   }
 
+  @Override
   @NotNull
   public GlobalSearchScope getResolveScope() {
     return myScope;
@@ -161,7 +181,7 @@
   }
 
   @NotNull
-  protected PsiType getLeastUpperBound(PsiType[] psiTypes) {
+  protected PsiType getLeastUpperBound(PsiType... psiTypes) {
     PsiType result = null;
     final PsiManager manager = getPsiManager();
     for (final PsiType other : psiTypes) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrMapType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrMapType.java
index 69f1176..1142db2 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrMapType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrMapType.java
@@ -37,8 +37,6 @@
  * @author peter
  */
 public class GrMapType extends GrLiteralClassType {
-  private static final PsiType[] RAW_PARAMETERS = new PsiType[]{null, null};
-  
   private final Map<String, PsiType> myStringEntries;
   private final List<Pair<PsiType, PsiType>> myOtherEntries;
   private final String myJavaClassName;
@@ -85,16 +83,11 @@
 
   @NotNull
   @Override
-  public PsiClassType rawType() {
-    return new GrMapType(myFacade, getResolveScope(), Collections.<String, PsiType>emptyMap(), Collections.<Pair<PsiType,PsiType>>emptyList(), getLanguageLevel());
-  }
-
-  @NotNull
-  @Override
   protected String getJavaClassName() {
     return myJavaClassName;
   }
 
+  @Override
   @NotNull
   public String getClassName() {
     return StringUtil.getShortName(myJavaClassName);
@@ -118,7 +111,7 @@
       result.add(entry.first);
     }
     result.remove(null);
-    return result.toArray(new PsiType[result.size()]);
+    return result.toArray(createArray(result.size()));
   }
 
   public PsiType[] getAllValueTypes() {
@@ -128,23 +121,26 @@
       result.add(entry.second);
     }
     result.remove(null);
-    return result.toArray(new PsiType[result.size()]);
+    return result.toArray(createArray(result.size()));
   }
 
+  @Override
   @NotNull
   public PsiType[] getParameters() {
     final PsiType[] keyTypes = getAllKeyTypes();
     final PsiType[] valueTypes = getAllValueTypes();
     if (keyTypes.length == 0 && valueTypes.length == 0) {
-      return RAW_PARAMETERS;
+      return EMPTY_ARRAY;
     }
 
     return new PsiType[]{getLeastUpperBound(keyTypes), getLeastUpperBound(valueTypes)};
   }
 
+  @Override
+  @NotNull
   public String getInternalCanonicalText() {
-    if (myStringEntries.size() == 0) {
-      if (myOtherEntries.size() == 0) return "[:]";
+    if (myStringEntries.isEmpty()) {
+      if (myOtherEntries.isEmpty()) return "[:]";
       String name = getJavaClassName();
       final PsiType[] params = getParameters();
       return name + "<" + getInternalText(params[0]) + ", " + getInternalText(params[1]) + ">";
@@ -167,6 +163,7 @@
     return param == null ? "null" : param.getInternalCanonicalText();
   }
 
+  @Override
   public boolean isValid() {
     for (PsiType type : myStringEntries.values()) {
       if (type != null && !type.isValid()) {
@@ -185,6 +182,7 @@
     return true;
   }
 
+  @Override
   @NotNull
   public PsiClassType setLanguageLevel(@NotNull final LanguageLevel languageLevel) {
     return new GrMapType(myFacade, getResolveScope(), myStringEntries, myOtherEntries, languageLevel);
@@ -197,6 +195,7 @@
     return super.equals(obj);
   }
 
+  @Override
   public boolean isAssignableFrom(@NotNull PsiType type) {
     return type instanceof GrMapType || super.isAssignableFrom(type);
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrPsiTypeStub.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrPsiTypeStub.java
new file mode 100644
index 0000000..aceb5b5
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrPsiTypeStub.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl;
+
+import com.intellij.psi.PsiAnnotation;
+import com.intellij.psi.PsiType;
+import com.intellij.psi.PsiTypeVisitor;
+import com.intellij.psi.search.GlobalSearchScope;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class GrPsiTypeStub extends PsiType {
+  public GrPsiTypeStub() {
+    super(PsiAnnotation.EMPTY_ARRAY);
+  }
+
+  @NotNull
+  @Override
+  public String getPresentableText() {
+    return "?";
+  }
+
+  @NotNull
+  @Override
+  public String getCanonicalText() {
+    return "?";
+  }
+
+  @NotNull
+  @Override
+  public String getInternalCanonicalText() {
+    return "?";
+  }
+
+  @Override
+  public boolean isValid() {
+    return true;
+  }
+
+  @Override
+  public boolean equalsToText(@NotNull @NonNls String text) {
+    return false;
+  }
+
+  @Override
+  public <A> A accept(@NotNull PsiTypeVisitor<A> visitor) {
+    return null;
+  }
+
+  @Nullable
+  @Override
+  public GlobalSearchScope getResolveScope() {
+    return null;
+  }
+
+  @NotNull
+  @Override
+  public PsiType[] getSuperTypes() {
+    return EMPTY_ARRAY;
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrRangeType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrRangeType.java
index bdd9368..9abcedf 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrRangeType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrRangeType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.JavaPsiFacade;
+import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiClassType;
 import com.intellij.psi.PsiType;
 import com.intellij.psi.search.GlobalSearchScope;
@@ -33,11 +34,13 @@
  * @author Maxim.Medvedev
  */
 public class GrRangeType extends GrLiteralClassType {
-  private final @Nullable PsiType myLeft;
-  private final @Nullable PsiType myRight;
+  @Nullable private final PsiType myLeft;
+  @Nullable private final PsiType myRight;
   private final PsiType myIterationType;
   private final String myQualifiedName;
 
+  private final PsiType[] myParameters;
+
   public GrRangeType(LanguageLevel languageLevel,
                      GlobalSearchScope scope,
                      JavaPsiFacade facade,
@@ -53,6 +56,8 @@
     else {
       myQualifiedName = GroovyCommonClassNames.GROOVY_LANG_OBJECT_RANGE;
     }
+
+    myParameters = inferParameters();
   }
 
   public GrRangeType(GlobalSearchScope scope, JavaPsiFacade facade, @Nullable PsiType left, @Nullable PsiType right) {
@@ -74,7 +79,16 @@
   @NotNull
   @Override
   public PsiType[] getParameters() {
-    return PsiType.EMPTY_ARRAY;
+    return myParameters;
+  }
+
+  private PsiType[] inferParameters() {
+    if (myIterationType == null) return EMPTY_ARRAY;
+
+    PsiClass resolved = resolve();
+    if (resolved == null || resolved.getTypeParameters().length == 0) return EMPTY_ARRAY;
+
+    return new PsiType[]{myIterationType};
   }
 
   @NotNull
@@ -83,6 +97,7 @@
     return new GrRangeType(languageLevel, myScope, myFacade, myLeft, myRight);
   }
 
+  @NotNull
   @Override
   public String getInternalCanonicalText() {
     return "[" +
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrReferenceElementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrReferenceElementImpl.java
index ada7e75..05e634b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrReferenceElementImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrReferenceElementImpl.java
@@ -41,6 +41,7 @@
     super(node);
   }
 
+  @Override
   public PsiReference getReference() {
     return this;
   }
@@ -52,6 +53,7 @@
     super.subtreeChanged();
   }
 
+  @Override
   public String getReferenceName() {
     PsiElement nameElement = getReferenceNameElement();
     if (nameElement != null) {
@@ -60,10 +62,12 @@
     return null;
   }
 
+  @Override
   public PsiElement getElement() {
     return this;
   }
 
+  @Override
   public TextRange getRangeInElement() {
     final PsiElement refNameElement = getReferenceNameElement();
     if (refNameElement != null) {
@@ -73,6 +77,7 @@
     return new TextRange(0, getTextLength());
   }
 
+  @Override
   public PsiElement handleElementRenameSimple(String newElementName) throws IncorrectOperationException {
     PsiElement nameElement = getReferenceNameElement();
     if (nameElement != null) {
@@ -92,10 +97,12 @@
     return this;
   }
 
+  @Override
   public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
     return handleElementRenameSimple(newElementName);
   }
 
+  @Override
   public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
     if (isReferenceTo(element)) return this;
     final boolean fullyQualified = isFullyQualified();
@@ -151,6 +158,7 @@
 
   public abstract boolean isFullyQualified();
 
+  @Override
   @NotNull
   public PsiType[] getTypeArguments() {
     final GrTypeArgumentList typeArgsList = getTypeArgumentList();
@@ -158,7 +166,7 @@
 
     final GrTypeElement[] args = typeArgsList.getTypeArgumentElements();
     if (args.length == 0) return PsiType.EMPTY_ARRAY;
-    PsiType[] result = new PsiType[args.length];
+    PsiType[] result = PsiType.createArray(args.length);
     for (int i = 0; i < result.length; i++) {
       result[i] = args[i].getType();
     }
@@ -166,15 +174,18 @@
     return result;
   }
 
+  @Override
   @Nullable
   public GrTypeArgumentList getTypeArgumentList() {
     return (GrTypeArgumentList)findChildByType(GroovyElementTypes.TYPE_ARGUMENTS);
   }
 
+  @Override
   public void setQualifier(@Nullable Q newQualifier) {
     PsiImplUtil.setQualifier(this, newQualifier);
   }
 
+  @Override
   public String getClassNameText() {
     String cachedQName = myCachedQName;
     if (cachedQName == null) {
@@ -191,6 +202,7 @@
     return whiteSpaceAndComments;
   }
 
+  @Override
   public boolean isQualified() {
     return getQualifier() != null;
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrSpreadType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrSpreadType.java
deleted file mode 100644
index 99b1556..0000000
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrSpreadType.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2000-2012 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jetbrains.plugins.groovy.lang.psi.impl;
-
-import com.intellij.openapi.project.Project;
-import com.intellij.pom.java.LanguageLevel;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.PsiClassType;
-import com.intellij.psi.PsiType;
-import com.intellij.psi.search.GlobalSearchScope;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
-
-/**
- * @author Max Medvedev
- */
-public class GrSpreadType extends GrLiteralClassType {
-
-  private PsiType myType;
-
-  public GrSpreadType(PsiType original, PsiType containerType, GlobalSearchScope scope) {
-    this(original, containerType, LanguageLevel.JDK_1_5, scope, JavaPsiFacade.getInstance(scope.getProject()));
-  }
-
-  public GrSpreadType(PsiType original, PsiType containerType, LanguageLevel languageLevel, GlobalSearchScope scope, JavaPsiFacade facade) {
-    super(languageLevel, scope, facade);
-
-    final Project project = facade.getProject();
-    myType = TypesUtil.createSimilarCollection(containerType, project, original);
-  }
-
-  @NotNull
-  @Override
-  protected String getJavaClassName() {
-    return null;  //To change body of implemented methods use File | Settings | File Templates.
-  }
-
-  @NotNull
-  @Override
-  public String getClassName() {
-    return null;  //To change body of implemented methods use File | Settings | File Templates.
-  }
-
-  @NotNull
-  @Override
-  public PsiType[] getParameters() {
-    return new PsiType[0];  //To change body of implemented methods use File | Settings | File Templates.
-  }
-
-  @NotNull
-  @Override
-  public PsiClassType setLanguageLevel(@NotNull LanguageLevel languageLevel) {
-    return null;  //To change body of implemented methods use File | Settings | File Templates.
-  }
-
-  @Override
-  public String getInternalCanonicalText() {
-    return null;  //To change body of implemented methods use File | Settings | File Templates.
-  }
-
-  @Override
-  public boolean isValid() {
-    return false;  //To change body of implemented methods use File | Settings | File Templates.
-  }
-}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrTupleType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrTupleType.java
index 0be4a66..1b444cd 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrTupleType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GrTupleType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,8 +31,8 @@
  * @author ven
  */
 public class GrTupleType extends GrLiteralClassType {
-  private static final PsiType[] RAW_PARAMETERS = new PsiType[]{null};
   private final PsiType[] myComponentTypes;
+  private final PsiType[] myParameters;
 
   public GrTupleType(PsiType[] componentTypes, JavaPsiFacade facade, GlobalSearchScope scope) {
     this(componentTypes, facade, scope,LanguageLevel.JDK_1_5);
@@ -40,6 +40,8 @@
   public GrTupleType(PsiType[] componentTypes, JavaPsiFacade facade, GlobalSearchScope scope,LanguageLevel languageLevel) {
     super(languageLevel, scope, facade);
     myComponentTypes = componentTypes;
+
+    myParameters = inferParameters();
   }
 
   @NotNull
@@ -48,25 +50,27 @@
     return CommonClassNames.JAVA_UTIL_ARRAY_LIST;
   }
 
-  @NotNull
   @Override
-  public PsiClassType rawType() {
-    return new GrTupleType(RAW_PARAMETERS, myFacade, getResolveScope(), getLanguageLevel());
-  }
-
   @NotNull
   public String getClassName() {
     return StringUtil.getShortName(getJavaClassName());
   }
 
+  @Override
   @NotNull
   public PsiType[] getParameters() {
-    if (myComponentTypes.length == 0) return RAW_PARAMETERS;
+    return myParameters;
+  }
+
+  private PsiType[] inferParameters() {
+    if (myComponentTypes.length == 0) return PsiType.EMPTY_ARRAY;
     final PsiType leastUpperBound = getLeastUpperBound(myComponentTypes);
-    if (leastUpperBound == PsiType.NULL) return RAW_PARAMETERS;
+    if (leastUpperBound == PsiType.NULL) return EMPTY_ARRAY;
     return new PsiType[]{leastUpperBound};
   }
 
+  @Override
+  @NotNull
   public String getInternalCanonicalText() {
     StringBuilder builder = new StringBuilder();
     builder.append("[");
@@ -83,6 +87,7 @@
     return builder.toString();
   }
 
+  @Override
   public boolean isValid() {
     for (PsiType initializer : myComponentTypes) {
       if (initializer != null && !initializer.isValid()) return false;
@@ -90,6 +95,7 @@
     return true;
   }
 
+  @Override
   @NotNull
   public PsiClassType setLanguageLevel(@NotNull final LanguageLevel languageLevel) {
     return new GrTupleType(myComponentTypes, myFacade, myScope,languageLevel);
@@ -106,6 +112,7 @@
     return super.equals(obj);
   }
 
+  @Override
   public boolean isAssignableFrom(@NotNull PsiType type) {
     if (type instanceof GrTupleType) {
       PsiType[] otherComponents = ((GrTupleType) type).myComponentTypes;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyDirectInheritorsSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyDirectInheritorsSearcher.java
index cc03c9a..0b54659 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyDirectInheritorsSearcher.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyDirectInheritorsSearcher.java
@@ -51,7 +51,7 @@
     final String name = clazz.getName();
     if (name == null) return Collections.emptyList();
     final ArrayList<PsiClass> inheritors = new ArrayList<PsiClass>();
-    for (GrReferenceList list : StubIndex.getInstance().safeGet(GrDirectInheritorsIndex.KEY, name, clazz.getProject(), scope,
+    for (GrReferenceList list : StubIndex.getElements(GrDirectInheritorsIndex.KEY, name, clazz.getProject(), scope,
                                                       GrReferenceList.class)) {
       final PsiElement parent = list.getParent();
       if (parent instanceof GrTypeDefinition) {
@@ -59,7 +59,7 @@
       }
     }
     final Collection<GrAnonymousClassDefinition> classes =
-      StubIndex.getInstance().get(GrAnonymousClassIndex.KEY, name, clazz.getProject(), scope);
+      StubIndex.getElements(GrAnonymousClassIndex.KEY, name, clazz.getProject(), scope, GrAnonymousClassDefinition.class);
     for (GrAnonymousClassDefinition aClass : classes) {
       inheritors.add(aClass);
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileBaseImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileBaseImpl.java
index 9641abf..764e321 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileBaseImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileBaseImpl.java
@@ -144,17 +144,17 @@
 
   public void removeImport(GrImportStatement importStatement) throws IncorrectOperationException {
     PsiElement before = importStatement;
-    while (isWhiteSpace(before.getPrevSibling())) {
+    while (isWhiteSpaceOrNls(before.getPrevSibling())) {
       before = before.getPrevSibling();
     }
 
     if (hasElementType(before.getPrevSibling(), GroovyTokenTypes.mSEMI)) before = before.getPrevSibling();
-    if (isWhiteSpace(before.getPrevSibling())) before = before.getPrevSibling();
+    if (isWhiteSpaceOrNls(before.getPrevSibling())) before = before.getPrevSibling();
 
     PsiElement after = importStatement;
-    if (isWhiteSpace(after.getNextSibling())) after = after.getNextSibling();
+    if (isWhiteSpaceOrNls(after.getNextSibling())) after = after.getNextSibling();
     if (hasElementType(after.getNextSibling(), GroovyTokenTypes.mSEMI)) after = after.getNextSibling();
-    while (isWhiteSpace(after.getNextSibling())) after = after.getNextSibling();
+    while (isWhiteSpaceOrNls(after.getNextSibling())) after = after.getNextSibling();
 
 
     if (before == null) before = importStatement;
@@ -243,8 +243,7 @@
 
   public Instruction[] getControlFlow() {
     assert isValid();
-    SoftReference<Instruction[]> flow = myControlFlow;
-    Instruction[] result = flow != null ? flow.get() : null;
+    Instruction[] result = SoftReference.dereference(myControlFlow);
     if (result == null) {
       result = new ControlFlowBuilder(getProject()).buildControlFlow(this);
       myControlFlow = new SoftReference<Instruction[]>(result);
@@ -272,11 +271,11 @@
     final PackageEntry[] entries = layoutTable.getEntries();
 
     PsiElement prev = result.getPrevSibling();
-    while (isWhiteSpace(prev)) {
+    while (isWhiteSpaceOrNls(prev)) {
       prev = prev.getPrevSibling();
     }
     if (hasElementType(prev, GroovyTokenTypes.mSEMI)) prev = prev.getPrevSibling();
-    if (isWhiteSpace(prev)) prev = prev.getPrevSibling();
+    if (isWhiteSpaceOrNls(prev)) prev = prev.getPrevSibling();
 
     if (prev instanceof GrImportStatement) {
       final int idx_before = getPackageEntryIdx(entries, (GrImportStatement)prev);
@@ -284,9 +283,9 @@
       final int spaceCount = getMaxSpaceCount(entries, idx_before, idx);
 
       //skip space and semicolon after import
-      if (isWhiteSpace(prev.getNextSibling()) && hasElementType(prev.getNextSibling().getNextSibling(), GroovyTokenTypes.mSEMI)) prev = prev.getNextSibling().getNextSibling();
+      if (isWhiteSpaceOrNls(prev.getNextSibling()) && hasElementType(prev.getNextSibling().getNextSibling(), GroovyTokenTypes.mSEMI)) prev = prev.getNextSibling().getNextSibling();
       final FileASTNode node = getNode();
-      while (isWhiteSpace(prev.getNextSibling())) {
+      while (isWhiteSpaceOrNls(prev.getNextSibling())) {
         node.removeChild(prev.getNextSibling().getNode());
       }
       node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), result.getNode());
@@ -299,9 +298,9 @@
     final PackageEntry[] entries = layoutTable.getEntries();
 
     PsiElement next = result.getNextSibling();
-    if (isWhiteSpace(next)) next = next.getNextSibling();
+    if (isWhiteSpaceOrNls(next)) next = next.getNextSibling();
     if (hasElementType(next, GroovyTokenTypes.mSEMI)) next = next.getNextSibling();
-    while (isWhiteSpace(next)) {
+    while (isWhiteSpaceOrNls(next)) {
       next = next.getNextSibling();
     }
     if (next instanceof GrImportStatement) {
@@ -311,7 +310,7 @@
 
 
       final FileASTNode node = getNode();
-      while (isWhiteSpace(next.getPrevSibling())) {
+      while (isWhiteSpaceOrNls(next.getPrevSibling())) {
         node.removeChild(next.getPrevSibling().getNode());
       }
       node.addLeaf(GroovyTokenTypes.mNLS, StringUtil.repeat("\n", spaceCount + 1), next.getNode());
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java
index b59c3ce..9728c54 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyFileImpl.java
@@ -17,6 +17,7 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl;
 
 import com.intellij.lang.ASTNode;
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
@@ -64,9 +65,7 @@
 import org.jetbrains.plugins.groovy.lang.resolve.processors.ClassHint;
 
 import javax.swing.*;
-import java.util.ArrayList;
 import java.util.Comparator;
-import java.util.List;
 import java.util.concurrent.ConcurrentMap;
 
 import static org.jetbrains.plugins.groovy.editor.GroovyImportHelper.processImplicitImports;
@@ -296,11 +295,12 @@
   }
 
   public GrImportStatement[] getImportStatements() {
-    List<GrImportStatement> result = new ArrayList<GrImportStatement>();
-    for (PsiElement child : getChildren()) {
-      if (child instanceof GrImportStatement) result.add((GrImportStatement)child);
+    final StubElement<?> stub = getStub();
+    if (stub != null) {
+      return stub.getChildrenByType(GroovyElementTypes.IMPORT_STATEMENT, GrImportStatement.ARRAY_FACTORY);
     }
-    return result.toArray(new GrImportStatement[result.size()]);
+
+    return calcTreeElement().getChildrenAsPsiElements(GroovyElementTypes.IMPORT_STATEMENT, GrImportStatement.ARRAY_FACTORY);
   }
 
   @Nullable
@@ -564,5 +564,13 @@
     }
     return this;
   }
+
+  @Override
+  public String toString() {
+    if (ApplicationManager.getApplication().isUnitTestMode()){
+      return super.toString();
+    }
+    return "GroovyFileImpl:" + getName();
+  }
 }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java
index dd95e4f..ec3def9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiElementFactoryImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -86,6 +86,7 @@
     myProject = project;
   }
 
+  @Override
   @NotNull
   public PsiElement createReferenceNameFromText(String refName) {
     PsiFile file = createGroovyFileChecked("a." + refName);
@@ -100,12 +101,14 @@
     return element;
   }
 
+  @Override
   public PsiElement createDocMemberReferenceNameFromText(String idText) {
     GrDocMemberReference reference = createDocMemberReferenceFromText("Foo", idText);
     LOG.assertTrue(reference != null, idText);
     return reference.getReferenceNameElement();
   }
 
+  @Override
   public GrDocMemberReference createDocMemberReferenceFromText(String className, String text) {
     PsiFile file = createGroovyFileChecked("/** @see " + className + "#" + text + " */");
     PsiElement element = file.getFirstChild();
@@ -115,6 +118,7 @@
     return PsiTreeUtil.getChildOfType(tag, GrDocMemberReference.class);
   }
 
+  @Override
   public GrDocReferenceElement createDocReferenceElementFromFQN(String qName) {
     PsiFile file = createGroovyFileChecked("/** @see " + qName + " */");
     PsiElement element = file.getFirstChild();
@@ -124,12 +128,14 @@
     return PsiTreeUtil.getChildOfType(tag, GrDocReferenceElement.class);
   }
 
+  @Override
   public GrCodeReferenceElement createReferenceElementFromText(String refName, final PsiElement context) {
     GroovyFile file = createGroovyFileChecked("(" + refName + ")foo", false, context);
     GrTypeElement typeElement = ((GrTypeCastExpression) file.getTopStatements()[0]).getCastTypeElement();
     return ((GrClassTypeElement) typeElement).getReferenceElement();
   }
 
+  @Override
   public GrReferenceExpression createReferenceExpressionFromText(String idText) {
     PsiFile file = createGroovyFileChecked(idText);
     final GrTopStatement[] statements = ((GroovyFileBase)file).getTopStatements();
@@ -137,6 +143,7 @@
     return (GrReferenceExpression) statements[0];
   }
 
+  @Override
   public GrReferenceExpression createReferenceExpressionFromText(String idText, PsiElement context) {
     GroovyFile file = createGroovyFileChecked(idText, false, context);
     GrTopStatement[] statements = file.getTopStatements();
@@ -159,6 +166,7 @@
     return createReferenceExpressionFromText(text);
   }
 
+  @Override
   @NotNull
   public GrExpression createExpressionFromText(@NotNull String text, PsiElement context) {
     GroovyFile file = createGroovyFile(text, false, context);
@@ -182,7 +190,7 @@
     final PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
     final PsiClass refClass = resolveResult.getElement();
     assert refClass != null : type;
-    return createCodeReferenceElementFromText(type.getPresentableText());
+    return createCodeReferenceElementFromText(type.getCanonicalText());
   }
 
   @NotNull
@@ -215,6 +223,7 @@
     }
   }
 
+  @Override
   public GrVariableDeclaration createVariableDeclaration(@Nullable String[] modifiers,
                                                          @Nullable GrExpression initializer,
                                                          @Nullable PsiType type,
@@ -289,6 +298,7 @@
     return enumClass.getEnumConstants()[0];
   }
 
+  @Override
   public GrVariableDeclaration createFieldDeclaration(String[] modifiers,
                                                       String identifier,
                                                       @Nullable GrExpression initializer,
@@ -336,6 +346,7 @@
     }
   }
 
+  @Override
   @Nullable
   public GrTopStatement createTopElementFromText(String text) {
     GroovyFile dummyFile = createGroovyFileChecked(text);
@@ -344,6 +355,7 @@
     return topStatements[0];
   }
 
+  @Override
   public GrClosableBlock createClosureFromText(String closureText, PsiElement context) throws IncorrectOperationException {
     GroovyFile psiFile = createGroovyFileChecked("def __hdsjfghk_sdhjfshglk_foo  = " + closureText, false, context);
     final GrStatement st = psiFile.getStatements()[0];
@@ -360,6 +372,7 @@
     return (GroovyFileImpl) factory.createFileFromText(fileName, GroovyFileType.GROOVY_FILE_TYPE, text, stamp, physical);
   }
 
+  @Override
   public GrParameter createParameter(String name,
                                      @Nullable String typeText,
                                      @Nullable String initializer,
@@ -375,7 +388,7 @@
         fileText.append(typeText).append(' ');
       }
       fileText.append(name);
-      if (initializer != null && initializer.length() > 0) {
+      if (initializer != null && !initializer.isEmpty()) {
         fileText.append(" = ").append(initializer);
       }
       fileText.append("){}");
@@ -389,6 +402,7 @@
     }
   }
 
+  @Override
   public GrCodeReferenceElement createTypeOrPackageReference(String qName) {
     try {
       final GroovyFileBase file = createGroovyFileChecked("def i = new " + qName + "()");
@@ -403,6 +417,7 @@
     }
   }
 
+  @Override
   public GrTypeDefinition createTypeDefinition(String text) throws IncorrectOperationException {
     final GroovyFileBase file = createGroovyFileChecked(text);
     final GrTypeDefinition[] classes = file.getTypeDefinitions();
@@ -410,6 +425,7 @@
     return classes[0];
   }
 
+  @Override
   @NotNull
   public GrTypeElement createTypeElement(String typeText, final PsiElement context) throws IncorrectOperationException {
     final GroovyFile file = createGroovyFileChecked("def " + typeText + " someVar", false, context);
@@ -427,6 +443,7 @@
     return element;
   }
 
+  @Override
   public GrTypeElement createTypeElement(PsiType type) throws IncorrectOperationException {
     final String typeText = getTypeText(type);
     if (typeText == null)
@@ -440,14 +457,17 @@
     return JavaPsiFacade.getElementFactory(myProject).createType(aClass);
   }
 
+  @Override
   public GrParenthesizedExpression createParenthesizedExpr(GrExpression expression) {
     return ((GrParenthesizedExpression) createExpressionFromText("(" + expression.getText() + ")"));
   }
 
+  @Override
   public PsiElement createStringLiteralForReference(String text) {
     return createLiteralFromValue(text).getFirstChild();
   }
 
+  @Override
   public PsiElement createModifierFromText(String name) {
     final GroovyFileBase file = createGroovyFileChecked(name + " foo() {}");
     final GrTopLevelDefinition[] definitions = file.getTopLevelDefinitions();
@@ -455,12 +475,14 @@
     return definitions[0].getFirstChild().getFirstChild();
   }
 
+  @Override
   public GrCodeBlock createMethodBodyFromText(String text) {
     final GroovyFileBase file = createGroovyFileChecked("def foo () {" + text + "}");
     final GrMethod method = (GrMethod) file.getTopLevelDefinitions()[0];
     return method.getBlock();
   }
 
+  @Override
   public GrVariableDeclaration createSimpleVariableDeclaration(String name, String typeText) {
     String classText;
     if (Character.isLowerCase(typeText.charAt(0))) {
@@ -474,14 +496,17 @@
     return (GrVariableDeclaration) body.getMemberDeclarations()[0];
   }
 
+  @Override
   public GrReferenceElement createPackageReferenceElementFromText(String newPackageName) {
     return ((GrPackageDefinition) createGroovyFileChecked("package " + newPackageName).getTopStatements()[0]).getPackageReference();
   }
 
+  @Override
   public PsiElement createDotToken(String newDot) {
     return createReferenceExpressionFromText("a" + newDot + "b").getDotToken();
   }
 
+  @Override
   public GrMethod createConstructorFromText(@NotNull String constructorName,
                                                      @Nullable String[] paramTypes,
                                                      String[] paramNames,
@@ -491,6 +516,7 @@
     return createConstructorFromText(constructorName, text, context);
   }
 
+  @Override
   public GrMethod createConstructorFromText(String constructorName, CharSequence constructorText, @Nullable PsiElement context) {
     GroovyFile file = createGroovyFileChecked("class " + constructorName + "{" + constructorText + "}", false, context);
     GrTopLevelDefinition definition = file.getTopLevelDefinitions()[0];
@@ -505,6 +531,7 @@
     return methods[0];
   }
 
+  @Override
   @NotNull
   public GrMethod createMethodFromText(@NotNull String methodText, @Nullable PsiElement context) {
     GroovyFile file = createGroovyFile(methodText, false, context);
@@ -523,14 +550,14 @@
   @NotNull
   @Override
   public GrAnnotation createAnnotationFromText(@NotNull @NonNls String annotationText, @Nullable PsiElement context) throws IncorrectOperationException {
-    return createMethodFromText(annotationText + " void ___shdjklf_pqweirupncp_foo() {}", context).getModifierList().getAnnotations()[0];
+    return createMethodFromText(annotationText + " void ___shdjklf_pqweirupncp_foo() {}", context).getModifierList().getRawAnnotations()[0];
   }
 
   @Override
   public GrMethod createMethodFromSignature(String name, GrClosureSignature signature) {
     StringBuilder builder = new StringBuilder("public");
     final PsiType returnType = signature.getReturnType();
-    if (returnType != null) {
+    if (returnType != null && returnType != PsiType.NULL) {
       builder.append(' ');
       builder.append(returnType.getCanonicalText());
     }
@@ -579,17 +606,20 @@
   /**
    * use createGroovyFileChecked() inside GroovyPsiElementFactoryImpl instead of this method
    */
+  @Override
   public GroovyFile createGroovyFile(CharSequence idText, boolean isPhysical, @Nullable PsiElement context) {
     GroovyFileImpl file = createDummyFile(idText, isPhysical);
     file.setContext(context);
     return file;
   }
 
+  @Override
   public PsiElement createWhiteSpace() {
     PsiFile dummyFile = createDummyFile(" ", false);
     return dummyFile.getFirstChild();
   }
 
+  @Override
   @NotNull
   public PsiElement createLineTerminator(int length) {
 
@@ -601,6 +631,7 @@
     return createLineTerminator(text);
   }
 
+  @Override
   @NotNull
   public PsiElement createLineTerminator(String text) {
     PsiFile dummyFile = createGroovyFileChecked(text);
@@ -609,6 +640,7 @@
     return child;
   }
 
+  @Override
   public GrArgumentList createExpressionArgumentList(GrExpression... expressions) {
     StringBuilder text = new StringBuilder();
     text.append("ven (");
@@ -624,6 +656,7 @@
     return (((GrMethodCallExpression) file.getChildren()[0])).getArgumentList();
   }
 
+  @Override
   public GrNamedArgument createNamedArgument(@NotNull final String name, final GrExpression expression) {
     PsiFile file = createGroovyFileChecked("foo (" + name + ":" + expression.getText() + ")");
     assert file.getChildren()[0] != null;
@@ -631,6 +664,7 @@
     return call.getArgumentList().getNamedArguments()[0];
   }
 
+  @Override
   public GrStatement createStatementFromText(CharSequence text) {
     return createStatementFromText(text, null);
   }
@@ -648,6 +682,7 @@
     return (GrStatement)statements[0];
   }
 
+  @Override
   public GrBlockStatement createBlockStatement(@NonNls GrStatement... statements) {
     StringBuilder text = new StringBuilder();
     text.append("while (true) { \n");
@@ -660,6 +695,7 @@
     return (GrBlockStatement) ((GrWhileStatement) file.getChildren()[0]).getBody();
   }
 
+  @Override
   public GrMethodCallExpression createMethodCallByAppCall(GrApplicationStatement callExpr) {
     StringBuilder text = new StringBuilder();
     text.append(callExpr.getInvokedExpression().getText());
@@ -741,10 +777,12 @@
     return sections[0];
   }
 
+  @Override
   public GrImportStatement createImportStatementFromText(@NotNull String qName, boolean isStatic, boolean isOnDemand, String alias) {
     return createImportStatement(qName, isStatic, isOnDemand, alias, null);
   }
 
+  @Override
   public GrImportStatement createImportStatementFromText(@NotNull String text) {
     PsiFile dummyFile = createGroovyFileChecked(text);
     return ((GrImportStatement) dummyFile.getFirstChild());
@@ -825,6 +863,7 @@
     return builder;
   }
 
+  @Override
   public GrMethod createMethodFromText(String modifier, String name, @Nullable String type, String[] paramTypes, PsiElement context) {
     PsiType psiType;
     List<PsiType> res = new ArrayList<PsiType>();
@@ -840,11 +879,12 @@
       res.add(psiType);
     }
 
-    String[] paramNames = QuickfixUtil.getMethodArgumentsNames(myProject, res.toArray(new PsiType[res.size()]));
+    String[] paramNames = QuickfixUtil.getMethodArgumentsNames(myProject, res.toArray(PsiType.createArray(res.size())));
     final CharSequence text = generateMethodText(modifier, name, type, paramTypes, paramNames, null, false);
     return createMethodFromText(text.toString(), context);
   }
 
+  @Override
   @NotNull
   public GrDocComment createDocCommentFromText(@NotNull String text) {
     return (GrDocComment)createGroovyFileChecked(text).getFirstChild();
@@ -899,6 +939,7 @@
     return ((GrCall)createExpressionFromText("foo()")).getArgumentList();
   }
 
+  @Override
   public GrArgumentList createArgumentListFromText(String argListText) {
     try {
       return ((GrCall)createExpressionFromText("foo " + argListText)).getArgumentList();
@@ -965,9 +1006,9 @@
 
   @NotNull
   @Override
-  public PsiField createField(@NotNull @NonNls String name, @NotNull PsiType type) throws IncorrectOperationException {
+  public GrField createField(@NotNull @NonNls String name, @NotNull PsiType type) throws IncorrectOperationException {
     final GrVariableDeclaration fieldDeclaration = createFieldDeclaration(ArrayUtil.EMPTY_STRING_ARRAY, name, null, type);
-    return (PsiField)fieldDeclaration.getVariables()[0];
+    return (GrField)fieldDeclaration.getVariables()[0];
   }
 
   @NotNull
@@ -1007,7 +1048,7 @@
 
   @NotNull
   @Override
-  public PsiMethod createConstructor() {
+  public GrMethod createConstructor() {
     return createConstructorFromText("Foo", "Foo(){}", null);
   }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiManager.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiManager.java
index d1822bb..bb8e0c3 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiManager.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyPsiManager.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -77,11 +77,13 @@
     myProject = project;
 
     ((PsiManagerEx)PsiManager.getInstance(myProject)).registerRunnableToRunOnAnyChange(new Runnable() {
+      @Override
       public void run() {
         dropTypesCache();
       }
     });
     ((PsiManagerEx)PsiManager.getInstance(myProject)).registerRunnableToRunOnChange(new Runnable() {
+      @Override
       public void run() {
         myClassCache.clear();
       }
@@ -89,6 +91,7 @@
 
     final MessageBusConnection connection = myProject.getMessageBus().connect();
     connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
+      @Override
       public void rootsChanged(ModuleRootEvent event) {
         dropTypesCache();
         myClassCache.clear();
@@ -185,8 +188,8 @@
     return result;
   }
 
+  private static final PsiType UNKNOWN_TYPE = new GrPsiTypeStub();
 
-  private static final PsiType UNKNOWN_TYPE = new PsiPrimitiveType("unknown type", PsiAnnotation.EMPTY_ARRAY);
   @Nullable
   public <T extends GroovyPsiElement> PsiType getType(@NotNull T element, @NotNull Function<T, PsiType> calculator) {
     PsiType type = myCalculatedTypes.get(element);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyResolveResultImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyResolveResultImpl.java
index ee45530..a50d882 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyResolveResultImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/GroovyResolveResultImpl.java
@@ -31,6 +31,8 @@
   private final PsiElement myElement;
   private final boolean myIsAccessible;
   private final boolean myIsStaticsOK;
+  private final boolean myIsApplicable;
+
   private final PsiSubstitutor mySubstitutor;
   private final boolean myIsInvokedOnProperty;
 
@@ -38,7 +40,7 @@
   private final SpreadState mySpreadState;
 
   public GroovyResolveResultImpl(@NotNull PsiElement element, boolean isAccessible) {
-    this(element, null, null, PsiSubstitutor.EMPTY, isAccessible, true, false);
+    this(element, null, null, PsiSubstitutor.EMPTY, isAccessible, true, false, true);
   }
 
   public GroovyResolveResultImpl(@NotNull PsiElement element,
@@ -47,11 +49,11 @@
                                  @NotNull PsiSubstitutor substitutor,
                                  boolean isAccessible,
                                  boolean staticsOK) {
-    this(element, resolveContext, spreadState, substitutor, isAccessible, staticsOK, false);
+    this(element, resolveContext, spreadState, substitutor, isAccessible, staticsOK, false, true);
   }
 
   public GroovyResolveResultImpl(PsiClassType.ClassResolveResult classResolveResult) {
-    this(classResolveResult.getElement(), null, null, classResolveResult.getSubstitutor(), classResolveResult.isAccessible(), classResolveResult.isStaticsScopeCorrect(), false);
+    this(classResolveResult.getElement(), null, null, classResolveResult.getSubstitutor(), classResolveResult.isAccessible(), classResolveResult.isStaticsScopeCorrect(), false, classResolveResult.isValidResult());
   }
 
   public GroovyResolveResultImpl(@NotNull PsiElement element,
@@ -60,7 +62,8 @@
                                  @NotNull PsiSubstitutor substitutor,
                                  boolean isAccessible,
                                  boolean staticsOK,
-                                 boolean isInvokedOnProperty) {
+                                 boolean isInvokedOnProperty,
+                                 boolean isApplicable) {
     myCurrentFileResolveContext = resolveContext;
     myElement = element;
     myIsAccessible = isAccessible;
@@ -68,6 +71,7 @@
     myIsStaticsOK = staticsOK;
     myIsInvokedOnProperty = isInvokedOnProperty;
     mySpreadState = spreadState;
+    myIsApplicable = isApplicable;
   }
 
   @NotNull
@@ -83,13 +87,18 @@
     return myIsStaticsOK;
   }
 
+  @Override
+  public boolean isApplicable() {
+    return myIsApplicable;
+  }
+
   @Nullable
   public PsiElement getElement() {
     return myElement;
   }
 
   public boolean isValidResult() {
-    return isAccessible();
+    return isAccessible() && isApplicable() && isStaticsOK();
   }
 
   public boolean equals(Object o) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/InferenceContext.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/InferenceContext.java
index 3f8eb9c..1dd57fc 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/InferenceContext.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/InferenceContext.java
@@ -141,8 +141,7 @@
       return _getCachedValue(element, new Computable<PsiType>() {
         @Override
         public PsiType compute() {
-          PsiType type = calculator.fun(element);
-          return type == PsiType.NULL ? null : type;
+          return calculator.fun(element);
         }
       }, "type");
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java
index 3525c44..5eaa8f2 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/PsiImplUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,6 +49,8 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrCondition;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrConstructorInvocation;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
@@ -74,9 +76,6 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.util.GrNamedArgumentsOwner;
 import org.jetbrains.plugins.groovy.lang.psi.api.util.GrStatementOwner;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.arithmetic.GrAdditiveExpressionImpl;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.arithmetic.GrMultiplicativeExpressionImpl;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.arithmetic.GrRangeExpressionImpl;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals.GrLiteralImpl;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrSyntheticCodeBlock;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrSyntheticExpression;
@@ -95,6 +94,8 @@
 import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*;
 import static org.jetbrains.plugins.groovy.lang.lexer.TokenSets.RELATIONS;
 import static org.jetbrains.plugins.groovy.lang.lexer.TokenSets.SHIFT_SIGNS;
+import static org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames.GROOVY_LANG_IMMUTABLE;
+import static org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames.GROOVY_TRANSFORM_IMMUTABLE;
 
 public class PsiImplUtil {
   private static final Logger LOG = Logger.getInstance("org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil");
@@ -271,20 +272,11 @@
 
   private static boolean isNotAssociative(GrBinaryExpression binaryExpression) {
     final IElementType opToken = binaryExpression.getOperationTokenType();
-    if (binaryExpression instanceof GrMultiplicativeExpressionImpl) {
-      return opToken != mSTAR;
-    }
-    if (binaryExpression instanceof GrAdditiveExpressionImpl) {
-      return opToken == mMINUS;
-    }
-    return RELATIONS.contains(opToken) || opToken == mCOMPARE_TO
-           || opToken == mREGEX_FIND || opToken == mREGEX_MATCH
-           || SHIFT_SIGNS.contains(opToken)
-           || opToken==mSTAR;
+    return !TokenSets.ASSOCIATIVE_BINARY_OP_SET.contains(opToken);
   }
 
   @Nullable
-  public static GrExpression getRuntimeQualifier(GrReferenceExpression refExpr) {
+  public static GrExpression getRuntimeQualifier(@NotNull GrReferenceExpression refExpr) {
     GrExpression qualifier = refExpr.getQualifierExpression();
     if (qualifier != null) return qualifier;
 
@@ -360,12 +352,11 @@
   }
 
   private static int getExprPriorityLevel(GrExpression expr) {
-    int priority = 0;
+    int priority;
     //if (expr instanceof GrNewExpression) priority = 1;
     if (expr instanceof GrUnaryExpression) priority = ((GrUnaryExpression)expr).isPostfix() ? 5 : 6;
     else if (expr instanceof GrTypeCastExpression) priority = 6;
 
-    else if (expr instanceof GrRangeExpressionImpl) priority = 11;
 
     else if (expr instanceof GrBinaryExpression) {
       final IElementType opToken = ((GrBinaryExpression)expr).getOperationTokenType();
@@ -374,6 +365,7 @@
       else if (opToken == mSTAR || opToken == mDIV) priority = 8;
       else if (opToken == mPLUS || opToken == mMINUS) priority = 9;
       else if (SHIFT_SIGNS.contains(opToken)) priority = 10;
+      else if (opToken == mRANGE_EXCLUSIVE || opToken == mRANGE_INCLUSIVE) priority = 11;
       else if (RELATIONS.contains(opToken)) priority = 12;
       else if (opToken == mEQUAL || opToken == mNOT_EQUAL || opToken == mCOMPARE_TO) priority = 13;
       else if (opToken == mREGEX_FIND || opToken == mREGEX_MATCH) priority = 14;
@@ -382,11 +374,16 @@
       else if (opToken == mBOR) priority = 17;
       else if (opToken == mLAND) priority = 18;
       else if (opToken == mLOR) priority = 19;
+      else {
+        assert false :"unknown operation:"+opToken;
+        priority = 0;
+      }
     }
     else if (expr instanceof GrConditionalExpression) priority = 20;
     else if (expr instanceof GrSafeCastExpression) priority = 21;
     else if (expr instanceof GrAssignmentExpression) priority = 22;
     else if (expr instanceof GrApplicationStatement) priority = 23;
+    else priority = 0;
 
     return -priority;
   }
@@ -580,7 +577,7 @@
     if (block == null) return null;
 
     final SoftReference<PsiCodeBlock> ref = block.getUserData(PSI_CODE_BLOCK);
-    final PsiCodeBlock body = ref == null ? null : ref.get();
+    final PsiCodeBlock body = SoftReference.dereference(ref);
     if (body != null) return body;
     final GrSyntheticCodeBlock newBody = new GrSyntheticCodeBlock(block);
     block.putUserData(PSI_CODE_BLOCK, new SoftReference<PsiCodeBlock>(newBody));
@@ -591,7 +588,7 @@
     if (typeElement == null) return null;
 
     final SoftReference<PsiTypeElement> ref = typeElement.getUserData(PSI_TYPE_ELEMENT);
-    final PsiTypeElement element = ref == null ? null : ref.get();
+    final PsiTypeElement element = SoftReference.dereference(ref);
     if (element != null) return element;
     final GrSyntheticTypeElement newTypeElement = new GrSyntheticTypeElement(typeElement);
     typeElement.putUserData(PSI_TYPE_ELEMENT, new SoftReference<PsiTypeElement>(newTypeElement));
@@ -602,7 +599,7 @@
     if (expr == null) return null;
 
     final SoftReference<PsiExpression> ref = expr.getUserData(PSI_EXPRESSION);
-    final PsiExpression element = ref == null ? null : ref.get();
+    final PsiExpression element = SoftReference.dereference(ref);
     if (element != null) return element;
     final GrSyntheticExpression newExpr = new GrSyntheticExpression(expr);
     expr.putUserData(PSI_EXPRESSION, new SoftReference<PsiExpression>(newExpr));
@@ -613,7 +610,7 @@
     if (list == null) return null;
 
     final SoftReference<PsiReferenceList> ref = list.getUserData(PSI_REFERENCE_LIST);
-    final PsiReferenceList element = ref == null ? null : ref.get();
+    final PsiReferenceList element = SoftReference.dereference(ref);
     if (element != null) return element;
     final GrSyntheticReferenceList newList = new GrSyntheticReferenceList(list, role);
     list.putUserData(PSI_REFERENCE_LIST, new SoftReference<PsiReferenceList>(newList));
@@ -754,10 +751,6 @@
     return type;
   }
 
-  public static boolean isWhiteSpace(@Nullable PsiElement element) {
-    return hasElementType(element, TokenSets.WHITE_SPACES_SET);
-  }
-
   public static boolean hasElementType(@Nullable PsiElement next, @NotNull final IElementType type) {
     if (next == null) return false;
     final ASTNode astNode = next.getNode();
@@ -842,4 +835,49 @@
 
     return null;
   }
+
+  public static boolean hasImmutableAnnotation(PsiModifierList modifierList) {
+    return modifierList.findAnnotation(GROOVY_LANG_IMMUTABLE) != null ||
+           modifierList.findAnnotation(GROOVY_TRANSFORM_IMMUTABLE) != null;
+  }
+
+  public static boolean isWhiteSpaceOrNls(@Nullable PsiElement sibling) {
+    return sibling != null && isWhiteSpaceOrNls(sibling.getNode());
+  }
+
+  public static boolean isWhiteSpaceOrNls(@Nullable ASTNode node) {
+    return node != null && TokenSets.WHITE_SPACES_SET.contains(node.getElementType());
+  }
+
+  public static void insertPlaceHolderToModifierListAtEndIfNeeded(GrModifierList modifierList) {
+    PsiElement newLineAfterModifierList = findNewLineAfterElement(modifierList);
+    if (newLineAfterModifierList != null) {
+      modifierList.setModifierProperty(GrModifier.DEF, false);
+
+      if (modifierList.getModifiers().length > 0) {
+        modifierList.getNode().addLeaf(mNLS, newLineAfterModifierList.getText(), null);
+      }
+      modifierList.getNode().addLeaf(kDEF, "def", null);
+      final PsiElement newLineUpdated = findNewLineAfterElement(modifierList);
+      if (newLineUpdated != null) newLineUpdated.delete();
+      if (!isWhiteSpaceOrNls(modifierList.getNextSibling())) {
+        modifierList.getParent().getNode().addLeaf(TokenType.WHITE_SPACE, " ", modifierList.getNextSibling().getNode());
+      }
+    }
+    else if (modifierList.getModifiers().length == 0) {
+      modifierList.setModifierProperty(GrModifier.DEF, true);
+    }
+  }
+
+  @Nullable
+  private static PsiElement findNewLineAfterElement(PsiElement element) {
+    PsiElement sibling = element.getNextSibling();
+    while (sibling != null && isWhiteSpaceOrNls(sibling)) {
+      if (PsiUtil.isNewLine(sibling)) {
+        return sibling;
+      }
+      sibling = sibling.getNextSibling();
+    }
+    return null;
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/GrListOrMapImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/GrListOrMapImpl.java
index 15791c2..bea29ef 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/GrListOrMapImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/GrListOrMapImpl.java
@@ -22,9 +22,12 @@
 import com.intellij.psi.impl.source.tree.LeafPsiElement;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.tree.TokenSet;
+import com.intellij.psi.util.CachedValueProvider;
+import com.intellij.psi.util.CachedValuesManager;
 import com.intellij.psi.util.InheritanceUtil;
+import com.intellij.psi.util.PsiModificationTracker;
 import com.intellij.util.Function;
-import com.intellij.util.ReflectionCache;
+import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.findUsages.LiteralConstructorReference;
@@ -46,7 +49,6 @@
 import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 
-import java.lang.reflect.Array;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -64,6 +66,7 @@
     super(node);
   }
 
+  @Override
   public void accept(GroovyElementVisitor visitor) {
     visitor.visitListOrMap(this);
   }
@@ -98,10 +101,12 @@
     super.deleteChildInternal(child);
   }
 
+  @Override
   public PsiType getType() {
     return TypeInferenceHelper.getCurrentContext().getExpressionType(this, TYPES_CALCULATOR);
   }
 
+  @Override
   public boolean isMap() {
     return findChildByType(MAP_LITERAL_TOKEN_SET) != null;
   }
@@ -116,15 +121,19 @@
     return findChildByType(GroovyTokenTypes.mRBRACK);
   }
 
+  @Override
   @NotNull
   public GrExpression[] getInitializers() {
-    List<GrExpression> result = new ArrayList<GrExpression>();
+    List<GrExpression> result = ContainerUtil.newArrayList();
     for (PsiElement cur = getFirstChild(); cur != null; cur = cur.getNextSibling()) {
-      if (ReflectionCache.isInstance(cur, GrExpression.class)) result.add((GrExpression)cur);
+      if (cur instanceof GrExpression) {
+        result.add((GrExpression)cur);
+      }
     }
-    return result.toArray((GrExpression[]) Array.newInstance(GrExpression.class, result.size()));
+    return result.toArray(new GrExpression[result.size()]);
   }
 
+  @Override
   @NotNull
   public GrNamedArgument[] getNamedArguments() {
     List<GrNamedArgument> result = new ArrayList<GrNamedArgument>();
@@ -141,13 +150,21 @@
 
   @Override
   public PsiReference getReference() {
+    return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiReference>() {
+      @Nullable
+      @Override
+      public Result<PsiReference> compute() {
+        return Result.create(getReferenceImpl(), PsiModificationTracker.MODIFICATION_COUNT);
+      }
+    });
+  }
+
+  @Nullable
+  private PsiReference getReferenceImpl() {
     final PsiClassType conversionType = LiteralConstructorReference.getTargetConversionType(this);
     if (conversionType == null) return null;
 
-    PsiType ownType = getType();
-    if (ownType instanceof PsiClassType) {
-      ownType = ((PsiClassType)ownType).rawType();
-    }
+    PsiType ownType = getTypeWithoutGenerics();
     if (ownType != null && TypesUtil.isAssignableWithoutConversions(conversionType.rawType(), ownType, this)) return null;
 
     final PsiClass resolved = conversionType.resolve();
@@ -159,7 +176,19 @@
     return new LiteralConstructorReference(this, conversionType);
   }
 
+  @Nullable
+  private PsiType getTypeWithoutGenerics() {
+    PsiType ownType = getType();
+    if (ownType instanceof PsiClassType) {
+      return ((PsiClassType)ownType).rawType();
+    }
+    else {
+      return ownType;
+    }
+  }
+
   private static class MyTypesCalculator implements Function<GrListOrMapImpl, PsiType> {
+    @Override
     @Nullable
     public PsiType fun(GrListOrMapImpl listOrMap) {
       final GlobalSearchScope scope = listOrMap.getResolveScope();
@@ -238,7 +267,7 @@
         }
       }
 
-      PsiType[] result = new PsiType[initializers.length];
+      PsiType[] result = PsiType.createArray(initializers.length);
       for (int i = 0; i < result.length; i++) {
         result[i] = initializers[i].getType();
       }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationImpl.java
index 674bfe6d..c672ca1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/annotation/GrAnnotationImpl.java
@@ -23,6 +23,7 @@
 import com.intellij.psi.impl.PsiImplUtil;
 import com.intellij.psi.impl.light.LightClassReference;
 import com.intellij.psi.meta.PsiMetaData;
+import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.PairFunction;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -88,35 +89,61 @@
   @Nullable
   @NonNls
   public String getQualifiedName() {
+    final GrAnnotationStub stub = getStub();
+    if (stub != null) {
+      return stub.getPsiElement().getQualifiedName();
+    }
+
     final GrCodeReferenceElement nameRef = getClassReference();
     final PsiElement resolved = nameRef.resolve();
-    if (resolved instanceof PsiClass) return ((PsiClass) resolved).getQualifiedName();
+    if (resolved instanceof PsiClass) return ((PsiClass)resolved).getQualifiedName();
     return null;
   }
 
   @Nullable
   public PsiJavaCodeReferenceElement getNameReferenceElement() {
-    final GroovyResolveResult resolveResult = getClassReference().advancedResolve();
-    final PsiElement resolved = resolveResult.getElement();
+    final GroovyResolveResult resolveResult = resolveWithStub();
 
-    if (resolved instanceof PsiClass) {
-      return new LightClassReference(getManager(), getClassReference().getText(), (PsiClass)resolved, resolveResult.getSubstitutor());
-    }
-    else {
-      return null;
-    }
+    final PsiElement resolved = resolveResult.getElement();
+    if (!(resolved instanceof PsiClass)) return null;
+
+    return new LightClassReference(getManager(), getClassReference().getText(), (PsiClass)resolved, resolveResult.getSubstitutor());
   }
 
+  @NotNull
+  private GroovyResolveResult resolveWithStub() {
+    final GrAnnotationStub stub = getStub();
+    final GrCodeReferenceElement reference = stub != null ? stub.getPsiElement().getClassReference() : getClassReference();
+    return reference.advancedResolve();
+  }
+
+  @Nullable
   public PsiAnnotationMemberValue findAttributeValue(@Nullable String attributeName) {
+    final GrAnnotationStub stub = getStub();
+    if (stub != null) {
+      final GrAnnotation stubbedPsi = stub.getPsiElement();
+      final PsiAnnotationMemberValue value = PsiImplUtil.findAttributeValue(stubbedPsi, attributeName);
+      if (value == null || !PsiTreeUtil.isAncestor(stubbedPsi, value, true)) {         // if value is a default value we can use it
+        return value;
+      }
+    }
     return PsiImplUtil.findAttributeValue(this, attributeName);
   }
 
   @Nullable
   public PsiAnnotationMemberValue findDeclaredAttributeValue(@NonNls final String attributeName) {
+    final GrAnnotationStub stub = getStub();
+    if (stub != null) {
+      final GrAnnotation stubbedPsi = stub.getPsiElement();
+      final PsiAnnotationMemberValue value = PsiImplUtil.findDeclaredAttributeValue(stubbedPsi, attributeName);
+      if (value == null) {
+        return null;
+      }
+    }
     return PsiImplUtil.findDeclaredAttributeValue(this, attributeName);
   }
 
-  public <T extends PsiAnnotationMemberValue>  T setDeclaredAttributeValue(@Nullable @NonNls String attributeName, T value) {
+  public <T extends PsiAnnotationMemberValue> T setDeclaredAttributeValue(@Nullable @NonNls String attributeName, T value) {
     return (T)PsiImplUtil.setDeclaredAttributeValue(this, attributeName, value, ANNOTATION_CREATOR);
   }
 
@@ -127,6 +154,11 @@
 
   @NotNull
   public GrCodeReferenceElement getClassReference() {
+    final GrAnnotationStub stub = getStub();
+    if (stub != null) {
+      return stub.getPsiElement().getClassReference();
+    }
+
     return findNotNullChildByClass(GrCodeReferenceElement.class);
   }
 
@@ -134,13 +166,15 @@
   public String getShortName() {
     final GrAnnotationStub stub = getStub();
     if (stub != null) {
-      return stub.getAnnotationName();
+      return stub.getPsiElement().getShortName();
     }
-    else {
-      return getClassReference().getReferenceName();
-    }
+
+    final String referenceName = getClassReference().getReferenceName();
+    assert referenceName != null;
+    return referenceName;
   }
 
+  @Nullable
   public PsiAnnotationOwner getOwner() {
     return (PsiAnnotationOwner)getParent();
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java
index c482aea..9415e88 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/auxiliary/modifiers/GrModifierListImpl.java
@@ -49,8 +49,8 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
 import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GrStubElementBase;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.stubs.GrModifierListStub;
-import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
 
 import java.util.ArrayList;
 import java.util.Map;
@@ -187,8 +187,7 @@
       }
       if (pParent instanceof GrTypeDefinition) {
         PsiModifierList pModifierList = ((GrTypeDefinition)pParent).getModifierList();
-        if (pModifierList != null && (pModifierList.findAnnotation(GroovyCommonClassNames.GROOVY_LANG_IMMUTABLE) != null ||
-                                      pModifierList.findAnnotation(GroovyCommonClassNames.GROOVY_TRANSFORM_IMMUTABLE) != null)) {
+        if (pModifierList != null && !modifierList.hasExplicitVisibilityModifiers() && PsiImplUtil.hasImmutableAnnotation(pModifierList)) {
           if (modifier.equals(GrModifier.FINAL)) return true;
         }
       }
@@ -298,7 +297,7 @@
     if (doSet) {
       if (isEmptyModifierList()) {
         final PsiElement nextSibling = getNextSibling();
-        if (nextSibling != null && !TokenSets.WHITE_SPACES_SET.contains(nextSibling.getNode().getElementType())) {
+        if (nextSibling != null && !PsiImplUtil.isWhiteSpaceOrNls(nextSibling)) {
           getNode().getTreeParent().addLeaf(TokenType.WHITE_SPACE, " ", nextSibling.getNode());
         }
       }
@@ -318,7 +317,7 @@
 
       if (isEmptyModifierList()) {
         final PsiElement nextSibling = getNextSibling();
-        if (nextSibling != null && TokenSets.WHITE_SPACES_SET.contains(nextSibling.getNode().getElementType())) {
+        if (nextSibling != null && PsiImplUtil.isWhiteSpaceOrNls(nextSibling)) {
           nextSibling.delete();
         }
       }
@@ -361,13 +360,13 @@
 
   @NotNull
   public GrAnnotation[] getAnnotations() {
-    return CachedValuesManager.getManager(getProject()).createCachedValue(new CachedValueProvider<GrAnnotation[]>() {
+    return CachedValuesManager.getCachedValue(this, new CachedValueProvider<GrAnnotation[]>() {
       @Nullable
       @Override
       public Result<GrAnnotation[]> compute() {
         return Result.create(GrAnnotationCollector.getResolvedAnnotations(GrModifierListImpl.this), PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
       }
-    }).getValue();
+    });
   }
 
   @NotNull
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosableSignatureImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosableSignatureImpl.java
new file mode 100644
index 0000000..3d1357d
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosableSignatureImpl.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.signatures;
+
+import com.intellij.psi.PsiArrayType;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiSubstitutor;
+import com.intellij.psi.PsiType;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature;
+import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature;
+import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignatureVisitor;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
+import org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter;
+
+/**
+* Created by Max Medvedev on 26/02/14
+*/
+class GrClosableSignatureImpl implements GrClosureSignature {
+  private final GrClosableBlock myBlock;
+
+  public GrClosableSignatureImpl(GrClosableBlock block) {
+    myBlock = block;
+  }
+
+  @NotNull
+  @Override
+  public PsiSubstitutor getSubstitutor() {
+    return PsiSubstitutor.EMPTY;
+  }
+
+  @NotNull
+  @Override
+  public GrClosureParameter[] getParameters() {
+    GrParameter[] parameters = myBlock.getAllParameters();
+
+    return ContainerUtil.map(parameters, new Function<GrParameter, GrClosureParameter>() {
+      @Override
+      public GrClosureParameter fun(final GrParameter parameter) {
+        return new GrClosureParameterImpl(parameter);
+      }
+    }, new GrClosureParameter[parameters.length]);
+  }
+
+  @Override
+  public int getParameterCount() {
+    return myBlock.getAllParameters().length;
+  }
+
+  @Override
+  public boolean isVarargs() {
+    GrParameter last = ArrayUtil.getLastElement(myBlock.getAllParameters());
+    return last != null && last.getType() instanceof PsiArrayType;
+  }
+
+  @Nullable
+  @Override
+  public PsiType getReturnType() {
+    return myBlock.getReturnType();
+  }
+
+  @Override
+  public boolean isCurried() {
+    return false;
+  }
+
+  @Override
+  public boolean isValid() {
+    return myBlock.isValid();
+  }
+
+  @Nullable
+  @Override
+  public GrSignature curry(@NotNull PsiType[] args, int position, @NotNull PsiElement context) {
+    return GrClosureSignatureUtil.curryImpl(this, args, position, context);
+  }
+
+  @Override
+  public void accept(GrSignatureVisitor visitor) {
+    visitor.visitClosureSignature(this);
+  }
+
+  private static class GrClosureParameterImpl implements GrClosureParameter {
+    private final GrParameter myParameter;
+
+    public GrClosureParameterImpl(GrParameter parameter) {
+      myParameter = parameter;
+    }
+
+    @Nullable
+    @Override
+    public PsiType getType() {
+      return myParameter.getType();
+    }
+
+    @Override
+    public boolean isOptional() {
+      return myParameter.isOptional();
+    }
+
+    @Nullable
+    @Override
+    public GrExpression getDefaultInitializer() {
+      return myParameter.getInitializerGroovy();
+    }
+
+    @Override
+    public boolean isValid() {
+      return myParameter.isValid();
+    }
+
+    @Nullable
+    @Override
+    public String getName() {
+      return myParameter.getName();
+    }
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosureSignatureUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosureSignatureUtil.java
index 83c5696..8f47ea0 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosureSignatureUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosureSignatureUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -50,7 +50,6 @@
 import org.jetbrains.plugins.groovy.lang.psi.impl.GrMapType;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
-import org.jetbrains.plugins.groovy.lang.psi.impl.types.GrClosureParameterImpl;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 
 import java.util.*;
@@ -98,29 +97,20 @@
     ContainerUtil.map(types, new Function<PsiType, GrClosureParameter>() {
       @Override
       public GrClosureParameter fun(PsiType type) {
-        return new GrClosureParameterImpl(type, null, false, null);
+        return new GrImmediateClosureParameterImpl(type, null, false, null);
       }
     }, parameters);
-    return new GrClosureSignatureImpl(parameters, null, false, false);
+    return new GrImmediateClosureSignatureImpl(parameters, null, false, false);
   }
 
 
+  @NotNull
   public static GrClosureSignature createSignature(final GrClosableBlock block) {
-    return new GrClosureSignatureImpl(block.getAllParameters(), null) {
-      @Override
-      public PsiType getReturnType() {
-        return block.getReturnType();
-      }
-
-      @Override
-      public boolean isValid() {
-        return block.isValid();
-      }
-    };
+    return new GrClosableSignatureImpl(block);
   }
 
   public static GrClosureSignature createSignature(final PsiMethod method, PsiSubstitutor substitutor) {
-    return new GrClosureSignatureImpl(method.getParameterList().getParameters(), null, substitutor) {
+    return new GrImmediateClosureSignatureImpl(method.getParameterList().getParameters(), null, substitutor) {
       @Override
       public PsiType getReturnType() {
         return getSubstitutor().substitute(PsiUtil.getSmartReturnType(method));
@@ -135,7 +125,7 @@
 
   public static GrClosureSignature removeParam(final GrClosureSignature signature, int i) {
     final GrClosureParameter[] newParams = ArrayUtil.remove(signature.getParameters(), i);
-    return new GrClosureSignatureImpl(newParams, null, newParams.length > 0 && signature.isVarargs(), false) {
+    return new GrImmediateClosureSignatureImpl(newParams, null, newParams.length > 0 && signature.isVarargs(), false) {
       @Override
       public PsiType getReturnType() {
         return signature.getReturnType();
@@ -150,15 +140,14 @@
 
   public static GrClosureSignature createSignatureWithErasedParameterTypes(final PsiMethod method) {
     final PsiParameter[] params = method.getParameterList().getParameters();
-    final GrClosureParameter[] closureParams = new GrClosureParameter[params.length];
-    for (int i = 0; i < params.length; i++) {
-      PsiParameter param = params[i];
-      PsiType type = TypeConversionUtil.erasure(param.getType());
-      closureParams[i] =
-        new GrClosureParameterImpl(type, GrClosureParameterImpl.getParameterName(param), GrClosureParameterImpl.isParameterOptional(param),
-                                   GrClosureParameterImpl.getDefaultInitializer(param));
-    }
-    return new GrClosureSignatureImpl(closureParams, null, GrClosureParameterImpl.isVararg(closureParams), false) {
+    final GrClosureParameter[] closureParams = ContainerUtil.map(params, new Function<PsiParameter, GrClosureParameter>() {
+      @Override
+      public GrClosureParameter fun(PsiParameter parameter) {
+        return GrImmediateClosureParameterImpl.createErasedParameter(parameter);
+      }
+    }, new GrClosureParameter[params.length]);
+
+    return new GrImmediateClosureSignatureImpl(closureParams, null, GrImmediateClosureParameterImpl.isVararg(closureParams), false) {
       @Override
       public PsiType getReturnType() {
         return PsiUtil.getSmartReturnType(method);
@@ -180,13 +169,16 @@
   @NotNull
   public static GrClosureSignature rawSignature(@NotNull final GrClosureSignature signature) {
     final GrClosureParameter[] params = signature.getParameters();
-    final GrClosureParameter[] closureParams = new GrClosureParameter[params.length];
-    for (int i = 0; i < params.length; i++) {
-      GrClosureParameter param = params[i];
-      PsiType type = TypeConversionUtil.erasure(param.getType());
-      closureParams[i] = new GrClosureParameterImpl(type, param.getName(), param.isOptional(), param.getDefaultInitializer());
-    }
-    return new GrClosureSignatureImpl(closureParams, null, GrClosureParameterImpl.isVararg(closureParams), false) {
+
+    final GrClosureParameter[] closureParams = ContainerUtil.map(params, new Function<GrClosureParameter, GrClosureParameter>() {
+      @Override
+      public GrClosureParameter fun(GrClosureParameter parameter) {
+        PsiType type = TypeConversionUtil.erasure(parameter.getType());
+        return new GrImmediateClosureParameterImpl(type, parameter.getName(), parameter.isOptional(), parameter.getDefaultInitializer());
+      }
+    }, new GrClosureParameter[params.length]);
+
+    return new GrImmediateClosureSignatureImpl(closureParams, null, GrImmediateClosureParameterImpl.isVararg(closureParams), false) {
       @Override
       public PsiType getReturnType() {
         return signature.getReturnType();
@@ -201,7 +193,7 @@
 
 
   public static GrClosureSignature createSignature(PsiParameter[] parameters, @Nullable PsiType returnType) {
-    return new GrClosureSignatureImpl(parameters, returnType);
+    return new GrImmediateClosureSignatureImpl(parameters, returnType);
   }
 
 
@@ -348,6 +340,46 @@
     return ApplicabilityResult.applicable;
   }
 
+  static GrSignature curryImpl(GrClosureSignature original, PsiType[] args, int position, PsiElement context) {
+    GrClosureParameter[] params = original.getParameters();
+
+    List<GrClosureParameter> newParams = new ArrayList<GrClosureParameter>(params.length);
+    List<GrClosureParameter> opts = new ArrayList<GrClosureParameter>(params.length);
+    List<Integer> optInds = new ArrayList<Integer>(params.length);
+
+    if (position == -1) {
+      position = params.length - args.length;
+    }
+
+    if (position < 0 || position >= params.length) return GrMultiSignature.EMPTY_SIGNATURE;
+
+    for (int i = 0; i < params.length; i++) {
+      if (params[i].isOptional()) {
+        opts.add(params[i]);
+        optInds.add(i);
+      }
+      else {
+        newParams.add(params[i]);
+      }
+    }
+
+    final PsiType rtype = original.getReturnType();
+    final ArrayList<GrClosureSignature> result = new ArrayList<GrClosureSignature>();
+    checkAndAddSignature(result, args, position, newParams, rtype, context);
+
+    for (int i = 0; i < opts.size(); i++) {
+      newParams.add(optInds.get(i), opts.get(i));
+      checkAndAddSignature(result, args, position, newParams, rtype, context);
+    }
+
+    if (result.size() == 1) {
+      return result.get(0);
+    }
+    else {
+      return new GrMultiSignatureImpl(result.toArray(new GrClosureSignature[result.size()]));
+    }
+  }
+
   public enum ApplicabilityResult {
     applicable, inapplicable, canBeApplicable, ambiguous;
 
@@ -368,7 +400,7 @@
     PsiType type;
     @Nullable Arg arg;
 
-    private ArgWrapper(PsiType type, Arg arg) {
+    private ArgWrapper(PsiType type, @Nullable Arg arg) {
       this.type = type;
       this.arg = arg;
     }
@@ -469,7 +501,7 @@
                                           int position,
                                           List<GrClosureParameter> params,
                                           PsiType returnType,
-                                          @NotNull GroovyPsiElement context) {
+                                          @NotNull PsiElement context) {
     final int last = position + args.length;
     if (last > params.size()) return;
 
@@ -487,7 +519,7 @@
       _p[j++] = params.get(i);
     }
 
-    list.add(new GrClosureSignatureImpl(_p, returnType, _p.length > 0 && _p[_p.length - 1].getType() instanceof PsiArrayType, true));
+    list.add(new GrImmediateClosureSignatureImpl(_p, returnType, _p.length > 0 && _p[_p.length - 1].getType() instanceof PsiArrayType, true));
   }
 
 
@@ -515,7 +547,7 @@
       this.context = context;
       this.params = params;
       this.args = args;
-      this.types = new PsiType[args.length];
+      this.types = PsiType.createArray(args.length);
       for (int i = 0; i < args.length; i++) {
         types[i] = typeComputer.fun(args[i]);
       }
@@ -735,6 +767,14 @@
       innerArgs.add(new InnerArg(TypeConversionUtil.erasure(closureArgument.getType()), closureArgument));
     }
 
+    return mapParametersToArguments(signature, innerArgs, hasNamedArgs, partial, context);
+  }
+
+  private static ArgInfo<PsiElement>[] mapParametersToArguments(@NotNull GrClosureSignature signature,
+                                                                @NotNull List<InnerArg> innerArgs,
+                                                                boolean hasNamedArgs,
+                                                                boolean partial,
+                                                                @NotNull PsiElement context) {
     final ArgInfo<InnerArg>[] innerMap = mapParametersToArguments(signature, innerArgs.toArray(new InnerArg[innerArgs.size()]), new Function<InnerArg, PsiType>() {
         @Override
         public PsiType fun(InnerArg o) {
@@ -819,7 +859,7 @@
                                                    List<PsiType> paramTypes,
                                                    PsiTypeParameter[] typeParameters,
                                                    PsiSubstitutor substitutor) {
-    return MethodSignatureUtil.createMethodSignature(name, paramTypes.toArray(new PsiType[paramTypes.size()]), typeParameters, substitutor);
+    return MethodSignatureUtil.createMethodSignature(name, paramTypes.toArray(PsiType.createArray(paramTypes.size())), typeParameters, substitutor);
   }
 
   public static void generateAllMethodSignaturesByClosureSignature(@NotNull String name,
@@ -866,7 +906,7 @@
   @Nullable
   public static PsiType getTypeByArg(ArgInfo<PsiElement> arg, PsiManager manager, GlobalSearchScope resolveScope) {
     if (arg.isMultiArg) {
-      if (arg.args.size() == 0) return PsiType.getJavaLangObject(manager, resolveScope).createArrayType();
+      if (arg.args.isEmpty()) return PsiType.getJavaLangObject(manager, resolveScope).createArrayType();
       PsiType leastUpperBound = null;
       PsiElement first = arg.args.get(0);
       if (first instanceof GrNamedArgument) {
@@ -887,7 +927,7 @@
       }
     }
     else {
-      if (arg.args.size() == 0) return null;
+      if (arg.args.isEmpty()) return null;
       PsiElement elem = arg.args.get(0);
       if (elem instanceof GrExpression) {
         return ((GrExpression)elem).getType();
@@ -990,7 +1030,7 @@
     return new MapResultWithError<Arg>(map, errors);
   }
 
-  public static List<GrClosureSignature> generateSimpleSignature(GrSignature signature) {
+  public static List<GrClosureSignature> generateSimpleSignatures(@NotNull GrSignature signature) {
     final List<GrClosureSignature> result = new ArrayList<GrClosureSignature>();
     signature.accept(new GrRecursiveSignatureVisitor() {
       @Override
@@ -999,17 +1039,17 @@
         final ArrayList<GrClosureParameter> parameters = new ArrayList<GrClosureParameter>(original.length);
 
         for (GrClosureParameter parameter : original) {
-          parameters.add(new GrClosureParameterImpl(parameter.getType(), parameter.getName(), false, null));
+          parameters.add(new GrImmediateClosureParameterImpl(parameter.getType(), parameter.getName(), false, null));
         }
 
         final int pcount = signature.isVarargs() ? signature.getParameterCount() - 2 : signature.getParameterCount() - 1;
         for (int i = pcount; i >= 0; i--) {
           if (original[i].isOptional()) {
-            result.add(new GrClosureSignatureImpl(parameters.toArray(new GrClosureParameter[parameters.size()]), signature.getReturnType(), signature.isVarargs(), false));
+            result.add(new GrImmediateClosureSignatureImpl(parameters.toArray(new GrClosureParameter[parameters.size()]), signature.getReturnType(), signature.isVarargs(), false));
             parameters.remove(i);
           }
         }
-        result.add(new GrClosureSignatureImpl(parameters.toArray(new GrClosureParameter[parameters.size()]), signature.getReturnType(), signature.isVarargs(), false));
+        result.add(new GrImmediateClosureSignatureImpl(parameters.toArray(new GrClosureParameter[parameters.size()]), signature.getReturnType(), signature.isVarargs(), false));
       }
     });
     return result;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrClosureParameterImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrImmediateClosureParameterImpl.java
similarity index 80%
rename from plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrClosureParameterImpl.java
rename to plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrImmediateClosureParameterImpl.java
index e5401b6..ef047f5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrClosureParameterImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrImmediateClosureParameterImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,10 +13,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.plugins.groovy.lang.psi.impl.types;
+package org.jetbrains.plugins.groovy.lang.psi.impl.signatures;
 
 import com.intellij.openapi.util.Comparing;
 import com.intellij.psi.*;
+import com.intellij.psi.util.TypeConversionUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
@@ -26,23 +27,30 @@
 /**
  * @author Maxim.Medvedev
  */
-public class GrClosureParameterImpl implements GrClosureParameter {
+public class GrImmediateClosureParameterImpl implements GrClosureParameter {
   @Nullable final PsiType myType;
   @Nullable private final String myName;
   final boolean myOptional;
   @Nullable final GrExpression myDefaultInitializer;
 
-  public GrClosureParameterImpl(@Nullable PsiType type, @Nullable String name, boolean optional, GrExpression defaultInitializer) {
+  public GrImmediateClosureParameterImpl(@Nullable PsiType type, @Nullable String name, boolean optional, GrExpression defaultInitializer) {
     myType = type;
     myName = name;
     myOptional = optional;
     myDefaultInitializer = optional ? defaultInitializer : null;
   }
 
-  public GrClosureParameterImpl(@NotNull PsiParameter parameter, @NotNull PsiSubstitutor substitutor) {
+  public GrImmediateClosureParameterImpl(@NotNull PsiParameter parameter, @NotNull PsiSubstitutor substitutor) {
     this(substitutor.substitute(getParameterType(parameter)), getParameterName(parameter), isParameterOptional(parameter), getDefaultInitializer(parameter));
   }
 
+  @NotNull
+  public static GrImmediateClosureParameterImpl createErasedParameter(@NotNull PsiParameter param) {
+    PsiType type = TypeConversionUtil.erasure(param.getType());
+    return new GrImmediateClosureParameterImpl(type, getParameterName(param), isParameterOptional(param), getDefaultInitializer(param));
+  }
+
+
   @Nullable
   private static PsiType getParameterType(@NotNull PsiParameter parameter) {
     return parameter instanceof GrParameter ? ((GrParameter)parameter).getDeclaredType() : parameter.getType();
@@ -71,7 +79,6 @@
     }
   }
 
-
   @Nullable
   public PsiType getType() {
     return myType;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosureSignatureImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrImmediateClosureSignatureImpl.java
similarity index 67%
rename from plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosureSignatureImpl.java
rename to plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrImmediateClosureSignatureImpl.java
index ddf887d..a09b2f7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrClosureSignatureImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrImmediateClosureSignatureImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,34 +20,30 @@
 import com.intellij.psi.*;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
 import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature;
-import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrMultiSignature;
 import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature;
 import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignatureVisitor;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
-import org.jetbrains.plugins.groovy.lang.psi.impl.types.GrClosureParameterImpl;
-
-import java.util.ArrayList;
-import java.util.List;
 
 /**
  * @author Maxim.Medvedev
  */
-public class GrClosureSignatureImpl implements GrClosureSignature {
+public class GrImmediateClosureSignatureImpl implements GrClosureSignature {
   private final boolean myIsVarargs;
   private final boolean myCurried;
   @Nullable private final PsiType myReturnType;
   @NotNull private final GrClosureParameter[] myParameters;
   @NotNull private final PsiSubstitutor mySubstitutor;
 
-  public GrClosureSignatureImpl(@NotNull PsiParameter[] parameters, @Nullable PsiType returnType, @NotNull PsiSubstitutor substitutor) {
+  public GrImmediateClosureSignatureImpl(@NotNull PsiParameter[] parameters,
+                                         @Nullable PsiType returnType,
+                                         @NotNull PsiSubstitutor substitutor) {
     myReturnType = substitutor.substitute(returnType);
     final int length = parameters.length;
     myParameters = new GrClosureParameter[length];
     for (int i = 0; i < length; i++) {
-      myParameters[i] = new GrClosureParameterImpl(parameters[i], substitutor);
+      myParameters[i] = new GrImmediateClosureParameterImpl(parameters[i], substitutor);
     }
     if (length > 0) {
       myIsVarargs = myParameters[length - 1].getType() instanceof PsiArrayType;
@@ -59,11 +55,11 @@
     myCurried = false;
   }
 
-  public GrClosureSignatureImpl(PsiParameter[] parameters, @Nullable PsiType returnType) {
+  public GrImmediateClosureSignatureImpl(PsiParameter[] parameters, @Nullable PsiType returnType) {
     this(parameters, returnType, PsiSubstitutor.EMPTY);
   }
 
-  GrClosureSignatureImpl(@NotNull GrClosureParameter[] params, @Nullable PsiType returnType, boolean isVarArgs, boolean isCurried) {
+  GrImmediateClosureSignatureImpl(@NotNull GrClosureParameter[] params, @Nullable PsiType returnType, boolean isVarArgs, boolean isCurried) {
     myParameters = params;
     myReturnType = returnType;
     myIsVarargs = isVarArgs;
@@ -99,44 +95,8 @@
   }
 
   @Nullable
-  public GrSignature curry(@NotNull PsiType[] args, int position, @NotNull GroovyPsiElement context) {
-    GrClosureParameter[] params = myParameters;
-
-    List<GrClosureParameter> newParams = new ArrayList<GrClosureParameter>(params.length);
-    List<GrClosureParameter> opts = new ArrayList<GrClosureParameter>(params.length);
-    List<Integer> optInds = new ArrayList<Integer>(params.length);
-
-    if (position == -1) {
-      position = params.length - args.length;
-    }
-
-    if (position < 0 || position >= params.length) return GrMultiSignature.EMPTY_SIGNATURE;
-
-    for (int i = 0; i < params.length; i++) {
-      if (params[i].isOptional()) {
-        opts.add(params[i]);
-        optInds.add(i);
-      }
-      else {
-        newParams.add(params[i]);
-      }
-    }
-
-    final PsiType rtype = getReturnType();
-    final ArrayList<GrClosureSignature> result = new ArrayList<GrClosureSignature>();
-    GrClosureSignatureUtil.checkAndAddSignature(result, args, position, newParams, rtype, context);
-
-    for (int i = 0; i < opts.size(); i++) {
-      newParams.add(optInds.get(i), opts.get(i));
-      GrClosureSignatureUtil.checkAndAddSignature(result, args, position, newParams, rtype, context);
-    }
-
-    if (result.size() == 1) {
-      return result.get(0);
-    }
-    else {
-      return new GrMultiSignatureImpl(result.toArray(new GrClosureSignature[result.size()]));
-    }
+  public GrSignature curry(@NotNull PsiType[] args, int position, @NotNull PsiElement context) {
+    return GrClosureSignatureUtil.curryImpl(this, args, position, context);
   }
 
   public boolean isValid() {
@@ -173,7 +133,7 @@
         final PsiType type = GenericsUtil.getGreatestLowerBound(parameters1[i].getType(), parameters2[i].getType());
         boolean opt = parameters1[i].isOptional() && parameters2[i].isOptional();
         String name = StringUtil.equals(parameters1[i].getName(), parameters2[i].getName()) ? parameters1[i].getName() : null;
-        params[i] = new GrClosureParameterImpl(type, name, opt, null);
+        params[i] = new GrImmediateClosureParameterImpl(type, name, opt, null);
       }
       final PsiType s1type = signature1.getReturnType();
       final PsiType s2type = signature2.getReturnType();
@@ -182,7 +142,7 @@
         returnType = TypesUtil.getLeastUpperBound(s1type, s2type, manager);
       }
       boolean isVarArgs = signature1.isVarargs() && signature2.isVarargs();
-      return new GrClosureSignatureImpl(params, returnType, isVarArgs, false);
+      return new GrImmediateClosureSignatureImpl(params, returnType, isVarArgs, false);
     }
     return null; //todo
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrMultiSignatureImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrMultiSignatureImpl.java
index c944410..7667510 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrMultiSignatureImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/signatures/GrMultiSignatureImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,9 @@
  */
 package org.jetbrains.plugins.groovy.lang.psi.impl.signatures;
 
+import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiType;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
 import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature;
 import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrMultiSignature;
 import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature;
@@ -51,7 +51,7 @@
   }
 
   @Override
-  public GrSignature curry(@NotNull PsiType[] args, int position, @NotNull GroovyPsiElement context) {
+  public GrSignature curry(@NotNull PsiType[] args, int position, @NotNull PsiElement context) {
     List<GrClosureSignature> newClosures = new ArrayList<GrClosureSignature>();
 
     for (GrClosureSignature old : mySignatures) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrClassInitializerImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrClassInitializerImpl.java
index 499c892..f896a80 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrClassInitializerImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrClassInitializerImpl.java
@@ -29,6 +29,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrClassInitializer;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
 import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 
@@ -71,6 +72,11 @@
     return null;
   }
 
+  @Override
+  public GrMember[] getMembers() {
+    return new GrMember[]{this};
+  }
+
   @NotNull
   public GrModifierList getModifierList() {
     return findNotNullChildByClass(GrModifierList.class);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrConstructorInvocationImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrConstructorInvocationImpl.java
index a591ed5..98763e5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrConstructorInvocationImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrConstructorInvocationImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -69,6 +69,7 @@
   }
 
 
+  @NotNull
   public GrReferenceExpression getInvokedExpression() {
     return findNotNullChildByClass(GrReferenceExpression.class);
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrFieldImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrFieldImpl.java
index 38439f1..7e85203 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrFieldImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrFieldImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
 import com.intellij.psi.search.SearchScope;
 import com.intellij.psi.stubs.IStubElementType;
 import com.intellij.ui.LayeredIcon;
+import com.intellij.util.Function;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.ContainerUtil;
 import icons.JetgroovyIcons;
@@ -43,6 +44,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
+import org.jetbrains.plugins.groovy.lang.psi.dataFlow.types.TypeInferenceHelper;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrAccessorMethodImpl;
 import org.jetbrains.plugins.groovy.lang.psi.stubs.GrFieldStub;
 import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrVariableEnhancer;
@@ -57,10 +59,8 @@
  * Date: 25.05.2007
  */
 public class GrFieldImpl extends GrVariableBaseImpl<GrFieldStub> implements GrField, StubBasedPsiElement<GrFieldStub> {
-  private GrAccessorMethod mySetter;
-  private GrAccessorMethod[] myGetters;
-
-  private boolean mySetterInitialized = false;
+  private volatile GrAccessorMethod mySetter;
+  private volatile GrAccessorMethod[] myGetters;
 
   public GrFieldImpl(@NotNull ASTNode node) {
     super(node);
@@ -142,12 +142,23 @@
 
   @Override
   public PsiType getTypeGroovy() {
-    if (getDeclaredType() == null && getInitializerGroovy() == null) {
-      final PsiType type = GrVariableEnhancer.getEnhancedType(this);
-      if (type != null) {
-        return type;
+    PsiType type = TypeInferenceHelper.getCurrentContext().getExpressionType(this, new Function<GrFieldImpl, PsiType>() {
+      @Override
+      public PsiType fun(GrFieldImpl field) {
+        if (getDeclaredType() == null && getInitializerGroovy() == null) {
+          final PsiType type = GrVariableEnhancer.getEnhancedType(field);
+          if (type != null) {
+            return type;
+          }
+        }
+        return null;
       }
+    });
+
+    if (type != null) {
+      return type;
     }
+
     return super.getTypeGroovy();
   }
 
@@ -177,16 +188,13 @@
   }
 
   public GrAccessorMethod getSetter() {
-    if (mySetterInitialized) return mySetter;
-
-    mySetter = GrAccessorMethodImpl.createSetterMethod(this);
-    mySetterInitialized = true;
-
+    if (mySetter == null) {
+      mySetter = GrAccessorMethodImpl.createSetterMethod(this);
+    }
     return mySetter;
   }
 
   public void clearCaches() {
-    mySetterInitialized = false;
     mySetter = null;
     myGetters = null;
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrIfStatementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrIfStatementImpl.java
index 0c2789a..ce98c9c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrIfStatementImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrIfStatementImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
 import com.intellij.lang.ASTNode;
 import com.intellij.psi.PsiElement;
 import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.ReflectionCache;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
@@ -66,7 +65,7 @@
   public GrStatement getThenBranch() {
     List<GrStatement> statements = new ArrayList<GrStatement>();
     for (PsiElement cur = getFirstChild(); cur != null; cur = cur.getNextSibling()) {
-      if (ReflectionCache.isInstance(cur, GrStatement.class)) statements.add((GrStatement)cur);
+      if (GrStatement.class.isInstance(cur)) statements.add((GrStatement)cur);
     }
 
     if (getCondition() == null && statements.size() > 0) return statements.get(0);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableBaseImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableBaseImpl.java
index 1f97eb4..d08d29a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableBaseImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableBaseImpl.java
@@ -279,11 +279,6 @@
     return JetgroovyIcons.Groovy.Variable;
   }
 
-  public PsiType getTypeNoResolve() {
-    return getType();
-  }
-
-
   @Nullable
   private GrVariableDeclaration getDeclaration() {
     PsiElement parent = getParent();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationImpl.java
index 1ab1a1a..990876d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrVariableDeclarationImpl.java
@@ -42,6 +42,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
@@ -85,7 +86,7 @@
 
   @NotNull
   public GrModifierList getModifierList() {
-    return (GrModifierList)findNotNullChildByType(GroovyElementTypes.MODIFIERS);
+    return getRequiredStubOrPsiChild(GroovyElementTypes.MODIFIERS);
   }
 
   @Override
@@ -192,7 +193,7 @@
                                      @NotNull ResolveState state,
                                      PsiElement lastParent,
                                      @NotNull PsiElement place) {
-    if (lastParent != null && lastParent == getTupleInitializer()) {
+    if (lastParent != null && !(getParent() instanceof GrTypeDefinitionBody) && lastParent == getTupleInitializer()) {
       return true;
     }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrWhileStatementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrWhileStatementImpl.java
index 1a36d72..696e94d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrWhileStatementImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/GrWhileStatementImpl.java
@@ -26,6 +26,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrCondition;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrWhileStatement;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
 import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
@@ -50,13 +51,13 @@
   }
 
   @Nullable
-  public GrCondition getCondition() {
+  public GrExpression getCondition() {
     PsiElement lParenth = getLParenth();
 
     if (lParenth == null) return null;
     PsiElement afterLParenth = PsiUtil.skipWhitespacesAndComments(lParenth.getNextSibling(), true);
 
-    if (afterLParenth instanceof GrCondition) return ((GrCondition) afterLParenth);
+    if (afterLParenth instanceof GrExpression) return ((GrExpression) afterLParenth);
 
     return null;
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelManipulator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelManipulator.java
index bc43ac6..0da73fe 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelManipulator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentLabelManipulator.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.jetbrains.plugins.groovy.lang.psi.impl.statements.arguments;
 
 import com.intellij.openapi.util.TextRange;
@@ -5,6 +20,7 @@
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.impl.source.tree.LeafPsiElement;
 import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentLabel;
 import org.jetbrains.plugins.groovy.lang.resolve.GroovyStringLiteralManipulator;
@@ -13,8 +29,9 @@
  * @author peter
  */
 public class GrArgumentLabelManipulator extends AbstractElementManipulator<GrArgumentLabel> {
+  @NotNull
   @Override
-  public TextRange getRangeInElement(GrArgumentLabel element) {
+  public TextRange getRangeInElement(@NotNull GrArgumentLabel element) {
     final PsiElement nameElement = element.getNameElement();
     if (nameElement instanceof LeafPsiElement && TokenSets.STRING_LITERAL_SET.contains(((LeafPsiElement)nameElement).getElementType())) {
       return GroovyStringLiteralManipulator.getLiteralRange(nameElement.getText());
@@ -23,7 +40,8 @@
     return super.getRangeInElement(element);
   }
 
-  public GrArgumentLabel handleContentChange(GrArgumentLabel element, TextRange range, String newContent)
+  @Override
+  public GrArgumentLabel handleContentChange(@NotNull GrArgumentLabel element, @NotNull TextRange range, String newContent)
     throws IncorrectOperationException {
     element.setName(newContent);
     return element;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentListImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentListImpl.java
index 3f09e10..79e6457 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentListImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrArgumentListImpl.java
@@ -209,7 +209,7 @@
       ASTNode prev = TreeUtil.skipElementsBack(child.getTreePrev(), TokenSets.WHITE_SPACES_OR_COMMENTS);
       if (prev != null && prev.getElementType() == mCOMMA) {
         final ASTNode pprev = prev.getTreePrev();
-        if (pprev != null && TokenSets.WHITE_SPACES_SET.contains(pprev.getElementType())) {
+        if (pprev != null && PsiImplUtil.isWhiteSpaceOrNls(pprev)) {
           super.deleteChildInternal(pprev);
         }
         super.deleteChildInternal(prev);
@@ -218,7 +218,7 @@
         ASTNode next = TreeUtil.skipElements(child.getTreeNext(), TokenSets.WHITE_SPACES_OR_COMMENTS);
         if (next != null && next.getElementType() == mCOMMA) {
           final ASTNode nnext = next.getTreeNext();
-          if (nnext != null && TokenSets.WHITE_SPACES_SET.contains(nnext.getElementType())) {
+          if (nnext != null && PsiImplUtil.isWhiteSpaceOrNls(nnext)) {
             super.deleteChildInternal(nnext);
           }
           super.deleteChildInternal(next);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrSpreadArgumentImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrSpreadArgumentImpl.java
index 3cf36fa..2e675d3 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrSpreadArgumentImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/arguments/GrSpreadArgumentImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 import com.intellij.lang.ASTNode;
 import com.intellij.psi.PsiType;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrSpreadArgument;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
@@ -56,4 +57,9 @@
   public String toString() {
     return "Spread argument";
   }
+
+  @Override
+  public void accept(GroovyElementVisitor visitor) {
+    visitor.visitSpreadArgument(this);
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java
index d2a514e..2cfbec5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrClosableBlockImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -118,7 +118,7 @@
                                      @NotNull PsiScopeProcessor nonCodeProcessor,
                                      @NotNull ResolveState state,
                                      @NotNull PsiElement place) {
-    GrDelegatesToUtil.DelegatesToInfo info = GrDelegatesToUtil.getDelegateToInfo(place, this);
+    GrDelegatesToUtil.DelegatesToInfo info = GrDelegatesToUtil.getDelegatesToInfo(place, this);
     if (info == null) {
       return null;
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrDelegatesToUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrDelegatesToUtil.java
index 01b96c5..313065af 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrDelegatesToUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/blocks/GrDelegatesToUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -44,7 +44,7 @@
  */
 public class GrDelegatesToUtil {
   @Nullable
-  static DelegatesToInfo getDelegateToInfo(@NotNull PsiElement place, @NotNull final GrClosableBlock closableBlock) {
+  static DelegatesToInfo getDelegatesToInfo(@NotNull PsiElement place, @NotNull final GrClosableBlock closableBlock) {
     GrCall call = getContainingCall(closableBlock);
     if (call == null) return null;
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java
index 4b7efe4..5362eb7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/CompleteReferenceExpression.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
+import com.intellij.psi.impl.source.resolve.FileContextUtil;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.util.InheritanceUtil;
 import com.intellij.psi.util.PsiTreeUtil;
@@ -75,10 +76,10 @@
   private CompleteReferenceExpression() {
   }
 
-  public static void processVariants(PrefixMatcher matcher,
-                                     final Consumer<LookupElement> consumer,
-                                     GrReferenceExpressionImpl refExpr,
-                                     CompletionParameters parameters) {
+  public static void processVariants(@NotNull PrefixMatcher matcher,
+                                     @NotNull final Consumer<LookupElement> consumer,
+                                     @NotNull GrReferenceExpressionImpl refExpr,
+                                     @NotNull CompletionParameters parameters) {
     processRefInAnnotation(refExpr, matcher, consumer);
 
     final int[] count = new int[]{0};
@@ -105,8 +106,9 @@
     }
   }
 
-  public static void processRefInAnnotation(GrReferenceExpression refExpr,
-                                            PrefixMatcher matcher, Consumer<LookupElement> consumer) {
+  public static void processRefInAnnotation(@NotNull GrReferenceExpression refExpr,
+                                            @NotNull PrefixMatcher matcher,
+                                            @NotNull Consumer<LookupElement> consumer) {
     if (refExpr.getParent() instanceof GrAnnotationNameValuePair &&
         ((GrAnnotationNameValuePair)refExpr.getParent()).getNameIdentifierGroovy() == null) {
       PsiElement parent = refExpr.getParent().getParent();
@@ -121,7 +123,9 @@
     }
   }
 
-  private static void processIfJavaLangClass(GrReferenceExpression refExpr, ResolverProcessor consumer, PsiType type) {
+  private static void processIfJavaLangClass(@NotNull GrReferenceExpression refExpr,
+                                             @NotNull ResolverProcessor consumer,
+                                             @Nullable PsiType type) {
     if (!(type instanceof PsiClassType)) return;
 
     final PsiClass psiClass = ((PsiClassType)type).resolve();
@@ -133,23 +137,24 @@
     getVariantsFromQualifierType(refExpr, consumer, params[0], refExpr.getProject());
   }
 
-  private static void getVariantsImpl(GrReferenceExpression refExpr, CompleteReferenceProcessor processor) {
+  private static void getVariantsImpl(@NotNull GrReferenceExpression refExpr,
+                                      @NotNull CompleteReferenceProcessor processor) {
     GrExpression qualifier = refExpr.getQualifierExpression();
     if (qualifier == null) {
       ResolveUtil.treeWalkUp(refExpr, processor, true);
 
       for (PsiElement e = refExpr.getParent(); e != null; e = e.getParent()) {
         if (e instanceof GrClosableBlock) {
-          ResolveState state = ResolveState.initial().put(ResolverProcessor.RESOLVE_CONTEXT, (GrClosableBlock)e);
+          ResolveState state = ResolveState.initial().put(ResolverProcessor.RESOLVE_CONTEXT, e);
           for (ClosureMissingMethodContributor contributor : ClosureMissingMethodContributor.EP_NAME.getExtensions()) {
             contributor.processMembers((GrClosableBlock)e, processor, refExpr, state);
           }
         }
       }
 
-      qualifier = PsiImplUtil.getRuntimeQualifier(refExpr);
-      if (qualifier != null) {
-        getVariantsFromQualifier(refExpr, processor, qualifier);
+      GrExpression runtimeQualifier = PsiImplUtil.getRuntimeQualifier(refExpr);
+      if (runtimeQualifier != null) {
+        getVariantsFromQualifier(refExpr, processor, runtimeQualifier);
       }
       
       getBindings(refExpr, processor);
@@ -170,11 +175,12 @@
     ResolveUtil.processCategoryMembers(refExpr, processor, ResolveState.initial());
   }
 
-  private static void getBindings(final GrReferenceExpression refExpr, final CompleteReferenceProcessor processor) {
+  private static void getBindings(@NotNull final GrReferenceExpression refExpr,
+                                  @NotNull final CompleteReferenceProcessor processor) {
     final PsiClass containingClass = PsiTreeUtil.getParentOfType(refExpr, PsiClass.class);
     if (containingClass != null) return;
 
-    final PsiFile file = refExpr.getContainingFile();
+    final PsiFile file = FileContextUtil.getContextFile(refExpr);
     if (file instanceof GroovyFile) {
       ((GroovyFile)file).accept(new GroovyRecursiveElementVisitor() {
         @Override
@@ -202,11 +208,13 @@
     }
   }
 
-  private static void getVariantsFromQualifierForSpreadOperator(GrReferenceExpression refExpr,
-                                                                ResolverProcessor processor,
-                                                                GrExpression qualifier) {
+  private static void getVariantsFromQualifierForSpreadOperator(@NotNull GrReferenceExpression refExpr,
+                                                                @NotNull ResolverProcessor processor,
+                                                                @NotNull GrExpression qualifier) {
     final PsiType spreadType = ClosureParameterEnhancer.findTypeForIteration(qualifier, refExpr);
-    getVariantsFromQualifierType(refExpr, processor, spreadType, refExpr.getProject());
+    if (spreadType != null) {
+      getVariantsFromQualifierType(refExpr, processor, spreadType, refExpr.getProject());
+    }
   }
 
   @NotNull
@@ -219,7 +227,8 @@
   }
 
   @Nullable
-  public static LookupElementBuilder createPropertyLookupElement(@NotNull PsiMethod accessor, @Nullable GroovyResolveResult resolveResult,
+  public static LookupElementBuilder createPropertyLookupElement(@NotNull PsiMethod accessor,
+                                                                 @Nullable GroovyResolveResult resolveResult,
                                                                  @Nullable PrefixMatcher matcher) {
     String propName;
     PsiType propType;
@@ -259,25 +268,26 @@
     return builder;
   }
 
+  @NotNull
   private static GroovyResolveResult generatePropertyResolveResult(@NotNull String name,
                                                                    @NotNull PsiMethod method,
                                                                    @Nullable PsiType type,
                                                                    @Nullable GroovyResolveResult resolveResult) {
-    if (type == null) {
-      type = TypesUtil.getJavaLangObject(method);
-    }
+    PsiType nonNullType = type != null ? type : TypesUtil.getJavaLangObject(method);
 
-    final GrPropertyForCompletion field = new GrPropertyForCompletion(method, name, type);
+    final GrPropertyForCompletion field = new GrPropertyForCompletion(method, name, nonNullType);
     if (resolveResult != null) {
       return new GroovyResolveResultImpl(field, resolveResult.getCurrentFileResolveContext(), resolveResult.getSpreadState(),
-                                         resolveResult.getSubstitutor(), resolveResult.isAccessible(), resolveResult.isStaticsOK(), false);
+                                         resolveResult.getSubstitutor(), resolveResult.isAccessible(), resolveResult.isStaticsOK());
     }
     else {
       return new GroovyResolveResultImpl(field, true);
     }
   }
 
-  private static void getVariantsFromQualifier(GrReferenceExpression refExpr, ResolverProcessor processor, GrExpression qualifier) {
+  private static void getVariantsFromQualifier(@NotNull GrReferenceExpression refExpr,
+                                               @NotNull ResolverProcessor processor,
+                                               @NotNull GrExpression qualifier) {
     Project project = qualifier.getProject();
     PsiType qualifierType = qualifier.getType();
     final ResolveState state = ResolveState.initial();
@@ -318,19 +328,25 @@
     }
   }
 
-  public static Set<String> getVariantsWithSameQualifier(PrefixMatcher matcher, @Nullable GrExpression qualifier, GrReferenceExpression refExpr) {
+  @NotNull
+  public static Set<String> getVariantsWithSameQualifier(@NotNull PrefixMatcher matcher,
+                                                         @Nullable GrExpression qualifier,
+                                                         @NotNull GrReferenceExpression refExpr) {
     if (qualifier != null && qualifier.getType() != null) return Collections.emptySet();
 
     final PsiElement scope = PsiTreeUtil.getParentOfType(refExpr, GrMember.class, PsiFile.class);
     Set<String> result = new LinkedHashSet<String>();
-    addVariantsWithSameQualifier(matcher, scope, refExpr, qualifier, result);
+    if (scope != null) {
+      addVariantsWithSameQualifier(matcher, scope, refExpr, qualifier, result);
+    }
     return result;
   }
 
-  private static void addVariantsWithSameQualifier(PrefixMatcher matcher, PsiElement element,
-                                                   GrReferenceExpression patternExpression,
+  private static void addVariantsWithSameQualifier(@NotNull PrefixMatcher matcher,
+                                                   @NotNull PsiElement element,
+                                                   @NotNull GrReferenceExpression patternExpression,
                                                    @Nullable GrExpression patternQualifier,
-                                                   Set<String> result) {
+                                                   @NotNull Set<String> result) {
     if (element instanceof GrReferenceExpression && element != patternExpression && !PsiUtil.isLValue((GroovyPsiElement)element)) {
       final GrReferenceExpression refExpr = (GrReferenceExpression)element;
       final String refName = refExpr.getReferenceName();
@@ -356,10 +372,10 @@
     }
   }
 
-  private static void getVariantsFromQualifierType(GrReferenceExpression refExpr,
-                                                   ResolverProcessor processor,
-                                                   PsiType qualifierType,
-                                                   Project project) {
+  private static void getVariantsFromQualifierType(@NotNull GrReferenceExpression refExpr,
+                                                   @NotNull ResolverProcessor processor,
+                                                   @NotNull PsiType qualifierType,
+                                                   @NotNull Project project) {
     final ResolveState state = ResolveState.initial();
     if (qualifierType instanceof PsiClassType) {
       PsiClassType.ClassResolveResult result = ((PsiClassType)qualifierType).resolveGenerics();
@@ -370,7 +386,9 @@
     }
     else if (qualifierType instanceof PsiArrayType) {
       final GrTypeDefinition arrayClass = GroovyPsiManager.getInstance(project).getArrayClass(((PsiArrayType)qualifierType).getComponentType());
-      if (!arrayClass.processDeclarations(processor, state, null, refExpr)) return;
+      if (arrayClass != null) {
+        if (!arrayClass.processDeclarations(processor, state, null, refExpr)) return;
+      }
     }
     else if (qualifierType instanceof PsiIntersectionType) {
       for (PsiType conjunct : ((PsiIntersectionType)qualifierType).getConjuncts()) {
@@ -381,7 +399,8 @@
     ResolveUtil.processNonCodeMembers(qualifierType, processor, refExpr, state);
   }
 
-  private static Set<String> addAllRestrictedProperties(GrReferenceExpression place) {
+  @NotNull
+  private static Set<String> addAllRestrictedProperties(@NotNull GrReferenceExpression place) {
     if (place.getQualifier() != null) {
       return Collections.emptySet();
     }
@@ -397,7 +416,7 @@
     return propertyNames;
   }
 
-  private static boolean isMap(GrReferenceExpression place) {
+  private static boolean isMap(@NotNull GrReferenceExpression place) {
     final PsiType qType = GrReferenceResolveUtil.getQualifierType(place);
     return InheritanceUtil.isInheritor(qType, CommonClassNames.JAVA_UTIL_MAP);
   }
@@ -423,9 +442,11 @@
     private final Set<GrMethod> myProcessedMethodWithOptionalParams = new HashSet<GrMethod>();
 
     private List<GroovyResolveResult> myInapplicable;
-    private GroovyResolveResult[] myInapplicableResults;
 
-    protected CompleteReferenceProcessor(GrReferenceExpression place, Consumer<LookupElement> consumer, @NotNull PrefixMatcher matcher, CompletionParameters parameters) {
+    protected CompleteReferenceProcessor(@NotNull GrReferenceExpression place,
+                                         @NotNull Consumer<LookupElement> consumer,
+                                         @NotNull PrefixMatcher matcher,
+                                         @NotNull CompletionParameters parameters) {
       super(null, EnumSet.allOf(ResolveKind.class), place, PsiType.EMPTY_ARRAY);
       myConsumer = consumer;
       myMatcher = matcher;
@@ -439,10 +460,10 @@
       myMethodPointerOperator = place.getDotTokenType() == GroovyTokenTypes.mMEMBER_POINTER;
       myIsMap = isMap(place);
       final PsiType thisType = GrReferenceResolveUtil.getQualifierType(place);
-      mySubstitutorComputer = new SubstitutorComputer(thisType, PsiType.EMPTY_ARRAY, PsiType.EMPTY_ARRAY, true, place, place.getParent());
+      mySubstitutorComputer = new SubstitutorComputer(thisType, PsiType.EMPTY_ARRAY, PsiType.EMPTY_ARRAY, place, place.getParent());
     }
 
-    private static boolean shouldSkipPackages(GrReferenceExpression place) {
+    private static boolean shouldSkipPackages(@NotNull GrReferenceExpression place) {
       if (PsiImplUtil.getRuntimeQualifier(place) != null) {
         return false;
       }
@@ -501,7 +522,7 @@
 
         result = new GroovyResolveResultImpl(element, result.getCurrentFileResolveContext(), result.getSpreadState(),
                                              result.getSubstitutor(), result.isAccessible(), result.isStaticsOK(),
-                                             result.isInvokedOnProperty());
+                                             result.isInvokedOnProperty(), result.isValidResult());
       }
 
       if (myFieldPointerOperator && !(element instanceof PsiVariable)) {
@@ -527,7 +548,7 @@
       }
     }
 
-    private void processPropertyFromField(GrField field, GroovyResolveResult resolveResult) {
+    private void processPropertyFromField(@NotNull GrField field, @NotNull GroovyResolveResult resolveResult) {
       if (field.getGetters().length != 0 || field.getSetter() != null || !myPropertyNames.add(field.getName()) || myIsMap) return;
 
       for (LookupElement element : GroovyCompletionUtil.createLookupElements(resolveResult, false, myMatcher, null)) {
@@ -536,7 +557,7 @@
 
     }
 
-    private void processProperty(PsiMethod method, GroovyResolveResult resolveResult) {
+    private void processProperty(@NotNull PsiMethod method, @NotNull GroovyResolveResult resolveResult) {
       if (myIsMap) return;
       final LookupElementBuilder lookup = createPropertyLookupElement(method, resolveResult, myMatcher);
       if (lookup != null) {
@@ -549,7 +570,7 @@
       }
     }
 
-    private void processListenerProperties(PsiMethod method) {
+    private void processListenerProperties(@NotNull PsiMethod method) {
       if (!method.getName().startsWith("add") || method.getParameterList().getParametersCount() != 1) return;
 
       final PsiParameter parameter = method.getParameterList().getParameters()[0];
@@ -602,6 +623,7 @@
       return list.toArray(new GroovyResolveResult[list.size()]);
     }
 
+    @NotNull
     private List<GroovyResolveResult> getInapplicableResults() {
       if (myInapplicable == null) return Collections.emptyList();
       return myInapplicable;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrAssignmentExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrAssignmentExpressionImpl.java
index 0f4b844..5382801 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrAssignmentExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrAssignmentExpressionImpl.java
@@ -19,7 +19,6 @@
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiManager;
 import com.intellij.psi.PsiReference;
 import com.intellij.psi.PsiType;
 import com.intellij.psi.impl.source.resolve.ResolveCache;
@@ -27,7 +26,6 @@
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.Function;
 import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.NullableFunction;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
@@ -39,34 +37,19 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrIndexProperty;
 import org.jetbrains.plugins.groovy.lang.psi.dataFlow.types.TypeInferenceHelper;
 import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
-import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators.GrBinaryExpressionTypeCalculators;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators.GrBinaryExpressionUtil;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators.GrBinaryFacade;
 
 /**
  * @author ilyas
  */
 public class GrAssignmentExpressionImpl extends GrExpressionImpl implements GrAssignmentExpression {
 
-  private static final Function<GrAssignmentExpressionImpl, PsiType> TYPE_CALCULATOR =
-    new NullableFunction<GrAssignmentExpressionImpl, PsiType>() {
-      @Override
-      public PsiType fun(GrAssignmentExpressionImpl assignment) {
-        final GroovyResolveResult[] results = assignment.multiResolve(false);
+  private GrBinaryFacade getFacade() {
+    return myFacade;
+  }
 
-        if (results.length == 0) {
-          final GrExpression rValue = assignment.getRValue();
-          return rValue == null ? null : rValue.getType();
-        }
-
-
-        PsiType returnType = null;
-        final PsiManager manager = assignment.getManager();
-        for (GroovyResolveResult result : results) {
-          final PsiType substituted = ResolveUtil.extractReturnTypeFromCandidate(result, assignment, new PsiType[]{getRValueType(assignment)});
-          returnType = TypesUtil.getLeastUpperBoundNullable(returnType, substituted, manager);
-        }
-        return returnType;
-      }
-    };
   public GrAssignmentExpressionImpl(@NotNull ASTNode node) {
     super(node);
   }
@@ -89,10 +72,12 @@
     return null;
   }
 
+  @NotNull
   public IElementType getOperationTokenType() {
     return getOperationToken().getNode().getElementType();
   }
 
+  @NotNull
   public PsiElement getOperationToken() {
     return findNotNullChildByType(TokenSets.ASSIGN_OP_SET);
   }
@@ -119,7 +104,6 @@
   @Override
   public TextRange getRangeInElement() {
     final PsiElement token = getOperationToken();
-    assert token != null;
     final int offset = token.getStartOffsetInParent();
     return new TextRange(offset, offset + token.getTextLength());
   }
@@ -169,38 +153,78 @@
     return this;
   }
 
-  private static final ResolveCache.PolyVariantResolver<GrAssignmentExpressionImpl> RESOLVER =
-    new ResolveCache.PolyVariantResolver<GrAssignmentExpressionImpl>() {
-      @NotNull
-      @Override
-      public GroovyResolveResult[] resolve(@NotNull GrAssignmentExpressionImpl assignmentExpression, boolean incompleteCode) {
-        final IElementType opType = assignmentExpression.getOperationTokenType();
-        if (opType == null || opType == GroovyTokenTypes.mASSIGN) return GroovyResolveResult.EMPTY_ARRAY;
+  private final GrBinaryFacade myFacade = new GrBinaryFacade() {
+    @NotNull
+    @Override
+    public GrExpression getLeftOperand() {
+      return getLValue();
+    }
 
-        final GrExpression lValue = assignmentExpression.getLValue();
-        final PsiType lType;
-        if (lValue instanceof GrIndexProperty) {
+    @Nullable
+    @Override
+    public GrExpression getRightOperand() {
+      return getRValue();
+    }
+
+    @NotNull
+    @Override
+    public IElementType getOperationTokenType() {
+      return GrAssignmentExpressionImpl.this.getOperationTokenType();
+    }
+
+    @NotNull
+    @Override
+    public PsiElement getOperationToken() {
+      return GrAssignmentExpressionImpl.this.getOperationToken();
+    }
+
+    @NotNull
+    @Override
+    public GroovyResolveResult[] multiResolve(boolean incompleteCode) {
+      return GrAssignmentExpressionImpl.this.multiResolve(false);
+    }
+
+    @NotNull
+    @Override
+    public GrExpression getPsiElement() {
+      return GrAssignmentExpressionImpl.this;
+    }
+  };
+
+
+  private static final ResolveCache.PolyVariantResolver<GrAssignmentExpressionImpl> RESOLVER = new ResolveCache.PolyVariantResolver<GrAssignmentExpressionImpl>() {
+    @NotNull
+    @Override
+    public GroovyResolveResult[] resolve(@NotNull GrAssignmentExpressionImpl assignmentExpression, boolean incompleteCode) {
+      final IElementType opType = assignmentExpression.getOperationTokenType();
+      if (opType == GroovyTokenTypes.mASSIGN) return GroovyResolveResult.EMPTY_ARRAY;
+
+      final GrExpression lValue = assignmentExpression.getLValue();
+      final PsiType lType;
+      if (lValue instanceof GrIndexProperty) {
           /*
           now we have something like map[i] += 2. It equals to map.putAt(i, map.getAt(i).plus(2))
           by default map[i] resolves to putAt, but we need getAt(). so this hack is for it =)
            */
-          lType = ((GrIndexProperty)lValue).getGetterType();
-        }
-        else {
-          lType = lValue.getType();
-        }
-        if (lType == null) return GroovyResolveResult.EMPTY_ARRAY;
-
-        PsiType rType = getRValueType(assignmentExpression);
-
-        final IElementType operatorToken = TokenSets.ASSIGNMENTS_TO_OPERATORS.get(opType);
-        return TypesUtil.getOverloadedOperatorCandidates(lType, operatorToken, lValue, new PsiType[]{rType});
+        lType = ((GrIndexProperty)lValue).getGetterType();
       }
-    };
+      else {
+        lType = lValue.getType();
+      }
+      if (lType == null) return GroovyResolveResult.EMPTY_ARRAY;
 
-  @Nullable
-  private static PsiType getRValueType(GrAssignmentExpressionImpl assignmentExpression) {
-    final GrExpression rightOperand = assignmentExpression.getRValue();
-    return rightOperand == null ? null : rightOperand.getType();
-  }
+      PsiType rType = GrBinaryExpressionUtil.getRightType(assignmentExpression.getFacade());
+
+      final IElementType operatorToken = TokenSets.ASSIGNMENTS_TO_OPERATORS.get(opType);
+      return TypesUtil.getOverloadedOperatorCandidates(lType, operatorToken, lValue, new PsiType[]{rType});
+    }
+  };
+
+  private static final Function<GrAssignmentExpressionImpl, PsiType> TYPE_CALCULATOR = new Function<GrAssignmentExpressionImpl, PsiType>() {
+    @Override
+    public PsiType fun(GrAssignmentExpressionImpl expression) {
+      final Function<GrBinaryFacade, PsiType> calculator = GrBinaryExpressionTypeCalculators.getTypeCalculator(expression.getFacade());
+      return calculator.fun(expression.getFacade());
+    }
+  };
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrBinaryExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrBinaryExpressionImpl.java
index bce762c..4f6487d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrBinaryExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrBinaryExpressionImpl.java
@@ -35,42 +35,83 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.dataFlow.types.TypeInferenceHelper;
 import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
-import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators.GrBinaryExpressionTypeCalculators;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators.GrBinaryFacade;
 
 /**
  * @author ilyas
  */
 public abstract class GrBinaryExpressionImpl extends GrExpressionImpl implements GrBinaryExpression {
 
-  private static final ResolveCache.PolyVariantResolver<GrBinaryExpressionImpl> RESOLVER =
-    new ResolveCache.PolyVariantResolver<GrBinaryExpressionImpl>() {
-      @NotNull
-      @Override
-      public GroovyResolveResult[] resolve(@NotNull GrBinaryExpressionImpl binary, boolean incompleteCode) {
-        final IElementType opType = binary.getOperationTokenType();
+  private static final ResolveCache.PolyVariantResolver<GrBinaryExpressionImpl> RESOLVER = new ResolveCache.PolyVariantResolver<GrBinaryExpressionImpl>() {
+    @NotNull
+    @Override
+    public GroovyResolveResult[] resolve(@NotNull GrBinaryExpressionImpl binary, boolean incompleteCode) {
+      final IElementType opType = binary.getOperationTokenType();
 
-        final GrExpression left = binary.getLeftOperand();
-        final PsiType lType = left.getType();
-        if (lType == null) return GroovyResolveResult.EMPTY_ARRAY;
+      final PsiType lType = binary.getLeftType();
+      if (lType == null) return GroovyResolveResult.EMPTY_ARRAY;
 
-        PsiType rType = getRightType(binary);
-        return TypesUtil.getOverloadedOperatorCandidates(lType, opType, binary, new PsiType[]{rType}, incompleteCode);
-      }
-    };
+      PsiType rType = binary.getRightType();
+      return TypesUtil.getOverloadedOperatorCandidates(lType, opType, binary, new PsiType[]{rType}, incompleteCode);
+    }
+  };
+
+  private static final Function<GrBinaryExpressionImpl, PsiType> TYPE_CALCULATOR = new Function<GrBinaryExpressionImpl, PsiType>() {
+    @Override
+    public PsiType fun(GrBinaryExpressionImpl expression) {
+      return GrBinaryExpressionTypeCalculators.getTypeCalculator(expression.getFacade()).fun(expression.getFacade());
+    }
+  };
+
+  private final GrBinaryFacade myFacade = new GrBinaryFacade() {
+    @NotNull
+    @Override
+    public GrExpression getLeftOperand() {
+      return GrBinaryExpressionImpl.this.getLeftOperand();
+    }
+
+    @Nullable
+    @Override
+    public GrExpression getRightOperand() {
+      return GrBinaryExpressionImpl.this.getRightOperand();
+    }
+
+    @NotNull
+    @Override
+    public IElementType getOperationTokenType() {
+      return GrBinaryExpressionImpl.this.getOperationTokenType();
+    }
+
+    @NotNull
+    @Override
+    public PsiElement getOperationToken() {
+      return GrBinaryExpressionImpl.this.getOperationToken();
+    }
+
+    @NotNull
+    @Override
+    public GroovyResolveResult[] multiResolve(boolean incompleteCode) {
+      return GrBinaryExpressionImpl.this.multiResolve(incompleteCode);
+    }
+
+    @NotNull
+    @Override
+    public GrExpression getPsiElement() {
+      return GrBinaryExpressionImpl.this;
+    }
+  };
 
   @Nullable
-  private static PsiType getRightType(GrBinaryExpressionImpl binary) {
-    final GrExpression rightOperand = binary.getRightOperand();
+  protected PsiType getRightType() {
+    final GrExpression rightOperand = getRightOperand();
     return rightOperand == null ? null : rightOperand.getType();
   }
 
-  private static final Function<GrBinaryExpressionImpl,PsiType> TYPE_CALCULATOR = new Function<GrBinaryExpressionImpl, PsiType>() {
-    @Nullable
-    @Override
-    public PsiType fun(GrBinaryExpressionImpl binary) {
-      return binary.calcType();
-    }
-  };
+  @Nullable
+  protected PsiType getLeftType() {
+    return getLeftOperand().getType();
+  }
 
   public GrBinaryExpressionImpl(@NotNull ASTNode node) {
     super(node);
@@ -82,20 +123,6 @@
   }
 
   @Nullable
-  public PsiType getLeftOperandType() {
-    GrExpression leftOperand = getLeftOperand();
-    return leftOperand instanceof GrBinaryExpressionImpl ? ((GrBinaryExpressionImpl)leftOperand).calcType() : leftOperand.getType();
-  }
-
-  @Nullable
-  public PsiType getRightOperandType() {
-    GrExpression rightOperand = getRightOperand();
-    if (rightOperand == null) return null;
-    if (rightOperand instanceof GrBinaryExpressionImpl) return ((GrBinaryExpressionImpl)rightOperand).calcType();
-    return rightOperand.getType();
-  }
-
-  @Nullable
   public GrExpression getRightOperand() {
     final PsiElement last = getLastChild();
     return last instanceof GrExpression ? (GrExpression)last : null;
@@ -129,23 +156,6 @@
     return TypeInferenceHelper.getCurrentContext().getExpressionType(this, TYPE_CALCULATOR);
   }
 
-  @Nullable
-  protected Function<GrBinaryExpressionImpl,PsiType> getTypeCalculator() {
-    return null;
-  }
-
-  protected PsiType calcType() {
-    final Function<GrBinaryExpressionImpl, PsiType> typeCalculator = getTypeCalculator();
-    if (typeCalculator != null) {
-      final PsiType result = typeCalculator.fun(this);
-      if (result != null) return result;
-    }
-
-    final GroovyResolveResult resolveResult = PsiImplUtil.extractUniqueResult(multiResolve(false));
-    final PsiType substituted = ResolveUtil.extractReturnTypeFromCandidate(resolveResult, this, new PsiType[]{getRightType(this)});
-    return TypesUtil.boxPrimitiveType(substituted, getManager(), getResolveScope());
-  }
-
   @Override
   public PsiElement getElement() {
     return this;
@@ -200,4 +210,8 @@
     return this;
   }
 
+  private GrBinaryFacade getFacade() {
+    return myFacade;
+  }
+
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrMethodCallImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrMethodCallImpl.java
index 194bc7e..b85d3a6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrMethodCallImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrMethodCallImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
 import com.intellij.psi.PsiMethod;
 import com.intellij.psi.PsiType;
 import com.intellij.util.Function;
+import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
@@ -72,12 +73,12 @@
     return ((GrReferenceExpressionImpl)invoked).getCallVariants(upToArgument);
   }
 
-  @Nullable
+  @NotNull
   public GrExpression getInvokedExpression() {
     for (PsiElement cur = this.getFirstChild(); cur != null; cur = cur.getNextSibling()) {
       if (cur instanceof GrExpression) return (GrExpression)cur;
     }
-    return null;
+    throw new IncorrectOperationException("invoked expression must not be null");
   }
 
   public PsiMethod resolveMethod() {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrNewExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrNewExpressionImpl.java
index cfc1db1..c6c3b0a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrNewExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrNewExpressionImpl.java
@@ -17,9 +17,12 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions;
 
 import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.TextRange;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.*;
+import com.intellij.psi.impl.source.resolve.ResolveCache;
 import com.intellij.psi.util.InheritanceUtil;
+import com.intellij.util.ArrayUtil;
 import com.intellij.util.Function;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.NullableFunction;
@@ -86,6 +89,16 @@
     }
   };
 
+  private static final ResolveCache.PolyVariantResolver<MyFakeReference> RESOLVER = new ResolveCache.PolyVariantResolver<MyFakeReference>() {
+    @NotNull
+    @Override
+    public GroovyResolveResult[] resolve(@NotNull MyFakeReference reference, boolean incompleteCode) {
+      return reference.getElement().resolveImpl(incompleteCode);
+    }
+  };
+
+  private final MyFakeReference myFakeReference = new MyFakeReference();
+
   public GrNewExpressionImpl(@NotNull ASTNode node) {
     super(node);
   }
@@ -208,6 +221,14 @@
   @NotNull
   @Override
   public GroovyResolveResult[] multiResolve(boolean incompleteCode) {
+    if (getArrayCount() > 0 || getReferenceElement() == null) {
+      return GroovyResolveResult.EMPTY_ARRAY;
+    }
+
+    return TypeInferenceHelper.getCurrentContext().multiResolve(myFakeReference, incompleteCode, RESOLVER);
+  }
+
+  private GroovyResolveResult[] resolveImpl(boolean incompleteCode) {
     GrCodeReferenceElement ref = getReferenceElement();
     if (ref == null) return GroovyResolveResult.EMPTY_ARRAY;
 
@@ -259,4 +280,60 @@
     }
     return null;
   }
+
+  private class MyFakeReference implements PsiPolyVariantReference {
+    @NotNull
+    @Override
+    public ResolveResult[] multiResolve(boolean incompleteCode) {
+      return GrNewExpressionImpl.this.multiResolve(incompleteCode);
+    }
+
+    @Override
+    public GrNewExpressionImpl getElement() {
+      return GrNewExpressionImpl.this;
+    }
+
+    @Override
+    public TextRange getRangeInElement() {
+      return TextRange.EMPTY_RANGE;
+    }
+
+    @Nullable
+    @Override
+    public PsiElement resolve() {
+      return resolveMethod();
+    }
+
+    @NotNull
+    @Override
+    public String getCanonicalText() {
+      return "new expression";
+    }
+
+    @Override
+    public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
+      throw new UnsupportedOperationException("unsupported!");
+    }
+
+    @Override
+    public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
+      throw new UnsupportedOperationException("unsupported!");
+    }
+
+    @Override
+    public boolean isReferenceTo(PsiElement element) {
+      return getManager().areElementsEquivalent(element, resolve());
+    }
+
+    @NotNull
+    @Override
+    public Object[] getVariants() {
+      return ArrayUtil.EMPTY_OBJECT_ARRAY;
+    }
+
+    @Override
+    public boolean isSoft() {
+      return false;
+    }
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java
index 583ba9b..3119608 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceExpressionImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -207,7 +207,7 @@
       final PsiElement element = candidate.getElement();
       if (element instanceof PsiField) {
         final PsiClass containingClass = ((PsiField)element).getContainingClass();
-        if (containingClass != null && PsiTreeUtil.isContextAncestor(containingClass, this, true)) return fieldCandidates;
+        if (containingClass != null && PsiUtil.getContextClass(this) == containingClass) return fieldCandidates;
       }
       else if (!(element instanceof GrBindingVariable)) {
         return fieldCandidates;
@@ -696,9 +696,6 @@
   private static final class OurTypesCalculator implements Function<GrReferenceExpressionImpl, PsiType> {
     @Nullable
     public PsiType fun(GrReferenceExpressionImpl refExpr) {
-      PsiType result = GrReassignedLocalVarsChecker.checkReassignedVar(refExpr, true);
-      if (result != null) return result;
-
       if (GrUnresolvedAccessInspection.isClassReference(refExpr)) {
         GrExpression qualifier = refExpr.getQualifier();
         LOG.assertTrue(qualifier != null);
@@ -706,9 +703,15 @@
       }
 
       final PsiElement resolved = refExpr.resolve();
-      final PsiType inferred = getInferredTypes(refExpr, resolved);
       final PsiType nominal = refExpr.getNominalType();
-      if (inferred == null || PsiType.NULL.equals(inferred)) {
+
+      Boolean reassigned = GrReassignedLocalVarsChecker.isReassignedVar(refExpr);
+      if (reassigned != null && reassigned.booleanValue()) {
+        return GrReassignedLocalVarsChecker.getReassignedVarType(refExpr, true);
+      }
+
+      final PsiType inferred = getInferredTypes(refExpr, resolved);
+      if (inferred == null) {
         if (nominal == null) {
           //inside nested closure we could still try to infer from variable initializer. Not sound, but makes sense
           if (resolved instanceof GrVariable) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceResolveUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceResolveUtil.java
index 44e3990..f500a0e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceResolveUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/GrReferenceResolveUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,9 +21,9 @@
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.TypeConversionUtil;
 import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection;
-import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
@@ -35,7 +35,6 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
-import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl;
 import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
@@ -43,8 +42,6 @@
 import org.jetbrains.plugins.groovy.lang.psi.util.GdkMethodUtil;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
-import org.jetbrains.plugins.groovy.lang.resolve.processors.CompletionProcessor;
-import org.jetbrains.plugins.groovy.lang.resolve.processors.MethodResolverProcessor;
 import org.jetbrains.plugins.groovy.lang.resolve.processors.ResolverProcessor;
 
 import java.util.List;
@@ -62,18 +59,11 @@
   static boolean resolveImpl(ResolverProcessor processor, GrReferenceExpression place) {
     GrExpression qualifier = place.getQualifier();
     if (qualifier == null) {
-      if (processor instanceof MethodResolverProcessor || processor instanceof CompletionProcessor) {
-        processStaticImports(place.getContainingFile(), processor, ResolveState.initial(), place);
-        if (processor instanceof MethodResolverProcessor && ((MethodResolverProcessor)processor).hasApplicableCandidates()) {
-          return false;
-        }
-      }
-
       if (!ResolveUtil.treeWalkUp(place, processor, true)) return false;
       if (!processor.hasCandidates()) {
-        qualifier = PsiImplUtil.getRuntimeQualifier(place);
-        if (qualifier != null) {
-          if (!processQualifier(processor, qualifier, place)) return false;
+        GrExpression runtimeQualifier = PsiImplUtil.getRuntimeQualifier(place);
+        if (runtimeQualifier != null) {
+          if (!processQualifier(processor, runtimeQualifier, place)) return false;
         }
       }
     }
@@ -101,18 +91,6 @@
     return true;
   }
 
-  private static boolean processStaticImports(PsiFile file, ResolverProcessor processor, ResolveState state, PsiElement place) {
-    if (file instanceof GroovyFile) {
-      GrImportStatement[] imports = ((GroovyFile)file).getImportStatements();
-      for (GrImportStatement anImport : imports) {
-        if (anImport.isStatic()) {
-          if (!anImport.processDeclarations(processor, state, null, place)) return false;
-        }
-      }
-    }
-    return true;
-  }
-
   private static boolean processIfJavaLangClass(ResolverProcessor processor,
                                                 @Nullable PsiType type,
                                                 GroovyPsiElement resolveContext,
@@ -225,7 +203,7 @@
   }
 
   @Nullable
-  public static PsiType getQualifierType(GrReferenceExpression ref) {
+  public static PsiType getQualifierType(@NotNull GrReferenceExpression ref) {
     final GrExpression rtQualifier = PsiImplUtil.getRuntimeQualifier(ref);
     if (rtQualifier != null) {
       return rtQualifier.getType();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java
index b3955ee..6734a22 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/TypesUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
 import org.jetbrains.plugins.groovy.lang.psi.api.SpreadState;
@@ -44,10 +45,9 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationMemberValue;
 import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature;
 import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.impl.*;
-import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureImpl;
+import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrImmediateClosureSignatureImpl;
 import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrTypeConverter;
 import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
 import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
@@ -88,27 +88,6 @@
   private TypesUtil() {
   }
 
-  @Nullable
-  public static PsiType getNumericResultType(GrBinaryExpression binaryExpression) {
-    PsiType lType = binaryExpression.getLeftOperand().getType();
-    final GrExpression rop = binaryExpression.getRightOperand();
-    PsiType rType = rop == null ? null : rop.getType();
-    if (lType == null || rType == null) return null;
-    return getLeastUpperBoundForNumericType(lType, rType);
-  }
-
-  @Nullable
-  private static PsiType getLeastUpperBoundForNumericType(@NotNull PsiType lType, @NotNull PsiType rType) {
-    String lCanonical = lType.getCanonicalText();
-    String rCanonical = rType.getCanonicalText();
-    if (JAVA_LANG_FLOAT.equals(lCanonical)) lCanonical = JAVA_LANG_DOUBLE;
-    if (JAVA_LANG_FLOAT.equals(rCanonical)) rCanonical = JAVA_LANG_DOUBLE;
-    if (TYPE_TO_RANK.containsKey(lCanonical) && TYPE_TO_RANK.containsKey(rCanonical)) {
-      return TYPE_TO_RANK.get(lCanonical) > TYPE_TO_RANK.get(rCanonical) ? lType : rType;
-    }
-    return null;
-  }
-
   @NotNull
   public static GroovyResolveResult[] getOverloadedOperatorCandidates(@NotNull PsiType thisType,
                                                                       IElementType tokenType,
@@ -182,6 +161,7 @@
     ourOperationsToOperatorNames.put(mSTAR_STAR, "power");
     ourOperationsToOperatorNames.put(COMPOSITE_LSHIFT_SIGN, "leftShift");
     ourOperationsToOperatorNames.put(COMPOSITE_RSHIFT_SIGN, "rightShift");
+    ourOperationsToOperatorNames.put(GroovyElementTypes.COMPOSITE_TRIPLE_SHIFT_SIGN, "rightShiftUnsigned");
     ourOperationsToOperatorNames.put(mEQUAL, "equals");
     ourOperationsToOperatorNames.put(mNOT_EQUAL, "equals");
 
@@ -380,6 +360,12 @@
       if (result != null && result.booleanValue()) return true;
     }
 
+    if (rType instanceof GrClosureType) {
+      if (canMakeClosureRaw(lType)) {
+        rType = ((GrClosureType)rType).rawType();
+      }
+    }
+
     if (TypeConversionUtil.isAssignable(lType, rType)) {
       return true;
     }
@@ -387,6 +373,19 @@
     return false;
   }
 
+  private static boolean canMakeClosureRaw(PsiType type) {
+    if (!(type instanceof PsiClassType)) return true;
+
+    final PsiType[] parameters = ((PsiClassType)type).getParameters();
+
+    if (parameters.length != 1) return true;
+
+    final PsiType parameter = parameters[0];
+    if (parameter instanceof PsiWildcardType) return true;
+
+    return false;
+  }
+
   @Nullable
   private static Boolean isAssignableForNativeTypes(@NotNull PsiType lType,
                                                     @NotNull PsiClassType rType,
@@ -509,7 +508,7 @@
       if (components1.length == 0) return genNewListBy(type2, manager);
       if (components2.length == 0) return genNewListBy(type1, manager);
 
-      PsiType[] components3 = new PsiType[Math.min(components1.length, components2.length)];
+      PsiType[] components3 = PsiType.createArray(Math.min(components1.length, components2.length));
       for (int i = 0; i < components3.length; i++) {
         PsiType c1 = components1[i];
         PsiType c2 = components2[i];
@@ -546,8 +545,8 @@
 
       if (signature1 instanceof GrClosureSignature && signature2 instanceof GrClosureSignature) {
         if (((GrClosureSignature)signature1).getParameterCount() == ((GrClosureSignature)signature2).getParameterCount()) {
-          final GrClosureSignature signature = GrClosureSignatureImpl.getLeastUpperBound(((GrClosureSignature)signature1),
-                                                                                         ((GrClosureSignature)signature2), manager);
+          final GrClosureSignature signature = GrImmediateClosureSignatureImpl.getLeastUpperBound(((GrClosureSignature)signature1),
+                                                                                                  ((GrClosureSignature)signature2), manager);
           if (signature != null) {
             GlobalSearchScope scope = clType1.getResolveScope().intersectWith(clType2.getResolveScope());
             final LanguageLevel languageLevel = ComparatorUtil.max(clType1.getLanguageLevel(), clType2.getLanguageLevel());
@@ -564,8 +563,6 @@
              CommonClassNames.JAVA_LANG_STRING.equals(type1.getInternalCanonicalText())) {
       return type1;
     }
-    final PsiType result = getLeastUpperBoundForNumericType(type1, type2);
-    if (result != null) return result;
     return GenericsUtil.getLeastUpperBound(type1, type2, manager);
   }
 
@@ -852,7 +849,7 @@
       public PsiType fun(GrAnnotationMemberValue value) {
         return inferAnnotationMemberValueType(value);
       }
-    }, new PsiType[initializers.length]);
+    }, PsiType.createArray(initializers.length));
     return new GrTupleType(types, JavaPsiFacade.getInstance(value.getProject()), value.getResolveScope());
   }
 
@@ -913,4 +910,13 @@
     if (!changed) return null;
     return JavaPsiFacade.getElementFactory(project).createType(element, parameters);
   }
+
+  public static boolean isPsiClassTypeToClosure(PsiType type) {
+    if (!(type instanceof PsiClassType)) return false;
+
+    final PsiClass psiClass = ((PsiClassType)type).resolve();
+    if (psiClass == null) return false;
+
+    return GROOVY_LANG_CLOSURE.equals(psiClass.getQualifiedName());
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrAdditiveExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrAdditiveExpressionImpl.java
index 542f682..22f124b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrAdditiveExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrAdditiveExpressionImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,14 +17,8 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.arithmetic;
 
 import com.intellij.lang.ASTNode;
-import com.intellij.psi.CommonClassNames;
-import com.intellij.psi.PsiType;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrBinaryExpressionImpl;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
-import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
 
 /**
  * @author ilyas
@@ -35,24 +29,8 @@
     super(node);
   }
 
-  private static boolean isStringType(@Nullable PsiType type) {
-    return type != null && (type.equalsToText(CommonClassNames.JAVA_LANG_STRING) || type.equalsToText(GroovyCommonClassNames.GROOVY_LANG_GSTRING));
-  }
-
   public String toString() {
     return "Additive expression";
   }
 
-  protected PsiType calcType() {
-    final PsiType numeric = TypesUtil.getNumericResultType(this);
-    if (numeric != null) return numeric;
-
-    if (getOperationTokenType() == GroovyTokenTypes.mPLUS) {
-      if (isStringType(getLeftOperandType()) || isStringType(getRightOperandType())) {
-        return getTypeByFQName(CommonClassNames.JAVA_LANG_STRING);
-      }
-    }
-
-    return super.calcType();
-  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrMultiplicativeExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrMultiplicativeExpressionImpl.java
index 82e5218..127eaf2 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrMultiplicativeExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrMultiplicativeExpressionImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,43 +17,13 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.arithmetic;
 
 import com.intellij.lang.ASTNode;
-import com.intellij.psi.PsiType;
-import com.intellij.util.Function;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrBinaryExpressionImpl;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
-import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
-
-import static com.intellij.psi.CommonClassNames.JAVA_LANG_DOUBLE;
-import static com.intellij.psi.CommonClassNames.JAVA_LANG_FLOAT;
 
 /**
  * @author ilyas
  */
 public class GrMultiplicativeExpressionImpl extends GrBinaryExpressionImpl {
-  private static final Function<GrBinaryExpressionImpl,PsiType> TYPE_CALCULATOR = new Function<GrBinaryExpressionImpl, PsiType>() {
-    @Nullable
-    @Override
-    public PsiType fun(GrBinaryExpressionImpl binary) {
-      PsiType lType = binary.getLeftOperand().getType();
-      GrExpression right = binary.getRightOperand();
-      PsiType rType = right == null ? null : right.getType();
-
-      if (binary.getOperationTokenType() == GroovyTokenTypes.mDIV) {
-        if (isDoubleOrFloat(lType) || isDoubleOrFloat(rType)) {
-          return binary.getTypeByFQName(JAVA_LANG_DOUBLE);
-        }
-        if (TypesUtil.isNumericType(lType) && TypesUtil.isNumericType(rType)) {
-          return binary.getTypeByFQName(GroovyCommonClassNames.JAVA_MATH_BIG_DECIMAL);
-        }
-      }
-
-      return TypesUtil.getNumericResultType(binary);
-    }
-  };
 
   public GrMultiplicativeExpressionImpl(@NotNull ASTNode node) {
     super(node);
@@ -62,13 +32,4 @@
   public String toString() {
     return "Multiplicative expression";
   }
-
-  @Override
-  protected Function<GrBinaryExpressionImpl, PsiType> getTypeCalculator() {
-    return TYPE_CALCULATOR;
-  }
-
-  private static boolean isDoubleOrFloat(PsiType type) {
-    return type != null && (type.equalsToText(JAVA_LANG_DOUBLE) || type.equalsToText(JAVA_LANG_FLOAT));
-  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrPowerExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrPowerExpressionImpl.java
index 0056670..a005ea1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrPowerExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrPowerExpressionImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrRangeExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrRangeExpressionImpl.java
index 0acf180..5e05974 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrRangeExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrRangeExpressionImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,16 +16,12 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.arithmetic;
 
 import com.intellij.lang.ASTNode;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.PsiType;
-import com.intellij.util.Function;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.arithmetic.GrRangeExpression;
-import org.jetbrains.plugins.groovy.lang.psi.impl.GrRangeType;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrBinaryExpressionImpl;
 
+
 /**
  * @author ilyas
  */
@@ -35,11 +31,6 @@
     super(node);
   }
 
-  @Override
-  protected Function<GrBinaryExpressionImpl, PsiType> getTypeCalculator() {
-    return TYPES_CALCULATOR;
-  }
-
   public String toString() {
     return "Range expression";
   }
@@ -49,16 +40,4 @@
     visitor.visitRangeExpression(this);
   }
 
-  private static final Function<GrBinaryExpressionImpl, PsiType> TYPES_CALCULATOR = new Function<GrBinaryExpressionImpl, PsiType>() {
-    @Override
-    public PsiType fun(GrBinaryExpressionImpl range) {
-      final JavaPsiFacade facade = JavaPsiFacade.getInstance(range.getProject());
-
-      final GrExpression right = range.getRightOperand();
-      final PsiType rtype = right == null ? null : right.getType();
-      final PsiType ltype = range.getLeftOperand().getType();
-
-      return new GrRangeType(range.getResolveScope(), facade, ltype, rtype);
-    }
-  };
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrShiftExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrShiftExpressionImpl.java
index 0c28edd..e0230ce 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrShiftExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrShiftExpressionImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,11 +17,7 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.arithmetic;
 
 import com.intellij.lang.ASTNode;
-import com.intellij.psi.CommonClassNames;
-import com.intellij.psi.PsiType;
-import com.intellij.util.Function;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrBinaryExpressionImpl;
 
 /**
@@ -29,24 +25,6 @@
  */
 public class GrShiftExpressionImpl extends GrBinaryExpressionImpl {
 
-  private static class MyTypeCalculator implements Function<GrBinaryExpressionImpl, PsiType> {
-    private static final Function<GrBinaryExpressionImpl, PsiType> INSTANCE = new MyTypeCalculator();
-
-    @Nullable
-    @Override
-    public PsiType fun(GrBinaryExpressionImpl binary) {
-      PsiType lopType = binary.getLeftOperand().getType();
-      if (lopType == null) return null;
-      if (lopType.equalsToText(CommonClassNames.JAVA_LANG_BYTE) ||
-          lopType.equalsToText(CommonClassNames.JAVA_LANG_CHARACTER) ||
-          lopType.equalsToText(CommonClassNames.JAVA_LANG_SHORT) ||
-          lopType.equalsToText(CommonClassNames.JAVA_LANG_INTEGER)) {
-        return binary.getTypeByFQName(CommonClassNames.JAVA_LANG_INTEGER);
-      }
-      return null;
-    }
-  }
-
   public GrShiftExpressionImpl(@NotNull ASTNode node) {
     super(node);
   }
@@ -55,8 +33,4 @@
     return "Shift expression";
   }
 
-  @Override
-  protected Function<GrBinaryExpressionImpl, PsiType> getTypeCalculator() {
-    return MyTypeCalculator.INSTANCE;
-  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrUnaryExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrUnaryExpressionImpl.java
index 3fd53f4..25038b6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrUnaryExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/arithmetic/GrUnaryExpressionImpl.java
@@ -18,10 +18,7 @@
 
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.CommonClassNames;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiReference;
-import com.intellij.psi.PsiType;
+import com.intellij.psi.*;
 import com.intellij.psi.impl.source.resolve.ResolveCache;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.util.ArrayUtil;
@@ -29,17 +26,17 @@
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
 import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrUnaryExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod;
 import org.jetbrains.plugins.groovy.lang.psi.dataFlow.types.TypeInferenceHelper;
 import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrExpressionImpl;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
-import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
 
 /**
@@ -51,41 +48,63 @@
     @Nullable
     @Override
     public PsiType fun(GrUnaryExpressionImpl unary) {
+      final GroovyResolveResult resolveResult = PsiImplUtil.extractUniqueResult(unary.multiResolve(false));
+
+      if (isIncDecNumber(resolveResult)) {
+        return unary.getOperand().getType();
+      }
+
+      final PsiType substituted = ResolveUtil.extractReturnTypeFromCandidate(resolveResult, unary, PsiType.EMPTY_ARRAY);
+      if (substituted != null) {
+        return substituted;
+      }
+
       GrExpression operand = unary.getOperand();
       if (operand == null) return null;
 
-      PsiType opType = operand.getType();
-      if (opType == null) return null;
-
-      final GroovyResolveResult resolveResult = PsiImplUtil.extractUniqueResult(unary.multiResolve(false));
-      final PsiType substituted = ResolveUtil.extractReturnTypeFromCandidate(resolveResult, unary, PsiType.EMPTY_ARRAY);
-      if (substituted != null) {
-        return TypesUtil.boxPrimitiveType(substituted, unary.getManager(), unary.getResolveScope());
+      final PsiType type = operand.getType();
+      if (TypesUtil.isNumericType(type)) {
+        return type;
       }
 
-      IElementType opToken = unary.getOperationTokenType();
-      if (opToken == GroovyTokenTypes.mBNOT && opType.equalsToText(CommonClassNames.JAVA_LANG_STRING)) {
-        return unary.getTypeByFQName(GroovyCommonClassNames.JAVA_UTIL_REGEX_PATTERN);
-      }
+      return null;
+    }
 
-      return opType;
+    //hack for DGM.next(Number):Number
+    private boolean isIncDecNumber(GroovyResolveResult result) {
+      PsiElement element = result.getElement();
+
+      if (!(element instanceof PsiMethod)) return false;
+
+      final PsiMethod method = element instanceof GrGdkMethod ? ((GrGdkMethod)element).getStaticMethod() : (PsiMethod)element;
+
+      final String name = method.getName();
+      if (!"next".equals(name) && !"previous".equals(name)) return false;
+
+      if (!PsiUtil.isDGMMethod(method)) return false;
+
+      final PsiParameter[] parameters = method.getParameterList().getParameters();
+      if (parameters.length != 1) return false;
+
+      if (!parameters[0].getType().equalsToText(CommonClassNames.JAVA_LANG_NUMBER)) return false;
+
+      return true;
     }
   };
 
-  private static final ResolveCache.PolyVariantResolver<GrUnaryExpressionImpl> OUR_RESOLVER =
-    new ResolveCache.PolyVariantResolver<GrUnaryExpressionImpl>() {
-      @NotNull
-      @Override
-      public GroovyResolveResult[] resolve(@NotNull GrUnaryExpressionImpl unary, boolean incompleteCode) {
-        final GrExpression operand = unary.getOperand();
-        if (operand == null) return GroovyResolveResult.EMPTY_ARRAY;
+  private static final ResolveCache.PolyVariantResolver<GrUnaryExpressionImpl> OUR_RESOLVER = new ResolveCache.PolyVariantResolver<GrUnaryExpressionImpl>() {
+    @NotNull
+    @Override
+    public GroovyResolveResult[] resolve(@NotNull GrUnaryExpressionImpl unary, boolean incompleteCode) {
+      final GrExpression operand = unary.getOperand();
+      if (operand == null) return GroovyResolveResult.EMPTY_ARRAY;
 
-        final PsiType type = operand.getType();
-        if (type == null) return GroovyResolveResult.EMPTY_ARRAY;
+      final PsiType type = operand.getType();
+      if (type == null) return GroovyResolveResult.EMPTY_ARRAY;
 
-        return TypesUtil.getOverloadedUnaryOperatorCandidates(type, unary.getOperationTokenType(), operand, PsiType.EMPTY_ARRAY);
-      }
-    };
+      return TypesUtil.getOverloadedUnaryOperatorCandidates(type, unary.getOperationTokenType(), operand, PsiType.EMPTY_ARRAY);
+    }
+  };
 
   public GrUnaryExpressionImpl(@NotNull ASTNode node) {
     super(node);
@@ -99,6 +118,7 @@
     return TypeInferenceHelper.getCurrentContext().getExpressionType(this, TYPE_CALCULATOR);
   }
 
+  @NotNull
   public IElementType getOperationTokenType() {
     PsiElement opElement = getOperationToken();
     ASTNode node = opElement.getNode();
@@ -106,6 +126,7 @@
     return node.getElementType();
   }
 
+  @NotNull
   public PsiElement getOperationToken() {
     PsiElement opElement = findChildByType(TokenSets.UNARY_OP_SET);
     assert opElement != null;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrAssignTypeCalculator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrAssignTypeCalculator.java
new file mode 100644
index 0000000..3264948
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrAssignTypeCalculator.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.PsiType;
+import com.intellij.util.Function;
+
+/**
+ * Created by Max Medvedev on 12/20/13
+ */
+public class GrAssignTypeCalculator implements Function<GrBinaryFacade, PsiType> {
+  public static final GrAssignTypeCalculator INSTANCE = new GrAssignTypeCalculator();
+
+  @Override
+  public PsiType fun(GrBinaryFacade expression) {
+    return GrBinaryExpressionUtil.getRightType(expression);
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBinaryExpressionTypeCalculator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBinaryExpressionTypeCalculator.java
new file mode 100644
index 0000000..87b70d2
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBinaryExpressionTypeCalculator.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.PsiType;
+import com.intellij.util.Function;
+import com.intellij.util.NullableFunction;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
+import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
+
+/**
+ * Created by Max Medvedev on 12/20/13
+ */
+public class GrBinaryExpressionTypeCalculator implements NullableFunction<GrBinaryFacade, PsiType> {
+  public static final Function<GrBinaryFacade, PsiType> INSTANCE = new GrBinaryExpressionTypeCalculator();
+
+  @Override
+  @Nullable
+  public PsiType fun(GrBinaryFacade e) {
+    final GroovyResolveResult resolveResult = PsiImplUtil.extractUniqueResult(e.multiResolve(false));
+    if (resolveResult.getElement() != null) {
+      return ResolveUtil.extractReturnTypeFromCandidate(resolveResult, e.getPsiElement(), new PsiType[]{getRightType(e)});
+    }
+    return null;
+  }
+
+  @Nullable
+  protected static PsiType getRightType(GrBinaryFacade e) {
+    final GrExpression rightOperand = e.getRightOperand();
+    return rightOperand == null ? null : rightOperand.getType();
+  }
+
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBinaryExpressionTypeCalculators.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBinaryExpressionTypeCalculators.java
new file mode 100644
index 0000000..09b834e
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBinaryExpressionTypeCalculators.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.PsiType;
+import com.intellij.psi.tree.IElementType;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Map;
+
+import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.*;
+
+/**
+ * Created by Max Medvedev on 12/20/13
+ */
+public class GrBinaryExpressionTypeCalculators {
+  private static final Map<IElementType, Function<GrBinaryFacade, PsiType>> MAP = ContainerUtil.newLinkedHashMap();
+
+  static {
+
+    MAP.put(mPLUS, GrNumericBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mPLUS_ASSIGN, GrNumericBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mMINUS, GrNumericBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mMINUS_ASSIGN, GrNumericBinaryExpressionTypeCalculator.INSTANCE);
+
+    MAP.put(mSTAR, GrMultiplicativeExpressionTypeCalculator.INSTANCE);
+    MAP.put(mSTAR_ASSIGN, GrMultiplicativeExpressionTypeCalculator.INSTANCE);
+    MAP.put(mDIV, GrDivExpressionTypeCalculator.INSTANCE);
+    MAP.put(mDIV_ASSIGN, GrDivExpressionTypeCalculator.INSTANCE);
+    MAP.put(mMOD, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mMOD_ASSIGN, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+
+    MAP.put(mSTAR_STAR, GrNumericBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mSTAR_STAR_ASSIGN, GrNumericBinaryExpressionTypeCalculator.INSTANCE);
+
+    MAP.put(COMPOSITE_RSHIFT_SIGN, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mSR_ASSIGN, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(COMPOSITE_LSHIFT_SIGN, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mSL_ASSIGN, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(COMPOSITE_TRIPLE_SHIFT_SIGN, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mBSR_ASSIGN, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+
+    MAP.put(mRANGE_EXCLUSIVE, GrRangeExpressionTypeCalculator.INSTANCE);
+    MAP.put(mRANGE_INCLUSIVE, GrRangeExpressionTypeCalculator.INSTANCE);
+
+    MAP.put(mBAND, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mBAND_ASSIGN, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mBOR, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mBOR_ASSIGN, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mBXOR, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mBXOR_ASSIGN, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mBAND, GrDecimalBinaryExpressionTypeCalculator.INSTANCE);
+    MAP.put(mCOMPARE_TO, GrIntegerTypeCalculator.INSTANCE);
+
+    MAP.put(mLOR, GrBooleanExpressionTypeCalculator.INSTANCE);
+    MAP.put(mLAND, GrBooleanExpressionTypeCalculator.INSTANCE);
+    MAP.put(mEQUAL, GrBooleanExpressionTypeCalculator.INSTANCE);
+    MAP.put(mNOT_EQUAL, GrBooleanExpressionTypeCalculator.INSTANCE);
+    MAP.put(mGT, GrBooleanExpressionTypeCalculator.INSTANCE);
+    MAP.put(mGE, GrBooleanExpressionTypeCalculator.INSTANCE);
+    MAP.put(mLT, GrBooleanExpressionTypeCalculator.INSTANCE);
+    MAP.put(mLE, GrBooleanExpressionTypeCalculator.INSTANCE);
+    MAP.put(kIN, GrBooleanExpressionTypeCalculator.INSTANCE);
+
+    MAP.put(mREGEX_FIND, GrMatcherTypeCalculator.INSTANCE);
+    MAP.put(mREGEX_MATCH, GrBooleanExpressionTypeCalculator.INSTANCE);
+
+    MAP.put(mASSIGN, GrAssignTypeCalculator.INSTANCE);
+  }
+
+  @NotNull
+  public static Function<GrBinaryFacade, PsiType> getTypeCalculator(GrBinaryFacade e) {
+    final Function<GrBinaryFacade, PsiType> function = MAP.get(e.getOperationTokenType());
+    assert function != null : e.getOperationTokenType();
+    return function;
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBinaryExpressionUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBinaryExpressionUtil.java
new file mode 100644
index 0000000..839e260
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBinaryExpressionUtil.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.CommonClassNames;
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
+import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
+
+/**
+ * Created by Max Medvedev on 12/20/13
+ */
+public class GrBinaryExpressionUtil {
+  @Nullable
+  public static PsiType getRightType(GrBinaryFacade e) {
+    final GrExpression rightOperand = e.getRightOperand();
+    return rightOperand == null ? null : rightOperand.getType();
+  }
+
+  @Nullable
+  public static PsiType getLeftType(GrBinaryFacade e) {
+    return e.getLeftOperand().getType();
+  }
+
+  public static PsiType getDefaultNumericResultType(PsiType ltype, PsiType rtype, GrBinaryFacade e) {
+    if (isBigDecimal(ltype, rtype)) return createBigDecimal(e);
+    if (isFloatOrDouble(ltype, rtype)) return createDouble(e);
+    if (isLong(ltype, rtype)) return createLong(e);
+    return createInteger(e);
+  }
+
+  public static PsiType createDouble(GrBinaryFacade e) {
+    return getTypeByFQName(CommonClassNames.JAVA_LANG_DOUBLE, e);
+  }
+
+  public static PsiType createLong(GrBinaryFacade e) {
+    return getTypeByFQName(CommonClassNames.JAVA_LANG_LONG, e);
+  }
+
+  public static PsiType createInteger(GrBinaryFacade e) {
+    return getTypeByFQName(CommonClassNames.JAVA_LANG_INTEGER, e);
+  }
+
+  public static PsiType createBigDecimal(GrBinaryFacade e) {
+    return getTypeByFQName(GroovyCommonClassNames.JAVA_MATH_BIG_DECIMAL, e);
+  }
+
+  public static boolean isBigDecimal(PsiType lType, PsiType rType) {
+    return lType.equalsToText(GroovyCommonClassNames.JAVA_MATH_BIG_DECIMAL) || rType.equalsToText(GroovyCommonClassNames.JAVA_MATH_BIG_DECIMAL);
+  }
+
+  public static boolean isFloatOrDouble(PsiType ltype, PsiType rtype) {
+    return ltype.equalsToText(CommonClassNames.JAVA_LANG_DOUBLE) || rtype.equalsToText(CommonClassNames.JAVA_LANG_DOUBLE) ||
+           ltype.equalsToText(CommonClassNames.JAVA_LANG_FLOAT)  || rtype.equalsToText(CommonClassNames.JAVA_LANG_FLOAT);
+  }
+
+  public static boolean isLong(PsiType ltype, PsiType rtype) {
+    return ltype.equalsToText(CommonClassNames.JAVA_LANG_LONG) || rtype.equalsToText(CommonClassNames.JAVA_LANG_LONG);
+  }
+
+  public static PsiType getTypeByFQName(String fqn, GrBinaryFacade e) {
+    return TypesUtil.createTypeByFQClassName(fqn, e.getPsiElement());
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBinaryFacade.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBinaryFacade.java
new file mode 100644
index 0000000..6d52e60
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBinaryFacade.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
+
+/**
+ * Created by Max Medvedev on 12/20/13
+ */
+public interface GrBinaryFacade {
+
+  @NotNull
+  GrExpression getLeftOperand();
+
+  @Nullable
+  GrExpression getRightOperand();
+
+  @NotNull
+  IElementType getOperationTokenType();
+
+  @NotNull
+  PsiElement getOperationToken();
+
+  @NotNull
+  GroovyResolveResult[] multiResolve(final boolean incompleteCode);
+
+  @NotNull
+  GrExpression getPsiElement();
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBooleanExpressionTypeCalculator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBooleanExpressionTypeCalculator.java
new file mode 100644
index 0000000..863bba5
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrBooleanExpressionTypeCalculator.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.CommonClassNames;
+import com.intellij.psi.PsiType;
+import com.intellij.util.Function;
+
+/**
+ * Created by Max Medvedev on 12/20/13
+ */
+public class GrBooleanExpressionTypeCalculator implements Function<GrBinaryFacade, PsiType>{
+  public static final GrBooleanExpressionTypeCalculator INSTANCE = new GrBooleanExpressionTypeCalculator();
+
+  @Override
+  public PsiType fun(GrBinaryFacade expression) {
+    return GrBinaryExpressionUtil.getTypeByFQName(CommonClassNames.JAVA_LANG_BOOLEAN, expression);
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrDecimalBinaryExpressionTypeCalculator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrDecimalBinaryExpressionTypeCalculator.java
new file mode 100644
index 0000000..0cf9b53
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrDecimalBinaryExpressionTypeCalculator.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import static org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators.GrBinaryExpressionUtil.*;
+
+/**
+ * Created by Max Medvedev on 12/20/13
+ */
+public class GrDecimalBinaryExpressionTypeCalculator extends GrNumericBinaryExpressionTypeCalculator {
+  public static final GrDecimalBinaryExpressionTypeCalculator INSTANCE = new GrDecimalBinaryExpressionTypeCalculator();
+
+  @Nullable
+  @Override
+  protected PsiType inferNumericType(@NotNull PsiType ltype, @NotNull PsiType rtype, GrBinaryFacade e) {
+    if (isBigDecimal(ltype, rtype)) return null;
+    if (isFloatOrDouble(ltype, rtype)) return null;
+    if (isLong(ltype, rtype)) return createLong(e);
+    return createInteger(e);
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrDivExpressionTypeCalculator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrDivExpressionTypeCalculator.java
new file mode 100644
index 0000000..9a1cf29
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrDivExpressionTypeCalculator.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Created by Max Medvedev on 12/20/13
+ */
+public class GrDivExpressionTypeCalculator extends GrNumericBinaryExpressionTypeCalculator {
+  public static final GrDivExpressionTypeCalculator INSTANCE = new GrDivExpressionTypeCalculator();
+
+  @Nullable
+  @Override
+  protected PsiType inferNumericType(@NotNull PsiType ltype, @NotNull PsiType rtype, GrBinaryFacade e) {
+    if (GrBinaryExpressionUtil.isFloatOrDouble(ltype, rtype)) {
+      return GrBinaryExpressionUtil.createDouble(e);
+    }
+
+    return GrBinaryExpressionUtil.createBigDecimal(e);
+  }
+
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrIntegerTypeCalculator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrIntegerTypeCalculator.java
new file mode 100644
index 0000000..1298f7be
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrIntegerTypeCalculator.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.CommonClassNames;
+import com.intellij.psi.PsiType;
+import com.intellij.util.Function;
+
+/**
+ * Created by Max Medvedev on 12/20/13
+ */
+public class GrIntegerTypeCalculator implements Function<GrBinaryFacade,PsiType> {
+  public static final GrIntegerTypeCalculator INSTANCE = new GrIntegerTypeCalculator();
+
+  @Override
+  public PsiType fun(GrBinaryFacade expression) {
+    return GrBinaryExpressionUtil.getTypeByFQName(CommonClassNames.JAVA_LANG_INTEGER, expression);
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrMatcherTypeCalculator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrMatcherTypeCalculator.java
new file mode 100644
index 0000000..1d5d8af
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrMatcherTypeCalculator.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.PsiType;
+import com.intellij.util.Function;
+import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
+
+/**
+ * Created by Max Medvedev on 12/20/13
+ */
+public class GrMatcherTypeCalculator implements Function<GrBinaryFacade, PsiType> {
+  public static final GrMatcherTypeCalculator INSTANCE = new GrMatcherTypeCalculator();
+
+  @Override
+  public PsiType fun(GrBinaryFacade expression) {
+    return GrBinaryExpressionUtil.getTypeByFQName(GroovyCommonClassNames.JAVA_UTIL_REGEX_MATCHER, expression);
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrMultiplicativeExpressionTypeCalculator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrMultiplicativeExpressionTypeCalculator.java
new file mode 100644
index 0000000..9455f714
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrMultiplicativeExpressionTypeCalculator.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.PsiType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Created by Max Medvedev on 12/20/13
+ */
+public class GrMultiplicativeExpressionTypeCalculator extends GrNumericBinaryExpressionTypeCalculator {
+  public static final GrMultiplicativeExpressionTypeCalculator INSTANCE = new GrMultiplicativeExpressionTypeCalculator();
+
+  @Nullable
+  @Override
+  protected PsiType inferNumericType(@NotNull PsiType ltype, @NotNull PsiType rtype, GrBinaryFacade e) {
+    return GrBinaryExpressionUtil.getDefaultNumericResultType(ltype, rtype, e);
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrNumericBinaryExpressionTypeCalculator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrNumericBinaryExpressionTypeCalculator.java
new file mode 100644
index 0000000..88c7fda
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrNumericBinaryExpressionTypeCalculator.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.PsiType;
+import com.intellij.util.NullableFunction;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
+import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
+
+import static org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators.GrBinaryExpressionUtil.*;
+
+/**
+ * Created by Max Medvedev on 12/20/13
+ */
+public class GrNumericBinaryExpressionTypeCalculator implements NullableFunction<GrBinaryFacade, PsiType> {
+  public static final GrNumericBinaryExpressionTypeCalculator INSTANCE = new GrNumericBinaryExpressionTypeCalculator();
+
+  @Nullable
+  @Override
+  public PsiType fun(GrBinaryFacade e) {
+
+    final GroovyResolveResult resolveResult = PsiImplUtil.extractUniqueResult(e.multiResolve(false));
+    if (resolveResult.isApplicable() && !PsiUtil.isDGMMethod(resolveResult.getElement())) {
+      return ResolveUtil.extractReturnTypeFromCandidate(resolveResult, e.getPsiElement(), new PsiType[]{getRightType(e)});
+    }
+
+    PsiType lType = getLeftType(e);
+    PsiType rType = getRightType(e);
+    if (TypesUtil.isNumericType(lType) && TypesUtil.isNumericType(rType)) {
+      assert lType != null;
+      assert rType != null;
+      return inferNumericType(lType, rType, e);
+    }
+
+    return ResolveUtil.extractReturnTypeFromCandidate(resolveResult, e.getPsiElement(), new PsiType[]{rType});
+  }
+
+  @Nullable
+  protected PsiType inferNumericType(@NotNull PsiType ltype, @NotNull PsiType rtype, GrBinaryFacade e) {
+    return getDefaultNumericResultType(ltype, rtype, e);
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrRangeExpressionTypeCalculator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrRangeExpressionTypeCalculator.java
new file mode 100644
index 0000000..e1b79a5
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/binaryCalculators/GrRangeExpressionTypeCalculator.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.binaryCalculators;
+
+import com.intellij.psi.JavaPsiFacade;
+import com.intellij.psi.PsiType;
+import org.jetbrains.plugins.groovy.lang.psi.impl.GrRangeType;
+
+/**
+* Created by Max Medvedev on 12/20/13
+*/
+public class GrRangeExpressionTypeCalculator extends GrBinaryExpressionTypeCalculator {
+  public static final GrBinaryExpressionTypeCalculator INSTANCE = new GrRangeExpressionTypeCalculator();
+
+  @Override
+  public PsiType fun(GrBinaryFacade e) {
+    final PsiType type = super.fun(e);
+    if (type != null) return type;
+
+    final PsiType ltype = GrBinaryExpressionUtil.getLeftType(e);
+    final PsiType rtype = GrBinaryExpressionUtil.getRightType(e);
+
+    return new GrRangeType(e.getPsiElement().getResolveScope(), JavaPsiFacade.getInstance(e.getPsiElement().getProject()), ltype, rtype);
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/bitwise/GrBitwiseExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/bitwise/GrBitwiseExpressionImpl.java
index 9c00f4b..831c96e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/bitwise/GrBitwiseExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/bitwise/GrBitwiseExpressionImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralEscaper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralEscaper.java
index 03f8b33..1944420 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralEscaper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralEscaper.java
@@ -16,7 +16,6 @@
 
 package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.literals;
 
-import com.intellij.openapi.util.ProperTextRange;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.LiteralTextEscaper;
 import com.intellij.psi.tree.IElementType;
@@ -34,7 +33,7 @@
 
   @Override
   public boolean decode(@NotNull TextRange rangeInsideHost, @NotNull StringBuilder outChars) {
-    ProperTextRange.assertProperRange(rangeInsideHost);
+    TextRange.assertProperRange(rangeInsideHost);
     String subText = rangeInsideHost.substring(myHost.getText());
     outSourceOffsets = new int[subText.length() + 1];
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralImpl.java
index 4da4d13..cf69b23 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrLiteralImpl.java
@@ -54,7 +54,7 @@
 
   public PsiType getType() {
     IElementType elemType = getLiteralType(this);
-    return elemType == kNULL ? PsiType.NULL : TypesUtil.getPsiType(this, elemType);
+    return TypesUtil.getPsiType(this, elemType);
   }
 
   public void accept(GroovyElementVisitor visitor) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrRegexImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrRegexImpl.java
index 1d0be96..453b452 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrRegexImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/literals/GrRegexImpl.java
@@ -84,7 +84,7 @@
   @NotNull
   @Override
   public LiteralTextEscaper<? extends PsiLanguageInjectionHost> createLiteralTextEscaper() {
-    return null;
+    return new GrLiteralEscaper(this);
   }
 }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/logical/GrLogicalExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/logical/GrLogicalExpressionImpl.java
index b8d88551..f837b14 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/logical/GrLogicalExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/logical/GrLogicalExpressionImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,9 +16,6 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.logical;
 
 import com.intellij.lang.ASTNode;
-import com.intellij.psi.CommonClassNames;
-import com.intellij.psi.PsiType;
-import com.intellij.util.Function;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrBinaryExpressionImpl;
 
@@ -26,23 +23,12 @@
  * author ven
  */
 public class GrLogicalExpressionImpl extends GrBinaryExpressionImpl {
-  private static final Function<GrBinaryExpressionImpl,PsiType> TYPE_CALCULATOR = new Function<GrBinaryExpressionImpl, PsiType>() {
-    @Override
-    public PsiType fun(GrBinaryExpressionImpl binary) {
-      return binary.getTypeByFQName(CommonClassNames.JAVA_LANG_BOOLEAN);
-    }
-  };
 
   public GrLogicalExpressionImpl(@NotNull ASTNode node) {
     super(node);
   }
 
   @Override
-  protected Function<GrBinaryExpressionImpl, PsiType> getTypeCalculator() {
-    return TYPE_CALCULATOR;
-  }
-
-  @Override
   public String toString() {
     return "Logical expression";
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/DefaultCallExpressionTypeCalculator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/DefaultCallExpressionTypeCalculator.java
index 7c6c7b9..410fb89 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/DefaultCallExpressionTypeCalculator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/DefaultCallExpressionTypeCalculator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,18 +54,21 @@
       PsiType result = null;
       for (GroovyResolveResult resolveResult : resolveResults) {
         PsiType returnType = calculateReturnTypeInner(callExpression, refExpr, resolveResult);
-
         if (returnType == null) return null;
-        if (!(returnType instanceof GrLiteralClassType)) {
-          returnType = TypesUtil.substituteBoxAndNormalizeType(returnType, resolveResult.getSubstitutor(), resolveResult.getSpreadState(), callExpression);
-          LOG.assertTrue(returnType != null);
-        }
 
-        if (result == null || returnType.isAssignableFrom(result)) {
-          result = returnType;
+        PsiType nonVoid = PsiType.VOID.equals(returnType) ? PsiType.NULL : returnType;
+
+        PsiType normalized = nonVoid instanceof GrLiteralClassType
+                             ? nonVoid
+                             : TypesUtil.substituteBoxAndNormalizeType(nonVoid, resolveResult.getSubstitutor(), resolveResult.getSpreadState(), callExpression);
+
+        LOG.assertTrue(normalized != null, "return type: " + returnType + "; substitutor: " + resolveResult.getSubstitutor());
+
+        if (result == null || normalized.isAssignableFrom(result)) {
+          result = normalized;
         }
-        else if (!result.isAssignableFrom(returnType)) {
-          result = TypesUtil.getLeastUpperBound(result, returnType, manager);
+        else if (!result.isAssignableFrom(normalized)) {
+          result = TypesUtil.getLeastUpperBound(result, normalized, manager);
         }
       }
 
@@ -81,26 +84,29 @@
                                                   GrReferenceExpression refExpr,
                                                   GroovyResolveResult resolveResult) {
     PsiElement resolved = resolveResult.getElement();
-    PsiType returnType = null;
     if (resolved instanceof PsiMethod) {
       PsiMethod method = (PsiMethod)resolved;
       if (resolveResult.isInvokedOnProperty()) {
         final PsiType propertyType = PsiUtil.getSmartReturnType(method);
-        returnType = extractReturnTypeFromType(propertyType, true, callExpression);
+        return extractReturnTypeFromType(propertyType, true, callExpression);
       }
       else {
-        returnType = getClosureMethodsReturnType(callExpression, refExpr, method);
-        if (returnType == null) {
-          returnType = PsiUtil.getSmartReturnType(method);
+        PsiType closureReturnType = getClosureMethodsReturnType(callExpression, refExpr, method);
+        if (closureReturnType != null) {
+          return closureReturnType;
+        }
+        else {
+          final PsiType smartReturnType = PsiUtil.getSmartReturnType(method);
+          return smartReturnType;
         }
       }
     }
     else if (resolved instanceof GrVariable) {
       PsiType refType = refExpr.getType();
       final PsiType type = refType == null ? ((GrVariable)resolved).getTypeGroovy() : refType;
-      returnType = extractReturnTypeFromType(type, false, callExpression);
+      return extractReturnTypeFromType(type, false, callExpression);
     }
-    return returnType;
+    return null;
   }
 
   @Nullable
@@ -109,7 +115,7 @@
     if (type instanceof GrClosureType) {
       returnType = GrClosureSignatureUtil.getReturnType(((GrClosureType)type).getSignature(), callExpression);
     }
-    else if (isPsiClassTypeToClosure(type)) {
+    else if (TypesUtil.isPsiClassTypeToClosure(type)) {
       assert type instanceof PsiClassType;
       final PsiType[] parameters = ((PsiClassType)type).getParameters();
       if (parameters.length == 1) {
@@ -131,15 +137,6 @@
   }
 
 
-  private static boolean isPsiClassTypeToClosure(PsiType type) {
-    if (!(type instanceof PsiClassType)) return false;
-
-    final PsiClass psiClass = ((PsiClassType)type).resolve();
-    if (psiClass == null) return false;
-
-    return GroovyCommonClassNames.GROOVY_LANG_CLOSURE.equals(psiClass.getQualifiedName());
-  }
-
   private static final Set<String> CLOSURE_METHODS = new HashSet<String>();
   static {
     CLOSURE_METHODS.add("call");
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java
index 0de1c35..bc81626 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/path/GrIndexPropertyImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -128,7 +128,7 @@
     if (element instanceof PsiNamedElement) {
       final String name = ((PsiNamedElement)element).getName();
       if ("putAt".equals(name) && args != null) {
-        args = ArrayUtil.append(args, TypeInferenceHelper.getInitializerFor(this), PsiType.class);
+        args = ArrayUtil.append(args, TypeInferenceHelper.getInitializerTypeFor(this), PsiType.class);
       }
     }
     PsiType overloadedOperatorType = ResolveUtil.extractReturnTypeFromCandidate(candidate, this, args);
@@ -192,7 +192,7 @@
     GroovyResolveResult[] candidates;
     final String name = isSetter ? "putAt" : "getAt";
     if (isSetter && !incompleteCode) {
-      argTypes = ArrayUtil.append(argTypes, TypeInferenceHelper.getInitializerFor(this), PsiType.class);
+      argTypes = ArrayUtil.append(argTypes, TypeInferenceHelper.getInitializerTypeFor(this), PsiType.class);
     }
 
     if (PsiImplUtil.isSimpleArrayAccess(thisType, argTypes, this, isSetter)) {
@@ -420,7 +420,7 @@
     @NotNull
     @Override
     public ResolveResult[] multiResolve(boolean incompleteCode) {
-      return resolveImpl(incompleteCode, null, null);
+      return GrIndexPropertyImpl.this.multiResolve(incompleteCode);
     }
   }
 }
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/regex/GrRegexFindExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/regex/GrRegexFindExpressionImpl.java
index b563bbd..525d7d1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/regex/GrRegexFindExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/regex/GrRegexFindExpressionImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,49 +17,18 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.regex;
 
 import com.intellij.lang.ASTNode;
-import com.intellij.psi.CommonClassNames;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiType;
-import com.intellij.util.Function;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrParenthesizedExpression;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrBinaryExpressionImpl;
-import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
 
 /**
  * @author ilyas
  */
 public class GrRegexFindExpressionImpl extends GrBinaryExpressionImpl {
-  private static final Function<GrBinaryExpressionImpl, PsiType> TYPE_CALCULATOR = new Function<GrBinaryExpressionImpl, PsiType>() {
-    @Override
-    public PsiType fun(GrBinaryExpressionImpl binary) {
-      PsiElement parent = binary.getParent();
-
-      while (parent instanceof GrParenthesizedExpression) {
-        parent = parent.getParent();
-      }
-
-      if (parent instanceof GrVariable) {
-        PsiType declaredType = ((GrVariable)parent).getDeclaredType();
-        if (declaredType == PsiType.BOOLEAN || (declaredType != null && declaredType.equalsToText(CommonClassNames.JAVA_LANG_BOOLEAN))) {
-          return PsiType.BOOLEAN;
-        }
-      }
-
-      return binary.getTypeByFQName(GroovyCommonClassNames.JAVA_UTIL_REGEX_MATCHER);
-    }
-  };
 
   public GrRegexFindExpressionImpl(@NotNull ASTNode node) {
     super(node);
   }
 
-  @Override
-  protected Function<GrBinaryExpressionImpl, PsiType> getTypeCalculator() {
-    return TYPE_CALCULATOR;
-  }
-
   public String toString() {
     return "RegexFindExpression";
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/relational/GrRelationalExpressionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/relational/GrRelationalExpressionImpl.java
index 971778c..4a3eac6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/relational/GrRelationalExpressionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/expressions/relational/GrRelationalExpressionImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,28 +17,14 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.relational;
 
 import com.intellij.lang.ASTNode;
-import com.intellij.psi.PsiType;
-import com.intellij.util.Function;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.GrBinaryExpressionImpl;
 
-import static com.intellij.psi.CommonClassNames.JAVA_LANG_BOOLEAN;
-import static com.intellij.psi.CommonClassNames.JAVA_LANG_INTEGER;
-import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.mCOMPARE_TO;
-
 /**
  * @author ilyas
  */
 public class GrRelationalExpressionImpl extends GrBinaryExpressionImpl {
 
-  private static final Function<GrBinaryExpressionImpl,PsiType> TYPE_CALCULATOR = new Function<GrBinaryExpressionImpl, PsiType>() {
-    @Override
-    public PsiType fun(GrBinaryExpressionImpl binary) {
-      final String typeName = mCOMPARE_TO == binary.getOperationTokenType() ? JAVA_LANG_INTEGER : JAVA_LANG_BOOLEAN;
-      return binary.getTypeByFQName(typeName);
-    }
-  };
-
   public GrRelationalExpressionImpl(@NotNull ASTNode node) {
     super(node);
   }
@@ -46,9 +32,4 @@
   public String toString() {
     return "Relational expression";
   }
-
-  @Override
-  protected Function<GrBinaryExpressionImpl, PsiType> getTypeCalculator() {
-    return TYPE_CALCULATOR;
-  }
 }
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrAnonymousClassDefinitionImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrAnonymousClassDefinitionImpl.java
index aa7876a..2ff2a00 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrAnonymousClassDefinitionImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrAnonymousClassDefinitionImpl.java
@@ -106,8 +106,7 @@
       return createClassType();
     }
 
-    PsiClassType type = null;
-    if (myCachedBaseType != null) type = myCachedBaseType.get();
+    PsiClassType type = SoftReference.dereference(myCachedBaseType);
     if (type != null && type.isValid()) return type;
 
     type = createClassType();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrReferenceListImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrReferenceListImpl.java
index 339e67d..548bf70 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrReferenceListImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrReferenceListImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,10 +17,7 @@
 
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.psi.PsiClassType;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiJavaCodeReferenceElement;
-import com.intellij.psi.StubBasedPsiElement;
+import com.intellij.psi.*;
 import com.intellij.psi.stubs.IStubElementType;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.util.IncorrectOperationException;
@@ -135,6 +132,7 @@
     //hack for inserting references from java code
     if (element instanceof GrCodeReferenceElement || element instanceof PsiJavaCodeReferenceElement) {
       if (findChildByType(getKeywordType()) == null) {
+        getNode().getTreeParent().addLeaf(TokenType.WHITE_SPACE, " ", getNode());
         getNode().addLeaf(getKeywordType(), getKeywordType().toString(), null);
       }
       else if (findChildByClass(GrCodeReferenceElement.class) != null) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrMethodBaseImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrMethodBaseImpl.java
index 9fac306..b608f29 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrMethodBaseImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/members/GrMethodBaseImpl.java
@@ -38,6 +38,7 @@
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.codeStyle.GrReferenceAdjuster;
 import org.jetbrains.plugins.groovy.extensions.NamedArgumentDescriptor;
 import org.jetbrains.plugins.groovy.gpp.GppTypeConverter;
 import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment;
@@ -260,30 +261,37 @@
   @Nullable
   public GrTypeElement setReturnType(@Nullable PsiType newReturnType) {
     GrTypeElement typeElement = getReturnTypeElementGroovy();
-    if (newReturnType == null) {
+    if (newReturnType == null || newReturnType == PsiType.NULL) {
       if (typeElement != null) typeElement.delete();
+      insertPlaceHolderToModifierList();
       return null;
     }
-    GrTypeElement newTypeElement = GroovyPsiElementFactory.getInstance(getProject()).createTypeElement(newReturnType);
+    final GrTypeElement stub = GroovyPsiElementFactory.getInstance(getProject()).createTypeElement(newReturnType);
+    GrTypeElement newTypeElement;
     if (typeElement == null) {
-      PsiElement anchor = getTypeParameterList();
-      if (anchor == null) anchor = getModifierList();
-      newTypeElement = (GrTypeElement)addAfter(newTypeElement, anchor);
+      final GrTypeParameterList typeParemeterList = getTypeParameterList();
+      PsiElement anchor = typeParemeterList != null ? typeParemeterList : getModifierList();
+      newTypeElement = (GrTypeElement)addAfter(stub, anchor);
     }
     else {
-      newTypeElement = (GrTypeElement)typeElement.replace(newTypeElement);
+      newTypeElement = (GrTypeElement)typeElement.replace(stub);
     }
 
     newTypeElement.accept(new GroovyRecursiveElementVisitor() {
       @Override
       public void visitCodeReferenceElement(GrCodeReferenceElement refElement) {
         super.visitCodeReferenceElement(refElement);
-        org.jetbrains.plugins.groovy.codeStyle.GrReferenceAdjuster.shortenReference(refElement);
+        GrReferenceAdjuster.shortenReference(refElement);
       }
     });
     return newTypeElement;
   }
 
+  private void insertPlaceHolderToModifierList() {
+    final GrModifierList list = getModifierList();
+    PsiImplUtil.insertPlaceHolderToModifierListAtEndIfNeeded(list);
+  }
+
   @Override
   protected boolean isVisibilitySupported() {
     return true;
@@ -538,10 +546,6 @@
     return visitor.getResult();
   }
 
-  public PsiType getReturnTypeNoResolve() {
-    return getReturnType();
-  }
-
   @Override
   public boolean isEquivalentTo(PsiElement another) {
     return PsiClassImplUtil.isMethodEquivalentTo(this, another);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/ClosureSyntheticParameter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/ClosureSyntheticParameter.java
index 2f51020..0b1cb26 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/ClosureSyntheticParameter.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/ClosureSyntheticParameter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 import com.intellij.psi.PsiType;
 import com.intellij.psi.search.LocalSearchScope;
 import com.intellij.psi.search.SearchScope;
+import com.intellij.util.Function;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -28,12 +29,24 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
+import org.jetbrains.plugins.groovy.lang.psi.dataFlow.types.TypeInferenceHelper;
 import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrVariableEnhancer;
 
 /**
  * @author ven
  */
 public class ClosureSyntheticParameter extends GrLightParameter implements NavigationItem, GrRenameableLightElement {
+  private static final Function<ClosureSyntheticParameter,PsiType> TYPES_CALCULATOR = new Function<ClosureSyntheticParameter, PsiType>() {
+    @Override
+    public PsiType fun(ClosureSyntheticParameter parameter) {
+      PsiType typeGroovy = GrVariableEnhancer.getEnhancedType(parameter);
+      if (typeGroovy instanceof PsiIntersectionType) {
+        return ((PsiIntersectionType)typeGroovy).getRepresentative();
+      }
+      return typeGroovy;
+    }
+  };
+
   private final GrClosableBlock myClosure;
 
   public ClosureSyntheticParameter(GrClosableBlock closure) {
@@ -54,11 +67,7 @@
   public PsiType getTypeGroovy() {
     assert isValid();
 
-    PsiType typeGroovy = GrVariableEnhancer.getEnhancedType(this);
-    if (typeGroovy instanceof PsiIntersectionType) {
-      return ((PsiIntersectionType)typeGroovy).getRepresentative();
-    }
-    return typeGroovy;
+    return TypeInferenceHelper.getCurrentContext().getExpressionType(this, TYPES_CALCULATOR);
   }
 
   @Nullable
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightMethodBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightMethodBuilder.java
index d90b73c..96f1e76 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightMethodBuilder.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightMethodBuilder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -445,11 +445,6 @@
     return getContainingFile();
   }
 
-  @Override
-  public PsiType getReturnTypeNoResolve() {
-    return getReturnType();
-  }
-
   protected void copyData(GrLightMethodBuilder dst) {
     dst.setMethodKind(myMethodKind);
     dst.setData(myData);
@@ -460,7 +455,7 @@
     dst.setBaseIcon(myBaseIcon);
     dst.setReturnType(myReturnType);
     dst.setContainingClass(myContainingClass);
-    
+
     dst.getModifierList().copyModifiers(this);
 
     dst.getParameterList().clear();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightTypeElement.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightTypeElement.java
index 14e285b..f10b160 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightTypeElement.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrLightTypeElement.java
@@ -1,8 +1,13 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance withe law or agreed to in writing, software
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
@@ -10,7 +15,6 @@
  */
 package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic;
 
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiManager;
 import com.intellij.psi.PsiType;
 import com.intellij.psi.impl.light.LightElement;
@@ -37,11 +41,6 @@
   }
 
   @Override
-  public PsiType getTypeNoResolve(PsiElement context) {
-    return myType;
-  }
-
-  @Override
   public void accept(GroovyElementVisitor visitor) {
     visitor.visitTypeElement(this);
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrMethodWrapper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrMethodWrapper.java
index 20b18ad..e9a47fb 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrMethodWrapper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrMethodWrapper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,21 +16,25 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.synthetic;
 
 import com.intellij.codeInsight.completion.originInfo.OriginInfoAwareElement;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiMethod;
+import com.intellij.psi.PsiType;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
+import org.jetbrains.plugins.groovy.lang.psi.impl.GrPsiTypeStub;
 
 /**
  * @author Sergey Evdokimov
  */
 public class GrMethodWrapper extends GrLightMethodBuilder {
-
-  private static PsiType TYPE_MARKER = new PsiPrimitiveType("xxx", PsiAnnotation.EMPTY_ARRAY);
-
-  private volatile boolean myNavigationElementInit;
+  private static final PsiType TYPE_MARKER = new GrPsiTypeStub() {
+    @Override
+    public boolean isValid() {
+      return false;
+    }
+  };
 
   private final PsiMethod myWrappedMethod;
+  private volatile boolean myNavigationElementInit;
 
   private GrMethodWrapper(PsiMethod method) {
     super(method.getManager(), method.getName());
@@ -41,15 +45,7 @@
 
     getModifierList().copyModifiers(method);
 
-    for (PsiParameter parameter : method.getParameterList().getParameters()) {
-      GrLightParameter p = new GrLightParameter(StringUtil.notNullize(parameter.getName()), parameter.getType(), this);
-
-      if (parameter instanceof GrParameter) {
-        p.setOptional(((GrParameter)parameter).isOptional());
-      }
-
-      addParameter(p);
-    }
+    getParameterList().copyParameters(method);
 
     if (method instanceof OriginInfoAwareElement) {
       setOriginInfo(((OriginInfoAwareElement)method).getOriginInfo());
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrSyntheticCodeBlock.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrSyntheticCodeBlock.java
index e0344e8..2b925cf 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrSyntheticCodeBlock.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrSyntheticCodeBlock.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -84,7 +84,7 @@
     if (element == null) return null;
 
     final SoftReference<PsiJavaToken> ref = element.getUserData(PSI_JAVA_TOKEN);
-    final PsiJavaToken token = ref == null ? null : ref.get();
+    final PsiJavaToken token = SoftReference.dereference(ref);
     if (token != null) return token;
     final LightJavaToken newToken = new LightJavaToken(element, type);
     element.putUserData(PSI_JAVA_TOKEN, new SoftReference<PsiJavaToken>(newToken));
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrSyntheticTypeElement.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrSyntheticTypeElement.java
index b3e2e3e..b200ed3 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrSyntheticTypeElement.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/synthetic/GrSyntheticTypeElement.java
@@ -48,16 +48,6 @@
     return null;
   }
 
-  @Override
-  public PsiAnnotationOwner getOwner(PsiAnnotation annotation) {
-    return this;
-  }
-
-  @Override
-  public PsiType getTypeNoResolve(@NotNull PsiElement context) {
-    return myElement.getType();
-  }
-
   @NotNull
   @Override
   public PsiAnnotation[] getAnnotations() {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java
index 0d739b4..761cbeb 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/toplevel/imports/GrImportStatementImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,13 +17,16 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.toplevel.imports;
 
 import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.scope.NameHint;
 import com.intellij.psi.scope.PsiScopeProcessor;
+import com.intellij.psi.stubs.IStubElementType;
 import com.intellij.psi.util.CachedValueProvider;
 import com.intellij.psi.util.CachedValuesManager;
 import com.intellij.psi.util.PsiModificationTracker;
 import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.ObjectUtils;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -31,10 +34,12 @@
 import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
 import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
-import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiElementImpl;
+import org.jetbrains.plugins.groovy.lang.psi.impl.GrStubElementBase;
+import org.jetbrains.plugins.groovy.lang.psi.stubs.GrImportStatementStub;
 import org.jetbrains.plugins.groovy.lang.psi.util.GroovyPropertyUtils;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
@@ -45,12 +50,22 @@
 /**
  * @author ilyas
  */
-public class GrImportStatementImpl extends GroovyPsiElementImpl implements GrImportStatement {
+public class GrImportStatementImpl extends GrStubElementBase<GrImportStatementStub> implements GrImportStatement, StubBasedPsiElement<GrImportStatementStub> {
 
   public GrImportStatementImpl(@NotNull ASTNode node) {
     super(node);
   }
 
+  public GrImportStatementImpl(GrImportStatementStub stub, IStubElementType nodeType) {
+    super(stub, nodeType);
+  }
+
+
+  @Override
+  public PsiElement getParent() {
+    return getParentByStub();
+  }
+
   public void accept(GroovyElementVisitor visitor) {
     visitor.visitImportStatement(this);
   }
@@ -84,14 +99,13 @@
 
     NameHint nameHint = processor.getHint(NameHint.KEY);
 
-    GrCodeReferenceElement ref = getImportReference();
-    if (ref == null) return true;
-
     if (isStatic()) {
-      return processSingleStaticImport(processor, state, name, nameHint, ref);
+      GrCodeReferenceElement ref = getImportReference();
+      return ref == null || processSingleStaticImport(processor, state, name, nameHint, ref);
     }
     if (nameHint == null || name.equals(nameHint.getName(state))) {
-      return processSingleClassImport(processor, state, ref);
+      GrCodeReferenceElement ref = getImportReference();
+      return ref == null || processSingleClassImport(processor, state, ref);
     }
     return true;
   }
@@ -240,6 +254,16 @@
   }
 
   public GrCodeReferenceElement getImportReference() {
+    GrImportStatementStub stub = getStub();
+    if (stub != null) {
+      String referenceText = stub.getReferenceText();
+      if (referenceText == null) {
+        return null;
+      }
+
+      return GroovyPsiElementFactory.getInstance(getProject()).createCodeReferenceElementFromText(referenceText);
+    }
+
     return (GrCodeReferenceElement)findChildByType(GroovyElementTypes.REFERENCE_ELEMENT);
   }
 
@@ -247,6 +271,20 @@
   public String getImportedName() {
     if (isOnDemand()) return null;
 
+    GrImportStatementStub stub = getStub();
+    if (stub != null) {
+      String name = stub.getAliasName();
+      if (name != null) {
+        return name;
+      }
+
+      String referenceText = stub.getReferenceText();
+      if (referenceText == null) return null;
+
+      return StringUtil.getShortName(referenceText);
+    }
+
+
     PsiElement aliasNameElement = getAliasNameElement();
     if (aliasNameElement != null) {
       return aliasNameElement.getText();
@@ -257,19 +295,36 @@
   }
 
   public boolean isStatic() {
+    GrImportStatementStub stub = getStub();
+    if (stub != null) {
+      return stub.isStatic();
+    }
+
     return findChildByType(GroovyTokenTypes.kSTATIC) != null;
   }
 
   public boolean isAliasedImport() {
+    GrImportStatementStub stub = getStub();
+    if (stub != null) {
+      return stub.getAliasName() != null;
+    }
     return getAliasNameElement() != null;
   }
 
   public boolean isOnDemand() {
+    GrImportStatementStub stub = getStub();
+    if (stub != null) {
+      return stub.isOnDemand();
+    }
     return findChildByType(GroovyTokenTypes.mSTAR) != null;
   }
 
   @NotNull
   public GrModifierList getAnnotationList() {
+    GrImportStatementStub stub = getStub();
+    if (stub != null) {
+      return ObjectUtils.assertNotNull(getStubOrPsiChild(GroovyElementTypes.MODIFIERS));
+    }
     return findNotNullChildByClass(GrModifierList.class);
   }
 
@@ -293,6 +348,15 @@
   @Nullable
   @Override
   public PsiElement getAliasNameElement() {
+    GrImportStatementStub stub = getStub();
+    if (stub != null) {
+      String alias = stub.getAliasName();
+      if (alias == null) return null;
+
+      GrImportStatement imp = GroovyPsiElementFactory.getInstance(getProject()).createImportStatementFromText("import A as " + alias);
+      return imp.getAliasNameElement();
+    }
+
     return findChildByType(GroovyTokenTypes.mIDENT);
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrArrayTypeElementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrArrayTypeElementImpl.java
index 39c4f00d..3cdec04 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrArrayTypeElementImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrArrayTypeElementImpl.java
@@ -17,7 +17,6 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.types;
 
 import com.intellij.lang.ASTNode;
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiType;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
@@ -51,9 +50,4 @@
   public PsiType getType() {
     return getComponentTypeElement().getType().createArrayType();
   }
-
-  @Override
-  public PsiType getTypeNoResolve(PsiElement context) {
-    return getType();
-  }
 }
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrBuiltInTypeElementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrBuiltInTypeElementImpl.java
index 861507f..5eec3d6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrBuiltInTypeElementImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrBuiltInTypeElementImpl.java
@@ -17,7 +17,6 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.types;
 
 import com.intellij.lang.ASTNode;
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiType;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
@@ -46,9 +45,4 @@
   public PsiType getType() {
     return TypesUtil.getPrimitiveTypeByText(getText());
   }
-
-  @Override
-  public PsiType getTypeNoResolve(PsiElement context) {
-    return getType();
-  }
 }
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrClassTypeElementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrClassTypeElementImpl.java
index 593b315..202b9a8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrClassTypeElementImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrClassTypeElementImpl.java
@@ -16,7 +16,6 @@
 package org.jetbrains.plugins.groovy.lang.psi.impl.types;
 
 import com.intellij.lang.ASTNode;
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiType;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
@@ -52,9 +51,4 @@
   public PsiType getType() {
     return new GrClassReferenceType(getReferenceElement());
   }
-
-  @Override
-  public PsiType getTypeNoResolve(PsiElement context) {
-    return getType();
-  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrCodeReferenceElementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrCodeReferenceElementImpl.java
index 159c92b..aa7ca4c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrCodeReferenceElementImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrCodeReferenceElementImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
+import com.intellij.psi.impl.source.resolve.FileContextUtil;
 import com.intellij.psi.impl.source.resolve.ResolveCache;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.util.PsiTreeUtil;
@@ -40,6 +41,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression;
@@ -142,7 +144,7 @@
         return CLASS_OR_PACKAGE;
       }
       else if (parentKind == STATIC_MEMBER_FQ) {
-        return CLASS;
+        return isQualified() ? CLASS_FQ : CLASS;
       }
       else if (parentKind == CLASS_FQ) return CLASS_OR_PACKAGE_FQ;
       return parentKind;
@@ -163,12 +165,9 @@
       }
     }
     else if (parent instanceof GrNewExpression || parent instanceof GrAnonymousClassDefinition) {
-      if (parent instanceof GrAnonymousClassDefinition) {
-        parent = parent.getParent();
-      }
-      assert parent instanceof GrNewExpression;
-      final GrNewExpression newExpression = (GrNewExpression)parent;
-      if (newExpression.getQualifier() != null) return CLASS_IN_QUALIFIED_NEW;
+      PsiElement newExpr = parent instanceof GrAnonymousClassDefinition ? parent.getParent() : parent;
+      assert newExpr instanceof GrNewExpression;
+      if (((GrNewExpression)newExpr).getQualifier() != null) return CLASS_IN_QUALIFIED_NEW;
     }
 
     return CLASS;
@@ -500,47 +499,29 @@
 
           break;
 
-        case CLASS:
-        case CLASS_OR_PACKAGE: {
+        case CLASS: {
+          EnumSet<ClassHint.ResolveKind> kinds = kind == CLASS ? ResolverProcessor.RESOLVE_KINDS_CLASS : ResolverProcessor.RESOLVE_KINDS_CLASS_PACKAGE;
+          ResolverProcessor processor = new ClassResolverProcessor(refName, ref, kinds);
           GrCodeReferenceElement qualifier = ref.getQualifier();
           if (qualifier != null) {
             PsiElement qualifierResolved = qualifier.resolve();
-            if (qualifierResolved instanceof PsiPackage) {
-              for (final PsiClass aClass : ((PsiPackage)qualifierResolved).getClasses(ref.getResolveScope())) {
-                if (refName.equals(aClass.getName())) {
-                  boolean isAccessible = PsiUtil.isAccessible(ref, aClass);
-                  return new GroovyResolveResult[]{new GroovyResolveResultImpl(aClass, isAccessible)};
-                }
-              }
-
-              if (kind == CLASS_OR_PACKAGE) {
-                final String fqName = ((PsiPackage)qualifierResolved).getQualifiedName() + "." + refName;
-                final PsiPackage aPackage = JavaPsiFacade.getInstance(ref.getProject()).findPackage(fqName);
-                if (aPackage != null) return new GroovyResolveResult[]{new GroovyResolveResultImpl(aPackage, true)};
-              }
-            }
-            else if ((kind == CLASS || kind == CLASS_OR_PACKAGE) && qualifierResolved instanceof PsiClass) {
-              final ClassResolverProcessor processor = new ClassResolverProcessor(refName, ref);
+            if (qualifierResolved instanceof PsiPackage || qualifierResolved instanceof PsiClass) {
               qualifierResolved.processDeclarations(processor, ResolveState.initial(), null, ref);
               return processor.getCandidates();
             }
           }
           else {
-            EnumSet<ClassHint.ResolveKind> kinds = kind == CLASS ? ResolverProcessor.RESOLVE_KINDS_CLASS :
-                                                   ResolverProcessor.RESOLVE_KINDS_CLASS_PACKAGE;
-            ResolverProcessor processor = new ClassResolverProcessor(refName, ref, kinds);
-            ResolveUtil.treeWalkUp(ref, processor, false);
+            // if ref is an annotation name reference we should not process declarations of annotated elements
+            // because inner annotations are not permitted and it can cause infinite recursion
+            PsiElement placeToStartWalking = isAnnotationRef(ref) ? FileContextUtil.getContextFile(ref) : ref;
+            ResolveUtil.treeWalkUp(placeToStartWalking, processor, false);
             GroovyResolveResult[] candidates = processor.getCandidates();
             if (candidates.length > 0) return candidates;
 
             if (kind == CLASS_OR_PACKAGE) {
-              PsiPackage defaultPackage = JavaPsiFacade.getInstance(ref.getProject()).findPackage("");
-              if (defaultPackage != null) {
-                for (final PsiPackage subpackage : defaultPackage.getSubPackages(ref.getResolveScope())) {
-                  if (refName.equals(subpackage.getName())) {
-                    return new GroovyResolveResult[]{new GroovyResolveResultImpl(subpackage, true)};
-                  }
-                }
+              PsiPackage pkg = JavaPsiFacade.getInstance(ref.getProject()).findPackage(refName);
+              if (pkg != null) {
+                return new GroovyResolveResult[]{new GroovyResolveResultImpl(pkg, true)};
               }
             }
           }
@@ -548,6 +529,21 @@
           break;
         }
 
+        case CLASS_OR_PACKAGE: {
+          GroovyResolveResult[] classResult = _resolve(ref, manager, CLASS);
+
+          if (classResult.length == 1 && !classResult[0].isAccessible()) {
+            GroovyResolveResult[] packageResult = _resolve(ref, manager, PACKAGE_FQ);
+            if (packageResult.length != 0) {
+              return packageResult;
+            }
+          }
+          else if (classResult.length == 0) {
+            return _resolve(ref, manager, PACKAGE_FQ);
+          }
+          
+          return classResult;
+        }
         case STATIC_MEMBER_FQ: {
           final GrCodeReferenceElement qualifier = ref.getQualifier();
           if (qualifier != null) {
@@ -600,6 +596,11 @@
       return GroovyResolveResult.EMPTY_ARRAY;
     }
 
+    private static boolean isAnnotationRef(GrCodeReferenceElement ref) {
+      final PsiElement parent = ref.getParent();
+      return parent instanceof GrAnnotation || parent instanceof GrCodeReferenceElement && isAnnotationRef((GrCodeReferenceElement)parent);
+    }
+
     private static void processAccessors(GrCodeReferenceElementImpl ref,
                                          String refName,
                                          PsiClass clazz,
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrDisjunctionTypeElementImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrDisjunctionTypeElementImpl.java
index 45ca807..1030331 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrDisjunctionTypeElementImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrDisjunctionTypeElementImpl.java
@@ -69,11 +69,6 @@
   }
 
   @Override
-  public PsiType getTypeNoResolve(PsiElement context) {
-    return getType();
-  }
-
-  @Override
   public void subtreeChanged() {
     super.subtreeChanged();
     myCachedType = null;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrTypeArgumentListImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrTypeArgumentListImpl.java
index a9fce13..fc22dda 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrTypeArgumentListImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrTypeArgumentListImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
 import com.intellij.lang.ASTNode;
 import com.intellij.psi.PsiType;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
@@ -33,6 +34,7 @@
     super(node);
   }
 
+  @Override
   public void accept(GroovyElementVisitor visitor) {
     visitor.visitTypeArgumentList(this);
   }
@@ -41,6 +43,7 @@
     return "Type arguments";
   }
 
+  @Override
   public GrTypeElement[] getTypeArgumentElements() {
     return findChildrenByClass(GrTypeElement.class);
   }
@@ -50,14 +53,39 @@
     final GrTypeElement[] elements = getTypeArgumentElements();
     if (elements.length == 0) return PsiType.EMPTY_ARRAY;
 
-    PsiType[] result = new PsiType[elements.length];
+    PsiType[] result = PsiType.createArray(elements.length);
     for (int i = 0; i < elements.length; i++) {
       result[i] = elements[i].getType();
     }
     return result;
   }
 
+  @Override
   public boolean isDiamond() {
     return getTypeArgumentElements().length == 0;
   }
+
+  @Override
+  public ASTNode addInternal(ASTNode first, ASTNode last, ASTNode anchor, Boolean before) {
+    if (first == last && first.getPsi() instanceof GrTypeElement) {
+      if (anchor == null) {
+        anchor = getLastChild().getNode();
+        before = true;
+      }
+      if (getTypeArgumentElements().length > 0) {
+        if (before == null || before.booleanValue()) {
+          getNode().addLeaf(GroovyTokenTypes.mCOMMA, ",", anchor);
+        }
+        else {
+          getNode().addLeaf(GroovyTokenTypes.mCOMMA, ",", anchor.getTreeNext());
+        }
+      }
+
+      return super.addInternal(first, last, anchor, before);
+    }
+
+    else {
+      return super.addInternal(first, last, anchor, before);
+    }
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrWildcardTypeArgumentImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrWildcardTypeArgumentImpl.java
index 0208258..01c1c71 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrWildcardTypeArgumentImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/types/GrWildcardTypeArgumentImpl.java
@@ -18,7 +18,6 @@
 
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiType;
 import com.intellij.psi.PsiWildcardType;
 import org.jetbrains.annotations.NotNull;
@@ -58,11 +57,6 @@
     return null;
   }
 
-  @Override
-  public PsiType getTypeNoResolve(PsiElement context) {
-    return getType();
-  }
-
   public GrTypeElement getBoundTypeElement() {
     return findChildByClass(GrTypeElement.class);
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/patterns/GroovyMethodCallPattern.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/patterns/GroovyMethodCallPattern.java
index 450a7bd..d87020b 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/patterns/GroovyMethodCallPattern.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/patterns/GroovyMethodCallPattern.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/GrAnnotationStub.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/GrAnnotationStub.java
index f78b7f3..811384c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/GrAnnotationStub.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/GrAnnotationStub.java
@@ -1,28 +1,65 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.jetbrains.plugins.groovy.lang.psi.stubs;
 
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.psi.stubs.StubBase;
 import com.intellij.psi.stubs.StubElement;
-import com.intellij.util.io.StringRef;
+import com.intellij.reference.SoftReference;
+import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
 
 /**
  * @author peter
  */
 public class GrAnnotationStub extends StubBase<GrAnnotation> {
-  private final StringRef myReference;
+  private static final Logger LOG = Logger.getInstance(GrAnnotationStub.class);
 
-  public GrAnnotationStub(StubElement parent, StringRef reference) {
+  private final String myText;
+  private SoftReference<GrAnnotation> myPsiRef;
+
+  public GrAnnotationStub(StubElement parent, String text) {
     super(parent, GroovyElementTypes.ANNOTATION);
-    myReference = reference;
+    myText = text;
   }
 
   public GrAnnotationStub(StubElement parent, GrAnnotation from) {
     super(parent, GroovyElementTypes.ANNOTATION);
-    myReference = StringRef.fromString(from.getClassReference().getReferenceName());
+    myText = from.getText();
   }
 
-  public String getAnnotationName() {
-    return myReference.getString();
+  public GrAnnotation getPsiElement() {
+    GrAnnotation annotation = SoftReference.dereference(myPsiRef);
+    if (annotation != null) {
+      return annotation;
+    }
+    try {
+      annotation = GroovyPsiElementFactory.getInstance(getProject()).createAnnotationFromText(myText, getPsi());
+      myPsiRef = new SoftReference<GrAnnotation>(annotation);
+      return annotation;
+    }
+    catch (IncorrectOperationException e) {
+      LOG.error("Bad annotation in repository!", e);
+      return null;
+    }
+  }
+
+  public String getText() {
+    return myText;
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/GrImportStatementStub.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/GrImportStatementStub.java
new file mode 100644
index 0000000..dd678bb
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/GrImportStatementStub.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.stubs;
+
+import com.intellij.psi.stubs.IStubElementType;
+import com.intellij.psi.stubs.StubBase;
+import com.intellij.psi.stubs.StubElement;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
+
+/**
+ * Created by Max Medvedev on 11/29/13
+ */
+public class GrImportStatementStub extends StubBase<GrImportStatement> implements StubElement<GrImportStatement> {
+  private static final byte STATIC_MASK = 0x1;
+  private static final byte ON_DEMAND_MASK = 0x2;
+
+  private final byte myFlags;
+  private final String myReferenceText;
+  private final String myAliasName;
+
+  public GrImportStatementStub(StubElement parent,
+                               IStubElementType elementType,
+                               @Nullable String referenceText,
+                               @Nullable String aliasName,
+                               byte flags) {
+    super(parent, elementType);
+
+    myFlags = flags;
+
+    myReferenceText = referenceText;
+    myAliasName = aliasName;
+  }
+
+  public static byte buildFlags(boolean isStatic, boolean isOnDemand) {
+    return (byte)((isStatic ? 1 : 0) * STATIC_MASK +
+                  (isOnDemand ? 1 : 0) * ON_DEMAND_MASK);
+  }
+
+  public boolean isStatic() {
+    return (myFlags & STATIC_MASK) != 0;
+  }
+
+  public boolean isOnDemand() {
+    return (myFlags & ON_DEMAND_MASK) != 0;
+  }
+
+  @Nullable
+  public String getReferenceText() {
+    return myReferenceText;
+  }
+
+  @Nullable
+  public String getAliasName() {
+    return myAliasName;
+  }
+
+  public byte getFlags() {
+    return myFlags;
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrAnnotationElementType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrAnnotationElementType.java
new file mode 100644
index 0000000..9dc51c8
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrAnnotationElementType.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.stubs.elements;
+
+import com.intellij.psi.stubs.StubElement;
+import com.intellij.psi.stubs.StubInputStream;
+import com.intellij.psi.stubs.StubOutputStream;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
+import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.annotation.GrAnnotationImpl;
+import org.jetbrains.plugins.groovy.lang.psi.stubs.GrAnnotationStub;
+
+import java.io.IOException;
+
+/**
+ * Created by Max Medvedev on 12/6/13
+ */
+public class GrAnnotationElementType extends GrStubElementType<GrAnnotationStub, GrAnnotation> {
+  public GrAnnotationElementType(@NotNull String name) {
+    super(name);
+  }
+
+  @Override
+  public GrAnnotation createPsi(@NotNull GrAnnotationStub stub) {
+    return new GrAnnotationImpl(stub);
+  }
+
+  @Override
+  public GrAnnotationStub createStub(@NotNull GrAnnotation psi, StubElement parentStub) {
+    return new GrAnnotationStub(parentStub, psi);
+  }
+
+  @Override
+  public void serialize(@NotNull GrAnnotationStub stub, @NotNull StubOutputStream dataStream) throws IOException {
+    dataStream.writeUTFFast(stub.getText());
+  }
+
+  @NotNull
+  @Override
+  public GrAnnotationStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
+    return new GrAnnotationStub(parentStub, dataStream.readUTFFast());
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrImportStatementElementType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrImportStatementElementType.java
new file mode 100644
index 0000000..6662470
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrImportStatementElementType.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi.stubs.elements;
+
+import com.intellij.psi.stubs.StubElement;
+import com.intellij.psi.stubs.StubInputStream;
+import com.intellij.psi.stubs.StubOutputStream;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
+import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
+import org.jetbrains.plugins.groovy.lang.psi.impl.toplevel.imports.GrImportStatementImpl;
+import org.jetbrains.plugins.groovy.lang.psi.stubs.GrImportStatementStub;
+import org.jetbrains.plugins.groovy.lang.psi.stubs.GrStubUtils;
+
+import java.io.IOException;
+
+/**
+ * Created by Max Medvedev on 11/29/13
+ */
+public class GrImportStatementElementType extends GrStubElementType<GrImportStatementStub, GrImportStatement> {
+
+  public GrImportStatementElementType(String debugName) {
+    super(debugName);
+  }
+
+  @Override
+  public GrImportStatement createPsi(@NotNull GrImportStatementStub stub) {
+    return new GrImportStatementImpl(stub, this);
+  }
+
+  @Override
+  public GrImportStatementStub createStub(@NotNull GrImportStatement psi, StubElement parentStub) {
+    GrCodeReferenceElement ref = psi.getImportReference();
+    return new GrImportStatementStub(parentStub,
+                                     this,
+                                     ref != null ? ref.getText() : null,
+                                     psi.isAliasedImport() ? psi.getImportedName() : null,
+                                     GrImportStatementStub.buildFlags(psi.isStatic(), psi.isOnDemand())
+    );
+  }
+
+  @Override
+  public void serialize(@NotNull GrImportStatementStub stub, @NotNull StubOutputStream dataStream) throws IOException {
+    GrStubUtils.writeNullableString(dataStream, stub.getReferenceText());
+    GrStubUtils.writeNullableString(dataStream, stub.getAliasName());
+    dataStream.writeByte(stub.getFlags());
+  }
+
+  @NotNull
+  @Override
+  public GrImportStatementStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException {
+    String referenceText = GrStubUtils.readNullableString(dataStream);
+    String aliasName = GrStubUtils.readNullableString(dataStream);
+    byte flags = dataStream.readByte();
+
+    return new GrImportStatementStub(parentStub, this, referenceText, aliasName, flags);
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrReferenceListElementType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrReferenceListElementType.java
index 3deae8d..71dab4f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrReferenceListElementType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrReferenceListElementType.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -70,5 +70,10 @@
       }
     }
   }
+
+  @Override
+  public boolean isLeftBound() {
+    return true;
+  }
 }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrStubFileElementType.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrStubFileElementType.java
index 9e888cc..c54cc96 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrStubFileElementType.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/elements/GrStubFileElementType.java
@@ -55,7 +55,7 @@
 
   @Override
   public int getStubVersion() {
-    return super.getStubVersion() + 18;
+    return super.getStubVersion() + 20;
   }
 
   @NotNull
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/index/GrFullClassNameIndex.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/index/GrFullClassNameIndex.java
index 696ea8e..eb00004 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/index/GrFullClassNameIndex.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/stubs/index/GrFullClassNameIndex.java
@@ -43,6 +43,6 @@
   }
 
   public Collection<PsiClass> get(final Integer integer, final Project project, final GlobalSearchScope scope) {
-    return StubIndex.getInstance().safeGet(getKey(), integer, project, new GrSourceFilterScope(scope), PsiClass.class);
+    return StubIndex.getElements(getKey(), integer, project, new GrSourceFilterScope(scope), PsiClass.class);
   }
 }
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/ClosureAsAnonymousParameterEnhancer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/ClosureAsAnonymousParameterEnhancer.java
index 7290d529..165b5f7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/ClosureAsAnonymousParameterEnhancer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/ClosureAsAnonymousParameterEnhancer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,9 +15,12 @@
  */
 package org.jetbrains.plugins.groovy.lang.psi.typeEnhancers;
 
+import com.intellij.psi.PsiSubstitutor;
 import com.intellij.psi.PsiType;
+import com.intellij.psi.PsiWildcardType;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.config.GroovyConfigUtils;
 import org.jetbrains.plugins.groovy.gpp.GppClosureParameterTypeProvider;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrSafeCastExpression;
@@ -63,7 +66,13 @@
     for (PsiType constraint : expectedTypes) {
       final PsiType suggestion = GppClosureParameterTypeProvider.getSingleMethodParameterType(constraint, index, closure);
       if (suggestion != null) {
-        return suggestion;
+        if (GroovyConfigUtils.getInstance().isVersionAtLeast(closure, GroovyConfigUtils.GROOVY2_3)) {
+          if (suggestion instanceof PsiWildcardType && ((PsiWildcardType)suggestion).isSuper()) {
+            return ((PsiWildcardType)suggestion).getBound();
+          }
+        }
+
+        return TypesUtil.substituteBoxAndNormalizeType(suggestion, PsiSubstitutor.EMPTY, null, closure);
       }
     }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/ClosureParameterEnhancer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/ClosureParameterEnhancer.java
index 6266c82..2e88f33 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/ClosureParameterEnhancer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/ClosureParameterEnhancer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,9 +16,11 @@
 package org.jetbrains.plugins.groovy.lang.psi.typeEnhancers;
 
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Pair;
 import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.util.InheritanceUtil;
+import com.intellij.psi.util.MethodSignature;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.util.containers.hash.HashMap;
 import com.intellij.util.containers.hash.HashSet;
@@ -35,6 +37,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.impl.GrRangeType;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType;
 import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
+import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
 import org.jetbrains.plugins.groovy.lang.psi.util.GdkMethodUtil;
 import org.jetbrains.plugins.groovy.lang.resolve.ResolveUtil;
@@ -84,6 +87,7 @@
     simpleTypes.put("replaceAll", "java.util.regex.Matcher");
     simpleTypes.put("replaceFirst", "java.util.regex.Matcher");
     simpleTypes.put("splitEachLine", "java.util.List<java.lang.String>");
+    simpleTypes.put("withBatch", "groovy.sql.BatchingStatementWrapper");
 
     iterations.add("each");
     iterations.add("any");
@@ -128,6 +132,12 @@
     if (!(parent instanceof GrMethodCall)) {
       return null;
     }
+
+    PsiType fromSam = inferParameterTypeFromSAM((GrMethodCall)parent, closure, index);
+    if (fromSam != null) {
+      return fromSam;
+    }
+
     String methodName = findMethodName((GrMethodCall)parent);
 
     GrExpression expression = ((GrMethodCall)parent).getInvokedExpression();
@@ -254,6 +264,41 @@
     return null;
   }
 
+  @Nullable
+  private static PsiType inferParameterTypeFromSAM(@NotNull GrMethodCall methodCall, @NotNull GrClosableBlock closure, int index) {
+    if (!ClosureToSamConverter.isSamConversionAllowed(methodCall)) return null;
+
+    GroovyResolveResult resolveResult = methodCall.advancedResolve();
+    PsiElement resolved = resolveResult.getElement();
+
+    if (!(resolved instanceof PsiMethod)) return null;
+
+
+
+    Map<GrExpression,Pair<PsiParameter,PsiType>> map = GrClosureSignatureUtil.mapArgumentsToParameters(resolveResult, methodCall, false, true,
+                                                                                                       methodCall.getNamedArguments(),
+                                                                                                       methodCall.getExpressionArguments(),
+                                                                                                       methodCall.getClosureArguments());
+    if (map == null) return null;
+
+    Pair<PsiParameter, PsiType> samParameter = map.get(closure);
+    assert samParameter != null;
+
+    PsiType samTypeSubstituted = samParameter.getSecond();
+    if (!(samTypeSubstituted instanceof PsiClassType)) return null;
+
+    MethodSignature samSignature = ClosureToSamConverter.findSAMSignature(samTypeSubstituted);
+    if (samSignature == null) return null;
+
+    PsiType[] parameterTypes = samSignature.getParameterTypes();
+
+    if (index >= parameterTypes.length) {
+      return null;
+    }
+
+    return parameterTypes[index];
+  }
+
 
   @Nullable
   private static PsiType getEntryForMap(@Nullable PsiType map, @NotNull final Project project, @NotNull final GlobalSearchScope scope) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/ClosureToSamConverter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/ClosureToSamConverter.java
index 8c574fe..32faeb7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/ClosureToSamConverter.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/ClosureToSamConverter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,8 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType;
 import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
+import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
 import org.jetbrains.plugins.groovy.util.LightCacheKey;
 
 import java.util.Collection;
@@ -44,19 +46,21 @@
 
   @Override
   public Boolean isConvertible(@NotNull PsiType ltype, @NotNull PsiType rtype, @NotNull final GroovyPsiElement context) {
-    if (rtype instanceof GrClosureType && ltype instanceof PsiClassType && GroovyConfigUtils.getInstance().isVersionAtLeast(context, GroovyConfigUtils.GROOVY2_2)) {
-      PsiClassType.ClassResolveResult resolveResult = ((PsiClassType)ltype).resolveGenerics();
-      final PsiClass resolved = resolveResult.getElement();
-      if (resolved != null) {
-        final MethodSignature signature = findSingleAbstractMethodClass(resolved, resolveResult.getSubstitutor());
-        if (signature != null) {
+    if (rtype instanceof GrClosureType &&
+        ltype instanceof PsiClassType &&
+        isSamConversionAllowed(context) &&
+        !TypesUtil.isClassType(ltype, GroovyCommonClassNames.GROOVY_LANG_CLOSURE)) {
+      MethodSignature signature = findSAMSignature(ltype);
+      if (signature != null) {
+        final PsiType[] samParameterTypes = signature.getParameterTypes();
 
-          final PsiType[] samParameterTypes = signature.getParameterTypes();
+        GrSignature closureSignature = ((GrClosureType)rtype).getSignature();
 
-          GrSignature closureSignature = ((GrClosureType)rtype).getSignature();
-          if (GrClosureSignatureUtil.isSignatureApplicable(closureSignature, samParameterTypes, context)) {
-            return true;
-          }
+        boolean raw = ((PsiClassType)ltype).isRaw();
+        if (raw) return true;
+
+        if (GrClosureSignatureUtil.isSignatureApplicable(closureSignature, samParameterTypes, context)) {
+          return true;
         }
       }
     }
@@ -64,17 +68,20 @@
     return null;
   }
 
+  public static boolean isSamConversionAllowed(PsiElement context) {
+    return GroovyConfigUtils.getInstance().isVersionAtLeast(context, GroovyConfigUtils.GROOVY2_2);
+  }
+
   @Nullable
-  private static MethodSignature findSingleAbstractMethodClass(@NotNull PsiClass aClass,
-                                                               @NotNull PsiSubstitutor substitutor) {
+  public static MethodSignature findSingleAbstractMethod(@NotNull PsiClass aClass, @NotNull PsiSubstitutor substitutor) {
     MethodSignature signature;
     Ref<MethodSignature> cached = SAM_SIGNATURE_LIGHT_CACHE_KEY.getCachedValue(aClass);
     if (cached != null) {
       signature = cached.get();
     }
     else {
-      cached = Ref.create(doFindSingleAbstractMethodClass(aClass));
-      signature = SAM_SIGNATURE_LIGHT_CACHE_KEY.putCachedValue(aClass, cached).get();
+      Ref<MethodSignature> newCached = Ref.create(doFindSingleAbstractMethodClass(aClass));
+      signature = SAM_SIGNATURE_LIGHT_CACHE_KEY.putCachedValue(aClass, newCached).get();
     }
 
     return signature != null ? substitute(signature, substitutor): null;
@@ -100,4 +107,20 @@
   private static MethodSignature substitute(@NotNull MethodSignature signature, @NotNull PsiSubstitutor substitutor) {
     return MethodSignatureUtil.createMethodSignature(signature.getName(), signature.getParameterTypes(), PsiTypeParameter.EMPTY_ARRAY, substitutor, false);
   }
+
+  @Nullable
+  public static MethodSignature findSAMSignature(@Nullable PsiType type) {
+    if (type instanceof PsiClassType) {
+      if (TypesUtil.isClassType(type, GroovyCommonClassNames.GROOVY_LANG_CLOSURE)) return null;
+
+      PsiClassType.ClassResolveResult result = ((PsiClassType)type).resolveGenerics();
+      PsiClass aClass = result.getElement();
+
+      if (aClass != null) {
+        return findSingleAbstractMethod(aClass, result.getSubstitutor());
+      }
+    }
+
+    return null;
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrGenericTypeConverter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrGenericTypeConverter.java
index e9a7c74..cb403a4 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrGenericTypeConverter.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/typeEnhancers/GrGenericTypeConverter.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.jetbrains.plugins.groovy.lang.psi.typeEnhancers;
 
 import com.intellij.psi.*;
@@ -25,12 +40,8 @@
       return null;
     }
 
-
-    PsiClassType.ClassResolveResult lresult = ((PsiClassType)ltype).resolveGenerics();
-    PsiClassType.ClassResolveResult rresult = ((PsiClassType)rtype).resolveGenerics();
-
-    PsiClass lclass = lresult.getElement();
-    PsiClass rclass = rresult.getElement();
+    PsiClass lclass = ((PsiClassType)ltype).resolve();
+    PsiClass rclass = ((PsiClassType)rtype).resolve();
 
     if (lclass == null || rclass == null) return null;
 
@@ -38,6 +49,9 @@
 
     if (!InheritanceUtil.isInheritorOrSelf(rclass, lclass, true)) return null;
 
+    PsiClassType.ClassResolveResult lresult = ((PsiClassType)ltype).resolveGenerics();
+    PsiClassType.ClassResolveResult rresult = ((PsiClassType)rtype).resolveGenerics();
+
     if (typeParametersAgree(lclass, rclass, lresult.getSubstitutor(), rresult.getSubstitutor(), context)) return Boolean.TRUE;
 
     return null;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java
index 27e42e2..dc08b53 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrClassImplUtil.java
@@ -40,7 +40,6 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumConstantInitializer;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
@@ -50,6 +49,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrReflectedMethod;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
+import org.jetbrains.plugins.groovy.lang.psi.impl.GrAnnotationUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyPsiManager;
 import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
@@ -616,21 +616,8 @@
   }
 
   private static boolean shouldImplementDelegatedInterfaces(PsiAnnotation delegate) {
-    final PsiAnnotationParameterList parameterList = delegate.getParameterList();
-    final PsiNameValuePair[] attributes = parameterList.getAttributes();
-    for (PsiNameValuePair attribute : attributes) {
-      final String name = attribute.getName();
-      if ("interfaces".equals(name)) {
-        final PsiAnnotationMemberValue value = attribute.getValue();
-        if (value instanceof GrLiteral) {
-          final Object innerValue = ((GrLiteral)value).getValue();
-          if (innerValue instanceof Boolean) {
-            return (Boolean)innerValue;
-          }
-        }
-      }
-    }
-    return true;
+    final Boolean result = GrAnnotationUtil.inferBooleanAttribute(delegate, "interfaces");
+    return result != null ? result.booleanValue() : true;
   }
 
   public static void addExpandingReflectedMethods(List<PsiMethod> result, PsiMethod method) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrImportUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrImportUtil.java
index 96e02cf..2c8196a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrImportUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrImportUtil.java
@@ -16,7 +16,7 @@
 package org.jetbrains.plugins.groovy.lang.psi.util;
 
 import com.intellij.psi.PsiFile;
-import com.intellij.util.containers.MultiMapBasedOnSet;
+import com.intellij.util.containers.MultiMap;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
@@ -30,7 +30,7 @@
  * @author Max Medvedev
  */
 public class GrImportUtil {
-  private static final LightCacheKey<MultiMapBasedOnSet<String, String>> KEY = LightCacheKey.createByFileModificationCount();
+  private static final LightCacheKey<MultiMap<String, String>> KEY = LightCacheKey.createByFileModificationCount();
 
   public static boolean acceptName(GrReferenceElement ref, String expected) {
     final String actual = ref.getReferenceName();
@@ -40,7 +40,7 @@
 
     final PsiFile file = ref.getContainingFile();
     if (file instanceof GroovyFile) {
-      MultiMapBasedOnSet<String, String> data = KEY.getCachedValue(file);
+      MultiMap<String, String> data = KEY.getCachedValue(file);
       if (data == null) {
         data = collectAliases((GroovyFile)file);
         KEY.putCachedValue(file, data);
@@ -55,8 +55,8 @@
   }
 
   @NotNull
-  private static MultiMapBasedOnSet<String, String> collectAliases(@NotNull GroovyFile file) {
-    MultiMapBasedOnSet<String, String> aliases = new MultiMapBasedOnSet<String, String>();
+  private static MultiMap<String, String> collectAliases(@NotNull GroovyFile file) {
+    MultiMap<String, String> aliases = MultiMap.createSet();
 
     for (GrImportStatement anImport : file.getImportStatements()) {
       if (anImport.isAliasedImport()) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrInnerClassConstructorUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrInnerClassConstructorUtil.java
index 2a9b081..e233d78 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrInnerClassConstructorUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrInnerClassConstructorUtil.java
@@ -68,13 +68,13 @@
         PsiElementFactory factory = JavaPsiFacade.getElementFactory(place.getProject());
         PsiClass scopeClass = PsiUtil.findEnclosingInstanceClassInScope(containingClass, place, true);
         if (scopeClass != null) {
-          PsiType[] newTypes = new PsiType[types.length + 1];
+          PsiType[] newTypes = PsiType.createArray(types.length + 1);
           newTypes[0] = factory.createType(scopeClass);
           System.arraycopy(types, 0, newTypes, 1, types.length);
           types = newTypes;
         }
         else if (types.length == 0 || !TypesUtil.isAssignableByMethodCallConversion(factory.createType(containingClass), types[0], place)) {
-          PsiType[] newTypes = new PsiType[types.length + 1];
+          PsiType[] newTypes = PsiType.createArray(types.length + 1);
           newTypes[0] = PsiType.NULL;
           System.arraycopy(types, 0, newTypes, 1, types.length);
           types = newTypes;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrStringUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrStringUtil.java
index 3cd67f2..e3f1da5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrStringUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GrStringUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -44,13 +44,13 @@
 public class GrStringUtil {
   private static final Logger LOG = Logger.getInstance(GrStringUtil.class);
 
-  private static final String TRIPLE_QUOTES = "'''";
-  private static final String QUOTE = "'";
-  private static final String DOUBLE_QUOTES = "\"";
-  private static final String TRIPLE_DOUBLE_QUOTES = "\"\"\"";
-  private static final String SLASH = "/";
-  private static final String DOLLAR_SLASH = "$/";
-  private static final String SLASH_DOLLAR = "/$";
+  public static final String TRIPLE_QUOTES = "'''";
+  public static final String QUOTE = "'";
+  public static final String DOUBLE_QUOTES = "\"";
+  public static final String TRIPLE_DOUBLE_QUOTES = "\"\"\"";
+  public static final String SLASH = "/";
+  public static final String DOLLAR_SLASH = "$/";
+  public static final String SLASH_DOLLAR = "/$";
 
   private GrStringUtil() {
   }
@@ -602,12 +602,12 @@
   }
 
   public static String getEndQuote(String text) {
-    if (text.startsWith(TRIPLE_QUOTES)) return TRIPLE_QUOTES;
-    if (text.startsWith(QUOTE)) return QUOTE;
-    if (text.startsWith(TRIPLE_DOUBLE_QUOTES)) return TRIPLE_DOUBLE_QUOTES;
-    if (text.startsWith(DOUBLE_QUOTES)) return DOUBLE_QUOTES;
-    if (text.startsWith(SLASH)) return SLASH;
-    if (text.startsWith(SLASH_DOLLAR)) return SLASH_DOLLAR;
+    if (text.endsWith(TRIPLE_QUOTES)) return TRIPLE_QUOTES;
+    if (text.endsWith(QUOTE)) return QUOTE;
+    if (text.endsWith(TRIPLE_DOUBLE_QUOTES)) return TRIPLE_DOUBLE_QUOTES;
+    if (text.endsWith(DOUBLE_QUOTES)) return DOUBLE_QUOTES;
+    if (text.endsWith(SLASH)) return SLASH;
+    if (text.endsWith(SLASH_DOLLAR)) return SLASH_DOLLAR;
     return "";
   }
 
@@ -690,6 +690,10 @@
           break;
         default:
           outChars.append('\\').append(c);
+          if (sourceOffsets != null) {
+            sourceOffsets[outChars.length() - outOffset] = index;
+          }
+
       }
     }
     return true;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyCommonClassNames.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyCommonClassNames.java
index 27f597b..cfd5a26 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyCommonClassNames.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/GroovyCommonClassNames.java
@@ -15,8 +15,12 @@
  */
 package org.jetbrains.plugins.groovy.lang.psi.util;
 
+import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NonNls;
 
+import java.util.Collections;
+import java.util.Set;
+
 /**
  * @author Maxim.Medvedev
  */
@@ -66,6 +70,22 @@
   @NonNls public static final String GROOVY_TRANSFORM_COMPILE_DYNAMIC = "groovy.transform.CompileDynamic";
 
 
+  public static final Set<String> GROOVY_EXTENSION_CLASSES = Collections.unmodifiableSet(ContainerUtil.newLinkedHashSet(
+    "org.codehaus.groovy.runtime.DateGroovyMethods",
+    "org.codehaus.groovy.runtime.DefaultGroovyMethods",
+    "org.codehaus.groovy.runtime.DefaultGroovyStaticMethods",
+    "org.codehaus.groovy.runtime.EncodingGroovyMethods",
+    "org.codehaus.groovy.runtime.IOGroovyMethods",
+    "org.codehaus.groovy.runtime.ProcessGroovyMethods",
+    "org.codehaus.groovy.runtime.ResourceGroovyMethods",
+    "org.codehaus.groovy.runtime.SocketGroovyMethods",
+    "org.codehaus.groovy.runtime.SqlGroovyMethods",
+    "org.codehaus.groovy.runtime.StringGroovyMethods",
+    "org.codehaus.groovy.runtime.SwingGroovyMethods",
+    "org.codehaus.groovy.runtime.XmlGroovyMethods",
+    "org.codehaus.groovy.vmplugin.v5.PluginDefaultGroovyMethods"
+  ));
+
   private GroovyCommonClassNames() {
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java
index 0577681..bbdd353 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,18 +28,18 @@
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.tree.TokenSet;
-import com.intellij.psi.util.InheritanceUtil;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.TypeConversionUtil;
+import com.intellij.psi.util.*;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.VisibilityUtil;
 import com.intellij.util.containers.HashSet;
 import gnu.trove.TIntStack;
+import org.jetbrains.annotations.Contract;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
 import org.jetbrains.plugins.groovy.config.GroovyConfigUtils;
+import org.jetbrains.plugins.groovy.intentions.base.ErrorUtil;
 import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyLexer;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
@@ -56,6 +56,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrSpreadArgument;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrAssertStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
@@ -63,6 +64,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrForInClause;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrIndexProperty;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrPropertySelection;
@@ -73,6 +75,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
 import org.jetbrains.plugins.groovy.lang.psi.api.util.GrNamedArgumentsOwner;
+import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction;
 import org.jetbrains.plugins.groovy.lang.psi.dataFlow.types.TypeInferenceHelper;
 import org.jetbrains.plugins.groovy.lang.psi.impl.*;
 import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil;
@@ -249,10 +252,9 @@
       GrIndexProperty index = (GrIndexProperty)parent;
       PsiType[] argTypes = getArgumentTypes(index.getNamedArguments(), index.getExpressionArguments(), index.getClosureArguments(), nullAsBottom, stopAt, byShape);
       if (isLValue(index) && argTypes != null) {
-        PsiType initializer = TypeInferenceHelper.getInitializerFor(index);
-        if (initializer == null && !nullAsBottom) {
-          initializer = TypesUtil.getJavaLangObject(index);
-        }
+        PsiType rawInitializer = TypeInferenceHelper.getInitializerTypeFor(index);
+
+        PsiType initializer = notNullizeType(rawInitializer, nullAsBottom, index);
         return ArrayUtil.append(argTypes, initializer);
       }
       else {
@@ -270,18 +272,26 @@
     else if (parent instanceof GrAnonymousClassDefinition) {
       final GrArgumentList argList = ((GrAnonymousClassDefinition)parent).getArgumentListGroovy();
       if (argList == null) {
-        return getArgumentTypes(GrNamedArgument.EMPTY_ARRAY, GrExpression.EMPTY_ARRAY, GrClosableBlock.EMPTY_ARRAY, nullAsBottom, stopAt,
-                                byShape);
+        return getArgumentTypes(GrNamedArgument.EMPTY_ARRAY, GrExpression.EMPTY_ARRAY, GrClosableBlock.EMPTY_ARRAY, nullAsBottom, stopAt, byShape);
       }
       else {
-        return getArgumentTypes(argList.getNamedArguments(), argList.getExpressionArguments(), GrClosableBlock.EMPTY_ARRAY, nullAsBottom,
-                                stopAt, byShape);
+        return getArgumentTypes(argList.getNamedArguments(), argList.getExpressionArguments(), GrClosableBlock.EMPTY_ARRAY, nullAsBottom, stopAt, byShape);
       }
     }
+    else if (parent instanceof GrBinaryExpression) {
+      GrExpression right = ((GrBinaryExpression)parent).getRightOperand();
+      PsiType type = right != null ? right.getType() : null;
+      return new PsiType[] {notNullizeType(type, nullAsBottom, parent)};
+    }
 
     return null;
   }
 
+  @Contract("_, false, _ -> !null; !null, _, _ -> !null; null, true, _ -> null")
+  private static PsiType notNullizeType(PsiType type, boolean acceptNull, PsiElement context) {
+    return type != null || acceptNull ? type : TypesUtil.getJavaLangObject(context);
+  }
+
   @Nullable
   public static PsiType[] getArgumentTypes(GrArgumentList argList) {
     return getArgumentTypes(argList, false, null, false);
@@ -323,7 +333,7 @@
       }
 
       if (stopAt == expression) {
-        return result.toArray(new PsiType[result.size()]);
+        return result.toArray(PsiType.createArray(result.size()));
       }
     }
 
@@ -333,14 +343,14 @@
         if (stopAt == closure) {
           closureType = TypeConversionUtil.erasure(closureType);
         }
-        result.add(closureType == null && !nullAsBottom ? TypesUtil.getJavaLangObject(closure) : closureType);
+        result.add(notNullizeType(closureType, nullAsBottom, closure));
       }
       if (stopAt == closure) {
         break;
       }
     }
 
-    return result.toArray(new PsiType[result.size()]);
+    return result.toArray(PsiType.createArray(result.size()));
   }
 
   @Nullable
@@ -390,8 +400,9 @@
     }
   }
 
-  public static Iterable<PsiClass> iterateSupers(final @NotNull PsiClass psiClass, final boolean includeSelf) {
+  public static Iterable<PsiClass> iterateSupers(@NotNull final PsiClass psiClass, final boolean includeSelf) {
     return new Iterable<PsiClass>() {
+      @Override
       public Iterator<PsiClass> iterator() {
         return new Iterator<PsiClass>() {
           TIntStack indices = new TIntStack();
@@ -413,6 +424,7 @@
             pushSuper(psiClass);
           }
 
+          @Override
           public boolean hasNext() {
             nextElement();
             return current != null;
@@ -450,6 +462,7 @@
             indices.push(0);
           }
 
+          @Override
           @NotNull
           public PsiClass next() {
             nextElement();
@@ -458,6 +471,7 @@
             return current;
           }
 
+          @Override
           public void remove() {
             throw new IllegalStateException("should not be called");
           }
@@ -600,7 +614,7 @@
       PsiClassType classType = (PsiClassType)qualifierType;
       final PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics();
       GrExpression[] arguments = expr.getArgumentList().getExpressionArguments();
-      PsiType[] argTypes = new PsiType[arguments.length];
+      PsiType[] argTypes = PsiType.createArray(arguments.length);
       for (int i = 0; i < arguments.length; i++) {
         PsiType argType = arguments[i].getType();
         if (argType == null) argType = TypesUtil.getJavaLangObject(expr);
@@ -968,6 +982,44 @@
     }
   }
 
+  public static int getArgumentIndex(@NotNull GrCall call, @NotNull PsiElement argument) {
+    GrArgumentList argumentList = call.getArgumentList();
+    if (argumentList == null) return -1;
+
+    GrExpression[] expressionArguments = argumentList.getExpressionArguments();
+
+    for (int i = 0; i < expressionArguments.length; i++) {
+      if (argument.equals(expressionArguments[i])) {
+        int res = i;
+
+        if (argumentList.getNamedArguments().length > 0) {
+          res++; // first argument is map defined by named arguments
+        }
+
+        return res;
+      }
+    }
+
+    if (argument instanceof GrClosableBlock) {
+      GrClosableBlock[] closureArgs = call.getClosureArguments();
+
+      for (int i = 0; i < closureArgs.length; i++) {
+        if (argument.equals(closureArgs[i])) {
+          int res = i + expressionArguments.length;
+
+          if (argumentList.getNamedArguments().length > 0) {
+            res++; // first argument is map defined by named arguments
+          }
+
+          return res;
+        }
+      }
+
+    }
+
+    return -1;
+  }
+
   /**
    * Returns all arguments passed to method. First argument is null if Named Arguments is present.
    */
@@ -1159,27 +1211,6 @@
     return !ref.isQualified() && name.equals(ref.getReferenceName());
   }
 
-  @Nullable
-  public static GrExpression getInitializerFor(GrReferenceExpression lValue) {
-    if (!isLValue(lValue)) throw new IllegalArgumentException("arg is not lValue");
-
-    final PsiElement parent = lValue.getParent();
-    if (parent instanceof GrAssignmentExpression) return ((GrAssignmentExpression)parent).getRValue();
-    if (parent instanceof GrTupleExpression) {
-      final int i = ((GrTupleExpression)parent).indexOf(lValue);
-      final PsiElement pparent = parent.getParent();
-      LOG.assertTrue(pparent instanceof GrAssignmentExpression);
-
-      final GrExpression rValue = ((GrAssignmentExpression)pparent).getRValue();
-      if (rValue instanceof GrListOrMap && !((GrListOrMap)rValue).isMap()) {
-        final GrExpression[] initializers = ((GrListOrMap)rValue).getInitializers();
-        if (initializers.length < i) return initializers[i];
-      }
-    }
-
-    return null;
-  }
-
   public static boolean isProperty(GrField field) {
     final PsiClass clazz = field.getContainingClass();
     if (clazz == null) return false;
@@ -1205,8 +1236,7 @@
   public static List<GrImportStatement> getValidImportStatements(final GroovyFile file) {
     final List<GrImportStatement> oldImports = new ArrayList<GrImportStatement>();
     for (GrImportStatement statement : file.getImportStatements()) {
-      final GrCodeReferenceElement reference = statement.getImportReference();
-      if (reference != null && reference.multiResolve(false).length > 0) {
+      if (!ErrorUtil.containsError(statement)) {
         oldImports.add(statement);
       }
     }
@@ -1271,7 +1301,7 @@
 
   public static boolean isLineFeed(@Nullable PsiElement e) {
     return e != null &&
-           TokenSets.WHITE_SPACES_SET.contains(e.getNode().getElementType()) &&
+           PsiImplUtil.isWhiteSpaceOrNls(e) &&
            (e.getText().indexOf('\n') >= 0 || e.getText().indexOf('\r') >= 0);
   }
 
@@ -1294,4 +1324,49 @@
       return null;
     }
   }
+
+  public static boolean isDGMMethod(@Nullable PsiElement element) {
+    if (!(element instanceof PsiMethod)) return false;
+
+    final PsiMethod method = element instanceof GrGdkMethod ? ((GrGdkMethod)element).getStaticMethod() : (PsiMethod)element;
+    final PsiClass aClass = method.getContainingClass();
+    if (aClass == null) return false;
+
+    final String qname = aClass.getQualifiedName();
+    return GroovyCommonClassNames.GROOVY_EXTENSION_CLASSES.contains(qname);
+  }
+
+  public static boolean isVoidMethodCall(@Nullable GrExpression expression) {
+    if (expression instanceof GrMethodCall && PsiType.NULL.equals(expression.getType())) {
+      final GroovyResolveResult resolveResult = ((GrMethodCall)expression).advancedResolve();
+      final PsiType[] args = getArgumentTypes(((GrMethodCall)expression).getInvokedExpression(), true);
+      return PsiType.VOID.equals(ResolveUtil.extractReturnTypeFromCandidate(resolveResult, expression, args));
+    }
+
+    return false;
+  }
+
+  public static boolean isVoidMethod(@NotNull PsiMethod method) {
+    return PsiType.VOID.equals(method.getReturnType()) ||
+
+           method instanceof GrMethod &&
+           ((GrMethod)method).getReturnTypeElementGroovy() == null &&
+           ((GrMethod)method).getBlock() != null &&
+           isBlockReturnVoid(((GrMethod)method).getBlock());
+  }
+
+  public static boolean isBlockReturnVoid(@NotNull final GrCodeBlock block) {
+    return CachedValuesManager.getCachedValue(block, new CachedValueProvider<Boolean>() {
+      @Nullable
+      @Override
+      public Result<Boolean> compute() {
+        return Result.create(ControlFlowUtils.visitAllExitPoints(block, new ControlFlowUtils.ExitPointVisitor() {
+          @Override
+          public boolean visitExitPoint(Instruction instruction, @Nullable GrExpression returnValue) {
+            return returnValue == null || !(returnValue instanceof GrLiteral);
+          }
+        }), PsiModificationTracker.MODIFICATION_COUNT);
+      }
+    });
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/CollectClassMembersUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/CollectClassMembersUtil.java
index 5d7e5bc..8e1382e7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/CollectClassMembersUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/CollectClassMembersUtil.java
@@ -85,7 +85,7 @@
 
   @NotNull
   private static ClassMembers getCachedMembers(@NotNull PsiClass aClass, boolean includeSynthetic) {
-    LOG.assertTrue(aClass.isValid());
+    PsiUtilCore.ensureValid(aClass);
     Key<CachedValue<ClassMembers>> key = includeSynthetic ? CACHED_MEMBERS_INCLUDING_SYNTHETIC : CACHED_MEMBERS;
     CachedValue<ClassMembers> cachedValue = aClass.getUserData(key);
     if (isCyclicDependence(aClass)) {
@@ -150,7 +150,7 @@
                                    @NotNull Set<PsiClass> visitedClasses,
                                    @NotNull PsiSubstitutor substitutor,
                                    boolean includeSynthetic) {
-    LOG.assertTrue(aClass.isValid());
+    PsiUtilCore.ensureValid(aClass);
 
     if (!visitedClasses.add(aClass)) return;
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/GroovyStringLiteralManipulator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/GroovyStringLiteralManipulator.java
index 3948815..596d45d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/GroovyStringLiteralManipulator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/GroovyStringLiteralManipulator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.AbstractElementManipulator;
 import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteralContainer;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringContent;
@@ -29,7 +30,7 @@
   private static final Logger LOG = Logger.getInstance(GroovyStringLiteralManipulator.class);
 
   @Override
-  public GrLiteralContainer handleContentChange(GrLiteralContainer expr, TextRange range, String newContent) throws IncorrectOperationException {
+  public GrLiteralContainer handleContentChange(@NotNull GrLiteralContainer expr, @NotNull TextRange range, String newContent) throws IncorrectOperationException {
     if (!(expr.getValue() instanceof String)) {
 //      throw new IncorrectOperationException("cannot handle content change, expr.getValue()=" + expr.getValue());
     }
@@ -56,8 +57,9 @@
     return expr.updateText(newText);
   }
 
+  @NotNull
   @Override
-  public TextRange getRangeInElement(final GrLiteralContainer element) {
+  public TextRange getRangeInElement(@NotNull final GrLiteralContainer element) {
     if (element instanceof GrStringContent) {
       return TextRange.from(0, element.getTextLength());
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/PluginXmlClosureMemberContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/PluginXmlClosureMemberContributor.java
new file mode 100644
index 0000000..b2a1f6a
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/PluginXmlClosureMemberContributor.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.resolve;
+
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiMethod;
+import com.intellij.psi.ResolveState;
+import com.intellij.psi.scope.PsiScopeProcessor;
+import com.intellij.util.SingletonInstancesCache;
+import org.jetbrains.plugins.groovy.extensions.GroovyMethodDescriptor;
+import org.jetbrains.plugins.groovy.extensions.GroovyMethodInfo;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
+
+import java.util.List;
+
+/**
+ * @author Sergey Evdokimov
+ */
+public class PluginXmlClosureMemberContributor extends ClosureMissingMethodContributor {
+  @Override
+  public boolean processMembers(GrClosableBlock closure, PsiScopeProcessor processor, GrReferenceExpression refExpr, ResolveState state) {
+    PsiElement parent = closure.getParent();
+    if (parent instanceof GrArgumentList) parent = parent.getParent();
+
+    if (!(parent instanceof GrMethodCall)) return true;
+
+    PsiMethod psiMethod = ((GrMethodCall)parent).resolveMethod();
+    if (psiMethod == null) return true;
+
+    List<GroovyMethodInfo> infos = GroovyMethodInfo.getInfos(psiMethod);
+    if (infos.isEmpty()) return true;
+
+    int index = PsiUtil.getArgumentIndex((GrMethodCall)parent, closure);
+    if (index == -1) return true;
+
+    for (GroovyMethodInfo info : infos) {
+      GroovyMethodDescriptor.ClosureArgument[] closureArguments = info.getDescriptor().myClosureArguments;
+      if (closureArguments != null) {
+        for (GroovyMethodDescriptor.ClosureArgument argument : closureArguments) {
+          if (argument.index == index && argument.methodContributor != null) {
+            ClosureMissingMethodContributor instance = SingletonInstancesCache.getInstance(argument.methodContributor, info.getPluginClassLoader());
+            if (!instance.processMembers(closure, processor, refExpr, state)) return false;
+          }
+        }
+      }
+    }
+
+    return true;
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java
index b78d2c8..98bd1d9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ResolveUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -640,7 +640,7 @@
     return variants;
   }
 
-  public static GroovyResolveResult[] getConstructorResolveResult(PsiMethod[] constructors, PsiElement place) {
+  private static GroovyResolveResult[] getConstructorResolveResult(PsiMethod[] constructors, PsiElement place) {
     GroovyResolveResult[] variants = new GroovyResolveResult[constructors.length];
     for (int i = 0; i < constructors.length; i++) {
       final boolean isAccessible = PsiUtil.isAccessible(constructors[i], place, null);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ast/ConstructorAnnotationsProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ast/ConstructorAnnotationsProcessor.java
index 537a4e4..60673ed 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ast/ConstructorAnnotationsProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ast/ConstructorAnnotationsProcessor.java
@@ -23,6 +23,7 @@
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightParameter;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
@@ -48,8 +49,7 @@
     if (modifierList == null) return;
 
     final PsiAnnotation tupleConstructor = modifierList.findAnnotation(GROOVY_TRANSFORM_TUPLE_CONSTRUCTOR);
-    final boolean immutable = modifierList.findAnnotation(GROOVY_LANG_IMMUTABLE) != null ||
-                              modifierList.findAnnotation(GROOVY_TRANSFORM_IMMUTABLE) != null;
+    final boolean immutable = PsiImplUtil.hasImmutableAnnotation(modifierList);
     final boolean canonical = modifierList.findAnnotation(GROOVY_TRANSFORM_CANONICAL) != null;
     if (!immutable && !canonical && tupleConstructor == null) {
       return;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ast/DelegatedMethodsContributor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ast/DelegatedMethodsContributor.java
index 3c584a68..2aa286e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ast/DelegatedMethodsContributor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/ast/DelegatedMethodsContributor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,10 +15,13 @@
  */
 package org.jetbrains.plugins.groovy.lang.resolve.ast;
 
+import com.intellij.lang.java.JavaLanguage;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.impl.PsiSuperMethodImplUtil;
 import com.intellij.psi.impl.light.LightMethodBuilder;
+import com.intellij.psi.impl.light.LightParameter;
+import com.intellij.psi.impl.source.tree.java.PsiCompositeModifierList;
 import com.intellij.psi.util.MethodSignature;
 import com.intellij.psi.util.MethodSignatureUtil;
 import com.intellij.psi.util.PsiUtil;
@@ -31,11 +34,11 @@
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.GroovyFileType;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
+import org.jetbrains.plugins.groovy.lang.psi.impl.GrAnnotationUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
 import org.jetbrains.plugins.groovy.lang.psi.util.GrClassImplUtil;
@@ -57,7 +60,7 @@
     initializeSignatures(clazz, PsiSubstitutor.EMPTY, signatures, processed);
 
     List<PsiMethod> methods = new ArrayList<PsiMethod>();
-    process(clazz, PsiSubstitutor.EMPTY, true, new HashSet<PsiClass>(), processed, methods, clazz);
+    process(clazz, PsiSubstitutor.EMPTY, true, new HashSet<PsiClass>(), processed, methods, clazz, false);
 
     final Set<PsiMethod> result = new LinkedHashSet<PsiMethod>();
     for (PsiMethod method : methods) {
@@ -151,12 +154,14 @@
                               Set<PsiClass> processedWithoutDeprecated,
                               Set<PsiClass> processedAll,
                               List<PsiMethod> collector,
-                              GrTypeDefinition classToDelegateTo) {
+                              GrTypeDefinition classToDelegateTo,
+                              boolean keepParameterAnnotations) {
     final List<PsiMethod> result = new ArrayList<PsiMethod>();
 
     //process super methods before delegated methods
     for (PsiClassType superType : getSuperTypes(clazz)) {
-      processClassInner(superType, superClassSubstitutor, shouldProcessDeprecated, result, classToDelegateTo, processedWithoutDeprecated, processedAll);
+      processClassInner(superType, superClassSubstitutor, shouldProcessDeprecated, result, classToDelegateTo, processedWithoutDeprecated,
+                        processedAll, keepParameterAnnotations);
     }
 
     if (clazz instanceof GrTypeDefinition) {
@@ -168,7 +173,8 @@
         final PsiType type = field.getDeclaredType();
         if (!(type instanceof PsiClassType)) continue;
 
-        processClassInner((PsiClassType)type, superClassSubstitutor, shouldDelegateDeprecated(delegate), result, classToDelegateTo, processedWithoutDeprecated, processedAll);
+        processClassInner((PsiClassType)type, superClassSubstitutor, shouldDelegateDeprecated(delegate), result, classToDelegateTo,
+                          processedWithoutDeprecated, processedAll, shouldKeepParameterAnnotations(delegate));
       }
     }
 
@@ -206,7 +212,7 @@
                                         List<PsiMethod> result,
                                         GrTypeDefinition classToDelegateTo,
                                         Set<PsiClass> processedWithoutDeprecated,
-                                        Set<PsiClass> processedAll) {
+                                        Set<PsiClass> processedAll, boolean keepParameterAnnotationsNew) {
     final PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
     final PsiClass psiClass = resolveResult.getElement();
     if (psiClass == null) return;
@@ -228,15 +234,16 @@
       processedWithoutDeprecated.add(psiClass);
     }
 
-    collectMethods(psiClass, substitutor, shouldProcessDeprecated, classToDelegateTo, result);
-    process(psiClass, substitutor, shouldProcessDeprecated, processedWithoutDeprecated, processedAll, result, classToDelegateTo);
+    collectMethods(psiClass, substitutor, shouldProcessDeprecated, classToDelegateTo, result, keepParameterAnnotationsNew);
+    process(psiClass, substitutor, shouldProcessDeprecated, processedWithoutDeprecated, processedAll, result, classToDelegateTo, keepParameterAnnotationsNew);
   }
 
   private static void collectMethods(PsiClass currentClass,
                                      PsiSubstitutor currentClassSubstitutor,
                                      boolean shouldProcessDeprecated,
                                      GrTypeDefinition classToDelegateTo,
-                                     Collection<PsiMethod> collector) {
+                                     Collection<PsiMethod> collector,
+                                     boolean keepParameterAnnotations) {
     final List<PsiMethod> methods;
     if (currentClass instanceof GrTypeDefinition) {
       methods = new ArrayList<PsiMethod>();
@@ -253,7 +260,7 @@
       if (method.isConstructor() || method.hasModifierProperty(PsiModifier.STATIC)) continue;
       if (overridesObjectOrGroovyObject(method)) continue;
       if (!shouldProcessDeprecated && PsiImplUtil.getAnnotation(method, CommonClassNames.JAVA_LANG_DEPRECATED) != null) continue;
-      collector.add(generateDelegateMethod(method, classToDelegateTo, currentClassSubstitutor));
+      collector.add(generateDelegateMethod(method, classToDelegateTo, currentClassSubstitutor, keepParameterAnnotations));
     }
   }
 
@@ -272,24 +279,20 @@
   }
 
   private static boolean shouldDelegateDeprecated(PsiAnnotation delegate) {
-    final PsiAnnotationParameterList parameterList = delegate.getParameterList();
-    final PsiNameValuePair[] attributes = parameterList.getAttributes();
-    for (PsiNameValuePair attribute : attributes) {
-      final String name = attribute.getName();
-      if ("deprecated".equals(name)) {
-        final PsiAnnotationMemberValue value = attribute.getValue();
-        if (value instanceof GrLiteral) {
-          final Object innerValue = ((GrLiteral)value).getValue();
-          if (innerValue instanceof Boolean) {
-            return (Boolean)innerValue;
-          }
-        }
-      }
-    }
-    return false;
+    final Boolean result = GrAnnotationUtil.inferBooleanAttribute(delegate, "deprecated");
+    return result != null && result.booleanValue();
   }
 
-  private static PsiMethod generateDelegateMethod(PsiMethod method, PsiClass superClass, PsiSubstitutor substitutor) {
+  private static boolean shouldKeepParameterAnnotations(PsiAnnotation delegate) {
+    final Boolean keepParameterAnnotations = GrAnnotationUtil.inferBooleanAttribute(delegate, "parameterAnnotations");
+    return keepParameterAnnotations != null && keepParameterAnnotations.booleanValue();
+  }
+
+
+  private static PsiMethod generateDelegateMethod(PsiMethod method,
+                                                  PsiClass superClass,
+                                                  PsiSubstitutor substitutor,
+                                                  boolean keepParameterAnnotations) {
     final LightMethodBuilder builder = new LightMethodBuilder(superClass.getManager(), GroovyFileType.GROOVY_LANGUAGE, method.getName());
     builder.setContainingClass(superClass);
     builder.setMethodReturnType(substitutor.substitute(method.getReturnType()));
@@ -324,7 +327,12 @@
       if (type == null) {
         type = PsiType.getJavaLangObject(superClass.getManager(), superClass.getResolveScope());
       }
-      builder.addParameter(StringUtil.notNullize(originalParameter.getName(), "p" + i), type);
+      final LightParameter lightParameter = new LightParameter(StringUtil.notNullize(originalParameter.getName(), "p" + i), type, builder, JavaLanguage.INSTANCE);
+      if (keepParameterAnnotations) {
+        final PsiCompositeModifierList delegatingModifierList = new PsiCompositeModifierList(method.getManager(), Collections.singletonList(originalParameter.getModifierList()));
+        lightParameter.setModifierList(delegatingModifierList);
+      }
+      builder.addParameter(lightParameter);
     }
     builder.setBaseIcon(JetgroovyIcons.Groovy.Method);
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/AccessorResolverProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/AccessorResolverProcessor.java
index 1fcda2d5..befda3c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/AccessorResolverProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/AccessorResolverProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -50,7 +50,7 @@
     myPropertyName = propertyName;
 
     mySearchForGetter = searchForGetter;
-    mySubstitutorComputer = byShape ? null : new SubstitutorComputer(thisType, PsiType.EMPTY_ARRAY, typeArguments, false, place, myPlace);
+    mySubstitutorComputer = byShape ? null : new SubstitutorComputer(thisType, PsiType.EMPTY_ARRAY, typeArguments, place, myPlace);
   }
 
   public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
@@ -110,9 +110,8 @@
     boolean isAccessible = isAccessible(method);
     final PsiElement resolveContext = state.get(RESOLVE_CONTEXT);
     final SpreadState spreadState = state.get(SpreadState.SPREAD_STATE);
-    boolean isStaticsOK = isStaticsOK(method, resolveContext, true);
-    final GroovyResolveResultImpl candidate =
-      new GroovyResolveResultImpl(method, resolveContext, spreadState, substitutor, isAccessible, isStaticsOK, true);
+    boolean isStaticsOK = isStaticsOK(method, resolveContext, false);
+    final GroovyResolveResultImpl candidate = new GroovyResolveResultImpl(method, resolveContext, spreadState, substitutor, isAccessible, isStaticsOK, true, true);
     if (isAccessible && isStaticsOK) {
       addCandidate(candidate);
       return method instanceof GrGdkMethod; //don't stop searching if we found only gdk method
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java
index 2a78565..bddbf4c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/MethodResolverProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,7 +59,7 @@
   private boolean myStopExecuting = false;
 
   private final boolean myByShape;
-  
+
   private final SubstitutorComputer mySubstitutorComputer;
 
   private final boolean myTypedContext;
@@ -88,45 +88,55 @@
     myAllVariants = allVariants;
     myByShape = byShape;
 
-    mySubstitutorComputer = new SubstitutorComputer(thisType, argumentTypes, typeArguments, allVariants, place, myPlace.getParent());
+    mySubstitutorComputer = new SubstitutorComputer(myThisType, myArgumentTypes, typeArguments, myPlace, myPlace.getParent());
     myTypedContext = GppTypeConverter.hasTypedContext(myPlace);
   }
 
 
+  @Override
   public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
     if (myStopExecuting) {
       return false;
     }
-    PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY);
     if (element instanceof PsiMethod) {
       PsiMethod method = (PsiMethod) element;
 
       if (method.isConstructor() != myIsConstructor) return true;
-      if (substitutor == null) substitutor = PsiSubstitutor.EMPTY;
-      if (!myByShape) {
-        substitutor = mySubstitutorComputer.obtainSubstitutor(substitutor, method, state);
-      }
+
+      PsiSubstitutor substitutor = inferSubstitutor(method, state);
 
       PsiElement resolveContext = state.get(RESOLVE_CONTEXT);
       final SpreadState spreadState = state.get(SpreadState.SPREAD_STATE);
 
       boolean isAccessible = isAccessible(method);
-      boolean isStaticsOK = isStaticsOK(method, resolveContext, true);
+      boolean isStaticsOK = isStaticsOK(method, resolveContext, false);
+      boolean isApplicable = PsiUtil.isApplicable(myArgumentTypes, method, substitutor, myPlace, myByShape);
+      boolean isValidResult = isStaticsOK && isAccessible && isApplicable;
 
-      if (!myAllVariants && isStaticsOK && isAccessible && PsiUtil.isApplicable(myArgumentTypes, method, substitutor, myPlace, myByShape)) {
-        addCandidate(new GroovyResolveResultImpl(method, resolveContext, spreadState, substitutor, isAccessible, isStaticsOK));
+      GroovyResolveResultImpl candidate = new GroovyResolveResultImpl(method, resolveContext, spreadState, substitutor, isAccessible, isStaticsOK, false, isValidResult);
+
+      if (!myAllVariants && isValidResult) {
+        addCandidate(candidate);
       }
       else {
-        myInapplicableCandidates.add(new GroovyResolveResultImpl(method, resolveContext, spreadState, substitutor, isAccessible, isStaticsOK));
+        myInapplicableCandidates.add(candidate);
       }
-
-      return true;
     }
 
     return true;
   }
 
   @NotNull
+  private PsiSubstitutor inferSubstitutor(@NotNull PsiMethod method, @NotNull ResolveState state) {
+    PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY);
+    if (substitutor == null) substitutor = PsiSubstitutor.EMPTY;
+
+    return myByShape ? substitutor
+                     : mySubstitutorComputer.obtainSubstitutor(substitutor, method, state);
+  }
+
+  @Override
+  @NotNull
   public GroovyResolveResult[] getCandidates() {
     if (!myAllVariants && super.hasCandidates()) {
       return filterCandidates();
@@ -148,7 +158,7 @@
         result.add(candidate);
       }
     }
-    if (result.size() > 0) return result;
+    if (!result.isEmpty()) return result;
     return candidates;
   }
 
@@ -220,7 +230,7 @@
 
     return 0;
   }
-  
+
   private static boolean isMoreConcreteThan(@NotNull PsiMethod method,
                                             @NotNull final PsiSubstitutor substitutor,
                                             @NotNull PsiMethod another,
@@ -230,7 +240,7 @@
       final PsiParameter[] plusParameters = method.getParameterList().getParameters();
       final PsiParameter[] defParameters = another.getParameterList().getParameters();
 
-      final PsiType[] paramTypes = new PsiType[plusParameters.length];
+      final PsiType[] paramTypes = PsiType.createArray(plusParameters.length);
       for (int i = 0; i < paramTypes.length; i++) {
         paramTypes[i] = eliminateOneMethodInterfaces(plusParameters[i], defParameters, i);
 
@@ -270,7 +280,7 @@
       method1 = ((GrGdkMethod)method1).getStaticMethod();
       method2 = ((GrGdkMethod)method2).getStaticMethod();
       if (myArgumentTypes != null) {
-        argTypes = new PsiType[argTypes.length + 1];
+        argTypes = PsiType.createArray(argTypes.length + 1);
         System.arraycopy(myArgumentTypes, 0, argTypes, 1, myArgumentTypes.length);
         argTypes[0] = myThisType;
       }
@@ -345,6 +355,7 @@
   }
 
 
+  @Override
   public boolean hasCandidates() {
     return super.hasCandidates() || !myInapplicableCandidates.isEmpty();
   }
@@ -353,6 +364,7 @@
     return super.hasCandidates();
   }
 
+  @Override
   @Nullable
   public PsiType[] getArgumentTypes() {
     return myArgumentTypes;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java
index fb7970c..4ef8e4d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/ResolverProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -100,7 +100,7 @@
       boolean isAccessible = isAccessible(namedElement);
       final PsiElement resolveContext = state.get(RESOLVE_CONTEXT);
       final SpreadState spreadState = state.get(SpreadState.SPREAD_STATE);
-      boolean isStaticsOK = isStaticsOK(namedElement, resolveContext, true);
+      boolean isStaticsOK = isStaticsOK(namedElement, resolveContext, false);
       addCandidate(new GroovyResolveResultImpl(namedElement, resolveContext, spreadState, substitutor, isAccessible, isStaticsOK));
       return !(isAccessible && isStaticsOK);
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/SubstitutorComputer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/SubstitutorComputer.java
index d4c42aa..6e74d68 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/SubstitutorComputer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/SubstitutorComputer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,9 +18,9 @@
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.TypeConversionUtil;
+import com.intellij.psi.util.*;
 import com.intellij.util.containers.hash.HashSet;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
 import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner;
@@ -39,7 +39,9 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrClosureParameter;
 import org.jetbrains.plugins.groovy.lang.psi.impl.signatures.GrClosureSignatureUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
+import org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.ClosureToSamConverter;
 import org.jetbrains.plugins.groovy.lang.psi.util.GdkMethodUtil;
+import org.jetbrains.plugins.groovy.lang.psi.util.GroovyCommonClassNames;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 
 import java.util.Set;
@@ -56,22 +58,19 @@
   @Nullable private final PsiType[] myArgumentTypes;
   private final PsiType[] myTypeArguments;
 
-  private final boolean myAllVariants;
-
   private final GrControlFlowOwner myFlowOwner;
   private final PsiElement myPlaceToInferContext;
+  private PsiResolveHelper myHelper;
 
 
   public SubstitutorComputer(PsiType thisType,
                              @Nullable PsiType[] argumentTypes,
                              PsiType[] typeArguments,
-                             boolean allVariants,
                              PsiElement place,
                              PsiElement placeToInferContext) {
     myThisType = thisType;
     myArgumentTypes = argumentTypes;
     myTypeArguments = typeArguments;
-    myAllVariants = allVariants;
     myPlace = place;
     myPlaceToInferContext = placeToInferContext;
 
@@ -81,9 +80,11 @@
     else {
       myFlowOwner = null;
     }
+
+    myHelper = JavaPsiFacade.getInstance(myPlace.getProject()).getResolveHelper();
+
   }
 
-  
   @Nullable
   protected PsiType inferContextType() {
     final PsiElement parent = myPlaceToInferContext.getParent();
@@ -127,7 +128,7 @@
       final PsiElement resolveContext = state.get(ResolverProcessor.RESOLVE_CONTEXT);
       if (method instanceof GrGdkMethod) {
         //type inference should be performed from static method
-        PsiType[] newArgTypes = new PsiType[argTypes.length + 1];
+        PsiType[] newArgTypes = PsiType.createArray(argTypes.length + 1);
         if (GdkMethodUtil.isInWithContext(resolveContext)) {
           newArgTypes[0] = ((GrExpression)resolveContext).getType();
         }
@@ -147,10 +148,10 @@
     return substitutor;
   }
 
-  private PsiSubstitutor inferMethodTypeParameters(PsiMethod method,
-                                                   PsiSubstitutor partialSubstitutor,
-                                                   final PsiTypeParameter[] typeParameters,
-                                                   final PsiType[] argTypes) {
+  private PsiSubstitutor inferMethodTypeParameters(@NotNull PsiMethod method,
+                                                   @NotNull PsiSubstitutor partialSubstitutor,
+                                                   @NotNull PsiTypeParameter[] typeParameters,
+                                                   @NotNull PsiType[] argTypes) {
     if (typeParameters.length == 0 || myArgumentTypes == null) return partialSubstitutor;
 
     final GrClosureSignature erasedSignature = GrClosureSignatureUtil.createSignatureWithErasedParameterTypes(method);
@@ -158,14 +159,13 @@
     final GrClosureSignature signature = GrClosureSignatureUtil.createSignature(method, partialSubstitutor);
     final GrClosureParameter[] params = signature.getParameters();
 
-    final GrClosureSignatureUtil.ArgInfo<PsiType>[] argInfos =
-      GrClosureSignatureUtil.mapArgTypesToParameters(erasedSignature, argTypes, myPlace, myAllVariants);
+    final GrClosureSignatureUtil.ArgInfo<PsiType>[] argInfos = GrClosureSignatureUtil.mapArgTypesToParameters(erasedSignature, argTypes, myPlace, true);
     if (argInfos == null) return partialSubstitutor;
 
     int max = Math.max(params.length, argTypes.length);
 
-    PsiType[] parameterTypes = new PsiType[max];
-    PsiType[] argumentTypes = new PsiType[max];
+    PsiType[] parameterTypes = PsiType.createArray(max);
+    PsiType[] argumentTypes = PsiType.createArray(max);
     int i = 0;
     for (int paramIndex = 0; paramIndex < argInfos.length; paramIndex++) {
       PsiType paramType = params[paramIndex].getType();
@@ -187,11 +187,10 @@
         i++;
       }
     }
-    final PsiResolveHelper helper = JavaPsiFacade.getInstance(method.getProject()).getResolveHelper();
-    PsiSubstitutor substitutor = helper.inferTypeArguments(typeParameters, parameterTypes, argumentTypes, LanguageLevel.HIGHEST);
+    PsiSubstitutor substitutor = myHelper.inferTypeArguments(typeParameters, parameterTypes, argumentTypes, LanguageLevel.JDK_1_7);
     for (PsiTypeParameter typeParameter : typeParameters) {
       if (!substitutor.getSubstitutionMap().containsKey(typeParameter)) {
-        substitutor = inferFromContext(typeParameter, PsiUtil.getSmartReturnType(method), substitutor, helper);
+        substitutor = inferFromContext(typeParameter, PsiUtil.getSmartReturnType(method), substitutor);
         if (!substitutor.getSubstitutionMap().containsKey(typeParameter)) {
           substitutor = substitutor.put(typeParameter, null);
         }
@@ -201,7 +200,19 @@
     return partialSubstitutor.putAll(substitutor);
   }
 
-  private PsiType handleConversion(PsiType paramType, PsiType argType) {
+  @Nullable
+  private PsiType handleConversion(@Nullable PsiType paramType, @Nullable PsiType argType) {
+    if (ClosureToSamConverter.isSamConversionAllowed(myPlace) &&
+        InheritanceUtil.isInheritor(argType, GroovyCommonClassNames.GROOVY_LANG_CLOSURE) &&
+        !TypesUtil.isClassType(paramType, GroovyCommonClassNames.GROOVY_LANG_CLOSURE)) {
+      PsiType converted = handleConversionOfSAMType(paramType, (PsiClassType)argType);
+      if (converted != null) {
+        return converted;
+      }
+
+      return argType;
+    }
+
     if (!TypesUtil.isAssignable(TypeConversionUtil.erasure(paramType), argType, myPlace) &&
         TypesUtil.isAssignableByMethodCallConversion(paramType, argType, myPlace)) {
       return paramType;
@@ -209,13 +220,44 @@
     return argType;
   }
 
-  private PsiSubstitutor inferFromContext(PsiTypeParameter typeParameter,
-                                          PsiType lType,
-                                          PsiSubstitutor substitutor,
-                                          PsiResolveHelper helper) {
+  @Nullable
+  private PsiType handleConversionOfSAMType(@Nullable PsiType samType, @NotNull PsiClassType closure) {
+    if (samType instanceof PsiClassType) {
+      PsiClassType.ClassResolveResult resolveResult = ((PsiClassType)samType).resolveGenerics();
+      PsiClass samClass = resolveResult.getElement();
+
+      if (samClass != null && samClass.getTypeParameters().length != 0) {
+        MethodSignature samSignature = ClosureToSamConverter.findSingleAbstractMethod(samClass, PsiSubstitutor.EMPTY);
+        if (samSignature != null) {
+
+          PsiMethod samMethod = MethodSignatureUtil.findMethodBySignature(samClass, samSignature, true);
+          if (samMethod != null) {
+            PsiType[] closureArgs = closure.getParameters();
+            if (closureArgs.length == 1 && samMethod.getReturnType() != null) {
+              PsiSubstitutor substitutor = myHelper.inferTypeArguments(samClass.getTypeParameters(),
+                                                                       new PsiType[]{samMethod.getReturnType()},
+                                                                       closureArgs,
+                                                                       LanguageLevel.JDK_1_7);
+
+              if (!substitutor.getSubstitutionMap().isEmpty()) {
+                return JavaPsiFacade.getElementFactory(myPlace.getProject()).createType(samClass, substitutor);
+              }
+            }
+          }
+        }
+      }
+    }
+
+    return null;
+  }
+
+
+  private PsiSubstitutor inferFromContext(@NotNull PsiTypeParameter typeParameter,
+                                          @Nullable PsiType lType,
+                                          @NotNull PsiSubstitutor substitutor) {
     if (myPlace == null) return substitutor;
 
-    final PsiType inferred = helper.getSubstitutionForTypeParameter(typeParameter, lType, inferContextType(), false, LanguageLevel.HIGHEST);
+    final PsiType inferred = myHelper.getSubstitutionForTypeParameter(typeParameter, lType, inferContextType(), false, LanguageLevel.JDK_1_7);
     if (inferred != PsiType.NULL) {
       return substitutor.put(typeParameter, inferred);
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/stubs/GroovyShortNamesCache.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/stubs/GroovyShortNamesCache.java
index 918fa27..4960a77 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/stubs/GroovyShortNamesCache.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/stubs/GroovyShortNamesCache.java
@@ -32,6 +32,9 @@
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAnnotationMethod;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
 import org.jetbrains.plugins.groovy.lang.psi.impl.search.GrSourceFilterScope;
 import org.jetbrains.plugins.groovy.lang.psi.stubs.index.*;
 
@@ -65,7 +68,8 @@
 
   public List<PsiClass> getScriptClassesByFQName(final String name, final GlobalSearchScope scope, final boolean srcOnly) {
     GlobalSearchScope actualScope = srcOnly ? new GrSourceFilterScope(scope) : scope;
-    final Collection<GroovyFile> files = StubIndex.getInstance().get(GrFullScriptNameIndex.KEY, name.hashCode(), myProject, actualScope);
+    final Collection<GroovyFile> files = StubIndex.getElements(GrFullScriptNameIndex.KEY, name.hashCode(), myProject, actualScope,
+                                                               GroovyFile.class);
     if (files.isEmpty()) {
       return Collections.emptyList();
     }
@@ -97,8 +101,8 @@
   private List<PsiClass> addClasses(String name, GlobalSearchScope scope, boolean inSource) {
     final List<PsiClass> result = new ArrayList<PsiClass>(getScriptClassesByFQName(name, scope, inSource));
 
-    for (PsiElement psiClass : StubIndex.getInstance().safeGet(GrFullClassNameIndex.KEY, name.hashCode(), myProject,
-                                                                inSource ? new GrSourceFilterScope(scope) : scope, PsiClass.class)) {
+    for (PsiElement psiClass : StubIndex.getElements(GrFullClassNameIndex.KEY, name.hashCode(), myProject,
+                                                     inSource ? new GrSourceFilterScope(scope) : scope, PsiClass.class)) {
       //hashcode doesn't guarantee equals
       if (name.equals(((PsiClass)psiClass).getQualifiedName())) {
         result.add((PsiClass)psiClass);
@@ -122,8 +126,11 @@
   @Override
   @NotNull
   public PsiMethod[] getMethodsByName(@NonNls @NotNull String name, @NotNull GlobalSearchScope scope) {
-    final Collection<? extends PsiMethod> methods = StubIndex.getInstance().get(GrMethodNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope));
-    final Collection<? extends PsiMethod> annMethods = StubIndex.getInstance().get(GrAnnotationMethodNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope));
+    final Collection<? extends PsiMethod> methods = StubIndex.getElements(GrMethodNameIndex.KEY, name, myProject,
+                                                                          new GrSourceFilterScope(scope), GrMethod.class);
+    final Collection<? extends PsiMethod> annMethods = StubIndex.getElements(GrAnnotationMethodNameIndex.KEY, name, myProject,
+                                                                             new GrSourceFilterScope(scope),
+                                                                             GrAnnotationMethod.class);
     if (methods.isEmpty() && annMethods.isEmpty()) return PsiMethod.EMPTY_ARRAY;
     return ArrayUtil.mergeCollections(annMethods, methods, PsiMethod.ARRAY_FACTORY);
   }
@@ -141,8 +148,9 @@
                                         @NotNull GlobalSearchScope scope,
                                         @Nullable IdFilter filter) {
     GrSourceFilterScope filterScope = new GrSourceFilterScope(scope);
-    return StubIndex.getInstance().process(GrMethodNameIndex.KEY, name, myProject, filterScope, filter, processor) &&
-           StubIndex.getInstance().process(GrAnnotationMethodNameIndex.KEY, name, myProject, filterScope, filter, processor);
+    return StubIndex.getInstance().processElements(GrMethodNameIndex.KEY, name, myProject, filterScope, filter, GrMethod.class, processor) &&
+           StubIndex.getInstance().processElements(GrAnnotationMethodNameIndex.KEY, name, myProject, filterScope, filter,
+                                                   GrAnnotationMethod.class, processor);
   }
 
   @Override
@@ -173,7 +181,8 @@
   @Override
   @NotNull
   public PsiField[] getFieldsByName(@NotNull @NonNls String name, @NotNull GlobalSearchScope scope) {
-    final Collection<? extends PsiField> fields = StubIndex.getInstance().get(GrFieldNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope));
+    final Collection<? extends PsiField> fields = StubIndex.getElements(GrFieldNameIndex.KEY, name, myProject,
+                                                                        new GrSourceFilterScope(scope), GrField.class);
     if (fields.isEmpty()) return PsiField.EMPTY_ARRAY;
     return fields.toArray(new PsiField[fields.size()]);
   }
@@ -195,7 +204,8 @@
                                        @NotNull Processor<? super PsiField> processor,
                                        @NotNull GlobalSearchScope scope,
                                        @Nullable IdFilter filter) {
-    return StubIndex.getInstance().process(GrFieldNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope), filter, processor);
+    return StubIndex.getInstance().processElements(GrFieldNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope), filter,
+                                                   GrField.class, processor);
   }
 
   @Override
@@ -203,7 +213,8 @@
                                         @NotNull Processor<? super PsiClass> processor,
                                         @NotNull GlobalSearchScope scope,
                                         @Nullable IdFilter filter) {
-    for (GroovyFile file : StubIndex.getInstance().get(GrScriptClassNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope), filter)) {
+    for (GroovyFile file : StubIndex.getElements(GrScriptClassNameIndex.KEY, name, myProject, new GrSourceFilterScope(scope), filter,
+                                                 GroovyFile.class)) {
       PsiClass aClass = file.getScriptClass();
       if (aClass != null && !processor.process(aClass)) return true;
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkForProjectFromSourcesStep.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkForProjectFromSourcesStep.java
index 83cd58f..55f0129 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkForProjectFromSourcesStep.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/GroovySdkForProjectFromSourcesStep.java
@@ -18,6 +18,7 @@
 import com.intellij.ide.util.importProject.ModuleDescriptor;
 import com.intellij.ide.util.importProject.ProjectDescriptor;
 import com.intellij.ide.util.projectWizard.importSources.DetectedProjectRoot;
+import com.intellij.ide.util.projectWizard.importSources.DetectedSourceRoot;
 import com.intellij.ide.util.projectWizard.importSources.ProjectFromSourcesBuilder;
 import com.intellij.openapi.module.StdModuleTypes;
 
@@ -47,7 +48,7 @@
     super.updateDataModel();
     List<ModuleDescriptor> modules = new ArrayList<ModuleDescriptor>();
     for (DetectedProjectRoot root : myBuilder.getProjectRoots(myDetector)) {
-      final ModuleDescriptor descriptor = new ModuleDescriptor(root.getDirectory(), StdModuleTypes.JAVA, Collections.<DetectedProjectRoot>emptyList());
+      final ModuleDescriptor descriptor = new ModuleDescriptor(root.getDirectory(), StdModuleTypes.JAVA, Collections.<DetectedSourceRoot>emptyList());
       descriptor.addConfigurationUpdater(createModuleConfigurationUpdater());
       modules.add(descriptor);
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java
index aa0eb3e..3617ad1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcFramework.java
@@ -131,7 +131,7 @@
         if (Messages.showYesNoDialog(module.getProject(), "Cannot generate " + getDisplayName() + " project structure because JDK is not specified for module \"" +
                                                           module.getName() + "\".\n" +
                                                           getDisplayName() + " project will not be created if you don't specify JDK.\nDo you want to specify JDK?",
-                                     "Error", Messages.getErrorIcon()) == 1) {
+                                     "Error", Messages.getErrorIcon()) == Messages.NO) {
           return;
         }
         ProjectSettingsService.getInstance(module.getProject()).showModuleConfigurationDialog(module.getName(), ClasspathEditor.NAME);
@@ -226,18 +226,25 @@
 
   public abstract String getUserLibraryName();
 
+  protected abstract boolean isCoreJar(@NotNull VirtualFile localFile);
+
   @Nullable
   protected VirtualFile findCoreJar(@Nullable Module module) {
     if (module == null) return null;
 
     JavaPsiFacade javaFacade = JavaPsiFacade.getInstance(module.getProject());
-    PsiClass aClass = javaFacade.findClass(getSomeFrameworkClass(), GlobalSearchScope.moduleWithLibrariesScope(module));
-    if (aClass == null) return null;
 
-    VirtualFile virtualFile = aClass.getContainingFile().getVirtualFile();
-    if (virtualFile == null || !(virtualFile.getFileSystem() instanceof JarFileSystem)) return null;
+    for (PsiClass aClass : javaFacade.findClasses(getSomeFrameworkClass(), GlobalSearchScope.moduleWithLibrariesScope(module))) {
+      VirtualFile virtualFile = aClass.getContainingFile().getVirtualFile();
+      if (virtualFile != null && virtualFile.getFileSystem() instanceof JarFileSystem) {
+        VirtualFile localFile = PathUtil.getLocalFile(virtualFile);
+        if (isCoreJar(localFile)) {
+          return localFile;
+        }
+      }
+    }
 
-    return PathUtil.getLocalFile(virtualFile);
+    return null;
   }
 
   protected List<File> getImplicitClasspathRoots(@NotNull Module module) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleBuilder.java
index 399a99d..5bfa4c6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleBuilder.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleBuilder.java
@@ -35,4 +35,9 @@
   protected MvcFramework getFramework() {
     return myFramework;
   }
+
+  @Override
+  public boolean isTemplate() {
+    return true;
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java
index a29e9d3..901a6d3 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcModuleStructureSynchronizer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,6 +24,9 @@
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleManager;
 import com.intellij.openapi.module.ModuleUtilCore;
+import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.progress.util.ProgressIndicatorUtils;
+import com.intellij.openapi.progress.util.ReadTask;
 import com.intellij.openapi.project.DumbAwareRunnable;
 import com.intellij.openapi.project.ModuleAdapter;
 import com.intellij.openapi.project.Project;
@@ -54,7 +57,7 @@
  * @author peter
  */
 public class MvcModuleStructureSynchronizer extends AbstractProjectComponent {
-  private final Set<Pair<Object, SyncAction>> myActions = new LinkedHashSet<Pair<Object, SyncAction>>();
+  private final Set<Pair<Object, SyncAction>> myOrders = new LinkedHashSet<Pair<Object, SyncAction>>();
 
   private Set<VirtualFile> myPluginRoots = Collections.emptySet();
 
@@ -106,7 +109,7 @@
 
     connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkVirtualFileListenerAdapter(new VirtualFileAdapter() {
       @Override
-      public void fileCreated(final VirtualFileEvent event) {
+      public void fileCreated(@NotNull final VirtualFileEvent event) {
         myModificationCount++;
 
         final VirtualFile file = event.getFile();
@@ -182,7 +185,7 @@
       }
 
       @Override
-      public void fileDeleted(VirtualFileEvent event) {
+      public void fileDeleted(@NotNull VirtualFileEvent event) {
         myModificationCount++;
 
         final VirtualFile file = event.getFile();
@@ -192,7 +195,7 @@
       }
 
       @Override
-      public void contentsChanged(VirtualFileEvent event) {
+      public void contentsChanged(@NotNull VirtualFileEvent event) {
         final String fileName = event.getFileName();
         if (MvcModuleStructureUtil.APPLICATION_PROPERTIES.equals(fileName)) {
           queue(SyncAction.UpdateProjectStructure, event.getFile());
@@ -200,12 +203,12 @@
       }
 
       @Override
-      public void fileMoved(VirtualFileMoveEvent event) {
+      public void fileMoved(@NotNull VirtualFileMoveEvent event) {
         myModificationCount++;
       }
 
       @Override
-      public void propertyChanged(VirtualFilePropertyEvent event) {
+      public void propertyChanged(@NotNull VirtualFilePropertyEvent event) {
         if (VirtualFile.PROP_NAME.equals(event.getPropertyName())) {
           myModificationCount++;
         }
@@ -240,29 +243,77 @@
 
   private void queue(SyncAction action, Object on) {
     ApplicationManager.getApplication().assertIsDispatchThread();
+    if (myProject.isDisposed()) return;
 
-    if (myActions.isEmpty()) {
-      if (myProject.isDisposed()) return;
+    boolean shouldSchedule;
+    synchronized (myOrders) {
+      shouldSchedule = myOrders.isEmpty();
+      myOrders.add(new Pair<Object, SyncAction>(on, action));
+    }
+    if (shouldSchedule) {
       StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() {
         @Override
         public void run() {
-          Application app = ApplicationManager.getApplication();
-          if (!app.isUnitTestMode()) {
-            app.invokeLater(new Runnable() {
-              @Override
-              public void run() {
-                runActions();
-              }
-            }, ModalityState.NON_MODAL);
-          }
-          else {
-            runActions();
-          }
+          scheduleRunActions();
         }
       });
     }
+  }
 
-    myActions.add(new Pair<Object, SyncAction>(on, action));
+  private void scheduleRunActions() {
+    if (myProject.isDisposed()) return;
+
+    final Application app = ApplicationManager.getApplication();
+    if (app.isUnitTestMode()) {
+      if (ourGrailsTestFlag && !myProject.isInitialized()) {
+        runActions(computeRawActions(takeOrderSnapshot()));
+      }
+      return;
+    }
+    
+    app.invokeLater(new Runnable() {
+      @Override
+      public void run() {
+        final Set<Pair<Object, SyncAction>> orderSnapshot = takeOrderSnapshot();
+        ProgressIndicatorUtils.scheduleWithWriteActionPriority(new ReadTask() {
+          @Override
+          public void computeInReadAction(@NotNull ProgressIndicator indicator) {
+            if (!isUpToDate()) {
+              indicator.cancel();
+              return;
+            }
+
+            final Set<Trinity<Module, SyncAction, MvcFramework>> actions = computeRawActions(orderSnapshot);
+            app.invokeLater(new Runnable() {
+              @Override
+              public void run() {
+                if (!isUpToDate()) {
+                  scheduleRunActions();
+                }
+                else {
+                  runActions(actions);
+                }
+              }
+            }, ModalityState.NON_MODAL);
+          }
+
+          @Override
+          public void onCanceled(@NotNull ProgressIndicator indicator) {
+            scheduleRunActions();
+          }
+
+          private boolean isUpToDate() {
+            return !myProject.isDisposed() && orderSnapshot.equals(takeOrderSnapshot());
+          }
+        });
+      }
+    });
+  }
+
+  private LinkedHashSet<Pair<Object, SyncAction>> takeOrderSnapshot() {
+    synchronized (myOrders) {
+      return new LinkedHashSet<Pair<Object, SyncAction>>(myOrders);
+    }
   }
 
   @NotNull
@@ -289,41 +340,15 @@
 
   @TestOnly
   public static void forceUpdateProject(Project project) {
-    project.getComponent(MvcModuleStructureSynchronizer.class).runActions();
+    MvcModuleStructureSynchronizer instance = project.getComponent(MvcModuleStructureSynchronizer.class);
+    instance.runActions(instance.computeRawActions(instance.takeOrderSnapshot()));
   }
 
-  private void runActions() {
+  private void runActions(Set<Trinity<Module, SyncAction, MvcFramework>> actions) {
     try {
-      if (myProject.isDisposed()) {
-        return;
-      }
-
-      if (ApplicationManager.getApplication().isUnitTestMode() && !ourGrailsTestFlag) {
-        return;
-      }
-
-      @SuppressWarnings("unchecked") Pair<Object, SyncAction>[] actions = myActions.toArray(new Pair[myActions.size()]);
-      //get module by object and kill duplicates
-
-      final Set<Trinity<Module, SyncAction, MvcFramework>> rawActions = new LinkedHashSet<Trinity<Module, SyncAction, MvcFramework>>();
-
-      for (final Pair<Object, SyncAction> pair : actions) {
-        for (Module module : determineModuleBySyncActionObject(pair.first)) {
-          if (!module.isDisposed()) {
-            final MvcFramework framework = (pair.second == SyncAction.CreateAppStructureIfNeeded)
-                                           ? MvcFramework.getInstanceBySdk(module)
-                                           : MvcFramework.getInstance(module);
-
-            if (framework != null && !framework.isAuxModule(module)) {
-              rawActions.add(Trinity.create(module, pair.second, framework));
-            }
-          }
-        }
-      }
-
       boolean isProjectStructureUpdated = false;
 
-      for (final Trinity<Module, SyncAction, MvcFramework> rawAction : rawActions) {
+      for (final Trinity<Module, SyncAction, MvcFramework> rawAction : actions) {
         final Module module = rawAction.first;
         if (module.isDisposed()) {
           continue;
@@ -341,15 +366,38 @@
       // if there were any actions added during performSyncAction, clear them too
       // all needed actions are already added to buffer and have thus been performed
       // otherwise you may get repetitive 'run create-app?' questions
-      myActions.clear();
+      synchronized (myOrders) {
+        myOrders.clear();
+      }
     }
   }
 
+  private Set<Trinity<Module, SyncAction, MvcFramework>> computeRawActions(Set<Pair<Object, SyncAction>> actions) {
+    //get module by object and kill duplicates
+    final Set<Trinity<Module, SyncAction, MvcFramework>> rawActions = new LinkedHashSet<Trinity<Module, SyncAction, MvcFramework>>();
+    for (final Pair<Object, SyncAction> pair : actions) {
+      for (Module module : determineModuleBySyncActionObject(pair.first)) {
+        if (!module.isDisposed()) {
+          final MvcFramework framework = (pair.second == SyncAction.CreateAppStructureIfNeeded)
+                                         ? MvcFramework.getInstanceBySdk(module)
+                                         : MvcFramework.getInstance(module);
+
+          if (framework != null && !framework.isAuxModule(module)) {
+            rawActions.add(Trinity.create(module, pair.second, framework));
+          }
+        }
+      }
+    }
+    return rawActions;
+  }
+
   private enum SyncAction {
     SyncLibrariesInPluginsModule {
       @Override
       void doAction(Module module, MvcFramework framework) {
-        framework.syncSdkAndLibrariesInPluginsModule(module);
+        if (MvcModuleStructureUtil.isEnabledStructureUpdate()) {
+          framework.syncSdkAndLibrariesInPluginsModule(module);
+        }
       }
     },
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcProjectWithoutLibraryNotificator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcProjectWithoutLibraryNotificator.java
index 7445188..8871a43 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcProjectWithoutLibraryNotificator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcProjectWithoutLibraryNotificator.java
@@ -1,20 +1,33 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.jetbrains.plugins.groovy.mvc;
 
 import com.intellij.notification.Notification;
 import com.intellij.notification.NotificationListener;
 import com.intellij.notification.NotificationType;
-import com.intellij.openapi.application.AccessToken;
-import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleManager;
+import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.progress.util.ProgressIndicatorUtils;
+import com.intellij.openapi.progress.util.ReadTask;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.startup.StartupActivity;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.psi.CommonClassNames;
-import com.intellij.psi.JavaPsiFacade;
-import com.intellij.psi.search.GlobalSearchScope;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
@@ -24,44 +37,41 @@
  * @author Sergey Evdokimov
  */
 public class MvcProjectWithoutLibraryNotificator implements StartupActivity, DumbAware {
-
   @Override
   public void runActivity(@NotNull final Project project) {
-    ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+    ProgressIndicatorUtils.scheduleWithWriteActionPriority(new ReadTask() {
       @Override
-      public void run() {
-        AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
+      public void computeInReadAction(@NotNull ProgressIndicator indicator) {
+        if (project.isDisposed()) {
+          return; 
+        }
 
-        try {
-          if (JavaPsiFacade.getInstance(project).findClass(CommonClassNames.JAVA_LANG_OBJECT, GlobalSearchScope.allScope(project)) == null) {
-            return; // If indexes is corrupted JavaPsiFacade.findClass() can't find classes during StartupActivity (may be it's a bug).
-                    // So we can't determine whether exists Grails library or not.
-          }
+        Pair<Module, MvcFramework> pair = findModuleWithoutLibrary(project);
 
-          Pair<Module, MvcFramework> pair = findModuleWithoutLibrary(project);
+        if (pair != null) {
+          final MvcFramework framework = pair.second;
+          final Module module = pair.first;
 
-          if (pair != null) {
-            final MvcFramework framework = pair.second;
-            final Module module = pair.first;
-
-            new Notification(framework.getFrameworkName() + ".Configure",
-                             framework.getFrameworkName() + " SDK not found.",
-                             "<html><body>Module '" +
-                             module.getName() +
-                             "' has no " +
-                             framework.getFrameworkName() +
-                             " SDK. <a href='create'>Configure SDK</a></body></html>", NotificationType.INFORMATION,
-                             new NotificationListener.Adapter() {
-                               @Override
-                               protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
+          String name = framework.getFrameworkName();
+          String content = "<html><body>Module '" + module.getName() + "' has no " + name + " SDK. <a href='create'>Configure SDK</a></body></html>";
+          new Notification(name + ".Configure",
+                           name + " SDK not found",
+                           content, NotificationType.INFORMATION,
+                           new NotificationListener.Adapter() {
+                             @Override
+                             protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent e) {
+                               if (!module.isDisposed()) {
                                  MvcConfigureNotification.configure(framework, module);
                                }
-                             }).notify(project);
-          }
+                             }
+                           }
+          ).notify(project);
         }
-        finally {
-          accessToken.finish();
-        }
+      }
+
+      @Override
+      public void onCanceled(@NotNull ProgressIndicator indicator) {
+        ProgressIndicatorUtils.scheduleWithWriteActionPriority(this);
       }
     });
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java
index 9be41ebd..30e158c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcRunTargetDialog.java
@@ -168,7 +168,7 @@
   }
 
   private void createUIComponents() {
-    myTargetField = new ComboBox(MvcRunTargetHistoryService.getInstance().getHistory(), -1);
+    myTargetField = new ComboBox(MvcRunTargetHistoryService.getInstance().getHistory());
     myTargetField.setLightWeightPopupEnabled(false);
 
     EditorComboBoxEditor editor = new StringComboboxEditor(myModule.getProject(), PlainTextFileType.INSTANCE, myTargetField);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/navbar/GrNavBarModelExtension.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/navbar/GrNavBarModelExtension.java
index 7285445..9116dbe 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/navbar/GrNavBarModelExtension.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/navbar/GrNavBarModelExtension.java
@@ -15,41 +15,35 @@
  */
 package org.jetbrains.plugins.groovy.navbar;
 
-import com.intellij.ide.navigationToolbar.NavBarModelExtension;
-import com.intellij.openapi.project.Project;
+import com.intellij.ide.navigationToolbar.AbstractNavBarModelExtension;
 import com.intellij.openapi.roots.ProjectFileIndex;
 import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
-import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.Nullable;
 import org.jetbrains.jps.model.java.JavaModuleSourceRootTypes;
 import org.jetbrains.plugins.groovy.GroovyFileType;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
 
-import java.util.Collection;
-
 /**
  * Created by Max Medvedev on 9/5/13
  */
-public class GrNavBarModelExtension implements NavBarModelExtension {
+public class GrNavBarModelExtension extends AbstractNavBarModelExtension {
+
+  @Nullable
   @Override
   public String getPresentableText(Object object) {
     return null;
   }
 
   @Override
-  public PsiElement getParent(PsiElement psiElement) {
-    return null;
-  }
-
-  @Override
   public PsiElement adjustElement(PsiElement psiElement) {
     final ProjectFileIndex index = ProjectRootManager.getInstance(psiElement.getProject()).getFileIndex();
     final PsiFile containingFile = psiElement.getContainingFile();
-    if (containingFile != null) {
+    if (containingFile instanceof GroovyFileBase) {
       final VirtualFile file = containingFile.getVirtualFile();
       if (file != null && (index.isUnderSourceRootOfType(file, JavaModuleSourceRootTypes.SOURCES) || index.isInLibraryClasses(file) || index.isInLibrarySource(file))) {
         if (psiElement instanceof GroovyFileBase) {
@@ -69,11 +63,6 @@
       return containingFile;
     }
 
-    return psiElement.isPhysical() ? psiElement : null;
-  }
-
-  @Override
-  public Collection<VirtualFile> additionalRoots(Project project) {
-    return ContainerUtil.emptyList();
+    return psiElement;
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java
index dab3cfe..c2a23fa 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideImplementUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -94,18 +94,19 @@
     GrParameter[] parameters = result.getParameters();
     for (int i = 0; i < parameters.length; i++) {
       GrParameter parameter = parameters[i];
-      final PsiParameter original = originalParams[i];
+      PsiParameter original = originalParams[i];
 
       for (PsiAnnotation annotation : original.getModifierList().getAnnotations()) {
         final GrModifierList modifierList = parameter.getModifierList();
 
         String qname = annotation.getQualifiedName();
-
-        if (annotation instanceof GrAnnotation) {
-          modifierList.add(annotation);
-        }
-        else {
-          modifierList.add(factory.createAnnotationFromText(annotation.getText()));
+        if (qname != null && modifierList.findAnnotation(qname) == null) {
+          if (annotation instanceof GrAnnotation) {
+            modifierList.add(annotation);
+          }
+          else {
+            modifierList.add(factory.createAnnotationFromText(annotation.getText()));
+          }
         }
       }
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideMethodsHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideMethodsHandler.java
index 364107f..324cf28 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideMethodsHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/overrideImplement/GroovyOverrideMethodsHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
 package org.jetbrains.plugins.groovy.overrideImplement;
 
 import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.generation.OverrideImplementExploreUtil;
 import com.intellij.codeInsight.generation.OverrideImplementUtil;
 import com.intellij.codeInsight.hint.HintManager;
 import com.intellij.lang.LanguageCodeInsightActionHandler;
@@ -40,7 +41,7 @@
     PsiClass aClass = OverrideImplementUtil.getContextClass(project, editor, file, true);
     if (aClass == null) return;
 
-    if (OverrideImplementUtil.getMethodSignaturesToOverride(aClass).isEmpty()) {
+    if (OverrideImplementExploreUtil.getMethodSignaturesToOverride(aClass).isEmpty()) {
       HintManager.getInstance().showErrorHint(editor, "No methods to override have been found");
       return;
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringBundle.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringBundle.java
index ab4d587..8a6fc6f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringBundle.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringBundle.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
 
 package org.jetbrains.plugins.groovy.refactoring;
 
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.GroovyBundle;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.PropertyKey;
@@ -31,19 +32,16 @@
  */
 public class GroovyRefactoringBundle {
 
-  private static Reference<ResourceBundle> ourBundle;
-
-  @NonNls
-  private static final String BUNDLE = "org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle";
-
-  public static String message(@PropertyKey(resourceBundle = BUNDLE)String key, Object... params) {
+  public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
     return CommonBundle.message(getBundle(), key, params);
   }
 
-  private static ResourceBundle getBundle() {
-    ResourceBundle bundle = null;
+  private static Reference<ResourceBundle> ourBundle;
+  @NonNls
+  private static final String BUNDLE = "org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle";
 
-    if (ourBundle != null) bundle = ourBundle.get();
+  private static ResourceBundle getBundle() {
+    ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
 
     if (bundle == null) {
       bundle = ResourceBundle.getBundle(BUNDLE);
@@ -51,5 +49,4 @@
     }
     return bundle;
   }
-
 }
\ No newline at end of file
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java
index feca69e..961cd88 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@
 import com.intellij.psi.util.*;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.ReflectionCache;
+import com.intellij.util.ReflectionUtil;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -53,6 +53,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrCallExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
@@ -64,6 +65,8 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
 import org.jetbrains.plugins.groovy.lang.psi.api.util.GrStatementOwner;
 import org.jetbrains.plugins.groovy.lang.psi.api.util.GrVariableDeclarationOwner;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
+import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo;
 
 import java.util.*;
 
@@ -91,11 +94,11 @@
     PsiElement element2 = file.getViewProvider().findElementAt(endOffset - 1, file.getLanguage());
     if (element1 == null || element2 == null) return null;
 
-    if (TokenSets.WHITE_SPACES_SET.contains(element1.getNode().getElementType())) {
+    if (PsiImplUtil.isWhiteSpaceOrNls(element1)) {
       startOffset = element1.getTextRange().getEndOffset();
       element1 = file.getViewProvider().findElementAt(startOffset, file.getLanguage());
     }
-    if (TokenSets.WHITE_SPACES_SET.contains(element2.getNode().getElementType())) {
+    if (PsiImplUtil.isWhiteSpaceOrNls(element2)) {
       endOffset = element2.getTextRange().getStartOffset();
       element2 = file.getViewProvider().findElementAt(endOffset - 1, file.getLanguage());
     }
@@ -103,13 +106,30 @@
     if (element2 == null || element1 == null) return null;
     final PsiElement commonParent = PsiTreeUtil.findCommonParent(element1, element2);
     assert commonParent != null;
-    final T element = ReflectionCache.isAssignable(klass, commonParent.getClass()) ? (T) commonParent : PsiTreeUtil.getParentOfType(commonParent, klass);
-    if (element == null || element.getTextRange().getStartOffset() != startOffset) {
+    final T element = ReflectionUtil.isAssignable(klass, commonParent.getClass()) ? (T) commonParent : PsiTreeUtil.getParentOfType(commonParent, klass);
+    if (element == null) {
       return null;
     }
+
+    if (!checkRanges(element, startOffset, endOffset)) {
+      return null;
+    }
+
     return element;
   }
 
+  private static boolean checkRanges(@NotNull PsiElement element, int startOffset, int endOffset) {
+    if (element instanceof GrLiteral && StringPartInfo.isWholeLiteralContentSelected((GrLiteral)element, startOffset, endOffset)) {
+      return true;
+    }
+
+    if (element.getTextRange().getStartOffset() == startOffset) {
+      return true;
+    }
+
+    return false;
+  }
+
   public static PsiElement[] getExpressionOccurrences(@NotNull PsiElement expr, @NotNull PsiElement scope) {
     ArrayList<PsiElement> occurrences = new ArrayList<PsiElement>();
     Comparator<PsiElement> comparator = new Comparator<PsiElement>() {
@@ -772,4 +792,20 @@
       }
     });
   }
+
+  public static boolean isSpreadAssignment(GrExpression lValue) {
+    if (lValue instanceof GrReferenceExpression) {
+      GrReferenceExpression expression = (GrReferenceExpression)lValue;
+      final PsiElement dot = expression.getDotToken();
+      //noinspection ConstantConditions
+      if (dot != null && dot.getNode().getElementType() == GroovyTokenTypes.mSPREAD_DOT) {
+        return true;
+      }
+      else {
+        final GrExpression qualifier = expression.getQualifierExpression();
+        if (qualifier != null) return isSpreadAssignment(qualifier);
+      }
+    }
+    return false;
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChageSignatureUsageSearcher.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChageSignatureUsageSearcher.java
index 0cd6775..0b78e3c 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChageSignatureUsageSearcher.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChageSignatureUsageSearcher.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -267,9 +267,7 @@
 
 
   private static void addParameterUsages(PsiParameter parameter, ArrayList<UsageInfo> results, ParameterInfo info) {
-    PsiManager manager = parameter.getManager();
-    GlobalSearchScope projectScope = GlobalSearchScope.projectScope(manager.getProject());
-    for (PsiReference psiReference : ReferencesSearch.search(parameter, projectScope, false)) {
+    for (PsiReference psiReference : ReferencesSearch.search(parameter)) {
       PsiElement parmRef = psiReference.getElement();
       UsageInfo usageInfo = new ChangeSignatureParameterUsageInfo(parmRef, parameter.getName(), info.getName());
       results.add(usageInfo);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/AnonymousFromMapGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/AnonymousFromMapGenerator.java
index 156e1d8..03290f5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/AnonymousFromMapGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/AnonymousFromMapGenerator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -68,9 +68,10 @@
       final GrExpression expression = arg.getExpression();
       if (name == null || expression == null || !(expression instanceof GrClosableBlock)) continue;
 
-      final GrParameter[] allParameters = ((GrClosableBlock)expression).getAllParameters();
+      final GrClosableBlock closure = (GrClosableBlock)expression;
+      final GrParameter[] allParameters = closure.getAllParameters();
       List<GrParameter> actual = new ArrayList<GrParameter>(Arrays.asList(allParameters));
-      final PsiType clReturnType = ((GrClosableBlock)expression).getReturnType();
+      final PsiType clReturnType = context.typeProvider.getReturnType(closure);
 
       GrExpression[] args = new GrExpression[allParameters.length];
       for (int i = 0; i < allParameters.length; i++) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClosureGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClosureGenerator.java
index 7f04df7..17d2892 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClosureGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ClosureGenerator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl;
 
 import java.util.Collection;
+import java.util.Collections;
 
 import static org.jetbrains.plugins.groovy.refactoring.convertToJava.TypeWriter.writeType;
 import static org.jetbrains.plugins.groovy.refactoring.convertToJava.TypeWriter.writeTypeForNew;
@@ -85,15 +86,15 @@
 
   private void generateClosureMainMethod(@NotNull GrClosableBlock block) {
     builder.append("public ");
-    final PsiType returnType = block.getReturnType();
+    final PsiType returnType = context.typeProvider.getReturnType(block);
     writeType(builder, returnType, block);
     builder.append(" doCall");
     final GrParameter[] parameters = block.getAllParameters();
     GenerationUtil.writeParameterList(builder, parameters, new GeneratorClassNameProvider(), context);
 
-    Collection<GrStatement> myExitPoints = ControlFlowUtils.collectReturns(block);
-    boolean shouldInsertReturnNull =
-      !(returnType instanceof PsiPrimitiveType) && MissingReturnInspection.methodMissesSomeReturns(block, MissingReturnInspection.ReturnStatus.shouldNotReturnValue);
+    Collection<GrStatement> myExitPoints = returnType != PsiType.VOID ? ControlFlowUtils.collectReturns(block) : Collections.<GrStatement>emptySet();
+    boolean shouldInsertReturnNull = !(returnType instanceof PsiPrimitiveType) &&
+                                     MissingReturnInspection.methodMissesSomeReturns(block, MissingReturnInspection.ReturnStatus.shouldNotReturnValue);
 
     new CodeBlockGenerator(builder, context.extend(), myExitPoints).generateCodeBlock(block, shouldInsertReturnNull);
     builder.append('\n');
@@ -104,7 +105,7 @@
     final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(context.project);
     final GrMethod method = factory.createMethodFromText("def doCall(){}", block);
 
-    method.setReturnType(block.getReturnType());
+    method.setReturnType(context.typeProvider.getReturnType(block));
     if (block.hasParametersSection()) {
       method.getParameterList().replace(block.getParameterList());
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java
index 739c6a9..51d39ae 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerator.java
@@ -101,14 +101,18 @@
   public void generateMethodBody(GrMethod method) {
     final GrOpenBlock block = method.getBlock();
 
-    boolean shouldInsertReturnNull = false;
+    boolean shouldInsertReturnNull;
     myExitPoints.clear();
     PsiType returnType = context.typeProvider.getReturnType(method);
     if (!method.isConstructor() && returnType != PsiType.VOID) {
       myExitPoints.addAll(ControlFlowUtils.collectReturns(block));
-      shouldInsertReturnNull = block != null && !(returnType instanceof PsiPrimitiveType) &&
-                               MissingReturnInspection.methodMissesSomeReturns(block,
-                                                                               MissingReturnInspection.ReturnStatus.getReturnStatus(method));
+      shouldInsertReturnNull = block != null &&
+                               !(returnType instanceof PsiPrimitiveType) &&
+                               MissingReturnInspection.methodMissesSomeReturns(block, MissingReturnInspection.ReturnStatus.getReturnStatus(
+                                 method));
+    }
+    else {
+      shouldInsertReturnNull = false;
     }
 
     if (block != null) {
@@ -186,9 +190,18 @@
     return StringUtil.repeatSymbol('\n', count);
   }
 
+
+  private void writeStatement(@Nullable GrStatement statement, @NotNull StatementWriter writer) {
+    GenerationUtil.writeStatement(builder, context, statement, writer);
+  }
+
+  private static void writeExpression(@NotNull GrExpression expression, @NotNull StringBuilder builder, @NotNull ExpressionContext context) {
+    expression.accept(new ExpressionGenerator(builder, context));
+  }
+
   @Override
   public void visitConstructorInvocation(final GrConstructorInvocation invocation) {
-    GenerationUtil.writeStatement(builder, context, invocation, new StatementWriter() {
+    writeStatement(invocation, new StatementWriter() {
       @Override
       public void writeStatement(StringBuilder builder, ExpressionContext context) {
         final GrReferenceExpression thisOrSuperKeyword = invocation.getInvokedExpression();
@@ -198,7 +211,7 @@
           builder.append(thisOrSuperKeyword.getReferenceName());
         }
         else {
-          thisOrSuperKeyword.accept(new ExpressionGenerator(builder, context));
+          writeExpression(thisOrSuperKeyword, builder, context);
         }
         new ArgumentListGenerator(builder, context).generate(
           GrClosureSignatureUtil.createSignature(resolveResult),
@@ -236,7 +249,7 @@
       return;
     }
 
-    GenerationUtil.writeStatement(builder, context, returnStatement, new StatementWriter() {
+    writeStatement(returnStatement, new StatementWriter() {
       @Override
       public void writeStatement(StringBuilder builder, ExpressionContext context) {
         writeReturn(builder, context, returnValue);
@@ -244,36 +257,30 @@
     });
   }
 
-  private void writeStatement(StringBuilder statementBuilder,
-                              GrStatement statement,
-                              @Nullable ExpressionContext context) {
-    GenerationUtil.writeStatement(builder, statementBuilder, statement, context);
-  }
-
   @Override
   public void visitAssertStatement(final GrAssertStatement assertStatement) {
     final GrExpression assertion = assertStatement.getAssertion();
     final GrExpression message = assertStatement.getErrorMessage();
     if (assertion != null) {
-      GenerationUtil.writeStatement(builder, context, assertStatement, new StatementWriter() {
+      writeStatement(assertStatement, new StatementWriter() {
         @Override
         public void writeStatement(StringBuilder builder, ExpressionContext context) {
           builder.append("assert ");
-          assertion.accept(new ExpressionGenerator(builder, context));
+          writeExpression(assertion, builder, context);
           if (message != null) {
             builder.append(" : ");
-            message.accept(new ExpressionGenerator(builder, context));
+            writeExpression(message, builder, context);
           }
           builder.append(';');
         }
       });
     }
     else if (message != null) {
-      GenerationUtil.writeStatement(builder, context, assertStatement, new StatementWriter() {
+      writeStatement(assertStatement, new StatementWriter() {
         @Override
         public void writeStatement(StringBuilder builder, ExpressionContext context) {
           builder.append("assert : ");
-          message.accept(new ExpressionGenerator(builder, context));
+          writeExpression(message, builder, context);
           builder.append(';');
         }
       });
@@ -290,11 +297,11 @@
       builder.append("throw ;");
       return;
     }
-    GenerationUtil.writeStatement(builder, context, throwStatement, new StatementWriter() {
+    writeStatement(throwStatement, new StatementWriter() {
       @Override
       public void writeStatement(StringBuilder builder, ExpressionContext context) {
         builder.append("throw ");
-        exception.accept(new ExpressionGenerator(builder, context));                     //todo add exception to method 'throws' list
+        writeExpression(exception, builder, context);                     //todo add exception to method 'throws' list
         builder.append(';');
       }
     });
@@ -302,7 +309,7 @@
 
   @Override
   public void visitLabeledStatement(final GrLabeledStatement labeledStatement) {
-    GenerationUtil.writeStatement(builder, context, labeledStatement, new StatementWriter() {
+    writeStatement(labeledStatement, new StatementWriter() {
       @Override
       public void writeStatement(StringBuilder builder, ExpressionContext context) {
         final String label = labeledStatement.getName();
@@ -318,17 +325,27 @@
 
   @Override
   public void visitExpression(final GrExpression expression) {
-    GenerationUtil.writeStatement(builder, context, expression, new StatementWriter() {
+    writeStatement(expression, new StatementWriter() {
       @Override
       public void writeStatement(StringBuilder builder, ExpressionContext context) {
-        if (myExitPoints.contains(expression) && expression.getType() != PsiType.VOID) {
+        if (myExitPoints.contains(expression) && isRealExpression(expression)) {
           writeReturn(builder, context, expression);
         }
         else {
-          expression.accept(new ExpressionGenerator(builder, context));
+          writeExpression(expression, builder, context);
           builder.append(';');
         }
       }
+
+      private boolean isRealExpression(GrExpression expression) {
+        final PsiType type = expression.getType();
+
+        if (type == PsiType.VOID) return false; //statement
+
+        if (type == PsiType.NULL) return !org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isVoidMethodCall(expression);
+
+        return true;
+      }
     });
   }
 
@@ -336,12 +353,11 @@
     builder.append("return ");
 
     final PsiType expectedReturnType = PsiImplUtil.inferReturnType(expression);
-    final PsiType nnReturnType =
-      expectedReturnType == null || expectedReturnType == PsiType.VOID ? TypesUtil.getJavaLangObject(expression) : expectedReturnType;
+    final PsiType nnReturnType = expectedReturnType == null || expectedReturnType == PsiType.VOID ? TypesUtil.getJavaLangObject(expression) : expectedReturnType;
     wrapInCastIfNeeded(builder, nnReturnType, expression.getNominalType(), expression, context, new StatementWriter() {
       @Override
       public void writeStatement(StringBuilder builder, ExpressionContext context) {
-        expression.accept(new ExpressionGenerator(builder, context));
+        writeExpression(expression, builder, context);
       }
     });
     builder.append(';');
@@ -359,7 +375,7 @@
 
   @Override
   public void visitIfStatement(final GrIfStatement ifStatement) {
-    GenerationUtil.writeStatement(builder, context, ifStatement, new StatementWriter() {
+    writeStatement(ifStatement, new StatementWriter() {
       @Override
       public void writeStatement(StringBuilder builder, ExpressionContext context) {
         final GrExpression condition = ifStatement.getCondition();
@@ -369,7 +385,7 @@
         if (condition != null) {
           final PsiType type = condition.getType();
           if (TypesUtil.unboxPrimitiveTypeWrapper(type) == PsiType.BOOLEAN) {
-            condition.accept(new ExpressionGenerator(builder, context));
+            writeExpression(condition, builder, context);
           }
           else {
             invokeMethodByName(
@@ -403,7 +419,7 @@
       builder.append(" : ");
       if (expression != null) {
         final ExpressionContext context = forContext.copy();
-        expression.accept(new ExpressionGenerator(builder, context));
+        writeExpression(expression, builder, context);
       }
     }
     else if (clause instanceof GrTraditionalForClause) {
@@ -419,19 +435,17 @@
         if (initializer != null) {
           final ExpressionContext partContext = forContext.copy();
           partBuilder.append(" = ");
-          initializer.accept(new ExpressionGenerator(partBuilder, partContext));
+          writeExpression(initializer, partBuilder, partContext);
           for (String statement : partContext.myStatements) {
             builder.append(statement).append(", ");
           }
           builder.append(partBuilder);
         }
       }
-      else {
-        if (initialization != null) {
-          StringBuilder partBuilder = new StringBuilder();
-          final ExpressionContext partContext = forContext.copy();
-          genForPart(builder, initialization, new CodeBlockGenerator(partBuilder, partContext, null));
-        }
+      else if (initialization != null) {
+        StringBuilder partBuilder = new StringBuilder();
+        final ExpressionContext partContext = forContext.copy();
+        genForPart(builder, initialization, new CodeBlockGenerator(partBuilder, partContext, null));
       }
 
       builder.append(';');
@@ -471,29 +485,33 @@
   }
 
   @Override
-  public void visitWhileStatement(GrWhileStatement whileStatement) {
-    final GrCondition condition = whileStatement.getCondition();
-    final GrStatement body = whileStatement.getBody();
+  public void visitWhileStatement(final GrWhileStatement whileStatement) {
+    writeStatement(whileStatement, new StatementWriter() {
+      @Override
+      public void writeStatement(StringBuilder builder, ExpressionContext context) {
+        final GrExpression condition = whileStatement.getCondition();
+        final GrStatement body = whileStatement.getBody();
 
-    StringBuilder builder = new StringBuilder();
-    builder.append("while (");
-    final ExpressionContext copy = context.copy();
-    if (condition != null) {
-      condition.accept(new ExpressionGenerator(builder, copy));           //todo update???
-    }
-    builder.append(" )");
-    if (body != null) {
-      body.accept(new CodeBlockGenerator(builder, copy.extend(), null));
-    }
-    writeStatement(builder, whileStatement, copy);
+        builder.append("while (");
+        if (condition != null) {
+          writeExpression(condition, builder, context);
+        }
+        builder.append(" )");
+        if (body != null) {
+          body.accept(new CodeBlockGenerator(builder, context.extend(), null));
+        }
+      }
+    });
   }
 
   @Override
-  public void visitSwitchStatement(GrSwitchStatement switchStatement) {
-    final StringBuilder builder = new StringBuilder();
-    final ExpressionContext copy = context.copy();
-    SwitchStatementGenerator.generate(builder, copy, switchStatement);
-    writeStatement(builder, switchStatement, copy);
+  public void visitSwitchStatement(final GrSwitchStatement switchStatement) {
+    writeStatement(switchStatement, new StatementWriter() {
+      @Override
+      public void writeStatement(StringBuilder builder, ExpressionContext context) {
+        SwitchStatementGenerator.generate(builder, context, switchStatement);
+      }
+    });
   }
 
   @Override
@@ -538,23 +556,28 @@
   }
 
   @Override
-  public void visitSynchronizedStatement(GrSynchronizedStatement synchronizedStatement) {
-    final GrExpression monitor = synchronizedStatement.getMonitor();
-    final GrOpenBlock body = synchronizedStatement.getBody();
+  public void visitSynchronizedStatement(final GrSynchronizedStatement statement) {
+    writeStatement(statement, new StatementWriter() {
+      @Override
+      public void writeStatement(StringBuilder builder, ExpressionContext context) {
+        final GrExpression monitor = statement.getMonitor();
+        final GrOpenBlock body = statement.getBody();
 
-    StringBuilder statementBuilder = new StringBuilder();
-    final ExpressionContext expressionContext = context.copy();
-
-    statementBuilder.append("synchronized(");
-    monitor.accept(new ExpressionGenerator(statementBuilder, expressionContext));
-    statementBuilder.append(')');
-    body.accept(new CodeBlockGenerator(statementBuilder, context.extend(), myExitPoints));
-    writeStatement(statementBuilder, synchronizedStatement, expressionContext);
+        builder.append("synchronized(");
+        if (monitor != null ) {
+          writeExpression(monitor, builder, context);
+        }
+        builder.append(')');
+        if (body != null) {
+          body.accept(new CodeBlockGenerator(builder, context.extend(), myExitPoints));
+        }
+      }
+    });
   }
 
   @Override
   public void visitVariableDeclaration(final GrVariableDeclaration variableDeclaration) {
-    GenerationUtil.writeStatement(builder, context, variableDeclaration, new StatementWriter() {
+    writeStatement(variableDeclaration, new StatementWriter() {
       @Override
       public void writeStatement(StringBuilder builder, ExpressionContext context) {
         if (variableDeclaration.isTuple()) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java
index 657f558..fb783b9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/ExpressionGenerator.java
@@ -55,6 +55,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrString;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrIndexProperty;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrPropertySelection;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
@@ -1271,6 +1272,13 @@
   }
 
   @Override
+  public void visitPropertySelection(GrPropertySelection expression) {
+    expression.getQualifier().accept(this);
+    builder.append('.');
+    builder.append(expression.getReferenceNameElement().getText());
+  }
+
+  @Override
   public void visitIndexProperty(GrIndexProperty expression) {
     final GrExpression selectedExpression = expression.getInvokedExpression();
     final PsiType thisType = selectedExpression.getType();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java
index 7b0769c..8af18d6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/GenerationUtil.java
@@ -248,7 +248,7 @@
     }
   }
 
-  public static void writeStatement(final StringBuilder builder, ExpressionContext context, @Nullable GrStatement statement, StatementWriter writer) {
+  public static void writeStatement(@NotNull StringBuilder builder, @NotNull ExpressionContext context, @Nullable GrStatement statement, @NotNull StatementWriter writer) {
     StringBuilder statementBuilder = new StringBuilder();
     ExpressionContext statementContext = context.copy();
     writer.writeStatement(statementBuilder, statementContext);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/SwitchStatementGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/SwitchStatementGenerator.java
index e88868b..b973288 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/SwitchStatementGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/SwitchStatementGenerator.java
@@ -17,8 +17,10 @@
 
 import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
 import com.intellij.psi.PsiType;
+import com.intellij.util.ArrayUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrSwitchStatement;
@@ -94,46 +96,11 @@
         final boolean isCase = labels.length > 1 || !labels[0].isDefault();
 
         if (isCase) {
-          builder.append("if (");
-          for (GrCaseLabel label : labels) {
-            if (label.isDefault()) {
-              builder.append("true");
-            }
-            else {
-              GenerationUtil.invokeMethodByName(
-                label.getValue(),
-                "isCase",
-                args,
-                GrNamedArgument.EMPTY_ARRAY,
-                GrClosableBlock.EMPTY_ARRAY,
-                new ExpressionGenerator(builder, context),
-                section
-              );
-            }
-            builder.append("||");
-          }
-          builder.delete(builder.length() - 2, builder.length());
-          builder.append(") ");
+          writeCondition(builder, context, section, labels, args);
         }
-        builder.append("{\n");
-        final ExpressionContext extended = context.extend();
-        CodeBlockGenerator generator = new CodeBlockGenerator(builder, extended);
+        writeCaseBody(builder, context, i, caseSections);
 
-        Outer:
-        for (int j = i; j < caseSections.length; j++) {
-          section = caseSections[j];
-          final GrStatement[] statements = section.getStatements();
-          for (GrStatement statement : statements) {
-            if (statement instanceof GrBreakStatement && ((GrBreakStatement)statement).getLabelIdentifier() == null) {
-              break Outer;
-            }
-            statement.accept(generator);
-            builder.append("\n");
-          }
-        }
-
-        builder.append('}');
-        if (isCase && i + 1 < caseSections.length) {
+        if (isCase && i != caseSections.length - 1) {
           builder.append("\nelse ");
           StringBuilder elseBuilder = new StringBuilder();
           final ExpressionContext elseContext = context.extend();
@@ -149,6 +116,64 @@
     });
   }
 
+  private static void writeCaseBody(@NotNull StringBuilder builder,
+                                    @NotNull ExpressionContext context,
+                                    int i,
+                                    @NotNull GrCaseSection[] caseSections) {
+    builder.append("{\n");
+
+    final ExpressionContext extended = context.extend();
+    CodeBlockGenerator generator = new CodeBlockGenerator(builder, extended);
+
+    Outer:
+    for (int j = i; j < caseSections.length; j++) {
+      GrCaseSection curSection = caseSections[j];
+      final GrStatement[] statements = curSection.getStatements();
+      for (GrStatement statement : statements) {
+        if (statement instanceof GrBreakStatement && ((GrBreakStatement)statement).getLabelIdentifier() == null) {
+          break Outer;
+        }
+        statement.accept(generator);
+        builder.append("\n");
+      }
+      if (brakesFlow(curSection)) break;
+    }
+
+    builder.append('}');
+  }
+
+  private static boolean brakesFlow(GrCaseSection section) {
+    final GrStatement[] statements = section.getStatements();
+    return statements.length > 0 && !ControlFlowUtils.statementMayCompleteNormally(ArrayUtil.getLastElement(statements));
+  }
+
+  private static void writeCondition(StringBuilder builder,
+                                     ExpressionContext context,
+                                     GrCaseSection section,
+                                     GrCaseLabel[] labels,
+                                     GrExpression[] args) {
+    builder.append("if (");
+    for (GrCaseLabel label : labels) {
+      if (label.isDefault()) {
+        builder.append("true");
+      }
+      else {
+        GenerationUtil.invokeMethodByName(
+          label.getValue(),
+          "isCase",
+          args,
+          GrNamedArgument.EMPTY_ARRAY,
+          GrClosableBlock.EMPTY_ARRAY,
+          new ExpressionGenerator(builder, context),
+          section
+        );
+      }
+      builder.append("||");
+    }
+    builder.delete(builder.length() - 2, builder.length());
+    builder.append(") ");
+  }
+
   private static String generateConditionVar(@NotNull StringBuilder builder,
                                              @NotNull ExpressionContext context,
                                              @NotNull GrExpression condition) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/TypeProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/TypeProvider.java
index 9870962..55df1da 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/TypeProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/TypeProvider.java
@@ -25,6 +25,7 @@
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrCall;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
@@ -55,7 +56,9 @@
       if (typeElement != null) return typeElement.getType();
     }
     final PsiType smartReturnType = PsiUtil.getSmartReturnType(method);
-    if (smartReturnType != null) return smartReturnType;
+    if (smartReturnType != null && !PsiType.NULL.equals(smartReturnType)) return smartReturnType;
+
+    if (PsiType.NULL.equals(smartReturnType) && PsiUtil.isVoidMethod(method)) return PsiType.VOID;
 
     //todo make smarter. search for usages and infer type from them
     return TypesUtil.getJavaLangObject(method);
@@ -113,7 +116,7 @@
     final GrParameter[] parameters = method.getParameters();
 
     final TIntArrayList paramInds = new TIntArrayList(parameters.length);
-    final PsiType[] types = new PsiType[parameters.length];
+    final PsiType[] types = PsiType.createArray(parameters.length);
     for (int i = 0; i < parameters.length; i++) {
       if (parameters[i].getTypeElementGroovy() == null) {
         paramInds.add(i);
@@ -122,7 +125,7 @@
       }
     }
 
-    if (paramInds.size() > 0) {
+    if (!paramInds.isEmpty()) {
       final GrClosureSignature signature = GrClosureSignatureUtil.createSignature(method, PsiSubstitutor.EMPTY);
       MethodReferencesSearch.search(method, true).forEach(new Processor<PsiReference>() {
         @Override
@@ -161,4 +164,18 @@
     inferredTypes.put(method, types);
     return types;
   }
+
+  @NotNull
+  public PsiType getReturnType(GrClosableBlock closure) {
+    final PsiType returnType = closure.getReturnType();
+    if (PsiType.NULL.equals(returnType) && PsiUtil.isBlockReturnVoid(closure)) {
+      return PsiType.VOID;
+    }
+
+    if (returnType == null) {
+      return TypesUtil.getJavaLangObject(closure);
+    }
+
+    return returnType;
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/TypeWriter.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/TypeWriter.java
index 4f0aade..4080f2f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/TypeWriter.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/convertToJava/TypeWriter.java
@@ -53,13 +53,13 @@
                                @Nullable PsiType type,
                                @NotNull final PsiElement context,
                                @NotNull final ClassNameProvider classNameProvider) {
-    if (type instanceof PsiPrimitiveType) {
-      builder.append(type.getCanonicalText());
+    if (type == null || PsiType.NULL.equals(type)) {
+      builder.append(CommonClassNames.JAVA_LANG_OBJECT);
       return;
     }
 
-    if (type == null) {
-      builder.append(CommonClassNames.JAVA_LANG_OBJECT);
+    if (type instanceof PsiPrimitiveType) {
+      builder.append(type.getCanonicalText());
       return;
     }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractInfoHelper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractInfoHelper.java
index fde920e2..85c4008 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractInfoHelper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractInfoHelper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.VariableInfo;
 import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo;
 
@@ -52,6 +53,9 @@
   @Nullable
   StringPartInfo getStringPartInfo();
 
+  @Nullable
+  GrVariable getVar();
+
   boolean hasReturnValue();
   
   String getName();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractInfoHelperBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractInfoHelperBase.java
index 24a8cd8..67f5487 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractInfoHelperBase.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractInfoHelperBase.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.VariableInfo;
 import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo;
 
@@ -113,6 +114,12 @@
     return myInitialInfo.getStringPartInfo();
   }
 
+  @Nullable
+  @Override
+  public GrVariable getVar() {
+    return myInitialInfo.getVar();
+  }
+
   public boolean hasReturnValue() {
     return myInitialInfo.hasReturnValue();
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractUtil.java
index 07ec5c4..190d5ba 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ExtractUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,7 +54,6 @@
 import org.jetbrains.plugins.groovy.refactoring.GroovyNamesUtil;
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
 import org.jetbrains.plugins.groovy.refactoring.extract.method.ExtractMethodInfoHelper;
-import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase;
 import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo;
 
 import java.util.*;
@@ -89,7 +88,7 @@
     else {
       GrExpression oldExpr;
       if (helper.getStringPartInfo() != null) {
-        oldExpr = GrIntroduceHandlerBase.processLiteral(helper.getName(), helper.getStringPartInfo(), helper.getProject());
+        oldExpr = helper.getStringPartInfo().replaceLiteralWithConcatenation("xyz");
       }
       else {
         oldExpr = (GrExpression)helper.getStatements()[0];
@@ -405,13 +404,13 @@
     }
     else {
       GrExpression expr = stringPartInfo != null
-                          ? GrIntroduceHandlerBase.generateExpressionFromStringPart(stringPartInfo, helper.getProject())
+                          ? stringPartInfo.createLiteralFromSelected()
                           : (GrExpression)PsiUtil.skipParentheses(helper.getStatements()[0], false);
-      boolean addReturn = !isVoid && forceReturn;
+      boolean addReturn = !isVoid && forceReturn && !PsiUtil.isVoidMethodCall(expr);
       if (addReturn) {
         buffer.append("return ");
-        expr = ApplicationStatementUtil.convertToMethodCallExpression(expr);
-        buffer.append(expr.getText());
+        final GrExpression methodCall = ApplicationStatementUtil.convertToMethodCallExpression(expr);
+        buffer.append(methodCall.getText());
       }
       else {
         buffer.append(expr != null ? expr.getText() : "");
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/GroovyExtractChooser.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/GroovyExtractChooser.java
index 6e61c36b..9132991 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/GroovyExtractChooser.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/GroovyExtractChooser.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,18 +19,22 @@
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.editor.SelectionModel;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.refactoring.util.CommonRefactoringUtil;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.containers.HashSet;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
 import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
@@ -78,18 +82,37 @@
     SelectionModel selectionModel = editor.getSelectionModel();
     PsiDocumentManager.getInstance(project).commitAllDocuments();
 
-    final StringPartInfo stringPart =
-      StringPartInfo.findStringPart(file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd());
-
+    final StringPartInfo stringPart = StringPartInfo.findStringPart(file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd());
     if (stringPart != null) {
-      return new InitialInfo(new VariableInfo[0], new VariableInfo[0], PsiElement.EMPTY_ARRAY, GrStatement.EMPTY_ARRAY, new ArrayList<GrStatement>(), stringPart, project);
+      return new InitialInfo(new VariableInfo[0], new VariableInfo[0], PsiElement.EMPTY_ARRAY, GrStatement.EMPTY_ARRAY, new ArrayList<GrStatement>(), stringPart, project, null);
     }
 
+    if (!forceStatements) {
+      GrVariable variable = GrIntroduceHandlerBase.findVariable(file, start, end);
+      if (variable != null) {
+        GrExpression initializer = variable.getInitializerGroovy();
+        if (initializer != null) {
+          TextRange range = initializer.getTextRange();
+          return buildInfo(project, file, range.getStartOffset(), range.getEndOffset(), forceStatements, selectionModel, variable);
+        }
+      }
+    }
 
+    return buildInfo(project, file, start, end, forceStatements, selectionModel, null);
+  }
+
+  @NotNull
+  private static InitialInfo buildInfo(@NotNull Project project,
+                                       @NotNull PsiFile file,
+                                       int start,
+                                       int end,
+                                       boolean forceStatements,
+                                       @NotNull SelectionModel selectionModel,
+                                       @Nullable GrVariable variable) throws GrRefactoringError {
     PsiElement[] elements = getElementsInOffset(file, start, end, forceStatements);
-    if (elements.length == 1 && elements[0] instanceof GrExpression) {
-      selectionModel.setSelection(start, elements[0].getTextRange().getEndOffset());
-    }
+    //if (elements.length == 1 && elements[0] instanceof GrExpression) {
+    //  selectionModel.setSelection(start, elements[0].getTextRange().getEndOffset());
+    //}
 
     GrStatement[] statements = getStatementsByElements(elements);
 
@@ -171,7 +194,7 @@
         GroovyRefactoringBundle.message("refactoring.is.not.supported.when.return.statement.interrupts.the.execution.flow"));
     }
 
-    return new InitialInfo(inputInfos, outputInfos, elements, statements, returnStatements, null, project);
+    return new InitialInfo(inputInfos, outputInfos, elements, statements, returnStatements, null, project, variable);
   }
 
   private static boolean isLastStatementOfMethodOrClosure(GrStatement[] statements) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/InitialInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/InitialInfo.java
index e50e6d5..896f1e2e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/InitialInfo.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/InitialInfo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.dataFlow.reachingDefs.VariableInfo;
@@ -47,6 +48,7 @@
   private final boolean myHasReturnValue;
   private final String[] myArgumentNames;
   private final StringPartInfo myStringPartInfo;
+  private final GrVariable myVariable;
 
   public InitialInfo(VariableInfo[] inputInfos,
                      VariableInfo[] outputInfos,
@@ -54,11 +56,12 @@
                      GrStatement[] statements,
                      ArrayList<GrStatement> returnStatements,
                      StringPartInfo stringPartInfo,
-                     Project project) {
+                     Project project, GrVariable variable) {
     myInnerElements = innerElements;
     myStatements = statements;
     myOutputNames = outputInfos;
     myStringPartInfo = stringPartInfo;
+    myVariable = variable;
 
     myHasReturnValue = ContainerUtil.find(returnStatements, new Condition<GrStatement>() {
       @Override
@@ -194,4 +197,10 @@
   public StringPartInfo getStringPartInfo() {
     return myStringPartInfo;
   }
+
+  @Nullable
+  @Override
+  public GrVariable getVar() {
+    return myVariable;
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ParameterTablePanel.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ParameterTablePanel.java
index cccdaa3..3125f08 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ParameterTablePanel.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/ParameterTablePanel.java
@@ -16,17 +16,13 @@
 
 package org.jetbrains.plugins.groovy.refactoring.extract;
 
-import com.intellij.ui.ListCellRendererWrapper;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiManager;
 import com.intellij.psi.PsiPrimitiveType;
 import com.intellij.psi.PsiType;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.refactoring.ui.TypeSelector;
-import com.intellij.ui.BooleanTableCellRenderer;
-import com.intellij.ui.IdeBorderFactory;
-import com.intellij.ui.TableUtil;
-import com.intellij.ui.ToolbarDecorator;
+import com.intellij.ui.*;
 import com.intellij.ui.table.JBTable;
 import com.intellij.util.ui.AbstractTableCellEditor;
 import com.intellij.util.ui.EditableModel;
@@ -38,6 +34,7 @@
 import javax.swing.table.AbstractTableModel;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableColumn;
 import java.awt.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
@@ -71,9 +68,13 @@
 
     myTable.setTableHeader(null);
     myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-    myTable.getColumnModel().getColumn(MyTableModel.CHECKMARK_COLUMN).setCellRenderer(new CheckBoxTableCellRenderer());
-    myTable.getColumnModel().getColumn(MyTableModel.CHECKMARK_COLUMN).setMaxWidth(new JCheckBox().getPreferredSize().width);
+
+    TableColumn checkBoxColumn = myTable.getColumnModel().getColumn(MyTableModel.CHECKMARK_COLUMN);
+    TableUtil.setupCheckboxColumn(checkBoxColumn);
+    checkBoxColumn.setCellRenderer(new CheckBoxTableCellRenderer());
+
     myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_NAME_COLUMN).setCellRenderer(new DefaultTableCellRenderer() {
+      @Override
       public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
         super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
         ParameterInfo info = myParameterInfos[row];
@@ -111,10 +112,12 @@
     myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_TYPE_COLUMN).setCellEditor(new AbstractTableCellEditor() {
       TypeSelector myCurrentSelector;
 
+      @Override
       public Object getCellEditorValue() {
         return myCurrentSelector.getSelectedType();
       }
 
+      @Override
       public Component getTableCellEditorComponent(final JTable table,
                                                    final Object value,
                                                    final boolean isSelected,
@@ -126,6 +129,7 @@
     });
 
     myTable.getColumnModel().getColumn(MyTableModel.PARAMETER_TYPE_COLUMN).setCellRenderer(new DefaultTableCellRenderer() {
+      @Override
       public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
         if (myParameterTypeSelectors[row].getComponent() instanceof JComboBox) {
           myTypeRendererCombo.setSelectedIndex(row);
@@ -149,6 +153,7 @@
     inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0), "enable_disable");
     @NonNls final ActionMap actionMap = myTable.getActionMap();
     actionMap.put("enable_disable", new AbstractAction() {
+      @Override
       public void actionPerformed(ActionEvent e) {
         if (myTable.isEditing()) return;
         int[] rows = myTable.getSelectedRows();
@@ -171,6 +176,7 @@
     // F2 should edit the name
     inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "edit_parameter_name");
     actionMap.put("edit_parameter_name", new AbstractAction() {
+      @Override
       public void actionPerformed(ActionEvent e) {
         if (!myTable.isEditing()) {
           int row = myTable.getSelectedRow();
@@ -184,6 +190,7 @@
     // make ENTER work when the table has focus
     inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "invokeImpl");
     actionMap.put("invokeImpl", new AbstractAction() {
+      @Override
       public void actionPerformed(ActionEvent e) {
         TableCellEditor editor = myTable.getCellEditor();
         if (editor != null) {
@@ -197,6 +204,7 @@
 
     // make ESCAPE work when the table has focus
     actionMap.put("doCancel", new AbstractAction() {
+      @Override
       public void actionPerformed(ActionEvent e) {
         TableCellEditor editor = myTable.getCellEditor();
         if (editor != null) {
@@ -256,14 +264,17 @@
       return true;
     }
 
+    @Override
     public int getRowCount() {
       return myParameterInfos.length;
     }
 
+    @Override
     public int getColumnCount() {
       return 3;
     }
 
+    @Override
     public Object getValueAt(int rowIndex, int columnIndex) {
       switch (columnIndex) {
         case CHECKMARK_COLUMN: {
@@ -281,6 +292,7 @@
       return null;
     }
 
+    @Override
     public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
       switch (columnIndex) {
         case CHECKMARK_COLUMN: {
@@ -308,6 +320,7 @@
       }
     }
 
+    @Override
     public boolean isCellEditable(int rowIndex, int columnIndex) {
       switch (columnIndex) {
         case CHECKMARK_COLUMN:
@@ -323,6 +336,7 @@
       }
     }
 
+    @Override
     public Class getColumnClass(int columnIndex) {
       if (columnIndex == CHECKMARK_COLUMN) {
         return Boolean.class;
@@ -332,6 +346,7 @@
   }
 
   private class CheckBoxTableCellRenderer extends BooleanTableCellRenderer {
+    @Override
     public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
       Component rendererComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
       rendererComponent.setEnabled(ParameterTablePanel.this.isEnabled());
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/closure/ExtractClosureHelperImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/closure/ExtractClosureHelperImpl.java
index baa5dbd..7b7f9ea 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/closure/ExtractClosureHelperImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/closure/ExtractClosureHelperImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
 import com.intellij.psi.PsiType;
 import gnu.trove.TIntArrayList;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrParametersOwner;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
@@ -42,6 +43,7 @@
   private final boolean myGenerateDelegate;
   private final int myReplaceFieldsWithGetters;
   private final boolean myForceReturn;
+  private final boolean myReplaceAllOccurrences;
 
   private PsiType myType = null;
   private boolean myForceDef;
@@ -52,9 +54,12 @@
                                   TIntArrayList toRemove,
                                   boolean generateDelegate,
                                   int replaceFieldsWithGetters,
-                                  boolean forceReturn, boolean forceDef) {
+                                  boolean forceReturn,
+                                  boolean replaceAllOccurrences,
+                                  boolean forceDef) {
     super(info);
     myForceReturn = forceReturn;
+    myReplaceAllOccurrences = replaceAllOccurrences;
     myForceDef = forceDef;
     myOwner = info.getToReplaceIn();
     myToSearchFor = info.getToSearchFor();
@@ -99,7 +104,7 @@
 
   @Override
   public boolean replaceAllOccurrences() {
-    return false;
+    return myReplaceAllOccurrences;
   }
 
   @Override
@@ -131,6 +136,7 @@
     return myForceReturn;
   }
 
+  @Nullable
   @Override
   public GrVariable getVar() {
     return null;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/closure/ExtractClosureProcessorBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/closure/ExtractClosureProcessorBase.java
index 7359fc0..07ed028 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/closure/ExtractClosureProcessorBase.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/extract/closure/ExtractClosureProcessorBase.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -60,7 +60,8 @@
     return EXTRACT_CLOSURE;
   }
 
-  public static GrClosableBlock generateClosure(GrIntroduceParameterSettings helper) {
+  @NotNull
+  public static GrClosableBlock generateClosure(@NotNull GrIntroduceParameterSettings helper) {
     StringBuilder buffer = new StringBuilder();
 
     buffer.append("{ ");
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineLocalHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineLocalHandler.java
index 2f0c6ce..3facacb 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineLocalHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineLocalHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -40,7 +40,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMember;
 import org.jetbrains.plugins.groovy.lang.psi.controlFlow.Instruction;
-import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
+import org.jetbrains.plugins.groovy.lang.psi.dataFlow.types.TypeInferenceHelper;
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle;
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
 
@@ -129,7 +129,7 @@
               initializer = ((GrVariable)element).getInitializerGroovy();
             }
             else if (element instanceof GrReferenceExpression) {
-              initializer = PsiUtil.getInitializerFor((GrReferenceExpression)element);
+              initializer = TypeInferenceHelper.getInitializerFor((GrReferenceExpression)element);
             }
           }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineMethodUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineMethodUtil.java
index 70b6807..4f64084 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineMethodUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyInlineMethodUtil.java
@@ -600,7 +600,7 @@
           final boolean isFinal = ((GrVariable)resolved).hasModifierProperty(PsiModifier.FINAL);
           if (!isFinal) {
             final PsiReference lastRef =
-              Collections.max(ReferencesSearch.search(resolved, resolved.getResolveScope()).findAll(), new Comparator<PsiReference>() {
+              Collections.max(ReferencesSearch.search(resolved).findAll(), new Comparator<PsiReference>() {
                 public int compare(PsiReference o1, PsiReference o2) {
                   return o1.getElement().getTextRange().getStartOffset() - o2.getElement().getTextRange().getStartOffset();
                 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyMethodInliner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyMethodInliner.java
index 5d43719..e5e398a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyMethodInliner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/inline/GroovyMethodInliner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,7 +28,6 @@
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.search.searches.ReferencesSearch;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.refactoring.util.CommonRefactoringUtil;
@@ -176,7 +175,10 @@
         GrExpression invoked = ((GrMethodCallExpression) call).getInvokedExpression();
         if (invoked instanceof GrReferenceExpression && ((GrReferenceExpression) invoked).getQualifierExpression() != null) {
           qualifier = ((GrReferenceExpression) invoked).getQualifierExpression();
-          if (!GroovyInlineMethodUtil.isSimpleReference(qualifier)) {
+          if (PsiUtil.isSuperReference(qualifier)) {
+            qualifier = null;
+          }
+          else if (!GroovyInlineMethodUtil.isSimpleReference(qualifier)) {
             String qualName = generateQualifierName(call, method, project, qualifier);
             qualifier = (GrExpression)PsiUtil.skipParentheses(qualifier, false);
             qualifierDeclaration = factory.createVariableDeclaration(ArrayUtil.EMPTY_STRING_ARRAY, qualifier, null, qualName);
@@ -373,7 +375,7 @@
                          InlineMethodConflictSolver.suggestNewName(name, method, call, ((GrReferenceExpression)qualifier).getReferenceName()) :
                          InlineMethodConflictSolver.suggestNewName(name, method, call);
         if (!newName.equals(namedElement.getName())) {
-          final Collection<PsiReference> refs = ReferencesSearch.search(namedElement, GlobalSearchScope.projectScope(namedElement.getProject()), false).findAll();
+          final Collection<PsiReference> refs = ReferencesSearch.search(namedElement).findAll();
           for (PsiReference ref : refs) {
             PsiElement element = ref.getElement();
             if (element instanceof GrReferenceExpression) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrAbstractInplaceIntroducer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrAbstractInplaceIntroducer.java
index 9d9fe9e..92b0368 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrAbstractInplaceIntroducer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrAbstractInplaceIntroducer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -262,7 +262,7 @@
 
   @Override
   public boolean isReplaceAllOccurrences() {
-    return myReplaceChoice != OccurrencesChooser.ReplaceChoice.NO || myContext.getOccurrences().length == 1;
+    return myReplaceChoice != OccurrencesChooser.ReplaceChoice.NO;
   }
 
   protected abstract Settings getSettings();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java
index 5235c0a..10e93ac 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,7 +43,9 @@
 import com.intellij.refactoring.IntroduceTargetChooser;
 import com.intellij.refactoring.RefactoringActionHandler;
 import com.intellij.refactoring.RefactoringBundle;
+import com.intellij.refactoring.introduce.inplace.AbstractInplaceIntroducer;
 import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
+import com.intellij.refactoring.rename.inplace.InplaceRefactoring;
 import com.intellij.refactoring.util.CommonRefactoringUtil;
 import com.intellij.util.Function;
 import com.intellij.util.IncorrectOperationException;
@@ -61,12 +63,11 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseLabel;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringInjection;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
 import org.jetbrains.plugins.groovy.lang.psi.api.util.GrDeclarationHolder;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
-import org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil;
+import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 import org.jetbrains.plugins.groovy.refactoring.GrRefactoringError;
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle;
@@ -185,6 +186,11 @@
     }
     else if (context.getStringPart() != null) {
       map.put(OccurrencesChooser.ReplaceChoice.NO, Collections.<Object>singletonList(context.getStringPart()));
+      return map;
+    }
+    else if (context.getVar() != null) {
+      map.put(OccurrencesChooser.ReplaceChoice.ALL, Collections.<Object>singletonList(context.getVar()));
+      return map;
     }
 
     PsiElement[] occurrences = context.getOccurrences();
@@ -273,14 +279,7 @@
 
       final List<GrExpression> expressions = collectExpressions(file, editor, offset, false);
       if (expressions.isEmpty()) {
-        final GrVariable variable = findVariableAtCaret(file, editor, offset);
-        if (variable == null || variable instanceof GrField || variable instanceof GrParameter) {
-          selectionModel.selectLineAtCaret();
-        }
-        else {
-          final TextRange textRange = variable.getTextRange();
-          selectionModel.setSelection(textRange.getStartOffset(), textRange.getEndOffset());
-        }
+        updateSelectionForVariable(editor, file, selectionModel, offset);
       }
       else if (expressions.size() == 1) {
         final TextRange textRange = expressions.get(0).getTextRange();
@@ -298,6 +297,17 @@
     invoke(project, editor, file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd());
   }
 
+  public static void updateSelectionForVariable(Editor editor, PsiFile file, SelectionModel selectionModel, int offset) {
+    final GrVariable variable = findVariableAtCaret(file, editor, offset);
+    if (variable == null || variable instanceof GrField || variable instanceof GrParameter) {
+      selectionModel.selectLineAtCaret();
+    }
+    else {
+      final TextRange textRange = variable.getTextRange();
+      selectionModel.setSelection(textRange.getStartOffset(), textRange.getEndOffset());
+    }
+  }
+
   @Override
   public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
     // Does nothing
@@ -340,7 +350,10 @@
           public void run() {
             GrIntroduceContext context = ref.get();
 
-            GrExpression expression = cutLiteral(context.getStringPart(), context.getProject());
+            StringPartInfo stringPart = context.getStringPart();
+            assert stringPart != null;
+
+            GrExpression expression = stringPart.replaceLiteralWithConcatenation(null);
 
             ref.set(new GrIntroduceContextImpl(context.getProject(), context.getEditor(), expression, null, null, new PsiElement[]{expression}, context.getScope()));
           }
@@ -427,19 +440,8 @@
                                        @Nullable StringPartInfo stringPart,
                                        @NotNull PsiElement scope) {
     if (variable != null) {
-      final List<PsiElement> list = Collections.synchronizedList(new ArrayList<PsiElement>());
-      ReferencesSearch.search(variable, new LocalSearchScope(scope)).forEach(new Processor<PsiReference>() {
-        @Override
-        public boolean process(PsiReference psiReference) {
-          final PsiElement element = psiReference.getElement();
-          if (element != null) {
-            list.add(element);
-          }
-          return true;
-        }
-      });
-      final PsiElement[] occurrences = list.toArray(new PsiElement[list.size()]);
-      return new GrIntroduceContextImpl(project, editor, variable.getInitializerGroovy(), variable, stringPart, occurrences, scope);
+      final PsiElement[] occurrences = collectVariableUsages(variable, scope);
+      return new GrIntroduceContextImpl(project, editor, null, variable, stringPart, occurrences, scope);
     }
     else if (expression != null ) {
       final PsiElement[] occurrences = findOccurrences(expression, scope);
@@ -451,6 +453,24 @@
     }
   }
 
+  public static PsiElement[] collectVariableUsages(GrVariable variable, PsiElement scope) {
+    final List<PsiElement> list = Collections.synchronizedList(new ArrayList<PsiElement>());
+    if (scope instanceof GroovyScriptClass) {
+      scope = scope.getContainingFile();
+    }
+    ReferencesSearch.search(variable, new LocalSearchScope(scope)).forEach(new Processor<PsiReference>() {
+      @Override
+      public boolean process(PsiReference psiReference) {
+        final PsiElement element = psiReference.getElement();
+        if (element != null) {
+          list.add(element);
+        }
+        return true;
+      }
+    });
+    return list.toArray(new PsiElement[list.size()]);
+  }
+
   private boolean invokeImpl(final Project project, final GrIntroduceContext context, final Editor editor) {
     try {
       if (!CommonRefactoringUtil.checkReadOnlyStatus(project, context.getOccurrences())) {
@@ -460,21 +480,8 @@
 
 
       if (isInplace(context.getEditor(), context.getPlace())) {
-        Map<OccurrencesChooser.ReplaceChoice, List<Object>> occurrencesMap = fillChoice(context);
-        new OccurrencesChooser<Object>(editor) {
-          @Override
-          protected TextRange getOccurrenceRange(Object occurrence) {
-            if (occurrence instanceof PsiElement) {
-              return ((PsiElement)occurrence).getTextRange();
-            }
-            else if (occurrence instanceof StringPartInfo) {
-              return ((StringPartInfo)occurrence).getRange();
-            }
-            else {
-              return null;
-            }
-          }
-        }.showChooser(new Pass<OccurrencesChooser.ReplaceChoice>() {
+        Map<OccurrencesChooser.ReplaceChoice, List<Object>> occurrencesMap = getOccurrenceOptions(context);
+        new IntroduceOccurrencesChooser(editor).showChooser(new Pass<OccurrencesChooser.ReplaceChoice>() {
           @Override
           public void pass(final OccurrencesChooser.ReplaceChoice choice) {
             getIntroducer(context, choice).startInplaceIntroduceTemplate();
@@ -507,6 +514,11 @@
   }
 
   @NotNull
+  protected Map<OccurrencesChooser.ReplaceChoice, List<Object>> getOccurrenceOptions(@NotNull GrIntroduceContext context) {
+    return fillChoice(context);
+  }
+
+  @NotNull
   protected PsiElement[] findOccurrences(@NotNull GrExpression expression, @NotNull PsiElement scope) {
     final PsiElement[] occurrences = GroovyRefactoringUtil.getExpressionOccurrences(skipParentheses(expression, false), scope);
     if (occurrences == null || occurrences.length == 0) {
@@ -574,6 +586,8 @@
   public static boolean isInplace(@NotNull Editor editor, @NotNull PsiElement place) {
     final RefactoringSupportProvider supportProvider = LanguageRefactoringSupport.INSTANCE.forLanguage(place.getLanguage());
     return supportProvider != null &&
+           (editor.getUserData(InplaceRefactoring.INTRODUCE_RESTART) == null || !editor.getUserData(InplaceRefactoring.INTRODUCE_RESTART)) &&
+           editor.getUserData(AbstractInplaceIntroducer.ACTIVE_INTRODUCE) == null &&
            editor.getSettings().isVariableInplaceRenameEnabled() &&
            supportProvider.isInplaceIntroduceAvailable(place, place) &&
            !ApplicationManager.getApplication().isUnitTestMode();
@@ -743,19 +757,29 @@
     }
   }
 
-  @NotNull
+  @Nullable
   public static GrVariable resolveLocalVar(@NotNull GrIntroduceContext context) {
     final GrVariable var = context.getVar();
     if (var != null) {
       return var;
     }
 
-    final GrReferenceExpression expression = (GrReferenceExpression)context.getExpression();
-    assert expression != null;
+    return resolveLocalVar(context.getExpression());
+  }
 
-    final PsiElement resolved = expression.resolve();
-    assert resolved instanceof GrVariable;
-    return (GrVariable)resolved;
+  @Nullable
+  public static GrVariable resolveLocalVar(@Nullable GrExpression expression) {
+    if (expression instanceof GrReferenceExpression) {
+      final GrReferenceExpression ref = (GrReferenceExpression)expression;
+
+      final PsiElement resolved = ref.resolve();
+      if (GroovyRefactoringUtil.isLocalVariable(resolved)) {
+        return (GrVariable)resolved;
+      }
+      return null;
+    }
+
+    return null;
   }
 
   public static boolean hasLhs(@NotNull final PsiElement[] occurrences) {
@@ -779,141 +803,7 @@
     throw new IncorrectOperationException();
   }
 
-  @NotNull
-  public static GrExpression generateExpressionFromStringPart(final StringPartInfo stringPart, final Project project) {
-    Data data = new Data(stringPart);
-    String startQuote = data.getStartQuote();
-    TextRange range = data.getRange();
-    String literalText = data.getText();
-    String endQuote = data.getEndQuote();
-
-    final String substringLiteral = startQuote + range.substring(literalText) + endQuote;
-    return GroovyPsiElementFactory.getInstance(project).createExpressionFromText(substringLiteral);
-  }
-
-  @NotNull
-  public static GrExpression processLiteral(final String varName, final StringPartInfo stringPart, final Project project) {
-    Data data = new Data(stringPart);
-    String startQuote = data.getStartQuote();
-    TextRange range = data.getRange();
-    String literalText = data.getText();
-    String endQuote = data.getEndQuote();
-
-    String prefix = literalText.substring(0, range.getStartOffset()) ;
-    String suffix =  literalText.substring(range.getEndOffset());
-
-    StringBuilder buffer = new StringBuilder();
-    if (!prefix.equals(startQuote)) {
-      buffer.append(prefix).append(endQuote).append('+');
-    }
-    buffer.append(varName);
-    if (!suffix.equals(endQuote)) {
-      buffer.append('+').append(startQuote).append(suffix);
-    }
-
-    final GrExpression concatenation = GroovyPsiElementFactory.getInstance(project).createExpressionFromText(buffer);
-
-    final GrExpression concat = stringPart.getLiteral().replaceWithExpression(concatenation, false);
-    if (concat instanceof GrReferenceExpression) {
-      return concat;
-    }
-    else {
-      assert concat instanceof GrBinaryExpression;
-      final GrExpression left = ((GrBinaryExpression)concat).getLeftOperand();
-      if (left instanceof GrReferenceExpression) {
-        return left;
-      }
-      else {
-        assert left instanceof GrBinaryExpression;
-        final GrExpression right = ((GrBinaryExpression)left).getRightOperand();
-        assert right != null;
-        return right;
-      }
-    }
-  }
-
-  @NotNull
-  public static GrExpression cutLiteral(final StringPartInfo stringPart, final Project project) {
-    Data data = new Data(stringPart);
-    String startQuote = data.getStartQuote();
-    TextRange range = data.getRange();
-    String literalText = data.getText();
-    String endQuote = data.getEndQuote();
-
-    String prefix = literalText.substring(0, range.getStartOffset()) ;
-    String suffix =  literalText.substring(range.getEndOffset());
-    String selected = literalText.substring(range.getStartOffset(), range.getEndOffset());
-
-    StringBuilder buffer = new StringBuilder();
-    if (!prefix.equals(startQuote)) {
-      buffer.append(prefix).append(endQuote).append('+');
-    }
-    buffer.append(startQuote).append(selected).append(endQuote);
-
-    if (!suffix.equals(endQuote)) {
-      buffer.append('+').append(startQuote).append(suffix);
-    }
-
-    final GrExpression concatenation = GroovyPsiElementFactory.getInstance(project).createExpressionFromText(buffer);
-
-    final GrExpression concat = stringPart.getLiteral().replaceWithExpression(concatenation, false);
-    if (concat instanceof GrReferenceExpression) {
-      return concat;
-    }
-    else {
-      assert concat instanceof GrBinaryExpression;
-      final GrExpression left = ((GrBinaryExpression)concat).getLeftOperand();
-      if (left instanceof GrReferenceExpression) {
-        return left;
-      }
-      else {
-        assert left instanceof GrBinaryExpression;
-        final GrExpression right = ((GrBinaryExpression)left).getRightOperand();
-        assert right != null;
-        return right;
-      }
-    }
-  }
-
-
   public interface Validator extends NameValidator {
     boolean isOK(GrIntroduceDialog dialog);
   }
-
-  private static class Data {
-    private String myText;
-    private String myStartQuote;
-    private String myEndQuote;
-    private TextRange myRange;
-
-    public Data(final StringPartInfo stringPartInfo) {
-      assert stringPartInfo != null;
-
-      final GrLiteral literal = stringPartInfo.getLiteral();
-
-      myText = literal.getText();
-
-      myStartQuote = GrStringUtil.getStartQuote(myText);
-      myEndQuote = GrStringUtil.getEndQuote(myText);
-      final TextRange dataRange = new TextRange(myStartQuote.length(), myText.length() - myEndQuote.length());
-
-      myRange = stringPartInfo.getRange().intersection(dataRange);
-    }
-
-    public String getText() {
-      return myText;
-    }
-
-    public String getStartQuote() {
-      return myStartQuote;
-    }
-
-    public String getEndQuote() {
-      return myEndQuote;
-    }
-
-    public TextRange getRange() {
-      return myRange;
-    }
-  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/IntroduceOccurrencesChooser.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/IntroduceOccurrencesChooser.java
new file mode 100644
index 0000000..78cb717
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/IntroduceOccurrencesChooser.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.refactoring.introduce;
+
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.PsiElement;
+import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
+
+/**
+* Created by Max Medvedev on 29/01/14
+*/
+public class IntroduceOccurrencesChooser extends OccurrencesChooser<Object> {
+  public IntroduceOccurrencesChooser(Editor editor) {
+    super(editor);
+  }
+
+  @Override
+  protected TextRange getOccurrenceRange(Object occurrence) {
+    if (occurrence instanceof PsiElement) {
+      return ((PsiElement)occurrence).getTextRange();
+    }
+    else if (occurrence instanceof StringPartInfo) {
+      return ((StringPartInfo)occurrence).getRange();
+    }
+    else {
+      return null;
+    }
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/StringPartInfo.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/StringPartInfo.java
index de72a79..d37f5ba 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/StringPartInfo.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/StringPartInfo.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,10 +20,15 @@
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrString;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrStringInjection;
@@ -32,6 +37,8 @@
 import java.util.Collections;
 import java.util.List;
 
+import static org.jetbrains.plugins.groovy.lang.psi.util.GrStringUtil.*;
+
 /**
  * @author Max Medvedev
  */
@@ -40,30 +47,29 @@
   private final TextRange myRange;
   private final List<GrStringInjection> myInjections;
 
+  private final String myText;
+  private final String myStartQuote;
+  private final String myEndQuote;
+
   @Nullable
   public static StringPartInfo findStringPart(@NotNull PsiFile file, int startOffset, int endOffset) {
     final PsiElement start = file.findElementAt(startOffset);
     final PsiElement fin = file.findElementAt(endOffset - 1);
     if (start == null || fin == null) return null;
 
-    final PsiElement parent = PsiTreeUtil.findCommonParent(start, fin);
+    final PsiElement psi = PsiTreeUtil.findCommonParent(start, fin);
+    if (psi == null) return null;
 
-    if (parent != null && isStringLiteral(parent.getParent()) && !parent.getParent().getTextRange().equalsToRange(startOffset, endOffset)) {
-      return new StringPartInfo((GrLiteral)parent.getParent(), new TextRange(startOffset, endOffset));
+    GrLiteral literal = findLiteral(psi);
+    if (literal != null && checkSelectedRange(startOffset, endOffset, literal)) {
+      return new StringPartInfo(literal, new TextRange(startOffset, endOffset));
     }
-    if (parent instanceof GrString && !parent.getTextRange().equalsToRange(startOffset, endOffset)) {
-      return new StringPartInfo((GrLiteral)parent, new TextRange(startOffset, endOffset));
-    }
+
     return null;
   }
 
-  private static boolean isStringLiteral(final PsiElement psi) {
-    return psi instanceof GrLiteral && TokenSets.STRING_LITERAL_SET.contains(GrLiteralImpl.getLiteralType((GrLiteral)psi));
-  }
-
   public StringPartInfo(@NotNull GrLiteral literal, @NotNull final TextRange range) {
     myLiteral = literal;
-    myRange = range.shiftRight(-literal.getTextRange().getStartOffset());
 
     if (literal instanceof GrString) {
       final GrStringInjection[] injections = ((GrString)literal).getInjections();
@@ -77,6 +83,188 @@
     else {
       myInjections = Collections.emptyList();
     }
+
+    myText = myLiteral.getText();
+
+    myStartQuote = getStartQuote(myText);
+    myEndQuote = getEndQuote(myText);
+
+    TextRange dataRange = new TextRange(myStartQuote.length(), myText.length() - myEndQuote.length());
+    myRange = range.shiftRight(-literal.getTextRange().getStartOffset()).intersection(dataRange);
+  }
+
+  private static boolean checkSelectedRange(int startOffset, int endOffset, GrLiteral literal) {
+    if (isWholeLiteralContentSelected(literal, startOffset, endOffset)) {
+      return false;
+    }
+
+    if (literal instanceof GrString) {
+      if (areInjectionsCut((GrString)literal, startOffset, endOffset)) {
+        return false;
+      }
+    }
+
+    if (isEscapesCut(literal, startOffset, endOffset)) {
+      return false;
+    }
+
+    return true;
+  }
+
+  private static boolean isEscapesCut(GrLiteral literal, int startOffset, int endOffset) {
+    String rawContent = removeQuotes(literal.getText());
+    int[] offsets = new int[rawContent.length() + 1];
+
+    if (isSingleQuoteString(literal) || isDoubleQuoteString(literal)) {
+      parseStringCharacters(rawContent, new StringBuilder(), offsets);
+    }
+    else if (isSlashyString(literal)) {
+      parseRegexCharacters(rawContent, new StringBuilder(), offsets, true);
+    }
+    else if (isDollarSlashyString(literal)) {
+      parseRegexCharacters(rawContent, new StringBuilder(), offsets, false);
+    }
+
+    int contentStart = literal.getTextRange().getStartOffset() + getStartQuote(literal.getText()).length();
+
+    int relativeStart = startOffset - contentStart;
+    int relativeEnd = endOffset - contentStart;
+
+    return ArrayUtil.find(offsets, relativeStart) < 0 ||
+           ArrayUtil.find(offsets, relativeEnd) < 0;
+  }
+
+  public static boolean isWholeLiteralContentSelected(GrLiteral literal, int startOffset, int endOffset) {
+    TextRange literalRange = literal.getTextRange();
+    String literalText = literal.getText();
+    String startQuote = getStartQuote(literalText);
+    String endQuote = getEndQuote(literalText);
+
+    return literalRange.getStartOffset()                    <= startOffset && startOffset <= literalRange.getStartOffset() + startQuote.length() &&
+           literalRange.getEndOffset() - endQuote.length()  <= endOffset   && endOffset   <= literalRange.getEndOffset();
+  }
+
+  private static boolean areInjectionsCut(GrString literal, int startOffset, int endOffset) {
+    TextRange selectionRange = new TextRange(startOffset, endOffset);
+
+    GrStringInjection[] injections = literal.getInjections();
+    for (GrStringInjection injection : injections) {
+      TextRange range = injection.getTextRange();
+      if (!selectionRange.contains(range) && !range.contains(selectionRange) && range.intersects(selectionRange)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  @Nullable
+  private static GrLiteral findLiteral(@NotNull PsiElement psi) {
+    if (isStringLiteral(psi.getParent())) {
+      return (GrLiteral)psi.getParent();
+    }
+
+    if (isStringLiteral(psi.getParent().getParent())) {
+      return (GrLiteral)psi.getParent().getParent();
+    }
+
+    if (psi instanceof GrString) {
+      return (GrLiteral)psi;
+    }
+
+    return null;
+  }
+
+  private static boolean isStringLiteral(final PsiElement psi) {
+    return psi instanceof GrLiteral && TokenSets.STRING_LITERAL_SET.contains(GrLiteralImpl.getLiteralType((GrLiteral)psi)) || psi instanceof GrString;
+  }
+
+  @NotNull
+  public GrExpression replaceLiteralWithConcatenation(@Nullable String varName) {
+
+    String prefix = preparePrefix();
+    String suffix = prepareSuffix();
+
+    StringBuilder buffer = new StringBuilder();
+    boolean prefixExists = !removeQuotes(prefix).isEmpty();
+    if (prefixExists) {
+      buffer.append(prefix).append('+');
+    }
+
+    buffer.append(varName != null ? varName : prepareSelected());
+
+    boolean suffixExists = !removeQuotes(suffix).isEmpty();
+    if (suffixExists) {
+      buffer.append('+').append(suffix);
+    }
+
+    final GrExpression concatenation = GroovyPsiElementFactory.getInstance(myLiteral.getProject()).createExpressionFromText(buffer);
+
+    final GrExpression replaced = getLiteral().replaceWithExpression(concatenation, false);
+
+    try {
+      if (prefixExists && suffixExists) {
+        return ((GrBinaryExpression)((GrBinaryExpression)replaced).getLeftOperand()).getRightOperand();
+      }
+      if (!prefixExists && suffixExists) {
+        return ((GrBinaryExpression)replaced).getLeftOperand();
+      }
+      if (prefixExists && !suffixExists) {
+        return ((GrBinaryExpression)replaced).getRightOperand();
+      }
+      if (!prefixExists && !suffixExists) {
+        return replaced;
+      }
+    }
+    catch (ClassCastException c) {
+      throw new IncorrectOperationException(buffer.toString());
+    }
+
+    throw new IncorrectOperationException(buffer.toString());
+  }
+
+  private String prepareSelected() {
+    String content = myRange.substring(myLiteral.getText());
+    return prepareLiteral(content);
+  }
+
+  private String prepareSuffix() {
+    return myStartQuote + myText.substring(myRange.getEndOffset());
+  }
+
+  private String preparePrefix() {
+    String prefix = myText.substring(0, myRange.getStartOffset());
+    String content = removeQuotes(prefix);
+
+    return prepareLiteral(content);
+  }
+
+  private String prepareLiteral(String content) {
+
+    if (isSlashyString(myLiteral)) {
+      if (content.endsWith("\\")) {
+        String unescaped = unescapeSlashyString(content);
+        return prepareGString(unescaped);
+      }
+    }
+    else if (isDollarSlashyString(myLiteral)) {
+      if (content.endsWith("$")) {
+        String unescaped = unescapeDollarSlashyString(content);
+        return prepareGString(unescaped);
+      }
+    }
+
+    return myStartQuote + content + myEndQuote;
+  }
+
+  @NotNull
+  private static String prepareGString(@NotNull String content) {
+    StringBuilder buffer = new StringBuilder();
+    boolean multiline = content.contains("\n");
+    buffer.append(multiline ? TRIPLE_DOUBLE_QUOTES : DOUBLE_QUOTES);
+    escapeSymbolsForGString(content, multiline, false, buffer);
+    buffer.append(multiline ? TRIPLE_DOUBLE_QUOTES : DOUBLE_QUOTES);
+
+    return buffer.toString();
   }
 
   @NotNull
@@ -93,4 +281,9 @@
   public List<GrStringInjection> getInjections() {
     return myInjections;
   }
+
+  @NotNull
+  public GrLiteral createLiteralFromSelected() {
+    return (GrLiteral)GroovyPsiElementFactory.getInstance(myLiteral.getProject()).createExpressionFromText(prepareSelected());
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceConstantIntroducer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceConstantIntroducer.java
index df6623b..7f7ef7e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceConstantIntroducer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrInplaceConstantIntroducer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,9 +16,12 @@
 package org.jetbrains.plugins.groovy.refactoring.introduce.constant;
 
 import com.intellij.psi.*;
+import com.intellij.refactoring.JavaRefactoringSettings;
 import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
 import com.intellij.refactoring.introduceField.IntroduceConstantHandler;
 import com.intellij.ui.components.JBCheckBox;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
@@ -27,10 +30,12 @@
 import org.jetbrains.plugins.groovy.refactoring.GroovyNameSuggestionUtil;
 import org.jetbrains.plugins.groovy.refactoring.introduce.GrAbstractInplaceIntroducer;
 import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContext;
+import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase;
 import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo;
 import org.jetbrains.plugins.groovy.refactoring.introduce.field.GroovyInplaceFieldValidator;
 
 import javax.swing.*;
+import java.util.ArrayList;
 
 /**
  * Created by Max Medvedev on 8/29/13
@@ -47,13 +52,26 @@
 
     myPanel = new GrInplaceIntroduceConstantPanel();
 
-    mySuggestedNames = GroovyNameSuggestionUtil.suggestVariableNames(context.getExpression(), new GroovyInplaceFieldValidator(context),
-                                                                     true);
+    GrVariable localVar = GrIntroduceHandlerBase.resolveLocalVar(context);
+    if (localVar != null) {
+      ArrayList<String> result = ContainerUtil.newArrayList(localVar.getName());
+
+      GrExpression initializer = localVar.getInitializerGroovy();
+      if (initializer != null) {
+        ContainerUtil.addAll(result, GroovyNameSuggestionUtil.suggestVariableNames(initializer, new GroovyInplaceFieldValidator(context), true));
+      }
+      mySuggestedNames = ArrayUtil.toStringArray(result);
+    }
+    else {
+      GrExpression expression = context.getExpression();
+      assert expression != null;
+      mySuggestedNames = GroovyNameSuggestionUtil.suggestVariableNames(expression, new GroovyInplaceFieldValidator(context), true);
+    }
   }
 
   @Override
   protected String getActionName() {
-    return null;
+    return GrIntroduceConstantHandler.REFACTORING_NAME;
   }
 
   @Override
@@ -164,6 +182,34 @@
     return ((PsiField)getVariable()).getContainingClass();
   }
 
+
+  @Override
+  protected boolean performRefactoring() {
+    JavaRefactoringSettings.getInstance().INTRODUCE_CONSTANT_MOVE_TO_ANOTHER_CLASS = myPanel.isMoveToAnotherClass();
+    if (myPanel.isMoveToAnotherClass()) {
+      try {
+        myEditor.putUserData(INTRODUCE_RESTART, true);
+        myEditor.putUserData(ACTIVE_INTRODUCE, this);
+        final GrIntroduceConstantHandler constantHandler = new GrIntroduceConstantHandler();
+        final PsiLocalVariable localVariable = (PsiLocalVariable)getLocalVariable();
+        constantHandler.getContextAndInvoke(myProject, myEditor, ((GrExpression)myExpr), (GrVariable)localVariable, null);
+      }
+      finally {
+        myEditor.putUserData(INTRODUCE_RESTART, false);
+        myEditor.putUserData(ACTIVE_INTRODUCE, null);
+        releaseResources();
+        if (myLocalMarker != null) {
+          myLocalMarker.dispose();
+        }
+        if (myExprMarker != null) {
+          myExprMarker.dispose();
+        }
+      }
+      return false;
+    }
+    return super.performRefactoring();
+  }
+
   /**
    * Created by Max Medvedev on 8/29/13
    */
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantDialog.java
index 0e2acfc..954c966 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantDialog.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantDialog.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -58,6 +58,7 @@
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle;
 import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContext;
 import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceDialog;
+import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase;
 import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo;
 import org.jetbrains.plugins.groovy.refactoring.introduce.field.GrFieldNameSuggester;
 import org.jetbrains.plugins.groovy.refactoring.introduce.variable.GroovyVariableValidator;
@@ -135,7 +136,7 @@
     initializeName();
     initializeTargetClassEditor();
 
-    if (myContext.getVar() != null) {
+    if (GrIntroduceHandlerBase.resolveLocalVar(myContext) != null) {
       myReplaceAllOccurrences.setEnabled(false);
       myReplaceAllOccurrences.setSelected(true);
     }
@@ -368,7 +369,7 @@
 
       if (newClass == null &&
           Messages.showOkCancelDialog(myContext.getProject(), GroovyRefactoringBundle.message("class.does.not.exist.in.the.module"),
-                                      IntroduceConstantHandler.REFACTORING_NAME, Messages.getErrorIcon()) != OK_EXIT_CODE) {
+                                      IntroduceConstantHandler.REFACTORING_NAME, Messages.getErrorIcon()) != Messages.OK) {
         return;
       }
       myTargetClassInfo = new TargetClassInfo(targetClassName, myContext.getPlace().getContainingFile().getContainingDirectory(), module, myContext.getProject());
@@ -436,7 +437,7 @@
       final AccessToken lock = ApplicationManager.getApplication().acquireWriteActionLock(GrIntroduceConstantDialog.class);
       try {
         final GroovyFile file =
-          (GroovyFile)GroovyTemplatesFactory.createFromTemplate(psiDirectory, shortName, fileName, GroovyTemplates.GROOVY_CLASS);
+          (GroovyFile)GroovyTemplatesFactory.createFromTemplate(psiDirectory, shortName, fileName, GroovyTemplates.GROOVY_CLASS, true);
         return file.getTypeDefinitions()[0];
       }
       finally {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantHandler.java
index 9d03af8..f7320b9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,11 +15,13 @@
  */
 package org.jetbrains.plugins.groovy.refactoring.introduce.constant;
 
+import com.intellij.openapi.util.Ref;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.refactoring.HelpID;
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
+import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyRecursiveElementVisitor;
@@ -32,6 +34,8 @@
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle;
 import org.jetbrains.plugins.groovy.refactoring.introduce.*;
 
+import java.util.*;
+
 /**
  * @author Maxim.Medvedev
  */
@@ -52,7 +56,13 @@
 
   @Override
   protected void checkExpression(@NotNull GrExpression selectedExpr) {
-    selectedExpr.accept(new ConstantChecker(selectedExpr, selectedExpr));
+    GrVariable variable = GrIntroduceHandlerBase.resolveLocalVar(selectedExpr);
+    if (variable != null) {
+      checkVariable(variable);
+    }
+    else {
+      selectedExpr.accept(new ConstantChecker(selectedExpr, selectedExpr));
+    }
   }
 
   @Override
@@ -93,9 +103,39 @@
   }
 
   @Override
-  protected GrAbstractInplaceIntroducer<GrIntroduceConstantSettings> getIntroducer(@NotNull GrIntroduceContext context,
-                                                                                   OccurrencesChooser.ReplaceChoice choice) {
-    return new GrInplaceConstantIntroducer(context, choice);
+  protected GrAbstractInplaceIntroducer<GrIntroduceConstantSettings> getIntroducer(@NotNull GrIntroduceContext context, @NotNull OccurrencesChooser.ReplaceChoice choice) {
+    final Ref<GrIntroduceContext> contextRef = Ref.create(context);
+
+    if (context.getStringPart() != null) {
+      extractStringPart(contextRef);
+    }
+
+    return new GrInplaceConstantIntroducer(contextRef.get(), choice);
+  }
+
+  @NotNull
+  @Override
+  protected Map<OccurrencesChooser.ReplaceChoice, List<Object>> getOccurrenceOptions(@NotNull GrIntroduceContext context) {
+    HashMap<OccurrencesChooser.ReplaceChoice, List<Object>> map = ContainerUtil.newLinkedHashMap();
+
+    GrVariable localVar = resolveLocalVar(context);
+    if (localVar != null) {
+      map.put(OccurrencesChooser.ReplaceChoice.ALL, Arrays.<Object>asList(context.getOccurrences()));
+      return map;
+    }
+
+    if (context.getExpression() != null) {
+      map.put(OccurrencesChooser.ReplaceChoice.NO, Collections.<Object>singletonList(context.getExpression()));
+    }
+    else if (context.getStringPart() != null) {
+      map.put(OccurrencesChooser.ReplaceChoice.NO, Collections.<Object>singletonList(context.getStringPart()));
+    }
+
+    PsiElement[] occurrences = context.getOccurrences();
+    if (occurrences.length > 1) {
+      map.put(OccurrencesChooser.ReplaceChoice.ALL, Arrays.<Object>asList(occurrences));
+    }
+    return map;
   }
 
   private static class ConstantChecker extends GroovyRecursiveElementVisitor {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java
index 24e33f6..64c3e28 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/constant/GrIntroduceConstantProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
 import org.jetbrains.plugins.groovy.codeStyle.GrReferenceAdjuster;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
@@ -45,7 +46,6 @@
 import java.util.ArrayList;
 
 import static org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase.deleteLocalVar;
-import static org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase.processLiteral;
 
 /**
  * @author Max Medvedev
@@ -72,22 +72,26 @@
     final GrVariableDeclaration declaration = addDeclaration(targetClass);
     final GrField field = (GrField)declaration.getVariables()[0];
 
-    if (context.getVar() != null) {
-      deleteLocalVar(context.getVar());
-    }
+    GrVariable localVar = GrIntroduceHandlerBase.resolveLocalVar(context);
+    if (localVar != null) {
+      assert localVar.getInitializerGroovy() != null : "initializer should exist: " + localVar.getText();
+      deleteLocalVar(localVar);
 
-    if (context.getStringPart() != null) {
-      final GrExpression ref = processLiteral(field.getName(), context.getStringPart(), context.getProject());
+      if (settings.replaceAllOccurrences()) {
+        processOccurrences(field);
+      }
+      else {
+        replaceOccurrence(field, localVar.getInitializerGroovy(), isEscalateVisibility());
+      }
+    }
+    else if (context.getStringPart() != null) {
+      final GrExpression ref = context.getStringPart().replaceLiteralWithConcatenation(field.getName());
       final PsiElement element = replaceOccurrence(field, ref, isEscalateVisibility());
       updateCaretPosition(element);
     }
-    else {
+    else if (context.getExpression() != null) {
       if (settings.replaceAllOccurrences()) {
-        final PsiElement[] occurrences = context.getOccurrences();
-        GroovyRefactoringUtil.sortOccurrences(occurrences);
-        for (PsiElement occurrence : occurrences) {
-          replaceOccurrence(field, occurrence, isEscalateVisibility());
-        }
+        processOccurrences(field);
       }
       else {
         replaceOccurrence(field, context.getExpression(), isEscalateVisibility());
@@ -96,6 +100,14 @@
     return field;
   }
 
+  private void processOccurrences(GrField field) {
+    final PsiElement[] occurrences = context.getOccurrences();
+    GroovyRefactoringUtil.sortOccurrences(occurrences);
+    for (PsiElement occurrence : occurrences) {
+      replaceOccurrence(field, occurrence, isEscalateVisibility());
+    }
+  }
+
   private void updateCaretPosition(PsiElement element) {
     context.getEditor().getCaretModel().moveToOffset(element.getTextRange().getEndOffset());
     context.getEditor().getSelectionModel().removeSelection();
@@ -132,7 +144,7 @@
       String message = RefactoringBundle.message("field.exists", fieldName, oldField.getContainingClass().getQualifiedName());
       int answer = Messages
         .showYesNoDialog(context.getProject(), message, GrIntroduceConstantHandler.REFACTORING_NAME, Messages.getWarningIcon());
-      if (answer != 0) {
+      if (answer != Messages.YES) {
         return true;
       }
     }
@@ -185,7 +197,9 @@
   private static GrReferenceExpression createRefExpression(@NotNull GrField field, @NotNull PsiElement place) {
     final PsiClass containingClass = field.getContainingClass();
     assert containingClass != null;
-    final String refText = containingClass.getQualifiedName() != null ? containingClass.getQualifiedName() + "." + field.getName() : field.getName();
+    final String qname = containingClass.getQualifiedName();
+    final String fieldName = field.getName();
+    final String refText = qname != null && !qname.equals(fieldName) ? qname + "." + fieldName : fieldName;
     return GroovyPsiElementFactory.getInstance(place.getProject()).createReferenceExpressionFromText(refText, place);
   }
 
@@ -202,12 +216,17 @@
 
   @NotNull
   protected GrExpression getInitializer() {
-    final GrExpression expression = context.getExpression();
-    if (expression != null) {
+    GrVariable var = GrIntroduceHandlerBase.resolveLocalVar(context);
+    GrExpression expression = context.getExpression();
+
+    if (var != null) {
+      return var.getInitializerGroovy();
+    }
+    else if (expression != null) {
       return expression;
     }
     else {
-      return GrIntroduceHandlerBase.generateExpressionFromStringPart(context.getStringPart(), context.getProject());
+      return context.getStringPart().createLiteralFromSelected();
     }
   }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrInplaceFieldIntroducer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrInplaceFieldIntroducer.java
index 43c41f4..ebc1228 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrInplaceFieldIntroducer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrInplaceFieldIntroducer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,8 +24,11 @@
 import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
 import com.intellij.refactoring.introduceField.IntroduceFieldHandler;
 import com.intellij.ui.NonFocusableCheckBox;
+import com.intellij.util.ArrayUtil;
+import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
@@ -38,6 +41,7 @@
 import javax.swing.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
+import java.util.ArrayList;
 import java.util.EnumSet;
 
 /**
@@ -49,22 +53,48 @@
   private final GrFinalListener finalListener;
   private String[] mySuggestedNames;
   private boolean myIsStatic;
-
-  @Nullable
-  @Override
-  protected PsiElement checkLocalScope() {
-    return ((PsiField)getVariable()).getContainingClass();
-  }
+  private final GrVariable myLocalVar;
 
   public GrInplaceFieldIntroducer(GrIntroduceContext context, OccurrencesChooser.ReplaceChoice choice) {
     super(IntroduceFieldHandler.REFACTORING_NAME, choice, context);
 
     finalListener = new GrFinalListener(myEditor);
 
-    mySuggestedNames = GroovyNameSuggestionUtil.suggestVariableNames(context.getExpression(), new GroovyInplaceFieldValidator(getContext()), false);
+    myLocalVar = GrIntroduceHandlerBase.resolveLocalVar(context);
+    if (myLocalVar != null) {
+      //myLocalVariable = myLocalVar;
+      ArrayList<String> result = ContainerUtil.newArrayList(myLocalVar.getName());
+
+      GrExpression initializer = myLocalVar.getInitializerGroovy();
+      if (initializer != null) {
+        ContainerUtil.addAll(result, GroovyNameSuggestionUtil.suggestVariableNames(initializer, new GroovyInplaceFieldValidator(getContext()), false));
+      }
+      mySuggestedNames = ArrayUtil.toStringArray(result);
+    }
+    else {
+      mySuggestedNames = GroovyNameSuggestionUtil.suggestVariableNames(context.getExpression(), new GroovyInplaceFieldValidator(getContext()), false);
+    }
     myApplicablePlaces = getApplicableInitPlaces();
   }
 
+  @Nullable
+  @Override
+  protected PsiElement checkLocalScope() {
+    final GrVariable variable = getVariable();
+    if (variable instanceof PsiField) {
+      return ((PsiField)getVariable()).getContainingClass();
+    }
+    else {
+      final PsiFile file = variable.getContainingFile();
+      if (file instanceof GroovyFile) {
+        return ((GroovyFile)file).getScriptClass();
+      }
+      else {
+        return null;
+      }
+    }
+  }
+
   @Override
   protected GrVariable runRefactoring(GrIntroduceContext context, GrIntroduceFieldSettings settings, boolean processUsages) {
       GrIntroduceFieldProcessor processor = new GrIntroduceFieldProcessor(context, settings);
@@ -117,7 +147,7 @@
 
       @Override
       public boolean removeLocalVar() {
-        return context.getVar() != null;
+        return myLocalVar != null;
       }
 
       @Nullable
@@ -170,7 +200,7 @@
 
       @Override
       public boolean removeLocalVar() {
-        return false;
+        return myLocalVar != null;
       }
 
       @Nullable
@@ -224,7 +254,13 @@
   private EnumSet<GrIntroduceFieldSettings.Init> getApplicableInitPlaces() {
     GrIntroduceContext context = getContext();
     PsiElement[] occurrences = getOccurrences();
-    EnumSet<GrIntroduceFieldSettings.Init> result = EnumSet.of(GrIntroduceFieldSettings.Init.FIELD_DECLARATION);
+    EnumSet<GrIntroduceFieldSettings.Init> result = EnumSet.noneOf(GrIntroduceFieldSettings.Init.class);
+
+    if (context.getExpression() != null ||
+        context.getVar() != null && context.getVar().getInitializerGroovy() != null ||
+        context.getStringPart() != null) {
+      result.add(GrIntroduceFieldSettings.Init.FIELD_DECLARATION);
+    }
 
     if (!(context.getScope() instanceof GroovyScriptClass || context.getScope() instanceof GroovyFileBase)) {
       result.add(GrIntroduceFieldSettings.Init.CONSTRUCTOR);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldDialog.java
index 48bb596..631b25e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldDialog.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldDialog.java
@@ -17,6 +17,7 @@
 
 import com.intellij.codeInsight.TestFrameworks;
 import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiTreeUtil;
@@ -463,7 +464,7 @@
     final String name = getName();
     String message = RefactoringBundle.message("field.exists", name, clazz.getQualifiedName());
     if (clazz.findFieldByName(name, true) != null &&
-        showYesNoDialog(myContext.getProject(), message, REFACTORING_NAME, getWarningIcon()) != 0) {
+        showYesNoDialog(myContext.getProject(), message, REFACTORING_NAME, getWarningIcon()) != Messages.YES) {
       return;
     }
     super.doOKAction();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldHandler.java
index f100448..849cac3 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldProcessor.java
index 50f07d5..bd57810 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.ArrayUtil;
+import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -52,6 +53,7 @@
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
 import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContext;
 import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase;
+import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -65,8 +67,9 @@
 
   private final GrIntroduceContext myContext;
   private final GrIntroduceFieldSettings mySettings;
-  private GrExpression myInitializer;
-  private GrVariable myLocalVariable;
+
+  @Nullable private GrExpression myInitializer;
+  @Nullable private GrVariable myLocalVariable;
 
   public GrIntroduceFieldProcessor(@NotNull GrIntroduceContext context,
                                    @NotNull GrIntroduceFieldSettings settings) {
@@ -85,6 +88,7 @@
 
     if (mySettings.removeLocalVar()) {
       myLocalVariable = GrIntroduceHandlerBase.resolveLocalVar(myContext);
+      assert myLocalVariable != null : myContext.getExpression() + ", " + myContext.getVar() + ", " + myContext.getStringPart();
     }
     myInitializer = (GrExpression)getInitializer().copy();
 
@@ -117,31 +121,40 @@
   @NotNull
   private List<PsiElement> processOccurrences(@NotNull PsiClass targetClass, @NotNull GrVariable field) {
     if (myContext.getStringPart() != null) {
-      final GrExpression expr = GrIntroduceHandlerBase.processLiteral(field.getName(), myContext.getStringPart(), myContext.getProject());
+      final GrExpression expr = myContext.getStringPart().replaceLiteralWithConcatenation(field.getName());
       final PsiElement occurrence = replaceOccurrence(field, expr, targetClass);
       updateCaretPosition(occurrence);
       return Collections.singletonList(occurrence);
     }
-    else {
-      if (mySettings.replaceAllOccurrences()) {
-        GroovyRefactoringUtil.sortOccurrences(myContext.getOccurrences());
-        ArrayList<PsiElement> result = ContainerUtil.newArrayList();
-        for (PsiElement occurrence : myContext.getOccurrences()) {
-          result.add(replaceOccurrence(field, occurrence, targetClass));
-        }
-        return result;
+
+    if (mySettings.replaceAllOccurrences()) {
+      GroovyRefactoringUtil.sortOccurrences(myContext.getOccurrences());
+      ArrayList<PsiElement> result = ContainerUtil.newArrayList();
+      for (PsiElement occurrence : myContext.getOccurrences()) {
+        result.add(replaceOccurrence(field, occurrence, targetClass));
+      }
+      return result;
+    }
+
+    GrVariable var = myContext.getVar();
+    if (var != null) {
+      GrExpression initializer = var.getInitializerGroovy();
+      if (initializer != null) {
+        return Collections.singletonList(replaceOccurrence(field, initializer, targetClass));
       }
       else {
-        final GrExpression expression = myContext.getExpression();
-        assert expression != null;
-        if (PsiUtil.isExpressionStatement(expression)) {
-          return Collections.<PsiElement>singletonList(expression);
-        }
-        else {
-          return Collections.singletonList(replaceOccurrence(field, expression, targetClass));
-        }
+        return Collections.emptyList();
       }
     }
+
+    final GrExpression expression = myContext.getExpression();
+    assert expression != null;
+    if (PsiUtil.isExpressionStatement(expression)) {
+      return Collections.<PsiElement>singletonList(expression);
+    }
+    else {
+      return Collections.singletonList(replaceOccurrence(field, expression, targetClass));
+    }
   }
 
   private void updateCaretPosition(@NotNull PsiElement occurrence) {
@@ -282,9 +295,10 @@
                                   @Nullable GrStatement anchor,
                                   @NotNull GrStatementOwner defaultContainer,
                                   @Nullable PsiElement occurrenceToDelete) {
-    final GrExpression initializer = myInitializer;
+    if (myInitializer == null) return;
+
     GrAssignmentExpression init = (GrAssignmentExpression)GroovyPsiElementFactory.getInstance(myContext.getProject())
-      .createExpressionFromText(mySettings.getName() + " = " + initializer.getText());
+      .createExpressionFromText(mySettings.getName() + " = " + myInitializer.getText());
 
     GrStatementOwner block;
     if (anchor != null) {
@@ -304,12 +318,10 @@
     }
   }
 
-  @NotNull
+  @Nullable
   private GrExpression extractVarInitializer() {
     assert myLocalVariable != null;
-    GrExpression initializer = myLocalVariable.getInitializerGroovy();
-    LOG.assertTrue(initializer != null);
-    return initializer;
+    return myLocalVariable.getInitializerGroovy();
   }
 
   @Nullable
@@ -386,19 +398,21 @@
     }
   }
 
-  @NotNull
+  @Nullable
   protected GrExpression getInitializer() {
     if (mySettings.removeLocalVar()) {
       return extractVarInitializer();
     }
 
-
-    final GrExpression expression = myContext.getExpression();
+    GrExpression expression = myContext.getExpression();
+    StringPartInfo stringPart = myContext.getStringPart();
     if (expression != null) {
       return expression;
     }
+    else if (stringPart != null) {
+      return stringPart.createLiteralFromSelected();
+    }
 
-
-    return GrIntroduceHandlerBase.generateExpressionFromStringPart(myContext.getStringPart(), myContext.getProject());
+    throw new IncorrectOperationException("cannot be here!");
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrExpressionWrapper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrExpressionWrapper.java
index 4bb4ee85..99ea5a7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrExpressionWrapper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrExpressionWrapper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@
   private final RangeMarker myMarker;
   private final PsiFile myFile;
 
-  public GrExpressionWrapper(GrExpression expression) {
+  public GrExpressionWrapper(@NotNull GrExpression expression) {
     assert expression.isValid();
 
     myExpression = expression;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrInplaceParameterIntroducer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrInplaceParameterIntroducer.java
index 759b788..5a841f9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrInplaceParameterIntroducer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrInplaceParameterIntroducer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,132 +18,85 @@
 import com.intellij.codeInsight.template.TextResult;
 import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
 import com.intellij.codeInsight.template.impl.TemplateState;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.EditorFactory;
-import com.intellij.openapi.editor.EditorSettings;
-import com.intellij.openapi.editor.RangeMarker;
-import com.intellij.openapi.editor.colors.EditorColors;
 import com.intellij.openapi.editor.event.DocumentAdapter;
 import com.intellij.openapi.editor.event.DocumentEvent;
-import com.intellij.openapi.editor.ex.EditorEx;
 import com.intellij.openapi.editor.impl.DocumentMarkupModel;
 import com.intellij.openapi.editor.markup.EffectType;
 import com.intellij.openapi.editor.markup.HighlighterTargetArea;
 import com.intellij.openapi.editor.markup.MarkupModel;
 import com.intellij.openapi.editor.markup.TextAttributes;
-import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiMethod;
 import com.intellij.psi.PsiParameter;
-import com.intellij.psi.PsiVariable;
+import com.intellij.psi.PsiType;
 import com.intellij.refactoring.IntroduceParameterRefactoring;
+import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
 import com.intellij.refactoring.rename.inplace.InplaceRefactoring;
-import com.intellij.ui.DottedBorder;
 import com.intellij.ui.JBColor;
 import com.intellij.ui.components.JBCheckBox;
+import com.intellij.usageView.UsageInfo;
 import com.intellij.util.ArrayUtil;
 import gnu.trove.TIntArrayList;
-import gnu.trove.TObjectIntHashMap;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.GroovyFileType;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrParametersOwner;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
-import org.jetbrains.plugins.groovy.refactoring.introduce.GrInplaceIntroducer;
+import org.jetbrains.plugins.groovy.refactoring.introduce.GrAbstractInplaceIntroducer;
 import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContext;
+import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase;
 
 import javax.swing.*;
 import javax.swing.border.EmptyBorder;
-import javax.swing.border.LineBorder;
 import java.awt.*;
 import java.util.ArrayList;
 import java.util.LinkedHashSet;
 import java.util.List;
 
+import static org.jetbrains.plugins.groovy.refactoring.introduce.parameter.GroovyIntroduceParameterUtil.findParametersToRemove;
+
 /**
  * Created by Max Medvedev on 9/1/13
  */
-public class GrInplaceParameterIntroducer extends GrInplaceIntroducer {
-  private final JPanel myPanel;
-  private EditorEx myPreview;
+public class GrInplaceParameterIntroducer extends GrAbstractInplaceIntroducer<GrIntroduceParameterSettings> {
+  private final IntroduceParameterInfo myInfo;
+  private final TIntArrayList myParametersToRemove;
 
-  private JComponent myPreviewComponent;
   private JBCheckBox myDelegateCB;
-  private GrIntroduceParameterSettings mySettings;
 
-  private final GrExpressionWrapper myExpr;
+  private LinkedHashSet<String> mySuggestedNames;
 
-  public GrInplaceParameterIntroducer(@NotNull GrVariable elementToRename,
-                                      @NotNull Editor editor,
-                                      @NotNull Project project,
-                                      @NotNull String title,
-                                      @NotNull List<RangeMarker> occurrences,
-                                      @Nullable PsiElement elementToIntroduce,
-                                      GrIntroduceParameterSettings settings,
-                                      GrExpressionWrapper expr) {
-    super(elementToRename, editor, project, title, occurrences, elementToIntroduce);
+  public GrInplaceParameterIntroducer(IntroduceParameterInfo info, GrIntroduceContext context, OccurrencesChooser.ReplaceChoice choice) {
+    super(GrIntroduceParameterHandler.REFACTORING_NAME, choice, context);
+    myInfo = info;
 
-    mySettings = settings;
+    GrVariable localVar = GrIntroduceHandlerBase.resolveLocalVar(context);
+    mySuggestedNames = GroovyIntroduceParameterUtil.suggestNames(localVar, context.getExpression(), context.getStringPart(), info.getToReplaceIn(), context.getProject());
 
-    initPreview(project);
-
-    myDelegateCB = new JBCheckBox("Delegate via overloading method");
-    myDelegateCB.setMnemonic('l');
-    myDelegateCB.setFocusable(false);
-
-    myPanel = new JPanel(new BorderLayout());
-    myPanel.add(myPreviewComponent, BorderLayout.CENTER);
-    myPanel.add(myDelegateCB, BorderLayout.SOUTH);
-
-    myExpr = expr;
-
+    myParametersToRemove = new TIntArrayList(findParametersToRemove(info).getValues());
   }
 
-  protected final void setPreviewText(final String text) {
-    if (myPreview == null) return; //already disposed
-    ApplicationManager.getApplication().runWriteAction(new Runnable() {
-      @Override
-      public void run() {
-        myPreview.getDocument().replaceString(0, myPreview.getDocument().getTextLength(), text);
-      }
-    });
+  @Override
+  protected String getActionName() {
+    return GrIntroduceParameterHandler.REFACTORING_NAME;
   }
 
+  @Override
+  protected String[] suggestNames(boolean replaceAll, @Nullable GrVariable variable) {
+    return ArrayUtil.toStringArray(mySuggestedNames);
+  }
 
-  private void initPreview(Project project) {
-    myPreview = (EditorEx)EditorFactory.getInstance()
-      .createEditor(EditorFactory.getInstance().createDocument(""), project, GroovyFileType.GROOVY_FILE_TYPE, true);
-    myPreview.setOneLineMode(true);
-    final EditorSettings settings = myPreview.getSettings();
-    settings.setAdditionalLinesCount(0);
-    settings.setAdditionalColumnsCount(1);
-    settings.setRightMarginShown(false);
-    settings.setFoldingOutlineShown(false);
-    settings.setLineNumbersShown(false);
-    settings.setLineMarkerAreaShown(false);
-    settings.setIndentGuidesShown(false);
-    settings.setVirtualSpace(false);
-    myPreview.setHorizontalScrollbarVisible(false);
-    myPreview.setVerticalScrollbarVisible(false);
-    myPreview.setCaretEnabled(false);
-    settings.setLineCursorWidth(1);
+  @Override
+  protected JComponent getComponent() {
 
-    final Color bg = myPreview.getColorsScheme().getColor(EditorColors.CARET_ROW_COLOR);
-    myPreview.setBackgroundColor(bg);
-    myPreview.setBorder(BorderFactory.createCompoundBorder(new DottedBorder(JBColor.GRAY), new LineBorder(bg, 2)));
-
-    myPreviewComponent = new JPanel(new BorderLayout());
-    myPreviewComponent.add(myPreview.getComponent(), BorderLayout.CENTER);
-    myPreviewComponent.setBorder(new EmptyBorder(2, 2, 6, 2));
+    JPanel previewPanel = new JPanel(new BorderLayout());
+    previewPanel.add(getPreviewEditor().getComponent(), BorderLayout.CENTER);
+    previewPanel.setBorder(new EmptyBorder(2, 2, 6, 2));
 
     DocumentAdapter documentAdapter = new DocumentAdapter() {
       @Override
       public void documentChanged(DocumentEvent e) {
-        if (myPreview == null) return;
         final TemplateState templateState = TemplateManagerImpl.getTemplateState(myEditor);
         if (templateState != null) {
           final TextResult value = templateState.getVariableValue(InplaceRefactoring.PRIMARY_VARIABLE_NAME);
@@ -155,59 +108,29 @@
     };
     myEditor.getDocument().addDocumentListener(documentAdapter);
 
-    updateTitle(getVariable(), getVariable().getName());
+    myDelegateCB = new JBCheckBox("Delegate via overloading method");
+    myDelegateCB.setMnemonic('l');
+    myDelegateCB.setFocusable(false);
+
+    JPanel panel = new JPanel(new BorderLayout());
+    panel.add(previewPanel, BorderLayout.CENTER);
+    panel.add(myDelegateCB, BorderLayout.SOUTH);
+    return panel;
   }
 
   @Override
-  public LinkedHashSet<String> suggestNames(GrIntroduceContext context) {
-    return GroovyIntroduceParameterUtil.suggestNames(null, myExpr.getExpression(), null, (GrParametersOwner)context.getScope(), context.getProject());
+  protected void saveSettings(@NotNull GrVariable variable) {
+
   }
 
-  static LinkedHashSet<String> suggestNames(GrIntroduceContext context, GrParametersOwner scope) {
-    return GroovyIntroduceParameterUtil.suggestNames(context.getVar(), context.getExpression(), context.getStringPart(), scope, context.getProject());
-  }
-
-  @Override
-  protected void moveOffsetAfter(boolean success) {
-    if (success) {
-      final GrVariable parameter = getVariable();
-      GrIntroduceParameterSettings settings = generateSettings((GrParameter)parameter, mySettings, myDelegateCB.isSelected());
-      assert parameter != null;
-      parameter.delete();
-      GrIntroduceParameterProcessor processor = new GrIntroduceParameterProcessor(settings, myExpr);
-      processor.run();
-    }
-
-
-    super.moveOffsetAfter(success);
-  }
-
-  public GrIntroduceParameterSettings generateSettings(GrParameter parameter, IntroduceParameterInfo info, boolean delegate) {
-
-    TObjectIntHashMap<GrParameter> toRemove = GroovyIntroduceParameterUtil.findParametersToRemove(info);
-    TIntArrayList removeList = new TIntArrayList(delegate ? ArrayUtil.EMPTY_INT_ARRAY: toRemove.getValues());
-
-    GrExpression _expr = myExpr.getExpression();
-    GrVariable _var = GroovyIntroduceParameterUtil.findVar(info);
-    return new GrIntroduceExpressionSettingsImpl(info, parameter.getName(), false, removeList, myDelegateCB.isSelected(),
-                                                 IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, _expr, _var,
-                                                 parameter.getType(), false);
-  }
-
-  @Override
-  protected JComponent getComponent() {
-    updateTitle(getVariable());
-    return myPanel;
-  }
-
-
-  protected void updateTitle(@Nullable PsiVariable variable) {
+  protected void updateTitle(@Nullable GrVariable variable) {
     if (variable == null) return;
     updateTitle(variable, variable.getName());
   }
 
-  protected void updateTitle(@Nullable final PsiVariable variable, final String value) {
-    final PsiElement declarationScope = variable != null ? ((PsiParameter)variable).getDeclarationScope() : null;
+  protected void updateTitle(@Nullable GrVariable variable, String value) {
+    if (getPreviewEditor() == null || variable == null) return;
+    final PsiElement declarationScope = ((PsiParameter)variable).getDeclarationScope();
     if (declarationScope instanceof PsiMethod) {
       final PsiMethod psiMethod = (PsiMethod)declarationScope;
       final StringBuilder buf = new StringBuilder();
@@ -233,15 +156,17 @@
         if (variable == parameter) {
           addedRange = new TextRange(startOffset, endOffset);
         }
-        else if (mySettings.parametersToRemove().contains(i)) {
+        else if (myParametersToRemove.contains(i)) {
           ranges2Remove.add(new TextRange(startOffset, endOffset));
         }
         i++;
       }
 
+      assert addedRange != null;
+
       buf.append(")");
       setPreviewText(buf.toString());
-      final MarkupModel markupModel = DocumentMarkupModel.forDocument(myPreview.getDocument(), myProject, true);
+      final MarkupModel markupModel = DocumentMarkupModel.forDocument(getPreviewEditor().getDocument(), myProject, true);
       markupModel.removeAllHighlighters();
       for (TextRange textRange : ranges2Remove) {
         markupModel.addRangeHighlighter(textRange.getStartOffset(), textRange.getEndOffset(), 0, getTestAttributesForRemoval(), HighlighterTargetArea.EXACT_RANGE);
@@ -261,7 +186,61 @@
   private static TextAttributes getTestAttributesForRemoval() {
     final TextAttributes textAttributes = new TextAttributes();
     textAttributes.setEffectType(EffectType.STRIKEOUT);
-    textAttributes.setEffectColor(Color.BLACK);
+    textAttributes.setEffectColor(JBColor.BLACK);
     return textAttributes;
   }
+
+  @Override
+  protected GrVariable runRefactoring(GrIntroduceContext context, GrIntroduceParameterSettings settings, boolean processUsages) {
+    GrExpressionWrapper wrapper = createExpressionWrapper(context);
+    if (processUsages) {
+      GrIntroduceExpressionSettingsImpl patchedSettings =
+        new GrIntroduceExpressionSettingsImpl(settings, settings.getName(), settings.declareFinal(), settings.parametersToRemove(),
+                                              settings.generateDelegate(), settings.replaceFieldsWithGetters(), context.getExpression(),
+                                              context.getVar(), settings.getSelectedType(), context.getVar() != null || settings.replaceAllOccurrences(),
+                                              context.getVar() != null, settings.isForceReturn());
+      GrIntroduceParameterProcessor processor = new GrIntroduceParameterProcessor(patchedSettings, wrapper);
+      processor.run();
+    }
+    else {
+      GrIntroduceParameterProcessor processor = new GrIntroduceParameterProcessor(settings, wrapper);
+      processor.performRefactoring(UsageInfo.EMPTY_ARRAY);
+    }
+    GrParametersOwner owner = settings.getToReplaceIn();
+    return ArrayUtil.getLastElement(owner.getParameters());
+  }
+
+  @NotNull
+  private static GrExpressionWrapper createExpressionWrapper(@NotNull GrIntroduceContext context) {
+    GrExpression expression = context.getExpression();
+    GrVariable var = context.getVar();
+    assert expression != null || var != null ;
+
+    GrExpression initializer = expression != null ? expression : var.getInitializerGroovy();
+    return new GrExpressionWrapper(initializer);
+  }
+
+  @Nullable
+  @Override
+  protected GrIntroduceParameterSettings getInitialSettingsForInplace(@NotNull GrIntroduceContext context,
+                                                                      @NotNull OccurrencesChooser.ReplaceChoice choice,
+                                                                      String[] names) {
+    GrExpression expression = context.getExpression();
+    GrVariable var = context.getVar();
+    PsiType type = var != null ? var.getDeclaredType() :
+                   expression != null ? expression.getType() :
+                   null;
+
+    return new GrIntroduceExpressionSettingsImpl(myInfo, names[0], false, new TIntArrayList(), false,
+                                                 IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, expression,
+                                                 var, type, false, false, false);
+
+  }
+
+  @Override
+  protected GrIntroduceParameterSettings getSettings() {
+    return new GrIntroduceExpressionSettingsImpl(myInfo, getInputName(), false, myParametersToRemove, myDelegateCB.isSelected(),
+                                                 IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, null,
+                                                 null, getSelectedType(), isReplaceAllOccurrences(), false, false);
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceClosureParameterProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceClosureParameterProcessor.java
index babc957..84389a6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceClosureParameterProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceClosureParameterProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -49,7 +49,6 @@
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.GroovyFileType;
 import org.jetbrains.plugins.groovy.codeInspection.utils.ControlFlowUtils;
-import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
 import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
 import org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature;
@@ -71,7 +70,6 @@
 import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle;
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringUtil;
-import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase;
 import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo;
 import org.jetbrains.plugins.groovy.refactoring.introduce.parameter.java2groovy.FieldConflictsResolver;
 import org.jetbrains.plugins.groovy.refactoring.introduce.parameter.java2groovy.OldReferencesResolver;
@@ -94,7 +92,7 @@
   private GrExpressionWrapper myParameterInitializer;
   private GroovyPsiElementFactory myFactory = GroovyPsiElementFactory.getInstance(myProject);
 
-  public GrIntroduceClosureParameterProcessor(GrIntroduceParameterSettings settings) {
+  public GrIntroduceClosureParameterProcessor(@NotNull GrIntroduceParameterSettings settings) {
     super(settings.getProject(), null);
     mySettings = settings;
 
@@ -103,7 +101,7 @@
 
     final StringPartInfo info = settings.getStringPartInfo();
     final GrExpression expression = info != null ?
-                                    GrIntroduceHandlerBase.generateExpressionFromStringPart(info, settings.getProject()) :
+                                    info.createLiteralFromSelected() :
                                     mySettings.getExpression();
     myParameterInitializer = new GrExpressionWrapper(expression);
   }
@@ -178,7 +176,7 @@
     if (!mySettings.generateDelegate() && toSearchFor != null) {
       Collection<PsiReference> refs;
       if (toSearchFor instanceof GrField) {
-        refs = ReferencesSearch.search(toSearchFor, toSearchFor.getResolveScope()).findAll();
+        refs = ReferencesSearch.search(toSearchFor).findAll();
         final GrAccessorMethod[] getters = ((GrField)toSearchFor).getGetters();
         for (GrAccessorMethod getter : getters) {
           refs.addAll(MethodReferencesSearch.search(getter, getter.getResolveScope(), true).findAll());
@@ -188,7 +186,7 @@
         refs = findUsagesForLocal(toReplaceIn, ((GrVariable)toSearchFor));
       }
       else {
-        refs = ReferencesSearch.search(toSearchFor, toSearchFor.getResolveScope()).findAll();
+        refs = ReferencesSearch.search(toSearchFor).findAll();
       }
 
       for (PsiReference ref1 : refs) {
@@ -316,7 +314,7 @@
 
     final StringPartInfo info = settings.getStringPartInfo();
     if (info != null) {
-      final GrExpression expr = GrIntroduceHandlerBase.processLiteral(settings.getName(), info, settings.getProject());
+      final GrExpression expr = info.replaceLiteralWithConcatenation(settings.getName());
       final Editor editor = PsiUtilBase.findEditor(expr);
       if (editor != null) {
         editor.getSelectionModel().removeSelection();
@@ -364,7 +362,7 @@
     if (block.getArrow() == null) {
       final PsiElement arrow = block.addAfter(factory.createClosureFromText("{->}").getArrow().copy(), parameterList);
       final PsiElement child = block.getFirstChild().getNextSibling();
-      if (TokenSets.WHITE_SPACES_SET.contains(child.getNode().getElementType())) {
+      if (PsiImplUtil.isWhiteSpaceOrNls(child)) {
         final String text = child.getText();
         child.delete();
         block.addAfter(factory.createLineTerminator(text), arrow);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceExpressionSettingsImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceExpressionSettingsImpl.java
index aafce74..3113473 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceExpressionSettingsImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceExpressionSettingsImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -31,21 +31,27 @@
   private final GrExpression myExpr;
   private final GrVariable myVar;
   private final PsiType mySelectedType;
+  private final boolean myRemoveLocalVar;
 
   public GrIntroduceExpressionSettingsImpl(IntroduceParameterInfo info,
                                            String name,
                                            boolean declareFinal,
                                            TIntArrayList toRemove,
                                            boolean generateDelegate,
-                                           @MagicConstant(intValues = {REPLACE_FIELDS_WITH_GETTERS_ALL, REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE, REPLACE_FIELDS_WITH_GETTERS_NONE}) int replaceFieldsWithGetters,
+                                           @MagicConstant(
+                                             intValues = {REPLACE_FIELDS_WITH_GETTERS_ALL, REPLACE_FIELDS_WITH_GETTERS_INACCESSIBLE,
+                                               REPLACE_FIELDS_WITH_GETTERS_NONE}) int replaceFieldsWithGetters,
                                            GrExpression expr,
                                            GrVariable var,
                                            PsiType selectedType,
+                                           boolean replaceAllOccurrences,
+                                           boolean removeLocalVar,
                                            boolean forceReturn) {
-    super(info, name, declareFinal, toRemove, generateDelegate, replaceFieldsWithGetters, forceReturn, false);
+    super(info, name, declareFinal, toRemove, generateDelegate, replaceFieldsWithGetters, forceReturn, replaceAllOccurrences, false);
     myExpr = expr;
     myVar = var;
     mySelectedType = selectedType;
+    myRemoveLocalVar = removeLocalVar;
   }
 
   @Override
@@ -64,4 +70,8 @@
   }
 
 
+  @Override
+  public boolean removeLocalVariable() {
+    return myRemoveLocalVar;
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterDialog.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterDialog.java
index 0ee6ba2..bd63f95 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterDialog.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterDialog.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -75,6 +75,7 @@
 import java.util.List;
 
 import static com.intellij.refactoring.IntroduceParameterRefactoring.*;
+import static org.jetbrains.plugins.groovy.refactoring.introduce.parameter.GroovyIntroduceParameterUtil.*;
 
 public class GrIntroduceParameterDialog extends DialogWrapper {
   private GrTypeComboBox myTypeComboBox;
@@ -100,9 +101,11 @@
     super(info.getProject(), true);
     myInfo = info;
     myProject = info.getProject();
-    myCanIntroduceSimpleParameter = GroovyIntroduceParameterUtil.findExpr(myInfo) != null || GroovyIntroduceParameterUtil.findVar(myInfo) != null || findStringPart() != null;
+    myCanIntroduceSimpleParameter = findExpr(myInfo) != null ||
+                                    findVar(myInfo) != null ||
+                                    findStringPart() != null;
 
-    TObjectIntHashMap<GrParameter> parametersToRemove = GroovyIntroduceParameterUtil.findParametersToRemove(info);
+    TObjectIntHashMap<GrParameter> parametersToRemove = findParametersToRemove(info);
     toRemoveCBs = new TObjectIntHashMap<JCheckBox>(parametersToRemove.size());
     for (Object p : parametersToRemove.keys()) {
       JCheckBox cb = new JCheckBox(GroovyRefactoringBundle.message("remove.parameter.0.no.longer.used", ((GrParameter)p).getName()));
@@ -274,7 +277,7 @@
     c.nextLine().next().weightx(0).fillCellNone();
     namePanel.add(typeLabel, c);
 
-    myTypeComboBox = createTypeComboBox(GroovyIntroduceParameterUtil.findVar(myInfo), GroovyIntroduceParameterUtil.findExpr(myInfo), findStringPart());
+    myTypeComboBox = createTypeComboBox(findVar(myInfo), findExpr(myInfo), findStringPart());
     c.next().weightx(1).fillCellHorizontally();
     namePanel.add(myTypeComboBox, c);
     typeLabel.setLabelFor(myTypeComboBox);
@@ -283,7 +286,7 @@
     c.nextLine().next().weightx(0).fillCellNone();
     namePanel.add(nameLabel, c);
 
-    myNameSuggestionsField = createNameField(GroovyIntroduceParameterUtil.findVar(myInfo));
+    myNameSuggestionsField = createNameField(findVar(myInfo));
     c.next().weightx(1).fillCellHorizontally();
     namePanel.add(myNameSuggestionsField, c);
     nameLabel.setLabelFor(myNameSuggestionsField);
@@ -335,7 +338,7 @@
   @Nullable
   private PsiType inferClosureReturnType() {
     final ExtractClosureHelperImpl mockHelper =
-      new ExtractClosureHelperImpl(myInfo, "__test___n_", false, new TIntArrayList(), false, 0, false, false);
+      new ExtractClosureHelperImpl(myInfo, "__test___n_", false, new TIntArrayList(), false, 0, false, false, false);
     final PsiType returnType;
     final AccessToken token = WriteAction.start();
     try {
@@ -358,7 +361,7 @@
   }
 
   private void initReplaceFieldsWithGetters(JavaRefactoringSettings settings) {
-    final PsiField[] usedFields = GroovyIntroduceParameterUtil.findUsedFieldsWithGetters(myInfo.getStatements(), getContainingClass());
+    final PsiField[] usedFields = findUsedFieldsWithGetters(myInfo.getStatements(), getContainingClass());
     myGetterPanel.setVisible(usedFields.length > 0);
     switch (settings.INTRODUCE_PARAMETER_REPLACE_FIELDS_WITH_GETTERS) {
       case REPLACE_FIELDS_WITH_GETTERS_ALL:
@@ -452,8 +455,8 @@
 
     final GrParametersOwner toReplaceIn = myInfo.getToReplaceIn();
 
-    final GrExpression expr = GroovyIntroduceParameterUtil.findExpr(myInfo);
-    final GrVariable var = GroovyIntroduceParameterUtil.findVar(myInfo);
+    final GrExpression expr = findExpr(myInfo);
+    final GrVariable var = findVar(myInfo);
     final StringPartInfo stringPart = findStringPart();
 
     if (myTypeComboBox.isClosureSelected() || expr == null && var == null && stringPart == null) {
@@ -464,6 +467,7 @@
                                                                            myDelegateViaOverloadingMethodCheckBox.isSelected(),
                                                                            getReplaceFieldsWithGetter(),
                                                                            myForceReturnCheckBox.isSelected(),
+                                                                           false,
                                                                            myTypeComboBox.getSelectedType() == null);
       if (toReplaceIn instanceof GrMethod) {
         invokeRefactoring(new ExtractClosureFromMethodProcessor(settings));
@@ -483,7 +487,7 @@
                                                                                     expr,
                                                                                     var,
                                                                                     myTypeComboBox.getSelectedType(),
-                                                                                    myForceReturnCheckBox.isSelected());
+                                                                                    var != null, true, myForceReturnCheckBox.isSelected());
       if (toReplaceIn instanceof GrMethod) {
         invokeRefactoring(new GrIntroduceParameterProcessor(settings));
       }
@@ -521,8 +525,8 @@
 
   @NotNull
   public LinkedHashSet<String> suggestNames() {
-    GrVariable var = GroovyIntroduceParameterUtil.findVar(myInfo);
-    GrExpression expr = GroovyIntroduceParameterUtil.findExpr(myInfo);
+    GrVariable var = findVar(myInfo);
+    GrExpression expr = findExpr(myInfo);
     StringPartInfo stringPart = findStringPart();
 
     return GroovyIntroduceParameterUtil.suggestNames(var, expr, stringPart, myInfo.getToReplaceIn(), myProject);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterHandler.java
index 8392482..9f1a984 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,19 +18,16 @@
 import com.intellij.ide.util.SuperMethodWarningUtil;
 import com.intellij.openapi.actionSystem.DataContext;
 import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.command.CommandProcessor;
-import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.editor.RangeMarker;
 import com.intellij.openapi.editor.SelectionModel;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.popup.JBPopup;
-import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.Pass;
 import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiMethod;
 import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.refactoring.IntroduceParameterRefactoring;
 import com.intellij.refactoring.IntroduceTargetChooser;
 import com.intellij.refactoring.RefactoringActionHandler;
 import com.intellij.refactoring.RefactoringBundle;
@@ -38,38 +35,31 @@
 import com.intellij.refactoring.util.CommonRefactoringUtil;
 import com.intellij.util.Function;
 import com.intellij.util.PairFunction;
-import com.intellij.util.containers.ContainerUtil;
-import gnu.trove.TIntArrayList;
-import gnu.trove.TObjectIntHashMap;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrParametersOwner;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
 import org.jetbrains.plugins.groovy.refactoring.GrRefactoringError;
 import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle;
 import org.jetbrains.plugins.groovy.refactoring.extract.GroovyExtractChooser;
 import org.jetbrains.plugins.groovy.refactoring.extract.InitialInfo;
-import org.jetbrains.plugins.groovy.refactoring.introduce.GrInplaceIntroducer;
 import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContext;
 import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase;
+import org.jetbrains.plugins.groovy.refactoring.introduce.IntroduceOccurrencesChooser;
 import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo;
-import org.jetbrains.plugins.groovy.refactoring.introduce.parameter.java2groovy.GroovyIntroduceParameterMethodUsagesProcessor;
 import org.jetbrains.plugins.groovy.refactoring.introduce.variable.GrIntroduceVariableHandler;
 import org.jetbrains.plugins.groovy.refactoring.ui.MethodOrClosureScopeChooser;
 
 import java.util.ArrayList;
-import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 
 import static org.jetbrains.plugins.groovy.refactoring.HelpID.GROOVY_INTRODUCE_PARAMETER;
-import static org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase.createRange;
+import static org.jetbrains.plugins.groovy.refactoring.introduce.parameter.GroovyIntroduceParameterUtil.findExpr;
+import static org.jetbrains.plugins.groovy.refactoring.introduce.parameter.GroovyIntroduceParameterUtil.findVar;
 
 /**
  * @author Maxim.Medvedev
@@ -78,21 +68,14 @@
   static final String REFACTORING_NAME = RefactoringBundle.message("introduce.parameter.title");
   private JBPopup myEnclosingMethodsPopup;
 
-  public void invoke(final @NotNull Project project, final Editor editor, final PsiFile file, final @Nullable DataContext dataContext) {
+  public void invoke(final @NotNull Project project, @NotNull final Editor editor, @NotNull final PsiFile file, final @Nullable DataContext dataContext) {
     final SelectionModel selectionModel = editor.getSelectionModel();
     if (!selectionModel.hasSelection()) {
       final int offset = editor.getCaretModel().getOffset();
 
       final List<GrExpression> expressions = GrIntroduceHandlerBase.collectExpressions(file, editor, offset, false);
       if (expressions.isEmpty()) {
-        final GrVariable variable = GrIntroduceHandlerBase.findVariableAtCaret(file, editor, offset);
-        if (variable == null || variable instanceof GrField || variable instanceof GrParameter) {
-          selectionModel.selectLineAtCaret();
-        }
-        else {
-          final TextRange textRange = variable.getTextRange();
-          selectionModel.setSelection(textRange.getStartOffset(), textRange.getEndOffset());
-        }
+        GrIntroduceHandlerBase.updateSelectionForVariable(editor, file, selectionModel, offset);
       }
       else if (expressions.size() == 1) {
         final TextRange textRange = expressions.get(0).getTextRange();
@@ -116,7 +99,7 @@
     invoke(project, editor, file, selectionModel.getSelectionStart(), selectionModel.getSelectionEnd());
   }
 
-  private void invoke(final Project project, final Editor editor, PsiFile file, int startOffset, int endOffset) {
+  private void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file, int startOffset, int endOffset) {
     try {
       final InitialInfo initialInfo = GroovyExtractChooser.invoke(project, editor, file, startOffset, endOffset, false);
       chooseScopeAndRun(initialInfo, editor);
@@ -157,7 +140,8 @@
     }
   }
 
-  private List<GrParametersOwner> findScopes(InitialInfo initialInfo) {
+  @NotNull
+  private static List<GrParametersOwner> findScopes(@NotNull InitialInfo initialInfo) {
     PsiElement place = initialInfo.getContext();
     final List<GrParametersOwner> scopes = new ArrayList<GrParametersOwner>();
     while (true) {
@@ -176,27 +160,14 @@
 
 
   //method to hack in tests
-  protected void showDialogOrStartInplace(final IntroduceParameterInfo info, final Editor editor) {
+  protected void showDialogOrStartInplace(@NotNull final IntroduceParameterInfo info, @NotNull final Editor editor) {
     if (isInplace(info, editor)) {
       final GrIntroduceContext context = createContext(info, editor);
       Map<OccurrencesChooser.ReplaceChoice, List<Object>> occurrencesMap = GrIntroduceHandlerBase.fillChoice(context);
-      new OccurrencesChooser<Object>(editor) {
-        @Override
-        protected TextRange getOccurrenceRange(Object occurrence) {
-          if (occurrence instanceof PsiElement) {
-            return ((PsiElement)occurrence).getTextRange();
-          }
-          else if (occurrence instanceof StringPartInfo) {
-            return ((StringPartInfo)occurrence).getRange();
-          }
-          else {
-            return null;
-          }
-        }
-      }.showChooser(new Pass<OccurrencesChooser.ReplaceChoice>() {
+      new IntroduceOccurrencesChooser(editor).showChooser(new Pass<OccurrencesChooser.ReplaceChoice>() {
         @Override
         public void pass(OccurrencesChooser.ReplaceChoice choice) {
-          startInplace(info, context);
+          startInplace(info, context, choice);
         }
       }, occurrencesMap);
     }
@@ -209,111 +180,27 @@
     new GrIntroduceParameterDialog(info).show();
   }
 
-  private void startInplace(final IntroduceParameterInfo info, final GrIntroduceContext context) {
-    final GrIntroduceParameterSettings settings = getSettingsForInplace(info, context);
-    if (settings == null) return;
-
-    CommandProcessor.getInstance().executeCommand(info.getProject(), new Runnable() {
-      public void run() {
-        List<RangeMarker> occurrences = ContainerUtil.newArrayList();
-        Document document = context.getEditor().getDocument();
-        for (PsiElement element : context.getOccurrences()) {
-          occurrences.add(createRange(document, element));
-        }
-        RangeMarker expressionRangeMarker = createRange(document, context.getExpression());
-        RangeMarker stringPartRangeMarker = createRange(document, context.getStringPart());
-        RangeMarker varRangeMarker = createRange(document, context.getVar());
-
-        GrExpressionWrapper expr = new GrExpressionWrapper(GroovyIntroduceParameterUtil.findExpr(settings));
-
-        SmartPsiElementPointer<GrParameter> pointer =
-          ApplicationManager.getApplication().runWriteAction(new Computable<SmartPsiElementPointer<GrParameter>>() {
-            @Override
-            public SmartPsiElementPointer<GrParameter> compute() {
-              Project project = context.getProject();
-              GrParametersOwner toReplaceIn = info.getToReplaceIn();
-              String name = GrInplaceParameterIntroducer.suggestNames(context, toReplaceIn).iterator().next();
-              PsiType type = getType(context.getExpression(), context.getVar(), context.getStringPart());
-              GrParameter parameter = GroovyIntroduceParameterMethodUsagesProcessor.addParameter(
-                toReplaceIn, null,
-                type != null ? type : PsiType.getJavaLangObject(PsiManager.getInstance(project), toReplaceIn.getResolveScope()), name,
-                false, project);
-              GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project);
-
-              for (PsiElement element : context.getOccurrences()) {
-                element.replace(factory.createReferenceExpressionFromText(name));
-              }
-              return SmartPointerManager.getInstance(project).createSmartPsiElementPointer(parameter);
-            }
-          });
-        GrVariable parameter = pointer != null ? pointer.getElement() : null;
-
-        if (parameter != null) {
-          GrInplaceIntroducer introducer = getIntroducer(parameter, context, settings, occurrences, varRangeMarker, expressionRangeMarker, stringPartRangeMarker,
-                                                         expr);
-          PsiDocumentManager.getInstance(info.getProject()).doPostponedOperationsAndUnblockDocument(context.getEditor().getDocument());
-          introducer.performInplaceRefactoring(introducer.suggestNames(context));
-        }
-      }
-    }, REFACTORING_NAME, REFACTORING_NAME);
-
+  private static void startInplace(@NotNull final IntroduceParameterInfo info,
+                                   @NotNull final GrIntroduceContext context,
+                                   OccurrencesChooser.ReplaceChoice replaceChoice) {
+    new GrInplaceParameterIntroducer(info, context, replaceChoice).startInplaceIntroduceTemplate();
   }
 
-  private static GrInplaceIntroducer getIntroducer(GrVariable parameter,
-                                                   GrIntroduceContext context,
-                                                   GrIntroduceParameterSettings settings,
-                                                   List<RangeMarker> occurrences,
-                                                   RangeMarker varRangeMarker,
-                                                   RangeMarker expressionRangeMarker,
-                                                   RangeMarker stringPartRangeMarker,
-                                                   GrExpressionWrapper expr) {
-    //return new GrInplaceVariableIntroducer(parameter, context.getEditor(), context.getProject(), REFACTORING_NAME, occurrences, parameter);
-    return new GrInplaceParameterIntroducer(parameter, context.getEditor(), context.getProject(), REFACTORING_NAME, occurrences, context.getPlace(), settings, expr);
+  private static boolean isInplace(@NotNull IntroduceParameterInfo info,
+                                   @NotNull Editor editor) {
+    return findExpr(info) != null && GrIntroduceHandlerBase.isInplace(editor, info.getContext());
   }
 
-  private static GrIntroduceParameterSettings getSettingsForInplace(@NotNull IntroduceParameterInfo info, @NotNull GrIntroduceContext context) {
-    GrExpression expr = context.getExpression();
-    GrVariable var = context.getVar();
-
-    TObjectIntHashMap<GrParameter> toRemove = GroovyIntroduceParameterUtil.findParametersToRemove(info);
-    LinkedHashSet<String> names =
-      GroovyIntroduceParameterUtil.suggestNames(var, expr, info.getStringPartInfo(), info.getToReplaceIn(), info.getProject());
-    return new GrIntroduceExpressionSettingsImpl(info, names.iterator().next(), false, new TIntArrayList(toRemove.getValues()), false,
-                                                 IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, expr, var,
-                                                 getType(expr, var, info.getStringPartInfo()), false);
-  }
-
-  @Nullable
-  private static PsiType getType(GrExpression expr, GrVariable var, StringPartInfo info) {
-    if (expr != null) {
-      return expr.getType();
-    }
-    else if (var != null) {
-      return var.getDeclaredType();
-    }
-    else if (info != null) {
-      return info.getLiteral().getType();
-    }
-    return null;
-  }
-
-  private static boolean isInplace(IntroduceParameterInfo info, Editor editor) {
-    GrExpression expr = GroovyIntroduceParameterUtil.findExpr(info);
-    GrVariable var = GroovyIntroduceParameterUtil.findVar(info);
-    StringPartInfo stringPart = info.getStringPartInfo();
-
-    return (expr != null || var != null || stringPart != null) && GrIntroduceHandlerBase.isInplace(editor, info.getContext());
-  }
-
-
   @Override
   public void invoke(@NotNull Project project, @NotNull PsiElement[] elements, DataContext dataContext) {
     // Does nothing
   }
 
-  private static GrIntroduceContext createContext(IntroduceParameterInfo info, Editor editor) {
-    GrExpression expr = GroovyIntroduceParameterUtil.findExpr(info);
-    GrVariable var = GroovyIntroduceParameterUtil.findVar(info);
-    return new GrIntroduceVariableHandler().getContext(info.getProject(), editor, expr, var, info.getStringPartInfo(), info.getToReplaceIn());
+  private static GrIntroduceContext createContext(@NotNull IntroduceParameterInfo info,
+                                                  @NotNull Editor editor) {
+    GrExpression expr = findExpr(info);
+    GrVariable var = findVar(info);
+    StringPartInfo stringPart = info.getStringPartInfo();
+    return new GrIntroduceVariableHandler().getContext(info.getProject(), editor, expr, var, stringPart, info.getToReplaceIn());
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterProcessor.java
index 86961a1..9a5ccb0 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GrIntroduceParameterProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -78,9 +78,10 @@
     LOG.assertTrue(settings.getToSearchFor() instanceof PsiMethod);
 
     final StringPartInfo stringPartInfo = settings.getStringPartInfo();
-    final GrExpression expression = stringPartInfo != null
-                                    ? GrIntroduceHandlerBase.generateExpressionFromStringPart(stringPartInfo, settings.getProject())
-                                    : settings.getExpression();
+    GrVariable var = settings.getVar();
+    final GrExpression expression = stringPartInfo != null ? stringPartInfo.createLiteralFromSelected() :
+                                    var != null ? var.getInitializerGroovy()
+                                                : settings.getExpression();
     return new GrExpressionWrapper(expression);
   }
 
@@ -177,9 +178,16 @@
     }
 
     if (mySettings.replaceAllOccurrences()) {
-      PsiElement[] exprs = GroovyIntroduceParameterUtil.getOccurrences(mySettings);
-      for (PsiElement expr : exprs) {
-        result.add(new InternalUsageInfo(expr));
+      if (mySettings.getVar() != null) {
+        for (PsiElement element : GrIntroduceHandlerBase.collectVariableUsages(mySettings.getVar(), mySettings.getToReplaceIn())) {
+          result.add(new InternalUsageInfo(element));
+        }
+      }
+      else {
+        PsiElement[] exprs = GroovyIntroduceParameterUtil.getOccurrences(mySettings);
+        for (PsiElement expr : exprs) {
+          result.add(new InternalUsageInfo(expr));
+        }
       }
     }
     else {
@@ -241,7 +249,7 @@
     final StringPartInfo stringPartInfo = mySettings.getStringPartInfo();
     if (stringPartInfo != null) {
       final GrExpression
-        expr = GrIntroduceHandlerBase.processLiteral(mySettings.getName(), mySettings.getStringPartInfo(), mySettings.getProject());
+        expr = mySettings.getStringPartInfo().replaceLiteralWithConcatenation(mySettings.getName());
       final Editor editor = PsiUtilBase.findEditor(expr);
       if (editor != null) {
         editor.getSelectionModel().removeSelection();
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GroovyIntroduceParameterUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GroovyIntroduceParameterUtil.java
index 5391a68..ef1e8f7 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GroovyIntroduceParameterUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/GroovyIntroduceParameterUtil.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -379,6 +379,9 @@
 
   @Nullable
   static GrVariable findVar(IntroduceParameterInfo info) {
+    GrVariable variable = info.getVar();
+    if (variable != null) return variable;
+
     final GrStatement[] statements = info.getStatements();
     if (statements.length != 1) return null;
     return GrIntroduceHandlerBase.findVariable(statements[0]);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/java2groovy/GroovyIntroduceParameterMethodUsagesProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/java2groovy/GroovyIntroduceParameterMethodUsagesProcessor.java
index 2e1b0f8..a5383af6 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/java2groovy/GroovyIntroduceParameterMethodUsagesProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/parameter/java2groovy/GroovyIntroduceParameterMethodUsagesProcessor.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -270,7 +270,7 @@
                                          @NotNull Project project) {
     GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project);
 
-    final String typeText = forcedType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) ? null : forcedType.getCanonicalText();
+    final String typeText = forcedType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) || forcedType == PsiType.NULL ? null : forcedType.getCanonicalText();
 
     GrParameter parameter = factory.createParameter(parameterName, typeText, parametersOwner);
     parameter.getModifierList().setModifierProperty(PsiModifier.FINAL, isFinal);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrInplaceVariableIntroducer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrInplaceVariableIntroducer.java
index a873298..ea1b272 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrInplaceVariableIntroducer.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrInplaceVariableIntroducer.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -133,7 +133,7 @@
                        var != null ? var.getType() :
                        stringPart != null ? stringPart.getLiteral().getType() :
                        null;
-        myType = type != null ? CanonicalTypes.createTypeWrapper(type) : null;
+        myType = type != null && !PsiType.NULL.equals(type)? CanonicalTypes.createTypeWrapper(type) : null;
       }
 
 
@@ -164,8 +164,10 @@
   @Override
   protected void addAdditionalVariables(TemplateBuilderImpl builder) {
     GrVariable variable = getVariable();
-    assert variable != null;
-    TypeConstraint[] constraints = {SupertypeConstraint.create(variable.getInitializerGroovy().getType())};
+    assert variable != null && variable.getInitializerGroovy() != null;
+    final PsiType initializerType = variable.getInitializerGroovy().getType();
+    TypeConstraint[] constraints = initializerType != null && !initializerType.equals(PsiType.NULL) ? new SupertypeConstraint[]{SupertypeConstraint.create(initializerType)}
+                                                                                                    : TypeConstraint.EMPTY_ARRAY;
     ChooseTypeExpression typeExpression = new ChooseTypeExpression(constraints, variable.getManager(), variable.getResolveScope(), true, GroovyApplicationSettings.getInstance().INTRODUCE_LOCAL_SELECT_DEF);
     PsiElement element = variable.getTypeElementGroovy() != null ? variable.getTypeElementGroovy()
                                                                  : PsiUtil.findModifierInList(variable.getModifierList(), GrModifier.DEF);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrIntroduceVariableHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrIntroduceVariableHandler.java
index 6b01652..849d2ca 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrIntroduceVariableHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/variable/GrIntroduceVariableHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -195,7 +195,7 @@
     GrVariableDeclaration varDecl = generateDeclaration(context, settings);
 
     if (context.getStringPart() != null) {
-      final GrExpression ref = processLiteral(DUMMY_NAME, context.getStringPart(), context.getProject());
+      final GrExpression ref = context.getStringPart().replaceLiteralWithConcatenation(DUMMY_NAME);
       return doProcessExpression(context, settings, varDecl, new PsiElement[]{ref}, ref, true);
     }
     else {
@@ -222,7 +222,7 @@
   private static GrExpression generateInitializer(@NotNull GrIntroduceContext context,
                                                   @NotNull GrVariable variable) {
     final GrExpression initializer = context.getStringPart() != null
-                                     ? GrIntroduceHandlerBase.generateExpressionFromStringPart(context.getStringPart(), context.getProject())
+                                     ? context.getStringPart().createLiteralFromSelected()
                                      : context.getExpression();
     final GrExpression dummyInitializer = variable.getInitializerGroovy();
     assert dummyInitializer != null;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/memberPullUp/GrPullUpHelper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/memberPullUp/GrPullUpHelper.java
index 6e98ba8..7b37a83 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/memberPullUp/GrPullUpHelper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/memberPullUp/GrPullUpHelper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -330,26 +330,27 @@
     final Map<PsiElement, PsiElement> replacement = new LinkedHashMap<PsiElement, PsiElement>();
     for (PsiTypeParameter parameter : parametersIterable) {
       PsiType substitutedType = substitutor.substitute(parameter);
-      if (substitutedType == null) {
-        substitutedType = TypeConversionUtil.erasure(factory.createType(parameter));
-      }
+
+      PsiType type = substitutedType != null ? substitutedType : TypeConversionUtil.erasure(factory.createType(parameter));
 
       PsiElement scopeElement = member instanceof GrField ? member.getParent() : member;
       for (PsiReference reference : ReferencesSearch.search(parameter, new LocalSearchScope(scopeElement))) {
         final PsiElement element = reference.getElement();
         final PsiElement parent = element.getParent();
         if (parent instanceof PsiTypeElement) {
-          replacement.put(parent, factory.createTypeElement(substitutedType));
+          replacement.put(parent, factory.createTypeElement(type));
         }
-        else if (element instanceof GrCodeReferenceElement && substitutedType instanceof PsiClassType) {
-          replacement.put(element, factory.createReferenceElementByType((PsiClassType)substitutedType));
+        else if (element instanceof GrCodeReferenceElement && type instanceof PsiClassType) {
+          replacement.put(element, factory.createReferenceElementByType((PsiClassType)type));
         }
       }
     }
 
+    final JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(member.getProject());
     for (PsiElement element : replacement.keySet()) {
       if (element.isValid()) {
-        element.replace(replacement.get(element));
+        final PsiElement replaced = element.replace(replacement.get(element));
+        codeStyleManager.shortenClassReferences(replaced);
       }
     }
   }
@@ -593,12 +594,12 @@
 
   private static void addSpacesAround(@NotNull GrReferenceList list) {
     PsiElement prev = list.getPrevSibling();
-    if (!PsiImplUtil.isWhiteSpace(prev)) {
+    if (!PsiImplUtil.isWhiteSpaceOrNls(prev)) {
       list.getParent().getNode().addLeaf(TokenType.WHITE_SPACE, " ", list.getNode());
     }
 
     PsiElement next = list.getNextSibling();
-    if (!PsiImplUtil.isWhiteSpace(next)) {
+    if (!PsiImplUtil.isWhiteSpaceOrNls(next)) {
       list.getParent().getNode().addLeaf(TokenType.WHITE_SPACE, " ", list.getNode().getTreeNext());
     }
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/move/MoveGroovyClassHandler.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/move/MoveGroovyClassHandler.java
index 5a81586..0bf6acc 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/move/MoveGroovyClassHandler.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/move/MoveGroovyClassHandler.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -37,7 +37,6 @@
 import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocCommentOwner;
 import org.jetbrains.plugins.groovy.lang.groovydoc.psi.impl.GrDocCommentUtil;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
-import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
 import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
@@ -48,6 +47,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition;
 import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
+import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
 import org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass;
 import org.jetbrains.plugins.groovy.refactoring.GroovyChangeContextUtil;
 
@@ -123,7 +123,7 @@
         correctSelfReferences(aClass, newPackage);
 
         final PsiFile fromTemplate =
-          GroovyTemplatesFactory.createFromTemplate(moveDestination, aClass.getName(), aClass.getName() + NewGroovyActionBase.GROOVY_EXTENSION, GroovyTemplates.GROOVY_CLASS);
+          GroovyTemplatesFactory.createFromTemplate(moveDestination, aClass.getName(), aClass.getName() + NewGroovyActionBase.GROOVY_EXTENSION, GroovyTemplates.GROOVY_CLASS, true);
         final PsiClass created = ((GroovyFile)fromTemplate).getClasses()[0];
         PsiDocComment docComment = aClass.getDocComment();
         if (docComment != null) {
@@ -186,7 +186,7 @@
     if (packageDefinition != null) packageDefinition.delete();
 
     PsiElement cur = newFile.getFirstChild();
-    while (cur != null && TokenSets.WHITE_SPACES_SET.contains(cur.getNode().getElementType())) {
+    while (cur != null && PsiImplUtil.isWhiteSpaceOrNls(cur)) {
       cur = cur.getNextSibling();
     }
     if (cur != null && cur != newFile.getFirstChild()) {
@@ -195,7 +195,7 @@
     }
 
     cur = newFile.getLastChild();
-    while (cur != null && TokenSets.WHITE_SPACES_SET.contains(cur.getNode().getElementType())) {
+    while (cur != null && PsiImplUtil.isWhiteSpaceOrNls(cur)) {
       cur = cur.getPrevSibling();
     }
     if (cur != null && cur != newFile.getLastChild()) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameGrFieldProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameGrFieldProcessor.java
index 8ec7ce6..89cfd5d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameGrFieldProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/rename/RenameGrFieldProcessor.java
@@ -32,7 +32,6 @@
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.MultiMap;
 import com.intellij.util.containers.hash.HashMap;
-import com.intellij.util.containers.hash.LinkedHashMap;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
@@ -99,18 +98,8 @@
       renames.put(setter, GroovyPropertyUtils.getSetterName(newName));
     }
 
-    MultiMap<PsiNamedElement, UsageInfo> propertyUsages = new MultiMap<PsiNamedElement, UsageInfo>() {
-      @Override
-      protected Map<PsiNamedElement, Collection<UsageInfo>> createMap() {
-        return new LinkedHashMap<PsiNamedElement, Collection<UsageInfo>>();
-      }
-    };
-    MultiMap<PsiNamedElement, UsageInfo> simpleUsages = new MultiMap<PsiNamedElement, UsageInfo>() {
-      @Override
-      protected Map<PsiNamedElement, Collection<UsageInfo>> createMap() {
-        return new LinkedHashMap<PsiNamedElement, Collection<UsageInfo>>();
-      }
-    };
+    MultiMap<PsiNamedElement, UsageInfo> propertyUsages = MultiMap.createLinked();
+    MultiMap<PsiNamedElement, UsageInfo> simpleUsages = MultiMap.createLinked();
 
     List<PsiReference> unknownUsages = new ArrayList<PsiReference>();
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java
index dff59a8..38e495e 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/DefaultGroovyScriptRunner.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -100,14 +100,13 @@
     setToolsJar(params);
 
     String groovyHome = useBundled ? FileUtil.toCanonicalPath(GroovyUtils.getBundledGroovyJar().getParentFile().getParent()) : LibrariesUtil.getGroovyHomePath(module);
-    if (groovyHome != null) {
-      groovyHome = FileUtil.toSystemDependentName(groovyHome);
-    }
-    if (groovyHome != null) {
-      setGroovyHome(params, groovyHome);
+    String groovyHomeDependentName = groovyHome != null ? FileUtil.toSystemDependentName(groovyHome) : null;
+
+    if (groovyHomeDependentName != null) {
+      setGroovyHome(params, groovyHomeDependentName);
     }
 
-    final String confPath = getConfPath(groovyHome);
+    final String confPath = getConfPath(groovyHomeDependentName);
     params.getVMParametersList().add("-Dgroovy.starter.conf=" + confPath);
     params.getVMParametersList().addAll(HttpConfigurable.convertArguments(HttpConfigurable.getJvmPropertiesList(false, null)));
 
@@ -119,6 +118,8 @@
     params.getProgramParametersList().add("--main");
     params.getProgramParametersList().add(mainClass);
 
+    addClasspathFromRootModel(module, tests, params, true);
+
     if (params.getVMParametersList().getPropertyValue(GroovycOSProcessHandler.GRAPE_ROOT) == null) {
       String sysRoot = System.getProperty(GroovycOSProcessHandler.GRAPE_ROOT);
       if (sysRoot != null) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java
index 33e3224..f4457d9 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/runner/GroovyScriptRunner.java
@@ -103,9 +103,7 @@
   protected static VirtualFile findGroovyJar(@NotNull Module module) {
     final VirtualFile[] files = OrderEnumerator.orderEntries(module).getAllLibrariesAndSdkClassesRoots();
     for (VirtualFile root : files) {
-      if (root.getName().matches(GroovyConfigUtils.GROOVY_JAR_PATTERN)
-          || GroovyConfigUtils.matchesGroovyAll(root.getName()))
-      {
+      if (GroovyConfigUtils.GROOVY_JAR_PATTERN.matcher(root.getName()).matches() || GroovyConfigUtils.matchesGroovyAll(root.getName())) {
         return root;
       }
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockTestFramework.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockTestFramework.java
index b7872dcc..9a36c8c8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockTestFramework.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockTestFramework.java
@@ -51,7 +51,7 @@
 
   @Override
   public FileTemplateDescriptor getSetUpMethodFileTemplateDescriptor() {
-    return new FileTemplateDescriptor("Spock SetUp Method.groovy");
+    return new FileTemplateDescriptor("Spock_SetUp_Method.groovy");
   }
 
   @Override
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockUtils.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockUtils.java
index 8d99ae1..3ce8cb1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockUtils.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/spock/SpockUtils.java
@@ -34,7 +34,6 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
-import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.arithmetic.GrShiftExpressionImpl;
 import org.jetbrains.plugins.groovy.util.LightCacheKey;
 
 import java.util.*;
@@ -57,9 +56,10 @@
 
     PsiFile containingFile = method.getContainingFile();
     if (containingFile != containingFile.getOriginalFile()) {
-      PsiElement originalPlace = containingFile.getOriginalFile().findElementAt(method.getTextOffset());
+      int methodOffset = method.getTextOffset();
+      PsiElement originalPlace = containingFile.getOriginalFile().findElementAt(methodOffset);
       originalMethod = PsiTreeUtil.getParentOfType(originalPlace, GrMethod.class);
-      assert originalMethod != null;
+      assert originalMethod != null : containingFile.getOriginalFile().getText().substring(Math.max(0, methodOffset - 50), Math.min(methodOffset + 50, containingFile.getOriginalFile().getText().length()));
     }
     else {
       originalMethod = method;
@@ -115,36 +115,33 @@
     PsiElement e = elementUnderLabel;
 
     while (e != null) {
-      if (e instanceof GrShiftExpressionImpl) {
-        GrShiftExpressionImpl shift = (GrShiftExpressionImpl)e;
+      if (e instanceof GrBinaryExpression && ((GrBinaryExpression)e).getOperationTokenType() == GroovyElementTypes.COMPOSITE_LSHIFT_SIGN) {
+        GrBinaryExpression shift = (GrBinaryExpression)e;
+        GrExpression leftOperand = shift.getLeftOperand();
+        GrExpression rightOperand = shift.getRightOperand();
 
-        if (shift.getOperationTokenType() == GroovyElementTypes.COMPOSITE_LSHIFT_SIGN) {
-          GrExpression leftOperand = shift.getLeftOperand();
-          GrExpression rightOperand = shift.getRightOperand();
-
-          if (leftOperand instanceof GrReferenceExpression) {
-            String name = getNameByReference(leftOperand);
-            if (name != null) {
-              SpockVariableDescriptor descriptor = new SpockVariableDescriptor(leftOperand, name);
-              descriptor.addExpressionOfCollection(rightOperand);
-              res.put(name, descriptor);
-            }
+        if (leftOperand instanceof GrReferenceExpression) {
+          String name = getNameByReference(leftOperand);
+          if (name != null) {
+            SpockVariableDescriptor descriptor = new SpockVariableDescriptor(leftOperand, name);
+            descriptor.addExpressionOfCollection(rightOperand);
+            res.put(name, descriptor);
           }
-          else if (leftOperand instanceof GrListOrMap) {
-            GrExpression[] variableDefinitions = ((GrListOrMap)leftOperand).getInitializers();
+        }
+        else if (leftOperand instanceof GrListOrMap) {
+          GrExpression[] variableDefinitions = ((GrListOrMap)leftOperand).getInitializers();
 
-            SpockVariableDescriptor[] variables = createVariables(res, Arrays.asList(variableDefinitions));
+          SpockVariableDescriptor[] variables = createVariables(res, Arrays.asList(variableDefinitions));
 
-            if (rightOperand instanceof GrListOrMap) {
-              for (GrExpression expression : ((GrListOrMap)rightOperand).getInitializers()) {
-                if (expression instanceof GrListOrMap) {
-                  add(variables, Arrays.asList(((GrListOrMap)expression).getInitializers()));
-                }
-                else {
-                  for (SpockVariableDescriptor variable : variables) {
-                    if (variable != null) {
-                      variable.addExpressionOfCollection(expression);
-                    }
+          if (rightOperand instanceof GrListOrMap) {
+            for (GrExpression expression : ((GrListOrMap)rightOperand).getInitializers()) {
+              if (expression instanceof GrListOrMap) {
+                add(variables, Arrays.asList(((GrListOrMap)expression).getInitializers()));
+              }
+              else {
+                for (SpockVariableDescriptor variable : variables) {
+                  if (variable != null) {
+                    variable.addExpressionOfCollection(expression);
                   }
                 }
               }
@@ -169,14 +166,14 @@
 
         List<GrExpression> row = new ArrayList<GrExpression>();
 
-        PsiElement rowElement = getNext(e, elementUnderLabel,elementAfterLabel);
+        PsiElement rowElement = getNext(e, elementUnderLabel, elementAfterLabel);
         while (isOrStatement(rowElement)) {
           row.clear();
           splitOr(row, (GrExpression)rowElement);
 
           add(variables, row);
 
-          rowElement = getNext(rowElement, elementUnderLabel,elementAfterLabel);
+          rowElement = getNext(rowElement, elementUnderLabel, elementAfterLabel);
         }
 
         e = rowElement;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/springloaded/SpringLoadedPositionManager.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/springloaded/SpringLoadedPositionManager.java
index 814a5f4..b285502 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/springloaded/SpringLoadedPositionManager.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/springloaded/SpringLoadedPositionManager.java
@@ -102,6 +102,10 @@
       }
     }
 
+    if (element != null) {
+      return getClassNameForJvm((PsiClass)element);
+    }
+
     return null;
   }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/template/expressions/ChooseTypeExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/template/expressions/ChooseTypeExpression.java
index f9217f2..7048e90 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/template/expressions/ChooseTypeExpression.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/template/expressions/ChooseTypeExpression.java
@@ -25,7 +25,8 @@
 import com.intellij.openapi.editor.Document;
 import com.intellij.psi.*;
 import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.PsiTypesUtil;
+import com.intellij.util.containers.ContainerUtil;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.lang.completion.GroovyCompletionUtil;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifier;
 import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.SubtypeConstraint;
@@ -33,7 +34,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.expectedTypes.TypeConstraint;
 import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
 
-import java.util.LinkedHashSet;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -46,13 +47,13 @@
       GroovyCompletionUtil.addImportForItem(context.getFile(), context.getStartOffset(), item);
     }
   };
+
   protected final SmartTypePointer myTypePointer;
-  private final LookupElement[] myItems;
-  private final PsiManager myManager;
+  private final List<SmartTypePointer> myItems;
   private final boolean myForGroovy;
   private final boolean mySelectDef;
 
-  public ChooseTypeExpression(TypeConstraint[] constraints, PsiManager manager, GlobalSearchScope resolveScope) {
+  public ChooseTypeExpression(@NotNull TypeConstraint[] constraints, PsiManager manager, GlobalSearchScope resolveScope) {
     this(constraints, manager, resolveScope, true);
   }
 
@@ -68,57 +69,44 @@
                               GlobalSearchScope resolveScope,
                               boolean forGroovy,
                               boolean selectDef) {
-    myManager = manager;
     myForGroovy = forGroovy;
-    myTypePointer = SmartTypePointerManager.getInstance(manager.getProject()).createSmartTypePointer(chooseType(constraints, resolveScope));
-    myItems = createItems(constraints, forGroovy);
+
+    SmartTypePointerManager typePointerManager = SmartTypePointerManager.getInstance(manager.getProject());
+    myTypePointer = typePointerManager.createSmartTypePointer(chooseType(constraints, resolveScope, manager));
+    myItems = createItems(constraints, typePointerManager);
 
     mySelectDef = selectDef;
   }
 
-  private static LookupElement[] createItems(TypeConstraint[] constraints, boolean forGroovy) {
-    Set<LookupElement> result = new LinkedHashSet<LookupElement>();
+  @NotNull
+  private static List<SmartTypePointer> createItems(@NotNull TypeConstraint[] constraints, @NotNull SmartTypePointerManager typePointerManager) {
+    List<SmartTypePointer> result = ContainerUtil.newArrayList();
 
-    if (forGroovy && constraints.length == 1 && constraints[0].getDefaultType().equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
-      result.add(LookupElementBuilder.create(GrModifier.DEF).bold());
-    }
     for (TypeConstraint constraint : constraints) {
       if (constraint instanceof SubtypeConstraint) {
         PsiType type = constraint.getDefaultType();
-        PsiTypeLookupItem item = PsiTypeLookupItem.createLookupItem(type, null, PsiTypeLookupItem.isDiamond(type), IMPORT_FIXER);
-        result.add(item);
+        result.add(typePointerManager.createSmartTypePointer(type));
       }
       else if (constraint instanceof SupertypeConstraint) {
-        processSuperTypes(constraint.getType(), result);
+        processSuperTypes(constraint.getType(), result, typePointerManager);
       }
     }
 
-    if (forGroovy) { //don't check whether we already added 'def' 'cause it is a set
-      result.add(LookupElementBuilder.create(GrModifier.DEF).bold());
-    }
-
-    return result.toArray(new LookupElement[result.size()]);
+    return result;
   }
 
-  private static void processSuperTypes(PsiType type, Set<LookupElement> result) {
-    String text = type.getCanonicalText();
-    String unboxed = PsiTypesUtil.unboxIfPossible(text);
-    if (unboxed != null && !unboxed.equals(text)) {
-      result.add(LookupElementBuilder.create(unboxed).bold());
-    }
-    else {
-      PsiTypeLookupItem item = PsiTypeLookupItem.createLookupItem(type, null, PsiTypeLookupItem.isDiamond(type), IMPORT_FIXER);
-      result.add(item);
-    }
+  private static void processSuperTypes(@NotNull PsiType type, @NotNull List<SmartTypePointer> result, @NotNull SmartTypePointerManager typePointerManager) {
+    result.add(typePointerManager.createSmartTypePointer(type));
     PsiType[] superTypes = type.getSuperTypes();
     for (PsiType superType : superTypes) {
-      processSuperTypes(superType, result);
+      processSuperTypes(superType, result, typePointerManager);
     }
   }
 
-  private PsiType chooseType(TypeConstraint[] constraints, GlobalSearchScope scope) {
+  @NotNull
+  private static PsiType chooseType(@NotNull TypeConstraint[] constraints, @NotNull GlobalSearchScope scope, @NotNull PsiManager manager) {
     if (constraints.length > 0) return constraints[0].getDefaultType();
-    return PsiType.getJavaLangObject(myManager, scope);
+    return PsiType.getJavaLangObject(manager, scope);
   }
 
   public Result calculateResult(ExpressionContext context) {
@@ -136,7 +124,7 @@
       return new PsiTypeResult(finalType, context.getProject()) {
         @Override
         public void handleRecalc(PsiFile psiFile, Document document, int segmentStart, int segmentEnd) {
-          if (myItems.length <= 1) {
+          if (myItems.size() <= 1) {
             super.handleRecalc(psiFile, document, segmentStart, segmentEnd);
           }
           else {
@@ -146,7 +134,7 @@
 
         @Override
         public String toString() {
-          return myItems.length == 1 ? super.toString() : finalType.getPresentableText();
+          return myItems.size() == 1 ? super.toString() : finalType.getPresentableText();
         }
 
       };
@@ -160,6 +148,20 @@
   }
 
   public LookupElement[] calculateLookupItems(ExpressionContext context) {
-    return myItems;
+    Set<LookupElement> result = ContainerUtil.newHashSet();
+
+    if (myForGroovy) {
+      result.add(LookupElementBuilder.create(GrModifier.DEF).bold());
+    }
+
+    for (SmartTypePointer item : myItems) {
+      PsiType type = TypesUtil.unboxPrimitiveTypeWrapper(item.getType());
+      if (type == null) continue;
+
+      PsiTypeLookupItem lookupItem = PsiTypeLookupItem.createLookupItem(type, null, PsiTypeLookupItem.isDiamond(type), IMPORT_FIXER);
+      result.add(lookupItem);
+    }
+
+    return result.toArray(new LookupElement[result.size()]);
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/testIntegration/GroovyTestGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/testIntegration/GroovyTestGenerator.java
index 22c7a18..5128763 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/testIntegration/GroovyTestGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/testIntegration/GroovyTestGenerator.java
@@ -71,7 +71,7 @@
                 d.getClassName(),
                 PsiManager.getInstance(project),
                 null,
-                GroovyTemplates.GROOVY_CLASS);
+                GroovyTemplates.GROOVY_CLASS, true);
               if (targetClass == null) return null;
 
               addSuperClass(targetClass, project, d.getSuperClassName());
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/unwrap/GroovyUnwrapper.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/unwrap/GroovyUnwrapper.java
index ee62e88..d41c691f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/unwrap/GroovyUnwrapper.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/unwrap/GroovyUnwrapper.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
-import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrBlockStatement;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrIfStatement;
@@ -104,7 +103,7 @@
     }
 
     protected boolean isWhiteSpace(PsiElement element) {
-      return PsiImplUtil.isLeafElementOfType(element, TokenSets.WHITE_SPACES_SET);
+      return org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil.isWhiteSpaceOrNls(element);
     }
 
     public void setElseBranch(GrIfStatement ifStatement, GrStatement elseBranch) throws IncorrectOperationException {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/LibrariesUtil.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/LibrariesUtil.java
index 3b05608..723f53a 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/LibrariesUtil.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/LibrariesUtil.java
@@ -143,7 +143,7 @@
   private static String getGroovySdkHome(VirtualFile[] classRoots) {
     for (VirtualFile file : classRoots) {
       final String name = file.getName();
-      if (name.matches(GroovyConfigUtils.GROOVY_JAR_PATTERN_NOVERSION) || name.matches(GroovyConfigUtils.GROOVY_JAR_PATTERN)) {
+      if (GroovyConfigUtils.GROOVY_JAR_PATTERN.matcher(name).matches()) {
         String jarPath = file.getPresentableUrl();
         File realFile = new File(jarPath);
         if (realFile.exists()) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicMethodImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicMethodImpl.java
index c2a1296..030693d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicMethodImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicMethodImpl.java
@@ -222,10 +222,6 @@
     return myMethod.getHierarchicalMethodSignature();
   }
 
-  public PsiType getReturnTypeNoResolve() {
-    return myMethod.getReturnType();
-  }
-
   @Override
   public boolean isEquivalentTo(PsiElement another) {
     return another instanceof GrDynamicMethodImpl && myMethod.isEquivalentTo(((GrDynamicMethodImpl)another).myMethod);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicPropertyImpl.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicPropertyImpl.java
index 605a06f..1521684 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicPropertyImpl.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/util/dynamicMembers/GrDynamicPropertyImpl.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -140,10 +140,6 @@
     return this;
   }
 
-  public PsiType getTypeNoResolve() {
-    return null;
-  }
-
   public String getText() {
     return null;
   }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/FastGroovyTestSuite.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/FastGroovyTestSuite.java
index 9635c38..11597e9 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/FastGroovyTestSuite.java
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/FastGroovyTestSuite.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
 import org.jetbrains.plugins.groovy.compiler.GppCompilerTest;
 import org.jetbrains.plugins.groovy.compiler.GroovyCompilerTest;
 import org.jetbrains.plugins.groovy.compiler.GroovyDebuggerTest;
+import org.jetbrains.plugins.groovy.lang.GroovyStressPerformanceTest;
 
 /**
  * @author Max Medvedev
@@ -44,6 +45,7 @@
 
   private static boolean isSlow(Class aClass) {
     return aClass.equals(GroovyDebuggerTest.class) ||
+           aClass.equals(GroovyStressPerformanceTest.class) ||
            aClass.getName().startsWith(GroovyCompilerTest.class.getName()) ||
            aClass.getName().startsWith(GppCompilerTest.class.getName());
   }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCopyPasteTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCopyPasteTest.groovy
index 52957e03..0c2306f 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCopyPasteTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyCopyPasteTest.groovy
@@ -23,7 +23,7 @@
  * @author peter
  */
 class GroovyCopyPasteTest extends LightCodeInsightFixtureTestCase {
-  int myAddImportsOld
+  private int myAddImportsOld
 
   @Override
   protected void setUp() throws Exception {
@@ -151,5 +151,22 @@
 ''')
   }
 
+  void testPasteEnumConstant() {
+    myFixture.addClass('''\
+package pack;
+enum E {
+  CONST
+}
+''')
+    doTest('''\
+import static pack.E.CONST
+print <selection>CONST</selection>
+''', '''\
+print <caret>
+''', '''\
+import static pack.E.CONST
 
+print CONST<caret>
+''')
+  }
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyLightProjectDescriptor.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyLightProjectDescriptor.groovy
index 3a2d9883..1063666 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyLightProjectDescriptor.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/GroovyLightProjectDescriptor.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,8 +24,7 @@
 import com.intellij.openapi.vfs.VirtualFile
 import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor
 
-import static org.jetbrains.plugins.groovy.util.TestUtils.getMockGroovy2_1LibraryName
-import static org.jetbrains.plugins.groovy.util.TestUtils.getMockGroovy2_2LibraryName
+import static org.jetbrains.plugins.groovy.util.TestUtils.*
 
 /**
  * @author Max Medvedev
@@ -33,6 +32,7 @@
 class GroovyLightProjectDescriptor extends DefaultLightProjectDescriptor {
   public static final GroovyLightProjectDescriptor GROOVY_2_1 = new GroovyLightProjectDescriptor(mockGroovy2_1LibraryName)
   public static final GroovyLightProjectDescriptor GROOVY_2_2 = new GroovyLightProjectDescriptor(mockGroovy2_2LibraryName)
+  public static final GroovyLightProjectDescriptor GROOVY_2_3 = new GroovyLightProjectDescriptor(mockGroovy2_3LibraryName)
 
   private final String myLibPath
 
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/LightGroovyTestCase.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/LightGroovyTestCase.groovy
index 388cf1d..c9959b7 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/LightGroovyTestCase.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/LightGroovyTestCase.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,10 +16,14 @@
 
 package org.jetbrains.plugins.groovy
 
+import com.intellij.psi.PsiIntersectionType
+import com.intellij.psi.PsiType
 import com.intellij.testFramework.LightProjectDescriptor
 import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
 import org.jetbrains.annotations.NonNls
 import org.jetbrains.annotations.NotNull
+import org.jetbrains.annotations.Nullable
+
 /**
  * @author peter
  */
@@ -245,4 +249,30 @@
 ''')
   }
 
+  public static void assertType(@Nullable String expected, @Nullable PsiType actual) {
+    if (expected == null) {
+      assertNull(actual)
+      return
+    }
+
+    assertNotNull(actual)
+    if (actual instanceof PsiIntersectionType) {
+      assertEquals(expected, genIntersectionTypeText(actual))
+    }
+    else {
+      assertEquals(expected, actual.canonicalText)
+    }
+  }
+
+  private static String genIntersectionTypeText(PsiIntersectionType t) {
+    StringBuilder b = new StringBuilder('[')
+    for (PsiType c : t.conjuncts) {
+      b << c.canonicalText << ','
+    }
+    if (t.conjuncts) {
+      b.replace(b.length() - 1, b.length(), ']')
+    }
+    return b
+  }
+
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyRangeTypeCheckTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyRangeTypeCheckTest.java
index 924b5e0..406a4b0 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyRangeTypeCheckTest.java
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/codeInspection/bugs/GroovyRangeTypeCheckTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
 import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemDescriptor;
 import com.intellij.codeInspection.ProblemHighlightType;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.command.WriteCommandAction;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.impl.source.PostprocessReformattingAspect;
 import com.intellij.psi.util.PsiTreeUtil;
@@ -49,7 +49,7 @@
 
     LocalQuickFix[] fixes = {fix};
     final ProblemDescriptor descriptor = InspectionManager.getInstance(getProject()).createProblemDescriptor(range, "bla-bla", false, fixes, ProblemHighlightType.WEAK_WARNING);
-    ApplicationManager.getApplication().runWriteAction(new Runnable() {
+    WriteCommandAction.runWriteCommandAction(null, new Runnable() {
       @Override
       public void run() {
         fix.applyFix(myFixture.getProject(), descriptor);
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java
index 205d3fc..4d25da3 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyCompilerTestCase.java
@@ -240,7 +240,9 @@
         semaphore.up();
       }
     });
-    semaphore.waitFor();
+    if (!semaphore.waitFor(20000)) {
+      fail("Process took too long");
+    }
     return processHandler.get();
   }
 
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy
index a4b3fda..5904e75 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/compiler/GroovyDebuggerTest.groovy
@@ -56,7 +56,7 @@
  */
 class GroovyDebuggerTest extends GroovyCompilerTestCase {
   @Override
-  protected boolean useJps() { false }
+  protected boolean useJps() { true }
 
   @Override
   protected void setUp() {
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GrCompletionWithLibraryTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GrCompletionWithLibraryTest.groovy
index 7516575..f0a4f1a 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GrCompletionWithLibraryTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GrCompletionWithLibraryTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -227,4 +227,8 @@
   void testListCompletionVariantsFromDGM() {
     doVariantableTest('drop', 'dropWhile')
   }
+
+  public void testGStringConcatenationCompletion() {
+    myFixture.testCompletionVariants(getTestName(false) + ".groovy", "substring", "substring", "subSequence");
+  }
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyAutoPopupTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyAutoPopupTest.groovy
index 151a779..724cf40 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyAutoPopupTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyAutoPopupTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -114,10 +114,10 @@
   }
 
   public void testClassesAndPackagesInUnqualifiedImports() {
-    myFixture.addClass("package xxxxx; public class xxxxxxxxx {}")
+    myFixture.addClass("package Xxxxx; public class Xxxxxxxxx {}")
     myFixture.configureByText 'a.groovy', 'package foo; import <caret>'
-    type 'xxx'
-    assert myFixture.lookupElementStrings == ['xxxxxxxxx', 'xxxxx']
+    type 'Xxx'
+    assert myFixture.lookupElementStrings == ['Xxxxxxxxx', 'Xxxxx']
   }
 
 
@@ -139,14 +139,18 @@
     myFixture.addClass("class Foo { static class Bar {} }")
     myFixture.configureByText "a.groovy", "void foo(Foo<caret>[] a) { }"
     type '.'
-    assert !lookup
+    assert lookup
+    type '.'
+    myFixture.checkResult('void foo(Foo..<caret>[] a) { }')
   }
 
   public void testTypingFirstVarargDot2() {
     myFixture.addClass("class Foo { static class Bar {} }")
     myFixture.configureByText "a.groovy", "void foo(Foo<caret>) { }"
     type '.'
-    assert !lookup
+    assert lookup
+    type '.'
+    myFixture.checkResult('void foo(Foo..<caret>) { }')
   }
 
   public void testDotDot() {
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyClassNameCompletionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyClassNameCompletionTest.groovy
index 43fcda2..5f186b7 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyClassNameCompletionTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyClassNameCompletionTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -88,7 +88,7 @@
     addClassToProject("a", "FooBarGooDoo");
     myFixture.configureByText("a.groovy", "FBGD<caret>a")
     myFixture.complete(CompletionType.BASIC, 2)
-    myFixture.type '.'.charAt(0)
+    myFixture.type '.'
     myFixture.checkResult "a.FooBarGooDoo.<caret>a"
   }
 
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy
index eee2196..946aae9 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTest.groovy
@@ -238,10 +238,6 @@
     doBasicTest();
   }
 
-  public void testGStringConcatenationCompletion() {
-    myFixture.testCompletionVariants(getTestName(false) + ".groovy", "substring", "substring", "subSequence");
-  }
-
   public void testPropertyWithSecondUpperLetter() {
     myFixture.testCompletionVariants(getTestName(false) + ".groovy", "geteMail", "getePost");
   }
@@ -1875,4 +1871,26 @@
 
     }
   }
+
+  void testNoClassNamesInComments() {
+    doVariantableTest("""\
+class drop{}
+class dropX{}
+
+class A {
+/*
+    print dr<caret>
+*/
+}
+""", "o", CompletionType.BASIC, CompletionResult.equal, 0)
+  }
+
+  void testIntellijIdeaRulezzzNotInCompletion() {
+    doVariantableTest('''\
+def foo() {
+  def var
+  va<caret>r = 'abc'
+}
+''', '', CompletionType.BASIC, CompletionResult.notContain, 1, 'vaIntellijIdeaRulezzzr')
+  }
 }
\ No newline at end of file
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTestBase.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTestBase.groovy
index cbef31b..09e6aeb 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTestBase.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovyCompletionTestBase.groovy
@@ -56,7 +56,7 @@
     }
   }
 
-  protected void doVariantableTest(String before = null, String type = "", CompletionType ct, CompletionResult testType = CompletionResult.equal, String... variants) {
+  protected void doVariantableTest(String before = null, String type = "", CompletionType ct, CompletionResult testType = CompletionResult.equal, int completionCount = 1, String... variants) {
     if (before == null) {
       myFixture.configureByFile(getTestName(false) + ".groovy")
     }
@@ -64,7 +64,7 @@
       myFixture.configureByText(getTestName(false) + ".groovy", before)
     }
 
-    myFixture.complete(ct)
+    myFixture.complete(ct, completionCount)
     type.each { myFixture.type(it) }
 
     assertNotNull(myFixture.lookupElements)
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovySmartCompletionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovySmartCompletionTest.groovy
index 315a534..017f399 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovySmartCompletionTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/GroovySmartCompletionTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -197,4 +197,21 @@
 a(new foo.User<String>()<caret>)
 ''')
   }
+
+  void testBinaryExpr() {
+    doSmartTest('''
+class A {
+  def plus(String s) {}
+}
+
+print new A() + new <caret>
+''', '''
+class A {
+  def plus(String s) {}
+}
+
+print new A() + new String(<caret>)
+'''
+)
+  }
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/KeywordCompletionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/KeywordCompletionTest.groovy
index 127f8d1..d4bbb2e 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/KeywordCompletionTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/completion/KeywordCompletionTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -104,6 +104,9 @@
   void testElse2()               { doTest() }
   void testClassAfterAnnotation(){ doTest() }
   void testClassAfterAnno2()     { doTest() }
+  void testExtends()             { doTest() }
+  void testImplements()          { doTest() }
+  void testAfterNumberLiteral()  { doTest() }
 
   String basePath = TestUtils.testDataPath + 'groovy/oldCompletion/keyword'
 
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/inspections/GrFinalVariableAccessTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/inspections/GrFinalVariableAccessTest.groovy
index 60d3af34..0b4271f 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/inspections/GrFinalVariableAccessTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/inspections/GrFinalVariableAccessTest.groovy
@@ -448,8 +448,9 @@
 
 @Immutable
 class Money {
-    String <warning>currency</warning>
-    int <warning>amount</warning>
+    String currency
+    int amount
+    private final <warning>privateField</warning>
 
     void doubleYourMoney() {
         <error>amount</error> *= 2
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertMapToClassTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertMapToClassTest.java
index 89edcef..14d064e 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertMapToClassTest.java
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertMapToClassTest.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2010 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
 package org.jetbrains.plugins.groovy.intentions;
 
 import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.command.WriteCommandAction;
 import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.util.PsiTreeUtil;
@@ -79,7 +79,7 @@
     final GrTypeDefinition foo = ConvertMapToClassIntention.createClass(getProject(), map.getNamedArguments(), "", "Foo");
     myFixture.addFileToProject(getTestName(true) + "/Foo.groovy", foo.getContainingFile().getText());
     final PsiClass psiClass = myFixture.findClass("Foo");
-    ApplicationManager.getApplication().runWriteAction(new Runnable() {
+    WriteCommandAction.runWriteCommandAction(null, new Runnable() {
       public void run() {
         ConvertMapToClassIntention
           .replaceMapWithClass(getProject(), map, psiClass, ConvertMapToClassIntention.checkForReturnFromMethod(map),
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/CreateFieldFromParameterTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/CreateFieldFromParameterTest.groovy
index 8156066..88f2e0e 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/CreateFieldFromParameterTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/CreateFieldFromParameterTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,12 +14,11 @@
  * limitations under the License.
  */
 package org.jetbrains.plugins.groovy.intentions
-
 import com.intellij.codeInsight.intention.impl.config.IntentionActionWrapper
+import com.intellij.openapi.command.WriteCommandAction
 import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
 import org.jetbrains.plugins.groovy.intentions.declaration.GrCreateFieldForParameterIntention
 import org.jetbrains.plugins.groovy.util.TestUtils
-
 /**
  * @author Max Medvedev
  */
@@ -56,8 +55,12 @@
     for (intention in intentions) {
       if (intention instanceof IntentionActionWrapper) intention = intention.delegate
       if (intention instanceof GrCreateFieldForParameterIntention) {
-        intention.invoke(myFixture.project, myFixture.editor, myFixture.file)
-        doPostponedFormatting(project)
+        WriteCommandAction.runWriteCommandAction(null, new Runnable() {
+          void run() {
+            intention.invoke(myFixture.project, myFixture.editor, myFixture.file)
+            doPostponedFormatting(myFixture.project)
+          }
+        })
         break
       }
     }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/GrIntentionTestCase.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/GrIntentionTestCase.groovy
index ef44b48..99143c2 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/GrIntentionTestCase.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/GrIntentionTestCase.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 import com.intellij.util.Function
 import org.jetbrains.annotations.NotNull
 import org.jetbrains.annotations.Nullable
+import org.jetbrains.plugins.groovy.intentions.base.Intention
 
 /**
  * @author Maxim.Medvedev
@@ -39,6 +40,11 @@
     myHint = hint
   }
 
+  GrIntentionTestCase(@NotNull Class<? extends IntentionAction> intention) {
+    myInspections = []
+    myHint = intention.newInstance().text
+  }
+
   protected void doTest(@NotNull String hint = myHint, boolean intentionExists) {
     assertNotNull(hint)
     myFixture.configureByFile(getTestName(false) + ".groovy");
@@ -48,8 +54,8 @@
       PostprocessReformattingAspect.getInstance(project).doPostponedFormatting();
       myFixture.checkResultByFile(getTestName(false) + "_after.groovy");
     }
-    else if (list.size() > 0) {
-      fail StringUtil.join(list, {it.familyName} as Function<IntentionAction, String>, ',')
+    else if (!list.empty) {
+      fail StringUtil.join(list, {IntentionAction it -> it.familyName}, ',')
     }
   }
 
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/GrSortMapTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/GrSortMapTest.groovy
new file mode 100644
index 0000000..86b0769
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/GrSortMapTest.groovy
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.intentions
+
+import org.jetbrains.plugins.groovy.intentions.other.GrSortMapKeysIntention
+import org.jetbrains.plugins.groovy.util.TestUtils
+
+/**
+ * Created by Max Medvedev on 11/01/14
+ */
+class GrSortMapTest extends GrIntentionTestCase {
+  GrSortMapTest() {
+    super(GrSortMapKeysIntention)
+  }
+
+  @Override
+  protected String getBasePath() {
+    TestUtils.testDataPath + 'intentions/sortMap/'
+  }
+
+  public void testBasicMapSort() throws Exception {
+    doTest(true)
+  }
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/RemoveExplicitTypeDeclarationTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/RemoveExplicitTypeDeclarationTest.groovy
new file mode 100644
index 0000000..6eeea4f
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/RemoveExplicitTypeDeclarationTest.groovy
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.intentions
+
+import org.jetbrains.plugins.groovy.intentions.declaration.GrRemoveExplicitTypeDeclarationIntention
+import org.jetbrains.plugins.groovy.util.TestUtils
+
+/**
+ * Created by Max Medvedev on 27/12/13
+ */
+class RemoveExplicitTypeDeclarationTest extends GrIntentionTestCase {
+  def RemoveExplicitTypeDeclarationTest() {
+    super(GrRemoveExplicitTypeDeclarationIntention)
+  }
+
+  final String basePath = TestUtils.testDataPath + 'intentions/removeExplicitTypeDeclaration/'
+
+  void testMethod1() { doTest(true) }
+  void testMethod2() { doTest(true) }
+  void testMethod3() { doTest(true) }
+  void testMethod4() { doTest(true) }
+  void testMethod5() { doTest(true) }
+
+
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GppFunctionalTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GppFunctionalTest.groovy
index 3287b76..39e4703 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GppFunctionalTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GppFunctionalTest.groovy
@@ -405,41 +405,6 @@
     assertEquals 1, multiResolveReference().size()
   }
 
-  public void testGotoSuperConstructorFromLiteralOnsets() throws Exception {
-    PsiClass point = myFixture.addClass("""
-class Point {
-  Point() {}
-  Point(int y) {}
-}""")
-
-    configureGppScript "Point p = <caret>[super: 2]"
-    assertEquals point.constructors[1], resolveReference()
-
-    configureGppScript "Point p = <caret>[2]"
-    assertEquals point.constructors[1], resolveReference()
-
-    configureGppScript "Point p = <caret>[]"
-    assertEquals point.constructors[0], resolveReference()
-
-    configureGppScript "Point p = <caret>[:]"
-    assertEquals point.constructors[0], resolveReference()
-
-    configureGppScript "Point p = <caret>[239, 42]"
-    assertEquals 2, multiResolveReference().size()
-
-    configureGppScript """
-def foo(Point p) {}
-foo(<caret>[2, 3])
-"""
-    assertEquals 2, multiResolveReference().size()
-
-    configureGppScript """
-def foo(Point... p) {}
-foo(<caret>['super':[2, 3]])
-"""
-    assertEquals 2, multiResolveReference().size()
-  }
-
   public void testGotoClassFromLiteralOnsetsWhenNoConstructorsPresent() throws Exception {
     PsiClass point = myFixture.addClass(""" class Point { }""")
     configureGppScript "Point p = <caret>[super: 2]"
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyFixesTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyFixesTest.groovy
index b5fa168..ac83d7d 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyFixesTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyFixesTest.groovy
@@ -14,7 +14,8 @@
  * limitations under the License.
  */
 package org.jetbrains.plugins.groovy.lang
-import com.intellij.openapi.application.ApplicationManager
+
+import com.intellij.openapi.command.WriteCommandAction
 import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
 import org.jetbrains.plugins.groovy.codeInspection.control.GroovyConstantIfStatementInspection
 import org.jetbrains.plugins.groovy.codeInspection.style.JavaStylePropertiesInvocationInspection
@@ -99,7 +100,7 @@
 
 class Foo {}
 ''')
-    ApplicationManager.application.runWriteAction { ((GroovyFile) myFixture.file).packageName = 'foo' }
+    WriteCommandAction.runWriteCommandAction project, { ((GroovyFile)myFixture.file).packageName = 'foo' }
     myFixture.checkResult '''\
 #!/usr/bin/groovy
 package foo
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyLiveTemplatesTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyLiveTemplatesTest.groovy
index 789e35e..e67b07c 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyLiveTemplatesTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyLiveTemplatesTest.groovy
@@ -1,9 +1,19 @@
 /*
- * Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
- * Use is subject to license terms.
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
-package org.jetbrains.plugins.groovy.lang;
-
+package org.jetbrains.plugins.groovy.lang
 
 import com.intellij.codeInsight.lookup.Lookup
 import com.intellij.codeInsight.lookup.LookupManager
@@ -12,10 +22,10 @@
 import com.intellij.codeInsight.template.impl.TemplateManagerImpl
 import com.intellij.codeInsight.template.impl.TemplateSettings
 import com.intellij.codeInsight.template.impl.actions.ListTemplatesAction
+import com.intellij.openapi.command.WriteCommandAction
 import com.intellij.openapi.editor.Editor
 import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
 import org.jetbrains.plugins.groovy.util.TestUtils
-
 /**
  * @author peter
  */
@@ -58,8 +68,13 @@
   }
 
   public static void expandTemplate(final Editor editor) {
-    new ListTemplatesAction().actionPerformedImpl(editor.getProject(), editor);
-    ((LookupImpl)LookupManager.getActiveLookup(editor)).finishLookup(Lookup.NORMAL_SELECT_CHAR);
+    WriteCommandAction.runWriteCommandAction(null, new Runnable() {
+      @Override
+      void run() {
+        new ListTemplatesAction().actionPerformedImpl(editor.getProject(), editor);
+        ((LookupImpl)LookupManager.getActiveLookup(editor)).finishLookup(Lookup.NORMAL_SELECT_CHAR);
+      }
+    })
   }
 
   public void testGroovyStatementContext() throws Exception {
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyRegexFindExpressionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyRegexFindExpressionTest.groovy
index 617dd41..73ea917 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyRegexFindExpressionTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyRegexFindExpressionTest.groovy
@@ -53,4 +53,10 @@
 
     myFixture.checkHighlighting(true, false, true)
   }
+
+  public void testRegex() {
+    myFixture.configureByText('a.groovy', '\'foo\' =~ /\\s/')
+    myFixture.checkHighlighting(true, false, true)
+  }
+
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyStressPerformanceTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyStressPerformanceTest.groovy
index 648617c..fcc821a 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyStressPerformanceTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyStressPerformanceTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -135,6 +135,21 @@
     measureHighlighting(defs + text, 10000)
   }
 
+  public void testDeeplyNestedClosuresInCompileStatic() {
+    RecursionManager.assertOnRecursionPrevention(testRootDisposable)
+
+    String text = "println 'hi'"
+    String defs = ""
+    for (i in 1..10) {
+      text = "foo$i {a = 5; $text }"
+      defs += "def foo$i(Closure cl) {}\n"
+    }
+    myFixture.enableInspections(new MissingReturnInspection())
+
+    addCompileStatic()
+    measureHighlighting(defs + "\n @groovy.transform.CompileStatic def compiledStatically() {\ndef a = ''\n" + text + "\n}", 10000)
+  }
+
   public void testDeeplyNestedClosuresInGenericCalls() {
     RecursionManager.assertOnRecursionPrevention(testRootDisposable)
     String text = "println it"
@@ -142,7 +157,8 @@
       text = "foo(it) { $text }"
     }
     myFixture.enableInspections(new MissingReturnInspection())
-    measureHighlighting("def <T> foo(T t, Closure cl) {}\n" + text, 10000)
+
+    measureHighlighting("def <T> void foo(T t, Closure cl) {}\n$text", 10000)
   }
 
   public void testDeeplyNestedClosuresInGenericCalls2() {
@@ -152,7 +168,7 @@
       text = "foo(it) { $text }"
     }
     myFixture.enableInspections(new MissingReturnInspection())
-    measureHighlighting("def <T> foo(T t, Closure<T> cl) {}\n" + text, 10000)
+    measureHighlighting("def <T> void foo(T t, Closure<T> cl) {}\n$text", 10000)
   }
 
   public void testManyAnnotatedScriptVariables() {
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/LiteralConstructorUsagesTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/LiteralConstructorUsagesTest.groovy
index d24fa7d..f56c2cb 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/LiteralConstructorUsagesTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/LiteralConstructorUsagesTest.groovy
@@ -42,7 +42,7 @@
     myFixture.addFileToProject "a.gpp", "Foo x = []"
     assertOneElement(ReferencesSearch.search(foo.constructors[0]).findAll())
   }
-  
+
   public void testList_ReturnValue() throws Exception {
     def foo = myFixture.addClass("""class Foo {
     Foo() {}
@@ -97,98 +97,6 @@
     assertEquals(2, ReferencesSearch.search(foo.constructors[0]).findAll().size())
   }
 
-  public void testList_GppMethodCall() throws Exception {
-    //------------------------declarations
-    def foo = myFixture.addClass("""
-    package z;
-    class Foo {
-        public Foo() {}
-    }
-    """)
-
-    myFixture.addClass("""
-    package z;
-    public class Bar {
-      public static void giveMeFoo(int a, Foo f) {}
-    }
-""")
-    myFixture.addFileToProject("Decl.groovy", "static def giveMeFooAsWell(z.Foo f) {}")
-
-    //----------------------usages
-    myFixture.addFileToProject "a.gpp", "z.Bar.giveMeFoo(2, []) //usage"
-    myFixture.addFileToProject "b.groovy", """
-      @Typed package aa;
-      z.Bar.giveMeFoo(3, []) //usage
-      """
-    myFixture.addFileToProject "c.groovy", """
-      @Typed def someMethod() {
-        z.Bar.giveMeFoo 4, [] //usage
-        Decl.giveMeFooAsWell([]) //usage
-      }
-      z.Bar.giveMeFoo 5, [] //non-typed context
-      Decl.giveMeFooAsWell([])
-      """
-    myFixture.addFileToProject "invalid.gpp", "z.Bar.giveMeFoo 42, 239, []"
-    myFixture.addFileToProject "nonGpp.groovy", "z.Bar.giveMeFoo(6, [])"
-    assertEquals(4, ReferencesSearch.search(foo.constructors[0]).findAll().size())
-  }
-
-  public void testList_GppConstructorCallWithSeveralParameters() throws Exception {
-    def foo = myFixture.addClass("""
-      class Foo {
-          Foo() {}
-      }
-      """)
-
-    myFixture.addClass("""
-    class Bar {
-      Bar(Foo f1, Foo f2, Foo f3) {}
-    }
-    """)
-    myFixture.addFileToProject "a.gpp", "new Bar([],[],[])"
-    assertEquals(3, ReferencesSearch.search(foo.constructors[0]).findAll().size())
-  }
-
-  public void testMap_GppOverloads() throws Exception {
-    def foo = myFixture.addClass("""
-      class Foo {
-          Foo() {}
-          Foo(int a) {}
-      }
-      """)
-
-    myFixture.addClass("""
-    class Bar {
-      static void foo(Foo f1, Foo f2) {}
-    }
-    """)
-    myFixture.addFileToProject "a.gpp", "Bar.foo([:], [super:2])"
-    assertEquals(1, ReferencesSearch.search(foo.constructors[0]).findAll().size())
-    assertEquals(1, ReferencesSearch.search(foo.constructors[1]).findAll().size())
-  }
-  
-  public void testGppCallVarargs() throws Exception {
-    def foo = myFixture.addClass("""
-      class Foo {
-          Foo() {}
-          Foo(int a) {}
-      }
-      """)
-
-    myFixture.addClass("""
-    class Bar {
-      static void foo(Foo f1, Foo f2) {}
-      static void doo(int a, Foo f1, Foo f2) {}
-    }
-    """)
-    myFixture.addFileToProject "a.gpp", """
-      Bar.foo([:], [super:2])
-      Bar.doo 3, [:], [super:2]
-      """
-    assertEquals(2, ReferencesSearch.search(foo.constructors[0]).findAll().size())
-    assertEquals(2, ReferencesSearch.search(foo.constructors[1]).findAll().size())
-  }
-
   public void testOverloadedConstructorUsages() throws Exception {
     def foo = myFixture.addClass("""
       class Foo {
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/controlFlow/ControlFlowTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/controlFlow/ControlFlowTest.groovy
index f90d2c5..859b81a 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/controlFlow/ControlFlowTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/controlFlow/ControlFlowTest.groovy
@@ -81,6 +81,7 @@
   public void testBinaryExpressionInReturn() { doTest() }
   public void testPendingFromIf() { doTest() }
   public void testSwitchWithEmptyCaseBeforeDefault() { doTest() }
+  public void testUnfinishedAssignment() { doTest() }
 
   public void doTest() {
     final List<String> input = TestUtils.readInput(testDataPath + getTestName(true) + ".test");
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy
index ba19392..01cb0f7 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 
 import com.intellij.openapi.util.text.StringUtil
 import com.intellij.psi.codeStyle.CommonCodeStyleSettings
+import org.jetbrains.plugins.groovy.GroovyFileType
 import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings
 import org.jetbrains.plugins.groovy.util.TestUtils
 /**
@@ -35,6 +36,7 @@
   public void testArg2() throws Throwable { doTest(); }
   public void testBin1() throws Throwable { doTest(); }
   public void testBin2() throws Throwable { doTest(); }
+  public void testBin3() throws Throwable { doTest(); }
   public void testBlockExpr1() throws Throwable {
     //groovySettings.KEEP_CONTROL_STATEMENT_IN_ONE_LINE = false
     groovySettings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false
@@ -711,6 +713,15 @@
 '''
   }
 
+  void testConditional2() {
+    groovySettings.ALIGN_MULTILINE_TERNARY_OPERATION = true
+    checkFormatting('''\
+print abc ? cde
+:xyz''', '''\
+print abc ? cde
+          : xyz''')
+  }
+
   void testLabelsInBasicMode() {
     groovySettings.indentOptions.INDENT_SIZE = 4
     groovySettings.indentOptions.LABEL_INDENT_SIZE = -2
@@ -761,15 +772,41 @@
     checkFormatting('foo in  bar', 'foo in bar')
   }
 
-  private void doGeeseTest() {
-    GroovyCodeStyleSettings customSettings = myTempSettings.getCustomSettings(GroovyCodeStyleSettings.class);
-    boolean oldvalue = customSettings.USE_FLYING_GEESE_BRACES;
+  void testGDocAfterImports() { doTest() }
+  void testGroovyDocAfterImports2() { doTest() }
+
+  void testRegexExpressions() { doTest() }
+
+  void testSpreadArg() { doTest() }
+
+  void testExtraLines() { doTest() }
+
+  void testLabelWithDescription() {
+    GroovyCodeStyleSettings customSettings = myTempSettings.getCustomSettings(GroovyCodeStyleSettings.class)
+    CommonCodeStyleSettings commonSettings = myTempSettings.getCommonSettings(GroovyFileType.GROOVY_LANGUAGE)
+
+    boolean indentLabelBlocks = customSettings.INDENT_LABEL_BLOCKS
+    int labelIndentSize = commonSettings.indentOptions.LABEL_INDENT_SIZE
     try {
-      customSettings.USE_FLYING_GEESE_BRACES = true;
-      doTest();
+      customSettings.INDENT_LABEL_BLOCKS = true
+      commonSettings.indentOptions.LABEL_INDENT_SIZE = 2
+      doTest()
     }
     finally {
-      customSettings.USE_FLYING_GEESE_BRACES = oldvalue;
+      customSettings.INDENT_LABEL_BLOCKS = indentLabelBlocks
+      commonSettings.indentOptions.LABEL_INDENT_SIZE = labelIndentSize
+    }
+  }
+
+  private void doGeeseTest() {
+    GroovyCodeStyleSettings customSettings = myTempSettings.getCustomSettings(GroovyCodeStyleSettings.class)
+    boolean oldvalue = customSettings.USE_FLYING_GEESE_BRACES
+    try {
+      customSettings.USE_FLYING_GEESE_BRACES = true
+      doTest()
+    }
+    finally {
+      customSettings.USE_FLYING_GEESE_BRACES = oldvalue
     }
   }
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityClosureToSamTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityClosureToSamTest.groovy
index 4464172..0d2e739 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityClosureToSamTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityClosureToSamTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -65,7 +65,8 @@
 A<String> a1 = {print 1}
 A<String> a2 = {String s -> print 1}
 A<String> <warning>a3</warning> = {int s -> print 1}
-A <warning>a4</warning> = {int s -> print 1}
+A a4 = {int s -> print 1}
+A a7 = {int s, String y -> print 1}
 A a5 = { print 1}
 A a6 = {x -> print 1}
 ''')
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy
index 0709db7..03ac29a 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrAssignabilityTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -368,7 +368,7 @@
 foo<warning descr="'foo' in '_' cannot be applied to '(Function<java.lang.Double,java.lang.Double>)'">({println  it.byteValue()} as Function<Double, Double>)</warning>
 foo({println  it.substring(1)} as Function)
 foo({println  it.substring(1)} as Function<String, String>)
-foo<warning descr="'foo' in '_' cannot be applied to '(groovy.lang.Closure<java.lang.Void>)'">({println  it})</warning>
+foo<warning descr="'foo' in '_' cannot be applied to '(groovy.lang.Closure)'">({println  it})</warning>
 
 ''')
   }
@@ -799,4 +799,20 @@
 }
 ''')
   }
+
+  void testBinaryOperatorApplicability() {
+    testHighlighting('''\
+void bug(Collection<String> foo, Collection<String> bar) {
+    foo <warning descr="'leftShift' in 'org.codehaus.groovy.runtime.DefaultGroovyMethods' cannot be applied to '(java.util.Collection<java.lang.String>)'"><<</warning> bar   // warning missed
+    foo << "a"
+}''')
+  }
+
+  void testPlusIsApplicable() {
+    testHighlighting('''\
+print 1 + 2
+
+print 4 <warning descr="'plus' in 'org.codehaus.groovy.runtime.StringGroovyMethods' cannot be applied to '(java.util.ArrayList)'">+</warning> new ArrayList()
+''')
+  }
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrInspectionTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrInspectionTest.groovy
index efed43e..2b9ecad 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrInspectionTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GrInspectionTest.groovy
@@ -20,10 +20,13 @@
 import org.jetbrains.plugins.groovy.codeInspection.confusing.*
 import org.jetbrains.plugins.groovy.codeInspection.control.GroovyTrivialConditionalInspection
 import org.jetbrains.plugins.groovy.codeInspection.control.GroovyTrivialIfInspection
+import org.jetbrains.plugins.groovy.codeInspection.control.GroovyUnnecessaryContinueInspection
 import org.jetbrains.plugins.groovy.codeInspection.control.GroovyUnnecessaryReturnInspection
 import org.jetbrains.plugins.groovy.codeInspection.declaration.GrMethodMayBeStaticInspection
+import org.jetbrains.plugins.groovy.codeInspection.exception.GroovyEmptyCatchBlockInspection
 import org.jetbrains.plugins.groovy.codeInspection.metrics.GroovyOverlyLongMethodInspection
 import org.jetbrains.plugins.groovy.codeInspection.noReturnMethod.MissingReturnInspection
+import org.jetbrains.plugins.groovy.codeInspection.threading.GroovyUnconditionalWaitInspection
 import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection
 import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GroovyUntypedAccessInspection
 /**
@@ -149,7 +152,7 @@
 test() {
     def var = "abc"
     def cl = {
-        <warning descr="Local variable var is reassigned in closure with other type">var</warning> = new Date()
+        <warning descr="Local variable 'var' is reassigned">var</warning> = new Date()
     }
     cl()
     var.toUpperCase()
@@ -158,7 +161,7 @@
 test2() {
     def var = "abc"
     def cl = {
-        var = 'cde'
+        <warning descr="Local variable 'var' is reassigned">var</warning> = 'cde'
     }
     cl()
     var.toUpperCase()
@@ -277,4 +280,71 @@
 
 ''', DelegatesToInspection)
   }
+
+  void testUnnecessaryContinue() {
+    testHighlighting('''
+for(i in []) {
+  print 2
+  <warning descr="continue is unnecessary as the last statement in a loop">continue</warning>
+}
+
+for(i in []) {
+  print 2
+  continue
+  print 3
+}
+
+for(i in []) {
+  print 2
+  switch(i) {
+    case not_last:
+      continue
+    case last:
+      <warning descr="continue is unnecessary as the last statement in a loop">continue</warning>
+  }
+}
+
+for(i in []) {
+  if (cond) {
+      print 2
+      <warning descr="continue is unnecessary as the last statement in a loop">continue</warning>
+  }
+  else {
+    continue
+    print 4
+  }
+}
+''', GroovyUnnecessaryContinueInspection)
+  }
+
+  void testEmptyCatchBlock1() {
+    testHighlighting('''
+try{} <warning descr="Empty 'catch' block">catch</warning>(IOException e) {}
+try{} catch(IOException ignored) {}
+try{} catch(IOException ignore) {}
+try{} catch(IOException e) {/*comment*/}
+''', GroovyEmptyCatchBlockInspection)
+  }
+
+  void testEmptyCatchBlock2() {
+    GroovyEmptyCatchBlockInspection inspection = new GroovyEmptyCatchBlockInspection()
+    inspection.myIgnore = false
+    myFixture.enableInspections(inspection)
+    testHighlighting('try{} <warning descr="Empty \'catch\' block">catch</warning>(IOException ignored) {}')
+  }
+
+  void testEmptyCatchBlock3() {
+    GroovyEmptyCatchBlockInspection inspection = new GroovyEmptyCatchBlockInspection()
+    inspection.myIgnore = false
+    myFixture.enableInspections(inspection)
+    testHighlighting('try{} <warning descr="Empty \'catch\' block">catch</warning>(IOException ignored) {}')
+  }
+
+  void testEmptyCatchBlock4() {
+    GroovyEmptyCatchBlockInspection inspection = new GroovyEmptyCatchBlockInspection()
+    inspection.myCountCommentsAsContent = false
+    myFixture.enableInspections(inspection)
+    testHighlighting('try{} <warning descr="Empty \'catch\' block">catch</warning>(IOException e) {/*comment*/}')
+  }
+
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/Groovy23HighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/Groovy23HighlightingTest.groovy
new file mode 100644
index 0000000..3df6895
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/Groovy23HighlightingTest.groovy
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.highlighting
+
+import com.intellij.codeInspection.InspectionProfileEntry
+import com.intellij.testFramework.LightProjectDescriptor
+import org.jetbrains.annotations.NotNull
+import org.jetbrains.plugins.groovy.GroovyLightProjectDescriptor
+import org.jetbrains.plugins.groovy.codeInspection.assignment.GroovyAssignabilityCheckInspection
+import org.jetbrains.plugins.groovy.codeInspection.untypedUnresolvedAccess.GrUnresolvedAccessInspection
+
+/**
+ * Created by Max Medvedev on 17/02/14
+ */
+class Groovy23HighlightingTest extends GrHighlightingTestBase {
+
+  @Override
+  @NotNull
+  protected LightProjectDescriptor getProjectDescriptor() {
+    return GroovyLightProjectDescriptor.GROOVY_2_3;
+  }
+
+  void testSam1() {
+    testHighlighting('''
+interface Action<T, X> {
+    void execute(T t, X x)
+}
+
+public <T, X> void exec(T t, Action<T, X> f, X x) {
+}
+
+def foo() {
+    exec('foo', { String t, Integer x -> ; }, 1)
+    exec<warning descr="'exec' in '_' cannot be applied to '(java.lang.String, groovy.lang.Closure<java.lang.Void>, java.lang.Integer)'">('foo', { Integer t, Integer x -> ; }, 1)</warning>
+}
+''')
+  }
+
+  void testSam2() {
+    testHighlighting('''
+interface Action<T> {
+    void execute(T t)
+}
+
+public <T> void exec(T t, Action<T> f) {
+}
+
+def foo() {
+    exec('foo') {print it.toUpperCase() ;print 2 }
+    exec('foo') {print it.<warning descr="Cannot resolve symbol 'intValue'">intValue</warning>() ;print 2 }
+}
+''')
+  }
+
+  void testSam3() {
+    testHighlighting('''
+ interface Action<T, X> {
+    void execute(T t, X x)
+}
+
+public <T, X> void exec(T t, Action<T, X> f, X x) {
+    f.execute(t, x)
+}
+
+def foo() {
+    exec('foo', { String s, Integer x -> print s + x }, 1)
+    exec<warning descr="'exec' in '_' cannot be applied to '(java.lang.String, groovy.lang.Closure, java.lang.Integer)'">('foo', { Integer s, Integer x -> print 9 }, 1)</warning>
+}
+''')
+  }
+
+  final InspectionProfileEntry[] customInspections = [new GroovyAssignabilityCheckInspection(), new GrUnresolvedAccessInspection()]
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy
index 31c881f..0405449 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/highlighting/GroovyHighlightingTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -576,13 +576,13 @@
 ''')
   }
 
-  void testReassignedVarInClosure() {
+  void testReassignedVarInClosure1() {
     addCompileStatic()
     testHighlighting("""
 $IMPORT_COMPILE_STATIC
 
 @CompileStatic
-test() {
+def test() {
     def var = "abc"
     def cl = {
         var = new Date()
@@ -593,6 +593,65 @@
 """, GrUnresolvedAccessInspection)
   }
 
+  void testReassignedVarInClosure2() {
+    addCompileStatic()
+    testHighlighting("""
+$IMPORT_COMPILE_STATIC
+
+@CompileStatic
+def test() {
+    def cl = {
+        def var
+        var = new Date()
+    }
+    def var = "abc"
+
+    cl()
+    var.toUpperCase()  //no errors
+}
+""", GrUnresolvedAccessInspection)
+  }
+
+  void testReassignedVarInClosure3() {
+    addCompileStatic()
+    testHighlighting("""
+$IMPORT_COMPILE_STATIC
+
+@CompileStatic
+def test() {
+    def var = "abc"
+    def cl = new Closure(this, this){
+      def call() {
+        var = new Date()
+      }
+    }
+    cl()
+    var.toUpperCase() //no errors
+}
+""", GrUnresolvedAccessInspection)
+  }
+
+  void testReassignedVarInClosure4() {
+    addCompileStatic()
+    testHighlighting("""
+$IMPORT_COMPILE_STATIC
+
+class X {
+  def var
+}
+
+@CompileStatic
+def test() {
+    def var = "abc"
+    new X().with {
+        var = new Date()
+    }
+
+    var.<error descr="Cannot resolve symbol 'toUpperCase'">toUpperCase</error>()
+}
+""", GrUnresolvedAccessInspection)
+  }
+
   void testOverrideForVars() {
     testHighlighting('''\
 class S {
@@ -1413,15 +1472,15 @@
 
   void testSOEIfExtendsItself() {
     testHighlighting('''\
-<error descr="Cyclic inheritance involving 'A'"><error descr="Method 'invokeMethod' is not implemented">class A extends A </error></error>{
+<error descr="Cyclic inheritance involving 'A'"><error descr="Method 'invokeMethod' is not implemented">class A extends A</error></error> {
   def foo
 }
 
-<error descr="Cyclic inheritance involving 'B'"><error descr="Method 'invokeMethod' is not implemented">class B extends C </error></error>{
+<error descr="Cyclic inheritance involving 'B'"><error descr="Method 'invokeMethod' is not implemented">class B extends C</error></error> {
   def foo
 }
 
-<error descr="Cyclic inheritance involving 'C'"><error descr="Method 'invokeMethod' is not implemented">class C extends B </error></error>{
+<error descr="Cyclic inheritance involving 'C'"><error descr="Method 'invokeMethod' is not implemented">class C extends B</error></error> {
 }
 ''')
   }
@@ -1584,7 +1643,7 @@
 }
 ''')
     testHighlighting('''\
-<error>class Foo extends p.Base </error>{
+<error>class Foo extends p.Base</error> {
 }
 ''')
   }
@@ -1645,6 +1704,89 @@
   <error>private foo()</error>{}
   <error>def foo(int x)</error> {}
 }
+
+class Z {
+ private Z() {}   //correct
+ private Z(x) {}  //correct
+}
 ''')
   }
+
+  void testImmutable() {
+    testHighlighting('''\
+import groovy.transform.Immutable
+
+@Immutable
+class A {
+  String immutable
+  private String mutable
+
+  def foo() {
+    <error descr="Cannot assign a value to final field 'immutable'">immutable</error> = 5
+    mutable = 5
+
+  }
+}
+''')
+  }
+
+  void testConstructorInImmutable() {
+    testHighlighting('''\
+import groovy.transform.Immutable
+
+@Immutable
+class A {
+  String immutable
+  private String mutable
+
+  def <error descr="Explicit constructors are not allowed for @Immutable class">A</error>() {}
+}
+''')
+  }
+
+  void testGetterInImmutable() {
+    testHighlighting('''\
+import groovy.transform.Immutable
+
+@Immutable
+class A {
+  String immutable
+  private String mutable
+
+  String <error descr="Repetitive method name 'getImmutable'">getImmutable</error>() {immutable}
+  String getMutable() {mutable}
+}
+''')
+  }
+
+  void testGetterInImmutable2() {
+    testHighlighting('''\
+import groovy.transform.Immutable
+
+@Immutable
+class A {
+  String immutable
+
+  int <error descr="Repetitive method name 'getImmutable'">getImmutable</error>() {1}
+}
+''')
+  }
+
+  void testMinusInAnnotationArg() {
+    testHighlighting('''\
+@interface Xx {
+    int value()
+}
+
+@Xx(-1)
+public class Bar1 { }
+
+@Xx(+1)
+public class Bar2 { }
+
+@Xx(<error descr="Expected '++1' to be an inline constant">++1</error>)
+public class Bar3 { }
+''')
+  }
+
 }
\ No newline at end of file
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/overriding/GroovyOverrideImplementTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/overriding/GroovyOverrideImplementTest.groovy
index 4dba591..f31a6e3 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/overriding/GroovyOverrideImplementTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/overriding/GroovyOverrideImplementTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
  */
 package org.jetbrains.plugins.groovy.lang.overriding
 import com.intellij.codeInsight.generation.OverrideImplementUtil
-import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.command.WriteCommandAction
 import com.intellij.psi.JavaPsiFacade
 import com.intellij.psi.PsiClassOwner
 import com.intellij.psi.PsiMethod
@@ -99,8 +99,8 @@
 """
   }
 
-  void testTrhowsList() {
-    myFixture.configureByText('a.groovy', '''\
+  void testThrowsList() {
+    assertImplement('''\
 class X implements I {
     <caret>
 }
@@ -108,11 +108,7 @@
 interface I {
     void foo() throws RuntimeException
 }
-''')
-
-    generateImplementation(findMethod('I', 'foo'))
-
-    myFixture.checkResult('''\
+''', 'I', 'foo', '''\
 class X implements I {
 
     @Override
@@ -127,6 +123,80 @@
 ''')
   }
 
+  private void assertImplement(String textBefore, String clazz, String name, String textAfter) {
+    myFixture.configureByText('a.groovy', textBefore)
+    generateImplementation(findMethod(clazz, name))
+    myFixture.checkResult(textAfter)
+  }
+
+  void testThrowsListWithImport() {
+    myFixture.addClass('''\
+package pack;
+public class Exc extends RuntimeException {}
+''')
+
+    myFixture.addClass('''\
+import pack.Exc;
+
+interface I {
+    void foo() throws Exc;
+}
+''')
+
+    myFixture.configureByText('a.groovy', '''\
+class X implements I {
+    <caret>
+}
+''')
+
+    generateImplementation(findMethod('I', 'foo'))
+
+    myFixture.checkResult('''\
+import pack.Exc
+
+class X implements I {
+
+    @Override
+    void foo() throws Exc {
+
+    }
+}
+''')
+  }
+
+  void testNullableParameter() {
+    myFixture.addClass('''
+package org.jetbrains.annotations;
+public @interface Nullable{}
+''')
+
+    assertImplement('''
+import org.jetbrains.annotations.Nullable
+
+class Inheritor implements I {
+  <caret>
+}
+
+interface I {
+  def foo(@Nullable p)
+}
+''', 'I', 'foo', '''
+import org.jetbrains.annotations.Nullable
+
+class Inheritor implements I {
+
+    @Override
+    def foo(@Nullable Object p) {
+        <caret>return null
+    }
+}
+
+interface I {
+  def foo(@Nullable p)
+}
+''')
+  }
+
   public void _testImplementIntention() {
     myFixture.configureByText('a.groovy', '''
 class Base<E> {
@@ -145,7 +215,7 @@
   }
 
   private def generateImplementation(PsiMethod method) {
-    ApplicationManager.application.runWriteAction {
+    WriteCommandAction.runWriteCommandAction project, {
       GrTypeDefinition clazz = (myFixture.file as PsiClassOwner).classes[0] as GrTypeDefinition
       OverrideImplementUtil.overrideOrImplement(clazz, method);
       PostprocessReformattingAspect.getInstance(myFixture.project).doPostponedFormatting()
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy
index 7e9e03c..5d933e7 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -254,6 +254,7 @@
   public void testreferences$ref5() throws Throwable { doTest(); }
   public void testreferences$ref6() throws Throwable { doTest(); }
   public void testreferences$ref7() throws Throwable { doTest(); }
+  public void testreferences$ref8() throws Throwable { doTest(); }
   public void testreferences$emptyTypeArgs() { doTest() }
 
   public void testregex$chen() throws Throwable { doTest(); }
@@ -296,6 +297,10 @@
 
   public void testregex$regex23() throws Throwable { doTest(); }
 
+  public void testregex$regex24() throws Throwable { doTest(); }
+
+  public void testregex$regex25() throws Throwable { doTest(); }
+
   public void testregex$regex3() throws Throwable { doTest(); }
 
   public void testregex$regex33() throws Throwable { doTest(); }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/StatementsParsingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/StatementsParsingTest.groovy
index f4086fe..98a5cf5 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/StatementsParsingTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/StatementsParsingTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -72,6 +72,7 @@
   public void testFor$for10() throws Throwable { doTest(); }
   public void testFor$for11() throws Throwable { doTest(); }
   public void testFor$for12() throws Throwable { doTest(); }
+  public void testFor$for13() throws Throwable { doTest(); }
   public void testFor$for2() throws Throwable { doTest(); }
   public void testFor$for3() throws Throwable { doTest(); }
   public void testFor$for4() throws Throwable { doTest(); }
@@ -94,6 +95,7 @@
   public void testImports$imp5() throws Throwable { doTest(); }
   public void testImports$imp6() throws Throwable { doTest(); }
   public void testImports$imp7() throws Throwable { doTest(); }
+  public void testImports$imp8() throws Throwable { doTest(); }
   public void testKing_regex$king1() throws Throwable { doTest(); }
   public void testKing_regex$king2() throws Throwable { doTest(); }
   public void testKing_regex$king3() throws Throwable { doTest(); }
@@ -105,7 +107,6 @@
   public void testLoop$while2() throws Throwable { doTest(); }
   public void testLoop$while3() throws Throwable { doTest(); }
   public void testLoop$while4() throws Throwable { doTest(); }
-  public void testLoop$while5() throws Throwable { doTest(); }
   public void testLoop$while6() throws Throwable { doTest(); }
   public void testMethods$method1() throws Throwable { doTest(); }
   public void testMethods$method2() throws Throwable { doTest(); }
@@ -116,6 +117,7 @@
   public void testMultiple_assign$grvy2086() throws Throwable { doTest("multiple_assign/grvy-2086.test"); }
   public void testMultiple_assign$mult_assign() throws Throwable { doTest(); }
   public void testMultiple_assign$mult_def() throws Throwable { doTest(); }
+  public void testMultiple_assign$without_assign() throws Throwable { doTest(); }
   public void testSwitch$laforge1() throws Throwable { doTest(); }
   public void testSwitch$swit1() throws Throwable { doTest(); }
   public void testSwitch$swit2() throws Throwable { doTest(); }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/TypesParsingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/TypesParsingTest.groovy
index 489a2fe..fd91208 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/TypesParsingTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/TypesParsingTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,6 +34,8 @@
   public void testType11() throws Throwable { doTest(); }
   public void testType12() throws Throwable { doTest(); }
   public void testType13() throws Throwable { doTest(); }
+  public void testType14() throws Throwable { doTest(); }
+  public void testType15() throws Throwable { doTest(); }
   public void testType2() throws Throwable { doTest(); }
   public void testType3() throws Throwable { doTest(); }
   public void testType4() throws Throwable { doTest(); }
@@ -49,5 +51,9 @@
   public void testStaticInitializer() throws Throwable { doTest(); }
   public void testInterfaceWithGroovyDoc() throws Throwable { doTest(); }
 
+  public void testIncorrectParam1() { doTest() }
+  public void testIncorrectParameter2() { doTest() }
+  public void testIncorrectParam3() { doTest() }
+
   public void testEmptyTypeArgs() {doTest()}
 }
\ No newline at end of file
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/psi/GrStubAstSwitchTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/psi/GrStubAstSwitchTest.groovy
new file mode 100644
index 0000000..2fba622
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/psi/GrStubAstSwitchTest.groovy
@@ -0,0 +1,223 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.psi
+
+import com.intellij.psi.*
+import org.jetbrains.plugins.groovy.LightGroovyTestCase
+import org.jetbrains.plugins.groovy.lang.psi.impl.GroovyFileImpl
+
+/**
+ * Created by Max Medvedev on 12/4/13
+ */
+class GrStubAstSwitchTest extends LightGroovyTestCase {
+  @Override
+  protected String getBasePath() {
+    null
+  }
+
+  void testDontLoadContentWhenProcessingImports() {
+    GroovyFileImpl file = (GroovyFileImpl) myFixture.addFileToProject("A.groovy", """
+import java.util.concurrent.ConcurrentHashMap
+
+class MyMap extends ConcurrentHashMap {}
+class B extends ConcurrentHashMap {
+  void foo() {
+    print 4
+  }
+}
+""")
+    assert !file.contentsLoaded
+    PsiClass bClass = file.classes[1]
+    assert !file.contentsLoaded
+
+    def fooMethod = bClass.methods[0]
+    assert !file.contentsLoaded
+
+    fooMethod.findDeepestSuperMethods()
+    assert !file.contentsLoaded
+  }
+
+  void testDontLoadAstForAnnotation() {
+    GroovyFileImpl file = myFixture.addFileToProject('a.groovy', '''\
+class A {
+  def foo(){}
+}
+
+class B {
+  @Delegate
+  A a = new A()
+}
+''') as GroovyFileImpl
+
+    assert !file.contentsLoaded
+    PsiClass clazzB = file.classes[1]
+    assert !file.contentsLoaded
+
+    PsiField field = clazzB.fields[0]
+    assert !file.contentsLoaded
+
+
+    PsiModifierList modifierList = field.modifierList
+    assert !file.contentsLoaded
+
+    PsiAnnotation[] annotations = modifierList.annotations
+    PsiAnnotation annotation = annotations[0]
+    assert !file.contentsLoaded
+
+    assert annotation.qualifiedName == 'groovy.lang.Delegate'
+    assert !file.contentsLoaded
+  }
+
+  void testDontLoadAstForAnnotation2() {
+    GroovyFileImpl file = myFixture.addFileToProject('a.groovy', '''\
+class A {
+  def foo(){}
+}
+
+class B extends A {
+  @Override
+  def foo() {}
+}
+''') as GroovyFileImpl
+
+    assert !file.contentsLoaded
+    PsiClass clazzB = file.classes[1]
+    assert !file.contentsLoaded
+
+    PsiMethod method = clazzB.methods[0]
+    assert !file.contentsLoaded
+
+
+    PsiModifierList modifierList = method.modifierList
+    assert !file.contentsLoaded
+
+    PsiAnnotation[] annotations = modifierList.annotations
+    PsiAnnotation annotation = annotations[0]
+    assert !file.contentsLoaded
+
+    assert annotation.qualifiedName == "java.lang.Override"
+    assert !file.contentsLoaded
+  }
+
+
+  void testDelegateExists() {
+    GroovyFileImpl file = myFixture.addFileToProject('a.groovy', '''\
+class A {
+  def foo(){}
+}
+
+class B {
+  @Delegate
+  A a = new A()
+}
+''') as GroovyFileImpl
+
+    assert !file.contentsLoaded
+    PsiClass clazzB = file.classes[1]
+    assert !file.contentsLoaded
+
+    assert clazzB.methods.find {it.name =='foo'}
+    assert !file.contentsLoaded
+  }
+
+  void testDefaultValueForAnnotation() {
+    myFixture.addFileToProject('pack/Ann.groovy', '''\
+package pack
+
+@interface Ann {
+    String foo() default 'def'
+}
+''')
+
+    GroovyFileImpl file = myFixture.addFileToProject('usage.groovy', '''\
+import pack.Ann
+
+class X {
+  @Ann()
+  String bar() {}
+}
+''') as GroovyFileImpl
+
+    assert !file.contentsLoaded
+    PsiClass clazz = file.classes[0]
+    assert !file.contentsLoaded
+    PsiMethod method = clazz.methods[0]
+    assert !file.contentsLoaded
+    PsiAnnotation annotation = method.modifierList.findAnnotation('pack.Ann')
+    assert !file.contentsLoaded
+    assert annotation.findAttributeValue('foo') != null
+    assert !file.contentsLoaded
+  }
+
+  void testDefaultValueForAnnotationWithAliases() {
+    myFixture.addFileToProject('pack/Ann.groovy', '''\
+package pack
+
+@interface Ann {
+    String foo() default 'def'
+}
+''')
+
+    GroovyFileImpl file = myFixture.addFileToProject('usage.groovy', '''\
+import pack.Ann as A
+
+class X {
+  @A()
+  String bar() {}
+}
+''') as GroovyFileImpl
+
+    assert !file.contentsLoaded
+    PsiClass clazz = file.classes[0]
+    assert !file.contentsLoaded
+    PsiMethod method = clazz.methods[0]
+    assert !file.contentsLoaded
+    PsiAnnotation annotation = method.modifierList.findAnnotation('pack.Ann')
+    assert !file.contentsLoaded
+    assert annotation.findAttributeValue('foo') != null
+    assert !file.contentsLoaded
+  }
+
+  void testValueForAnnotationWithAliases() {
+    myFixture.addFileToProject('pack/Ann.groovy', '''\
+package pack
+
+@interface Ann {
+    String foo() default 'def'
+}
+''')
+
+    GroovyFileImpl file = myFixture.addFileToProject('usage.groovy', '''\
+import pack.Ann as A
+
+class X {
+  @A(foo='non_def')
+  String bar() {}
+}
+''') as GroovyFileImpl
+
+    assert !file.contentsLoaded
+    PsiClass clazz = file.classes[0]
+    assert !file.contentsLoaded
+    PsiMethod method = clazz.methods[0]
+    assert !file.contentsLoaded
+    PsiAnnotation annotation = method.modifierList.findAnnotation('pack.Ann')
+    assert !file.contentsLoaded
+    assert annotation.findAttributeValue('foo') != null
+    assert file.contentsLoaded
+  }
+
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.groovy
index c481df1..5c7a25b 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/GroovyResolveTestCase.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
 import com.intellij.openapi.vfs.VirtualFile
 import com.intellij.psi.PsiElement
 import com.intellij.psi.PsiReference
+import org.intellij.lang.annotations.Language
 import org.jetbrains.annotations.NonNls
 import org.jetbrains.annotations.Nullable
 import org.jetbrains.plugins.groovy.LightGroovyTestCase
@@ -74,7 +75,7 @@
     return ref;
   }
 
-  protected <T extends PsiReference> T configureByText(String fileName = '_a.groovy', String text, Class<T> refType = PsiReference) {
+  protected <T extends PsiReference> T configureByText(String fileName = '_a.groovy', @Language("Groovy") String text, Class<T> refType = PsiReference) {
     myFixture.configureByText fileName, text
     final ref = myFixture.file.findReferenceAt(myFixture.editor.caretModel.offset)
     assertInstanceOf(ref, refType)
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveClassTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveClassTest.groovy
index 2092272..485f91e 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveClassTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveClassTest.groovy
@@ -306,5 +306,93 @@
 ''', PsiClass)
   }
 
+  void testCollisionOfClassAndPackage() {
+    myFixture.addFileToProject('foo/Bar.groovy', '''\
+package foo
+
+class Bar {
+  static void xyz(){}
+}
+''')
+    def ref = configureByText('foo.groovy', '''\
+import foo.B<caret>ar
+
+print new Bar()
+''')
+
+    assertNotNull(ref.resolve())
+  }
+
+  void testCollisionOfClassAndPackage2() {
+    myFixture.addFileToProject('foo/Bar.groovy', '''\
+package foo
+
+class Bar {
+  static void xyz(){}
+}
+''')
+    def ref = configureByText('foo.groovy', '''\
+import static foo.Bar.xyz
+
+class foo {
+  public static void main(args) {
+    x<caret>yz()      //should resolve to inner class
+  }
+
+  static class Bar {
+    static void xyz() {}
+  }
+}
+''')
+
+    PsiElement resolved = ref.resolve()
+    assertInstanceOf(resolved, PsiMethod)
+
+    PsiClass clazz = resolved.containingClass
+    assertNotNull(clazz.containingClass)
+  }
+
+
+  void testCollisionOfClassAndPackage3() {
+    myFixture.addFileToProject('foo/Bar.groovy', '''\
+package foo
+
+class Bar {
+  static void xyz(){}
+}
+''')
+    def ref = configureByText('foo.groovy', '''\
+import static foo.Bar.xyz
+
+x<caret>yz()
+''')
+
+    assertNotNull(ref.resolve())
+  }
+
+  void testCollisionOfClassAndPackage4() {
+    myFixture.addFileToProject('foo/Bar.groovy', '''\
+package foo
+
+class Bar {
+  static void xyz(){}
+}
+''')
+
+    def ref = configureByText('foo.groovy', '''\
+import static foo.Bar.xyz
+
+class foo {
+  public static void main(String[] args) {
+    x<caret>yz()
+  }
+}
+''')
+
+    PsiElement resolved = ref.resolve()
+    assertInstanceOf(resolved, PsiMethod)
+  }
+
+
   private void doTest(String fileName = getTestName(false) + ".groovy") { resolve(fileName, PsiClass) }
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy
index 7b8296c..ebfcf79 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveMethodTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -906,7 +906,7 @@
 
     def resolved = ref.resolve()
     assertInstanceOf resolved, PsiMethod
-    assertEquals 'Other', resolved.containingClass.name
+    assertEquals 'A', resolved.containingClass.name
   }
 
   public void testInapplicableStaticallyImportedMethodsVsCurrentClassMethod() {
@@ -1872,11 +1872,11 @@
   void testBinaryWithQualifiedRefsInArgs() {
     GrBinaryExpression expr = configureByText('_.groovy', '''\
 class Base {
-    public static final int SHOW_NAME = 0x0001; // variable, method, class
-    public static final int SHOW_TYPE = 0x0002; // variable, method
-    public static final int TYPE_AFTER = 0x0004; // variable, method
-    public static final int SHOW_MODIFIERS = 0x0008; // variable, method, class
-    public static final int MODIFIERS_AFTER = 0x0010; // variable, method, class
+    def or(String s) {}
+    def or(Base b) {}
+
+    public static Base SHOW_NAME = new Base()
+    public static Base SHOW_TYPE = new Base()
 }
 
 class GrTypeDefinition  {
@@ -1891,4 +1891,16 @@
     assert expr.multiResolve(true).length > 1
   }
 
+  void testStaticMethodInInstanceContext() {
+    GrMethod resolved = resolveByText('''\
+class Foo {
+    def foo(String s){}
+    static def foo(File f){}
+}
+
+new Foo().f<caret>oo(new File(''))
+''', GrMethod)
+
+    assertTrue(resolved.hasModifierProperty(PsiModifier.STATIC))
+  }
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy
index 733b5fc..2574715 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1269,4 +1269,64 @@
 ''', PsiVariable)
   }
 
+  void testPropertyVsAccessor() {
+    resolveByText('''\
+class ProductServiceImplTest  {
+    BackendClient backendClient
+
+    def setup() {
+        new ProductServiceImpl() {
+            protected BackendClient getBackendClient() {
+                return backend<caret>Client // <--- this expression is highlighted as member variable
+            }
+        }
+    }
+}
+
+class BackendClient{}
+class ProductServiceImpl{}
+''', GrMethod)
+  }
+
+  void testPropertyVsAccessor2() {
+    resolveByText('''\
+class ProductServiceImplTest  {
+    def setup() {
+        new ProductServiceImpl() {
+            BackendClient backendClient
+
+            protected BackendClient getBackendClient() {
+                return backendC<caret>lient
+            }
+        }
+    }
+}
+
+class BackendClient{}
+class ProductServiceImpl{}
+''', GrField)
+  }
+
+  void testPropertyVsAccessor3() {
+    resolveByText('''\
+class ProductServiceImplTest  {
+    BackendClient backendClient
+
+    protected BackendClient getBackendClient() {
+        return backendClient
+    }
+    def setup() {
+        new ProductServiceImpl() {
+           def foo() {
+             return backendClie<caret>nt
+           }
+        }
+    }
+}
+
+class BackendClient{}
+class ProductServiceImpl{}
+''', GrMethod)
+  }
+
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveWithDelegatesToTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveWithDelegatesToTest.groovy
index 6237f92..9762f67 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveWithDelegatesToTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolveWithDelegatesToTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -653,6 +653,34 @@
 ''', 'String')
   }
 
+  void testDelegateAndDelegatesTo() {
+    assertScript('''
+import groovy.transform.CompileStatic
+
+class Subject {
+    List list = []
+
+    void withList(@DelegatesTo(List) Closure<?> closure) {
+        list.with(closure)
+    }
+}
+
+class Wrapper {
+    @Delegate(parameterAnnotations = true)
+    Subject subject = new Subject()
+}
+
+@CompileStatic
+def staticOnWrapper() {
+    def wrapper = new Wrapper()
+    wrapper.withList {
+        ad<caret>d(1)
+    }
+    assert wrapper.list == [1]
+}
+''', 'List')
+  }
+
 
   void assertScript(String text, String resolvedClass) {
     myFixture.configureByText('_a.groovy', text)
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInference2_3Test.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInference2_3Test.groovy
new file mode 100644
index 0000000..7382469
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInference2_3Test.groovy
@@ -0,0 +1,208 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.resolve
+
+import com.intellij.testFramework.LightProjectDescriptor
+import org.jetbrains.plugins.groovy.GroovyLightProjectDescriptor
+
+/**
+ * Created by Max Medvedev on 10/02/14
+ */
+class TypeInference2_3Test extends TypeInferenceTestBase {
+  @Override
+  protected LightProjectDescriptor getProjectDescriptor() {
+    return GroovyLightProjectDescriptor.GROOVY_2_3
+  }
+
+  public void testContravariantType() throws Exception {
+    doTest('''\
+import groovy.transform.CompileStatic
+import java.util.concurrent.Callable
+
+@CompileStatic
+class TestCase {
+
+    interface Action<T> {
+        void execute(T thing)
+    }
+
+    static class Wrapper<T> {
+
+        private final T thing
+
+        Wrapper(T thing) {
+            this.thing = thing
+        }
+
+        void contravariantTake(Action<? super T> action) {
+            action.execute(thing)
+        }
+
+    }
+
+    static <T> Wrapper<T> wrap(Callable<T> callable) {
+        new Wrapper(callable.call())
+    }
+
+    static Integer dub(Integer integer) {
+        integer * 2
+    }
+
+    static void main(String[] args) {
+        wrap {
+            1
+        } contravariantTake {
+            dub(i<caret>t) // fails static compile, 'it' is not known to be Integer
+        }
+    }
+
+}
+''', 'java.lang.Integer')
+  }
+
+  void testSAMInference() {
+    doTest('''\
+import groovy.transform.CompileStatic
+
+interface CustomCallable<T> {
+  T call()
+}
+
+class Thing {
+  static <T> T customType(CustomCallable<T> callable) {
+    callable.call()
+  }
+
+  @CompileStatic
+  static void run() {
+    customType { [] }.ad<caret>d(1) // return type is not inferred - fails compile
+  }
+}
+''', "java.lang.Boolean")
+  }
+
+  void testSAMInference2() {
+    doTest('''\
+import groovy.transform.CompileStatic
+
+interface CustomCallable<T> {
+  List<T> call()
+}
+
+class Thing {
+  static <T> T first(CustomCallable<T> callable) {
+    callable.call().iterator().next()
+  }
+
+  @CompileStatic
+  static void run() {
+    first { [[]] }.ad<caret>d(1) // return type is not inferred - fails compile
+  }
+}
+''', "java.lang.Boolean")
+  }
+
+  void testSAMInference3() {
+    doTest('''\
+import groovy.transform.CompileStatic
+
+interface CustomCallable<K, V> {
+    Map<K, V> call()
+}
+
+class Thing {
+    static <K, V> Map<K, V> customType(CustomCallable<K, V> callable) {
+        callable.call()
+    }
+
+    @CompileStatic
+    static void run() {
+        customType { [(1):3] }.pu<caret>t(1, 5) // return type is not inferred - fails compile
+    }
+}
+
+''', 'java.lang.Integer')
+  }
+
+  void testSamInference4() {
+    doTest('''
+interface Action<T> {
+    void execute(T t)
+}
+
+public <T> void exec(T t, Action<T> f) {
+}
+
+
+def foo() {
+    exec('foo') {print i<caret>t.toUpperCase() ;print 2 }
+}
+
+''', 'java.lang.String')
+  }
+
+  void testSamInference5() {
+    doTest('''
+interface Action<T> {
+    void execute(T t)
+}
+
+public <T> void exec(T t, Action<T> f) {
+}
+
+
+def foo() {
+    exec('foo') {i<caret>t.toUpperCase() }
+}
+
+''', 'java.lang.String')
+  }
+
+  void testSamInference6() {
+    doTest('''
+interface Action<T> {
+    void execute(T t)
+}
+
+public <T> void exec(T t, Action<T> f) {
+}
+
+
+def foo() {
+    exec('foo') {print i<caret>t.toUpperCase() }
+}
+
+''', 'java.lang.String')
+  }
+
+  void testSamInference7() {
+    doTest('''
+interface CustomCallable<T> {
+    T call()
+}
+
+class Thing {
+    static <T> T customType(CustomCallable<T> callable) {
+    }
+
+    static void run() {
+        customType { i<caret>t }
+    }
+}''', null)
+  }
+
+
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTest.groovy
index e3dfe63..f02b940 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,8 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.plugins.groovy.lang.resolve;
-
+package org.jetbrains.plugins.groovy.lang.resolve
 
 import com.intellij.psi.PsiIntersectionType
 import com.intellij.psi.PsiReference
@@ -26,15 +25,13 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression
 import org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType
-import org.jetbrains.plugins.groovy.util.TestUtils
 
 import static com.intellij.psi.CommonClassNames.*
 
 /**
  * @author ven
  */
-public class TypeInferenceTest extends GroovyResolveTestCase {
-  final String basePath = TestUtils.testDataPath + "resolve/inference/"
+public class TypeInferenceTest extends TypeInferenceTestBase {
 
   public void testTryFinallyFlow() {
     GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow/A.groovy").element;
@@ -168,7 +165,7 @@
   }
 
   public void testConditionalExpressionWithNumericTypes() {
-    assertTypeEquals("java.math.BigDecimal", "A.groovy");
+    assertTypeEquals("java.lang.Number", "A.groovy");
   }
 
   public void testImplicitCallMethod() {
@@ -223,7 +220,7 @@
     final PsiReference ref = configureByFile(getTestName(true) + "/A.groovy");
     assertInstanceOf(ref, GrReferenceExpression.class);
     final PsiType type = ((GrReferenceExpression)ref).type;
-    assertNull(type);
+    assertTrue(true); //test just should not fail with SOF exception
   }
 
   public void testTraditionalForVar() {
@@ -257,7 +254,7 @@
 
     def getAt(String s) {new X()}
 
-    def plus(X x, int i) {x}
+    def plus(int i) {this}
 }
 
 map = new X()
@@ -265,7 +262,7 @@
 map['i'] += 2
 ''') as GroovyFile
     GrAssignmentExpression assignment = file.topStatements[2] as GrAssignmentExpression
-    assertTrue(assignment.LValue.type.equalsToText(JAVA_UTIL_DATE))
+    assertType("X", assignment.type)
   }
 
   void testAllTypeParamsAreSubstituted() {
@@ -605,33 +602,98 @@
 ''', 'java.lang.Object')
   }
 
-  private void doTest(String text, String type) {
-    def file = myFixture.configureByText('_.groovy', text)
-    def ref = file.findReferenceAt(myFixture.editor.caretModel.offset) as GrReferenceExpression
-    def actual = ref.type
-    if (type == null) {
-      assertNull(actual)
-      return
-    }
-
-    assertNotNull(actual)
-    if (actual instanceof PsiIntersectionType) {
-      assertEquals(type, genIntersectionTypeText(actual))
-    }
-    else {
-      assertEquals(type, actual.canonicalText)
-    }
+  void testUnary() {
+    doExprTest('~/abc/', 'java.util.regex.Pattern')
   }
 
-  private static String genIntersectionTypeText(PsiIntersectionType t) {
-    StringBuilder b = new StringBuilder('[')
-    for (PsiType c : t.conjuncts) {
-      b.append(c.canonicalText).append(',')
-    }
-    if (t.conjuncts) {
-      b.replace(b.length() - 1, b.length(), ']')
-    }
-    return b.toString()
+  void testUnary2() {
+    doExprTest('-/abc/', null)
+  }
+
+  void testUnary3() {
+    doExprTest('''
+      class A {
+        def bitwiseNegate() {'abc'}
+      }
+      ~new A()
+''', 'java.lang.String')
+  }
+
+  void testPlus1() {
+    doExprTest('2+2', 'java.lang.Integer')
+  }
+
+  void testPlus2() {
+    doExprTest('2f+2', 'java.lang.Double')
+  }
+
+  void testPlus3() {
+    doExprTest('2f+2f', 'java.lang.Double')
+  }
+
+  void testPlus4() {
+    doExprTest('2.5+2', 'java.math.BigDecimal')
+  }
+
+  void testMultiply1() {
+    doExprTest('2*2', 'java.lang.Integer')
+  }
+
+  void testMultiply2() {
+    doExprTest('2f*2f', 'java.lang.Double')
+  }
+
+  void testMultiply3() {
+    doExprTest('2d*2d', 'java.lang.Double')
+  }
+
+  void testMultiply4() {
+    doExprTest('2.4*2', 'java.math.BigDecimal')
+  }
+
+  void testMultiply5() {
+    doExprTest('((byte)2)*((byte)2)', 'java.lang.Integer')
+  }
+
+  void testMultiply6() {
+    doExprTest('"abc"*"cde"', 'java.lang.String') //expected number as a right operand
+  }
+
+  void testMultiply7() {
+    doExprTest('''
+      class A {
+        def multiply(A a) {new B()}
+      }
+      class B{}
+      new A()*new A()
+''', 'B')
+  }
+
+  void testMultiply8() {
+    doExprTest('''
+      class A { }
+      new A()*new A()
+''', null)
+  }
+
+  void testDiv1() {
+    doExprTest('1/2', 'java.math.BigDecimal')
+  }
+
+  void testDiv2() {
+    doExprTest('1/2.4', 'java.math.BigDecimal')
+  }
+
+  void testDiv3() {
+    doExprTest('1d/2', 'java.lang.Double')
+  }
+
+  void testDiv4() {
+    doExprTest('1f/2', 'java.lang.Double')
+  }
+
+  void testDiv5() {
+    doExprTest('1f/2.4', 'java.lang.Double')
   }
 
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTestBase.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTestBase.groovy
new file mode 100644
index 0000000..fbbd630
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTestBase.groovy
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.resolve
+
+import org.intellij.lang.annotations.Language
+import org.jetbrains.annotations.Nullable
+import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression
+import org.jetbrains.plugins.groovy.util.TestUtils
+
+/**
+ * Created by Max Medvedev on 10/02/14
+ */
+abstract class TypeInferenceTestBase extends GroovyResolveTestCase {
+  final String basePath = TestUtils.testDataPath + "resolve/inference/"
+
+  @Override
+  protected void setUp() {
+    super.setUp()
+
+    myFixture.addClass("package java.math; public class BigDecimal extends Number implements Comparable<BigDecimal> {}");
+  }
+
+  protected void doTest(@Language("Groovy") String text, @Nullable String type) {
+    def file = myFixture.configureByText('_.groovy', text)
+    def ref = file.findReferenceAt(myFixture.editor.caretModel.offset) as GrReferenceExpression
+    def actual = ref.type
+    assertType(type, actual)
+  }
+
+  protected void doExprTest(@Language("Groovy") String text, @Nullable String expectedType) {
+    GroovyFile file = myFixture.configureByText('_.groovy', text) as GroovyFile
+    GrStatement lastStatement = file.statements.last()
+    assertInstanceOf lastStatement, GrExpression
+    assertType(expectedType, (lastStatement as GrExpression).type)
+  }
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/surroundWith/SurroundTestCase.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/surroundWith/SurroundTestCase.groovy
index 297a17c..ff86ea44 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/surroundWith/SurroundTestCase.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/surroundWith/SurroundTestCase.groovy
@@ -14,13 +14,11 @@
  * limitations under the License.
  */
 package org.jetbrains.plugins.groovy.lang.surroundWith
-
 import com.intellij.codeInsight.generation.surroundWith.SurroundWithHandler
 import com.intellij.lang.surroundWith.Surrounder
-import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.command.WriteCommandAction
 import org.jetbrains.plugins.groovy.LightGroovyTestCase
 import org.jetbrains.plugins.groovy.util.TestUtils
-
 /**
  * @author peter
  */
@@ -33,7 +31,7 @@
   protected void doTest(final Surrounder surrounder, String textBefore, String textAfter) {
     myFixture.configureByText("a.groovy", textBefore)
 
-    ApplicationManager.application.runWriteAction {
+    WriteCommandAction.runWriteCommandAction project, {
       SurroundWithHandler.invoke(project, myFixture.editor, myFixture.file, surrounder)
       doPostponedFormatting(project)
     }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerationTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerationTest.groovy
index ab2af7e..f6e5275 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerationTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/convertToJava/CodeBlockGenerationTest.groovy
@@ -196,4 +196,8 @@
   void testStringConverting() { doTest() }
 
   void testInWitchClassCheck() { doTest() }
+
+  void testSwitch() { doTest() }
+
+  void testPropSelection() { doTest() }
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extract/method/ExtractMethodTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extract/method/ExtractMethodTest.groovy
index d17fea8..baa7026 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extract/method/ExtractMethodTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/extract/method/ExtractMethodTest.groovy
@@ -239,4 +239,15 @@
 ''')
   }
 
+  void testExtractMethodFromStringPart() {
+    doTest('-', '''\
+print 'a<begin>b<end>c'
+''', '''\
+print 'a' + '-'() + 'c'
+
+private String '-'() {
+    return 'b'
+}
+''')
+  }
 }
\ No newline at end of file
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/implExtQuickFix/ImplementsExtendsQuickFixTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/implExtQuickFix/ImplementsExtendsQuickFixTest.groovy
index c1f689b..214d41f 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/implExtQuickFix/ImplementsExtendsQuickFixTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/implExtQuickFix/ImplementsExtendsQuickFixTest.groovy
@@ -1,6 +1,21 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.jetbrains.plugins.groovy.refactoring.implExtQuickFix
 
-import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.command.WriteCommandAction
 import com.intellij.psi.PsiFile
 import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
 import org.jetbrains.plugins.groovy.annotator.intentions.ChangeExtendsImplementsQuickFix
@@ -38,7 +53,7 @@
       }
       else {
 
-        ApplicationManager.application.runWriteAction {
+        WriteCommandAction.runWriteCommandAction project, {
           ChangeExtendsImplementsQuickFix fix = new ChangeExtendsImplementsQuickFix(typeDefinition)
           fix.invoke(project, null, psiFile)
           doPostponedFormatting(project)
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineMethodTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineMethodTest.groovy
index b3153d1..30ee1f9 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineMethodTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/inline/InlineMethodTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -132,6 +132,8 @@
     }
   }
 
+  public void testSuperCall() { doTest() }
+
   protected void doTest() {
     doTest(new GroovyInlineHandler());
   }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduce/IntroduceConstantTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduce/IntroduceConstantTest.groovy
similarity index 72%
rename from plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduce/IntroduceConstantTest.java
rename to plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduce/IntroduceConstantTest.groovy
index 81317cc..99c5476 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduce/IntroduceConstantTest.java
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduce/IntroduceConstantTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -13,24 +13,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.plugins.groovy.refactoring.introduce;
+package org.jetbrains.plugins.groovy.refactoring.introduce
 
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiModifier;
-import com.intellij.psi.PsiType;
-import com.intellij.psi.impl.source.PostprocessReformattingAspect;
-import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
-import com.intellij.util.VisibilityUtil;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
-import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
-import org.jetbrains.plugins.groovy.refactoring.introduce.constant.GrIntroduceConstantHandler;
-import org.jetbrains.plugins.groovy.refactoring.introduce.constant.GrIntroduceConstantSettings;
-import org.jetbrains.plugins.groovy.util.TestUtils;
+import com.intellij.openapi.command.WriteCommandAction
+import com.intellij.openapi.editor.Editor
+import com.intellij.psi.PsiClass
+import com.intellij.psi.PsiElement
+import com.intellij.psi.PsiModifier
+import com.intellij.psi.PsiType
+import com.intellij.psi.impl.source.PostprocessReformattingAspect
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
+import com.intellij.util.VisibilityUtil
+import org.jetbrains.annotations.NotNull
+import org.jetbrains.annotations.Nullable
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression
+import org.jetbrains.plugins.groovy.refactoring.introduce.constant.GrIntroduceConstantHandler
+import org.jetbrains.plugins.groovy.refactoring.introduce.constant.GrIntroduceConstantSettings
+import org.jetbrains.plugins.groovy.util.TestUtils
 
 /**
  * @author Maxim.Medvedev
@@ -38,7 +38,7 @@
 public class IntroduceConstantTest extends LightCodeInsightFixtureTestCase {
   @Override
   protected String getBasePath() {
-    return TestUtils.getTestDataPath() + "refactoring/introduceConstant/";
+    TestUtils.testDataPath + "refactoring/introduceConstant/"
   }
 
   public void testSimple() {
@@ -62,7 +62,7 @@
   }
 
   public void testTupleDeclaration() {
-    doTest("Test", false, false, PsiModifier.PUBLIC);
+    doTest("Test", true, false, PsiModifier.PUBLIC);
   }
 
   public void testStringPart() {
@@ -73,11 +73,19 @@
     doTest();
   }
 
+  public void testFieldWithClassName() {
+    doTest();
+  }
+
+  void testLocalVarRef() {
+    doTest()
+  }
+
   private void doTest() {
     doTest(null, true, true, PsiModifier.PUBLIC);
   }
 
-  private void doTest(@Nullable String targetClassName, boolean replaceAllOccurences, boolean useExplicitType, String modifier) {
+  private void doTest(@Nullable String targetClassName, boolean replaceAllOccurrences, boolean useExplicitType, String modifier) {
     myFixture.configureByFile(getTestName(false) + ".groovy");
 
 
@@ -91,25 +99,17 @@
     PsiElement[] scopes = handler.findPossibleScopes(expression, variable, stringPart, editor);
     final GrIntroduceContext context = handler.getContext(getProject(), editor, expression, variable, stringPart, scopes[0]);
 
-    PsiClass targetClass;
-    if (targetClassName == null) {
-      targetClass = GrIntroduceConstantHandler.findContainingClass(context);
-    }
-    else {
-      targetClass = myFixture.findClass(targetClassName);
-    }
+    PsiClass targetClass = targetClassName == null ? GrIntroduceConstantHandler.findContainingClass(context)
+                                                   : myFixture.findClass(targetClassName);
     assertNotNull("target class is null", targetClass);
 
-    final GrIntroduceConstantSettings settings =
-      new MockIntroduceConstantSettings(targetClass, replaceAllOccurences, getType(useExplicitType, expression, variable, stringPart), modifier);
+    def type = getType(useExplicitType, expression, variable, stringPart)
+    final GrIntroduceConstantSettings settings = new MockIntroduceConstantSettings(targetClass, replaceAllOccurrences, type, modifier);
 
-    ApplicationManager.getApplication().runWriteAction(new Runnable() {
-      @Override
-      public void run() {
-        handler.runRefactoring(context, settings);
-        PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting();
-      }
-    });
+    WriteCommandAction.runWriteCommandAction(null) {
+      handler.runRefactoring(context, settings);
+      PostprocessReformattingAspect.getInstance(project).doPostponedFormatting();
+    }
     myFixture.checkResultByFile(getTestName(false) + "_after.groovy", true);
   }
 
@@ -118,8 +118,8 @@
       return null;
     }
     return expression != null ? expression.getType() :
-           variable != null ? variable.getType() :
-           stringPart.getLiteral().getType();
+           variable   != null ? variable.getType() :
+                                stringPart.getLiteral().getType();
   }
 
   @Nullable
@@ -147,10 +147,10 @@
   }
 
   private static class MockIntroduceConstantSettings implements GrIntroduceConstantSettings {
-    private PsiClass myTargetClass;
-    private boolean myReplaceAllOccurrences;
-    private PsiType mySelectedType;
-    private String myModifier;
+    private final PsiClass myTargetClass;
+    private final boolean myReplaceAllOccurrences;
+    private final PsiType mySelectedType;
+    private final String myModifier;
 
     private MockIntroduceConstantSettings(@NotNull PsiClass targetClass,
                                           boolean replaceAllOccurrences,
@@ -164,7 +164,6 @@
 
     @Override
     public String getVisibilityModifier() {
-
       return myModifier;
     }
 
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldTest.groovy
index 911f3a4..945eb1f 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduce/field/GrIntroduceFieldTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -328,6 +328,23 @@
 ''', false, false, false, CUR_METHOD, false, null)
   }
 
+  void testFromVar() {
+    doTest('''\
+class A {
+    def foo() {
+        def <selection>a = 5</selection>
+        print a
+    }
+}''', '''\
+class A {
+    def f = 5
+
+    def foo() {
+        print f
+    }
+}''', false, true, false, FIELD_DECLARATION, true, null)
+  }
+
 
   private void doTest(final boolean isStatic,
                       final boolean removeLocal,
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/ExtractClosureTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/ExtractClosureTest.groovy
index dcc405e..2f6b96a 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/ExtractClosureTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/ExtractClosureTest.groovy
@@ -13,9 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.jetbrains.plugins.groovy.refactoring.introduceParameter;
+package org.jetbrains.plugins.groovy.refactoring.introduceParameter
 
-
+import com.intellij.openapi.command.WriteCommandAction
 import com.intellij.refactoring.IntroduceParameterRefactoring
 import gnu.trove.TIntArrayList
 import org.jetbrains.plugins.groovy.LightGroovyTestCase
@@ -47,7 +47,7 @@
         GrIntroduceParameterSettings helper = new ExtractClosureHelperImpl(info, "closure", false,
                                                                            new TIntArrayList(toRemove as int[]), false,
                                                                            IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE,
-                                                                           forceReturn, false)
+                                                                           forceReturn, false, false)
         for (p in notToUseAsParams) {
           helper.parameterInfos[p].passAsParameter = false
         }
@@ -60,8 +60,10 @@
       }
     }
 
-    handler.invoke myFixture.project, myFixture.editor, myFixture.file, null
-    doPostponedFormatting(myFixture.project)
+    WriteCommandAction.runWriteCommandAction project, {
+      handler.invoke myFixture.project, myFixture.editor, myFixture.file, null
+      doPostponedFormatting(myFixture.project)
+    }
     myFixture.checkResult after
   }
 
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/GrIntroduceParameterTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/GrIntroduceParameterTest.groovy
index 6c7f1b5..550c5a1 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/GrIntroduceParameterTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/GrIntroduceParameterTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,11 +23,10 @@
 import com.intellij.psi.PsiType
 import com.intellij.psi.impl.source.PostprocessReformattingAspect
 import com.intellij.refactoring.IntroduceParameterRefactoring
-import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
 import gnu.trove.TIntArrayList
 import gnu.trove.TObjectIntHashMap
-import junit.framework.Assert
 import org.jetbrains.annotations.Nullable
+import org.jetbrains.plugins.groovy.LightGroovyTestCase
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression
@@ -37,10 +36,12 @@
 import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceHandlerBase
 import org.jetbrains.plugins.groovy.refactoring.introduce.parameter.*
 import org.jetbrains.plugins.groovy.util.TestUtils
+import org.junit.Assert
+
 /**
  * @author Maxim.Medvedev
  */
-public class GrIntroduceParameterTest extends LightCodeInsightFixtureTestCase {
+public class GrIntroduceParameterTest extends LightGroovyTestCase {
 
   protected String getBasePath() {
     return TestUtils.getTestDataPath() + "refactoring/introduceParameterGroovy/" + getTestName(true) + '/';
@@ -122,37 +123,32 @@
                       final Project project,
                       final Editor editor,
                       final PsiFile file) {
-    CommandProcessor.getInstance().executeCommand(project, new Runnable() {
-      @Override
-      public void run() {
-        ApplicationManager.getApplication().runWriteAction(new Runnable() {
-          @Override
-          public void run() {
-            try {
-              final GrIntroduceParameterHandler hackedHandler = new GrIntroduceParameterHandler() {
-                @Override
-                protected void showDialog(IntroduceParameterInfo info) {
-                  final GrIntroduceParameterSettings hackedSettings = GrIntroduceParameterTest.getSettings(info, removeUnusedParameters, replaceFieldsWithGetters, declareFinal, generateDelegate);
-                  if (info.getToReplaceIn() instanceof GrMethod) {
-                    new GrIntroduceParameterProcessor(hackedSettings).run();
-                  }
-                  else {
-                    new GrIntroduceClosureParameterProcessor(hackedSettings).run();
-                  }
-                }
-              };
-              hackedHandler.invoke(project, editor, file, null);
-              if (conflicts != null) fail("Conflicts were expected");
-            }
-            catch (Exception e) {
-              if (conflicts == null) {
-                e.printStackTrace();
-                fail("Conflicts were not expected");
+    CommandProcessor.instance.executeCommand(project, {
+      ApplicationManager.application.runWriteAction {
+        try {
+          final GrIntroduceParameterHandler hackedHandler = new GrIntroduceParameterHandler() {
+            @Override
+            protected void showDialog(IntroduceParameterInfo info) {
+              final GrIntroduceParameterSettings hackedSettings =
+                getSettings(info, removeUnusedParameters, replaceFieldsWithGetters, declareFinal, generateDelegate);
+              if (info.getToReplaceIn() instanceof GrMethod) {
+                new GrIntroduceParameterProcessor(hackedSettings).run();
               }
-              Assert.assertEquals(conflicts, e.getMessage());
+              else {
+                new GrIntroduceClosureParameterProcessor(hackedSettings).run();
+              }
             }
+          };
+          hackedHandler.invoke(project, editor, file, null);
+          if (conflicts != null) fail("Conflicts were expected");
+        }
+        catch (Exception e) {
+          if (conflicts == null) {
+            e.printStackTrace();
+            fail("Conflicts were not expected");
           }
-        });
+          Assert.assertEquals(conflicts, e.getMessage());
+        }
       }
     }, "introduce Parameter", null);
   }
@@ -173,11 +169,10 @@
 
     final GrStatement[] statements = context.getStatements()
     GrExpression expr = statements.length == 1 ? GrIntroduceHandlerBase.findExpression(statements[0]) : null;
-    GrVariable var = statements.length == 1 ? GrIntroduceHandlerBase.findVariable(context.getStatements()[0]) : null;
-    final PsiType type = TypesUtil.
-      unboxPrimitiveTypeWrapper(var != null ? var.getType() : expr != null ? expr.getType() : context.stringPartInfo.literal.type);
+    GrVariable var = context.var
+    final PsiType type = TypesUtil.unboxPrimitiveTypeWrapper(var != null ? var.getType() : expr != null ? expr.getType() : context.stringPartInfo.literal.type);
     return new GrIntroduceExpressionSettingsImpl(context, "anObject", declareFinal, toRemove, generateDelegate, replaceFieldsWithGetters,
-                                                 expr, var, type, true);
+                                                 expr, var, type, var !=null, var != null, true);
   }
   
   
@@ -357,4 +352,42 @@
 }
 ''')
   }
+
+
+  void testNullType() {
+    doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, null, false, '''\
+def foo() {
+    def a = '4'
+    <selection>print a</selection>
+}
+
+foo()
+''', '''\
+def foo(anObject) {
+    def a = '4'
+    anObject
+}
+
+foo(print(a))
+''')
+  }
+
+  void testIntroduceFromLocalVar() {
+    doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, null, false, '''\
+def foo() {
+    def <selection>var = 5</selection>
+
+    print var + var
+}
+
+foo()
+''', '''\
+def foo(anObject) {
+
+    print anObject + anObject
+}
+
+foo(5)
+''')
+  }
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/IntroduceLocalVariableTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/IntroduceLocalVariableTest.groovy
index 5d307b4..4d4c838 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/IntroduceLocalVariableTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/IntroduceLocalVariableTest.groovy
@@ -14,21 +14,17 @@
  * limitations under the License.
  */
 package org.jetbrains.plugins.groovy.refactoring.introduceVariable
+
 import com.intellij.codeInsight.intention.impl.config.IntentionActionWrapper
 import com.intellij.openapi.editor.Editor
 import com.intellij.openapi.project.Project
 import com.intellij.psi.PsiElement
-import com.intellij.psi.PsiType
 import com.intellij.util.IncorrectOperationException
 import org.jetbrains.annotations.NotNull
 import org.jetbrains.plugins.groovy.intentions.GrIntentionTestCase
 import org.jetbrains.plugins.groovy.intentions.declaration.GrIntroduceLocalVariableIntention
-import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContext
-import org.jetbrains.plugins.groovy.refactoring.introduce.variable.GrIntroduceVariableHandler
-import org.jetbrains.plugins.groovy.refactoring.introduce.variable.GroovyIntroduceVariableDialog
-import org.jetbrains.plugins.groovy.refactoring.introduce.variable.GroovyIntroduceVariableSettings
-import org.jetbrains.plugins.groovy.refactoring.introduce.variable.GroovyVariableValidator
 import org.jetbrains.plugins.groovy.util.TestUtils
+
 /**
  * @author siosio
  */
@@ -62,80 +58,10 @@
 
   static class MockGrIntroduceLocalVariableIntention extends GrIntroduceLocalVariableIntention {
     @Override
-    protected void processIntention(PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
+    protected void processIntention(@NotNull PsiElement element, Project project, Editor editor) throws IncorrectOperationException {
       setSelection(editor, getTargetExpression(element));
       MockSettings settings = new MockSettings(false, "varName", null, false)
       new MockGrIntroduceVariableHandler(settings).invoke(project, editor, element.containingFile, null);
     }
   }
-
-  static class MockGrIntroduceVariableHandler extends GrIntroduceVariableHandler {
-    private final MockSettings mySettings
-
-    MockGrIntroduceVariableHandler(MockSettings settings) {
-      mySettings = settings
-    }
-
-    @NotNull
-    @Override
-    protected GroovyIntroduceVariableDialog getDialog(@NotNull GrIntroduceContext context) {
-      new MockGrIntroduceVariableDialog(context, new GroovyVariableValidator(context), mySettings)
-    }
-  }
-
-  static class MockGrIntroduceVariableDialog extends GroovyIntroduceVariableDialog {
-    private final MockSettings mySettings
-
-    MockGrIntroduceVariableDialog(GrIntroduceContext context, GroovyVariableValidator validator, MockSettings settings) {
-      super(context, validator)
-      mySettings = settings
-    }
-
-    @Override
-    void show() {
-      close(0)
-    }
-
-    @Override
-    MockSettings getSettings() { mySettings }
-
-    @Override
-    boolean isOK() {
-      true
-    }
-  }
-
-  static class MockSettings implements GroovyIntroduceVariableSettings {
-    private final boolean myFinal
-    private final String myName
-    private final boolean myAllOccurrences
-    private final PsiType myType
-
-    MockSettings(final boolean isFinal, final String name, PsiType type, boolean allOccurrences) {
-      myFinal = isFinal
-      myName = name
-      myType = type
-      myAllOccurrences = allOccurrences
-    }
-
-    @Override
-    boolean isDeclareFinal() {
-      return myFinal
-    }
-
-    @Override
-    String getName() {
-        myName
-    }
-
-    @Override
-    boolean replaceAllOccurrences() {
-      return myAllOccurrences
-    }
-
-    @Override
-    PsiType getSelectedType() {
-      return myType
-    }
-  }
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/IntroduceVariableTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/IntroduceVariableTest.groovy
index 60a96ef..6d06726 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/IntroduceVariableTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/IntroduceVariableTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -119,6 +119,15 @@
 ''')
   }
 
+  void testDollarSlashyString() {
+    doTest('''\
+print($/a<begin>b<end>c/$)
+''', '''\
+def preved = $/b/$
+print($/a/$ + preved + $/c/$)
+''')
+  }
+
   protected static final String ALL_MARKER = "<all>"
 
   private void processFile(String fileText, boolean explicitType) {
@@ -126,8 +135,8 @@
 
     PsiType type = inferType(explicitType)
 
-    final IntroduceLocalVariableTest.MockSettings settings = new IntroduceLocalVariableTest.MockSettings(false, "preved", type, replaceAllOccurrences)
-    final GrIntroduceVariableHandler introduceVariableHandler = new IntroduceLocalVariableTest.MockGrIntroduceVariableHandler(settings)
+    final MockSettings settings = new MockSettings(false, "preved", type, replaceAllOccurrences)
+    final GrIntroduceVariableHandler introduceVariableHandler = new MockGrIntroduceVariableHandler(settings)
 
     introduceVariableHandler.invoke(myFixture.project, myFixture.editor, myFixture.file, null)
   }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/MockGrIntroduceVariableDialog.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/MockGrIntroduceVariableDialog.java
new file mode 100644
index 0000000..a6113b7
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/MockGrIntroduceVariableDialog.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.refactoring.introduceVariable;
+
+import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContext;
+import org.jetbrains.plugins.groovy.refactoring.introduce.variable.GroovyIntroduceVariableDialog;
+import org.jetbrains.plugins.groovy.refactoring.introduce.variable.GroovyVariableValidator;
+
+/**
+ * Created by Max Medvedev on 12/1/13
+ */
+public class MockGrIntroduceVariableDialog extends GroovyIntroduceVariableDialog {
+  private final MockSettings mySettings;
+
+  public MockGrIntroduceVariableDialog(GrIntroduceContext context, GroovyVariableValidator validator, MockSettings settings) {
+    super(context, validator);
+    mySettings = settings;
+  }
+
+  @Override
+  public void show() {
+    close(0);
+  }
+
+  @Override
+  public MockSettings getSettings() {
+    return mySettings;
+  }
+
+  @Override
+  public boolean isOK() {
+    return true;
+  }
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/MockGrIntroduceVariableHandler.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/MockGrIntroduceVariableHandler.java
new file mode 100644
index 0000000..64166c5
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/MockGrIntroduceVariableHandler.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.refactoring.introduceVariable;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.refactoring.introduce.GrIntroduceContext;
+import org.jetbrains.plugins.groovy.refactoring.introduce.variable.GrIntroduceVariableHandler;
+import org.jetbrains.plugins.groovy.refactoring.introduce.variable.GroovyIntroduceVariableDialog;
+import org.jetbrains.plugins.groovy.refactoring.introduce.variable.GroovyVariableValidator;
+
+/**
+ * Created by Max Medvedev on 12/1/13
+ */
+public class MockGrIntroduceVariableHandler extends GrIntroduceVariableHandler {
+  private final MockSettings mySettings;
+
+  public MockGrIntroduceVariableHandler(MockSettings settings) {
+    mySettings = settings;
+  }
+
+  @NotNull
+  @Override
+  protected GroovyIntroduceVariableDialog getDialog(@NotNull GrIntroduceContext context) {
+    return new MockGrIntroduceVariableDialog(context, new GroovyVariableValidator(context), mySettings);
+  }
+
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/MockSettings.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/MockSettings.java
new file mode 100644
index 0000000..36d32ed
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/MockSettings.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.refactoring.introduceVariable;
+
+import com.intellij.psi.PsiType;
+import org.jetbrains.plugins.groovy.refactoring.introduce.variable.GroovyIntroduceVariableSettings;
+
+/**
+ * Created by Max Medvedev on 12/1/13
+ */
+public class MockSettings implements GroovyIntroduceVariableSettings {
+  private final boolean myFinal;
+  private final String myName;
+  private final boolean myAllOccurrences;
+  private final PsiType myType;
+
+  public MockSettings(final boolean isFinal, final String name, PsiType type, boolean allOccurrences) {
+    myFinal = isFinal;
+    myName = name;
+    myType = type;
+    myAllOccurrences = allOccurrences;
+  }
+
+  @Override
+  public boolean isDeclareFinal() {
+    return myFinal;
+  }
+
+  @Override
+  public String getName() {
+    return myName;
+  }
+
+  @Override
+  public boolean replaceAllOccurrences() {
+    return myAllOccurrences;
+  }
+
+  @Override
+  public PsiType getSelectedType() {
+    return myType;
+  }
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/StringExtractingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/StringExtractingTest.groovy
new file mode 100644
index 0000000..3a06da0
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceVariable/StringExtractingTest.groovy
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.refactoring.introduceVariable
+
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.command.CommandProcessor
+import com.intellij.openapi.util.TextRange
+import org.jetbrains.plugins.groovy.LightGroovyTestCase
+import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral
+import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil
+import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo
+import org.jetbrains.plugins.groovy.util.TestUtils
+
+/**
+ * Created by Max Medvedev on 04/02/14
+ */
+class StringExtractingTest extends LightGroovyTestCase {
+
+  @Override
+  protected String getBasePath() {
+    return TestUtils.testDataPath + "refactoring/stringExtracting/"
+  }
+
+  public void testStringExtractingFromQuote() { doTest() }
+
+  public void testStringExtractingFromDoubleQuotes() { doTest() }
+
+  public void testStringExtractingFromSlashyString() { doTest() }
+
+  public void testStringExtractingFromDollarSlashyString() { doTest() }
+
+  public void testSlashyWithSlash() { doTest() }
+
+  public void testDollarSlashyWithDollar() { doTest() }
+
+  public void testSlashyWithSlashInsideExtractedPart() { doTest() }
+
+  private void doTest() {
+    GroovyFile file = myFixture.configureByFile(getTestName(true) + '.groovy') as GroovyFile
+
+    TextRange range = new TextRange(*myFixture.editor.selectionModel.with { [selectionStart, selectionEnd] })
+
+    CommandProcessor.instance.executeCommand(myFixture.project, {
+      ApplicationManager.application.runWriteAction {
+        new StringPartInfo(PsiUtil.skipParentheses(file.statements[0], false) as GrLiteral, range).replaceLiteralWithConcatenation(null)
+        myFixture.editor.selectionModel.removeSelection()
+      }
+    }, null, null)
+
+    myFixture.checkResultByFile(getTestName(true) + '_after.groovy')
+  }
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy
index 1abac51..2239271 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -125,8 +125,6 @@
     doTest();
   }
 
-  public void testJavaUtilString() { doTest(); }
-
   public void testSamePackage() {
     myFixture.addClass("package foo; public class Bar {}");
     myFixture.configureFromExistingVirtualFile(myFixture.copyFileToProject(getTestName(false) + ".groovy", "foo/Foo.groovy"));
@@ -146,6 +144,14 @@
   public void testRemoveImplicitlyImported() { doTest(); }
   public void testRemoveImplicitlyDemandImported() { doTest(); }
   public void testDontRemoveRedImports() { doTest(); }
+  public void testDontRemoveRedImports2() { doTest(); }
+  public void testDontRemoveRedImports3() { doTest(); }
+  public void testDontRemoveRedImports4() { doTest(); }
+  public void testDontRemoveRedImports5() { doTest(); }
+  public void testDontRemoveRedImports6() { doTest(); }
+  public void testDontRemoveRedImports7() { doTest(); }
+  public void testDontRemoveRedImports8() { doTest(); }
+  public void testDontRemoveRedImports9() { doTest(); }
 
   public void testRemoveSamePackaged() {
     myFixture.addClass("package foo.bar; public class Aaaa {}");
@@ -157,9 +163,9 @@
   }
 
   public void testJustWrongImport() throws Exception {
-    myFixture.configureByText("a.groovy", "import a.b.c.d");
+    myFixture.configureByText("a.groovy", "import a.b.c.d; final d c;");
     doOptimizeImports();
-    myFixture.checkResult("import a.b.c.d");
+    myFixture.checkResult("import a.b.c.d; final d c;");
   }
 
   public void testCleanBeforeJavadoc() throws Exception {
@@ -359,5 +365,4 @@
 GParsExecutorsPool oi
 ''')
   }
-
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy
index 38d3b39..e1a39a1 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/rename/RenameTest.groovy
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
  */
 package org.jetbrains.plugins.groovy.refactoring.rename
 
+import com.intellij.openapi.command.WriteCommandAction
 import com.intellij.openapi.util.text.StringUtil
 import com.intellij.psi.*
 import com.intellij.psi.impl.source.PostprocessReformattingAspect
@@ -76,11 +77,13 @@
     myFixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, """
 import foo.bar.Zoo
 SomeClass c = new SomeClass()
+Zoo zoo
 """)
     myFixture.renameElement(someClass, "NewClass")
     myFixture.checkResult """
 import foo.bar.Zoo
 NewClass c = new NewClass()
+Zoo zoo
 """
   }
 
@@ -523,7 +526,9 @@
   private def doInplaceRenameTest() {
     String prefix = "/${getTestName(false)}"
     myFixture.configureByFile prefix + ".groovy";
-    CodeInsightTestUtil.doInlineRename(new GrVariableInplaceRenameHandler(), "foo", myFixture);
+    WriteCommandAction.runWriteCommandAction project, {
+      CodeInsightTestUtil.doInlineRename(new GrVariableInplaceRenameHandler(), "foo", myFixture);
+    }
     myFixture.checkResultByFile prefix + "_after.groovy"
   }
 
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/util/TestUtils.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/util/TestUtils.java
index b709431..e534333 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/util/TestUtils.java
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/util/TestUtils.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,6 +59,7 @@
   public static final String GROOVY_JAR_18 = "groovy-1.8.0-beta-2.jar";
   public static final String GROOVY_JAR_21 = "groovy-all-2.1.3.jar";
   public static final String GROOVY_JAR_22 = "groovy-all-2.2.0-beta-1.jar";
+  public static final String GROOVY_JAR_23 = "groovy-all-2.3.0.jar";
 
   public static String getMockJdkHome() {
     return getAbsoluteTestDataPath() + "/mockJDK";
@@ -92,6 +93,10 @@
     return getAbsoluteTestDataPath() + "/mockGroovyLib2.2";
   }
 
+  private static String getMockGroovy2_3LibraryHome() {
+    return getAbsoluteTestDataPath() + "/mockGroovyLib2.3";
+  }
+
   public static String getMockGroovy1_8LibraryName() {
     return getMockGroovy1_8LibraryHome()+"/"+GROOVY_JAR_18;
   }
@@ -104,6 +109,10 @@
     return getMockGroovy2_2LibraryHome() + "/" + GROOVY_JAR_22;
   }
 
+  public static String getMockGroovy2_3LibraryName() {
+    return getMockGroovy2_3LibraryHome() + "/" + GROOVY_JAR_23;
+  }
+
   public static PsiFile createPseudoPhysicalGroovyFile(final Project project, final String text) throws IncorrectOperationException {
     return createPseudoPhysicalFile(project, TEMP_FILE, text);
   }
diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/moveIntoEmptyLine.test b/plugins/groovy/testdata/groovy/actions/moveStatement/moveIntoEmptyLine.test
index 56aeaea..2d542f2 100644
--- a/plugins/groovy/testdata/groovy/actions/moveStatement/moveIntoEmptyLine.test
+++ b/plugins/groovy/testdata/groovy/actions/moveStatement/moveIntoEmptyLine.test
@@ -3,11 +3,11 @@
 
 }
 pri<caret>ntln 'b'
-pri<caret>ntln 'c'
+println 'c'
 -----
 if (true) {
     println 'a'
 
     pri<caret>ntln 'b'
 }
-pri<caret>ntln 'c'
\ No newline at end of file
+println 'c'
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/actions/moveStatement/moveIntoEmptyLine2.test b/plugins/groovy/testdata/groovy/actions/moveStatement/moveIntoEmptyLine2.test
index b144854..2d8ab23 100644
--- a/plugins/groovy/testdata/groovy/actions/moveStatement/moveIntoEmptyLine2.test
+++ b/plugins/groovy/testdata/groovy/actions/moveStatement/moveIntoEmptyLine2.test
@@ -2,10 +2,10 @@
 
 }
 pri<caret>ntln 'b'
-pri<caret>ntln 'c'
+println 'c'
 -----
 if (true) {
 
     pri<caret>ntln 'b'
 }
-pri<caret>ntln 'c'
\ No newline at end of file
+println 'c'
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/completion/GroovyDocParameter.groovy b/plugins/groovy/testdata/groovy/completion/GroovyDocParameter.groovy
index 69eb9e6..a14f4b7 100644
--- a/plugins/groovy/testdata/groovy/completion/GroovyDocParameter.groovy
+++ b/plugins/groovy/testdata/groovy/completion/GroovyDocParameter.groovy
@@ -3,7 +3,7 @@
    * @param x<caret> abc
    * dfgdsfgdjkg
    * @param y sdgfhjsd
-   * @param <caret>
+   * @param
    */
   def abc(def xx, def xy) {
 
diff --git a/plugins/groovy/testdata/groovy/controlFlow/mayBeStaticWithCondition.test b/plugins/groovy/testdata/groovy/controlFlow/mayBeStaticWithCondition.test
index bd37862..362d0ea 100644
--- a/plugins/groovy/testdata/groovy/controlFlow/mayBeStaticWithCondition.test
+++ b/plugins/groovy/testdata/groovy/controlFlow/mayBeStaticWithCondition.test
@@ -4,9 +4,8 @@
 1(2) READ a
 2(3,6) Condition Instanceof expression
 3(4) instanceof: a instanceof String
-4(5,9)  Negating goto instruction, condition=2Instanceof expression
-5() element: Instanceof expression MAYBE_RETURN
+4(5)  Negating goto instruction, condition=2Instanceof expression
+5(8) element: Instanceof expression MAYBE_RETURN
 6(7) instanceof: a instanceof String
 7(8) element: Instanceof expression MAYBE_RETURN
-8(9) element: Instanceof expression MAYBE_RETURN
-9() element: null
\ No newline at end of file
+8() element: null
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/controlFlow/unfinishedAssignment.test b/plugins/groovy/testdata/groovy/controlFlow/unfinishedAssignment.test
new file mode 100644
index 0000000..3fc4b3b
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/controlFlow/unfinishedAssignment.test
@@ -0,0 +1,9 @@
+def a = 5
+
+a =
+-----
+0(1) element: null
+1(2) WRITE a
+2(3) WRITE a
+3(4) element: Assignment expression MAYBE_RETURN
+4() element: null
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/formatter/bin3.test b/plugins/groovy/testdata/groovy/formatter/bin3.test
new file mode 100644
index 0000000..bb943d5
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/formatter/bin3.test
@@ -0,0 +1,3 @@
+a<=>b
+-----
+a <=> b
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/formatter/extraLines.test b/plugins/groovy/testdata/groovy/formatter/extraLines.test
new file mode 100644
index 0000000..1fa2e57
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/formatter/extraLines.test
@@ -0,0 +1,14 @@
+package abc
+
+
+
+
+
+
+
+print 1
+-----
+package abc
+
+
+print 1
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/formatter/gDocAfterImports.test b/plugins/groovy/testdata/groovy/formatter/gDocAfterImports.test
new file mode 100644
index 0000000..51d91ac
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/formatter/gDocAfterImports.test
@@ -0,0 +1,14 @@
+import javax.swing.*
+/**
+ * doc
+ */
+class MyFrame extends JFrame {
+}
+-----
+import javax.swing.*
+
+/**
+ * doc
+ */
+class MyFrame extends JFrame {
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/formatter/groovyDocAfterImports2.test b/plugins/groovy/testdata/groovy/formatter/groovyDocAfterImports2.test
new file mode 100644
index 0000000..4cb1d39
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/formatter/groovyDocAfterImports2.test
@@ -0,0 +1,15 @@
+import javax.swing.*;
+
+/**
+ * doc
+ */
+class MyFrame extends JFrame {
+}
+-----
+import javax.swing.*;
+
+/**
+ * doc
+ */
+class MyFrame extends JFrame {
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/formatter/labelWithDescription.test b/plugins/groovy/testdata/groovy/formatter/labelWithDescription.test
new file mode 100644
index 0000000..920a699b
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/formatter/labelWithDescription.test
@@ -0,0 +1,9 @@
+def "test"() {
+  given: "groovy"
+  def stack = new Stack()
+}
+-----
+def "test"() {
+  given: "groovy"
+    def stack = new Stack()
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/formatter/mapInArgumentList.test b/plugins/groovy/testdata/groovy/formatter/mapInArgumentList.test
index ea87e82..8101230 100644
--- a/plugins/groovy/testdata/groovy/formatter/mapInArgumentList.test
+++ b/plugins/groovy/testdata/groovy/formatter/mapInArgumentList.test
@@ -7,7 +7,7 @@
 -----
 test(
     changesSorter: [
-        (GradleMismatchedLibraryPathChange): 2,
+        (GradleMismatchedLibraryPathChange)    : 2,
         (GradleLibraryDependencyPresenceChange): 1
     ]
 )
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/formatter/regexExpressions.test b/plugins/groovy/testdata/groovy/formatter/regexExpressions.test
new file mode 100644
index 0000000..aa07247a
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/formatter/regexExpressions.test
@@ -0,0 +1,5 @@
+"foo"==~/bar/
+"foo"=~/bar/
+-----
+"foo" ==~ /bar/
+"foo" =~ /bar/
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/formatter/spreadArg.test b/plugins/groovy/testdata/groovy/formatter/spreadArg.test
new file mode 100644
index 0000000..e259549
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/formatter/spreadArg.test
@@ -0,0 +1,7 @@
+def foo(x, y) {}
+
+foo(* [1, 3])
+-----
+def foo(x, y) {}
+
+foo(*[1, 3])
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/formatter/stuffAfterLineComments.test b/plugins/groovy/testdata/groovy/formatter/stuffAfterLineComments.test
index 65af467..c602447 100644
--- a/plugins/groovy/testdata/groovy/formatter/stuffAfterLineComments.test
+++ b/plugins/groovy/testdata/groovy/formatter/stuffAfterLineComments.test
@@ -23,9 +23,9 @@
     // comment for this formal parameter
     , b) {
   [a + b
-      // comment for this formula
-      , a * b
-      , a / b
+   // comment for this formula
+   , a * b
+   , a / b
   ].collect { it * 2 }
 }
 
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/afterExpression.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/afterExpression.test
new file mode 100644
index 0000000..676652a
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/afterExpression.test
@@ -0,0 +1,4 @@
+def foo() {
+  foo() <caret>
+}
+-----
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/afterLabel.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/afterLabel.test
index 13aa418..9dc9886 100644
--- a/plugins/groovy/testdata/groovy/oldCompletion/keyword/afterLabel.test
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/afterLabel.test
@@ -1,6 +1,5 @@
 foo: <caret>
 -----
-as
 assert
 boolean
 byte
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/afterNumberLiteral.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/afterNumberLiteral.test
new file mode 100644
index 0000000..8bf7c11
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/afterNumberLiteral.test
@@ -0,0 +1,13 @@
+def foo() {
+  4 <caret>
+}
+-----
+as
+false
+in
+instanceof
+new
+null
+super
+this
+true
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/assert.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/assert.test
index 0e0be88..ecc24d2 100644
--- a/plugins/groovy/testdata/groovy/oldCompletion/keyword/assert.test
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/assert.test
@@ -1,4 +1,3 @@
 as<caret>sert true
 -----
-as
 assert
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/else2.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/else2.test
index e95f662..afcd1e9 100644
--- a/plugins/groovy/testdata/groovy/oldCompletion/keyword/else2.test
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/else2.test
@@ -8,7 +8,6 @@
 
 String abc = 5
 -----
-as
 assert
 boolean
 byte
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/extends.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/extends.test
new file mode 100644
index 0000000..0bea567
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/extends.test
@@ -0,0 +1,3 @@
+class A ext<caret>
+-----
+extends
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/file12.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/file12.test
index 88fa02c..c671d6d 100644
--- a/plugins/groovy/testdata/groovy/oldCompletion/keyword/file12.test
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/file12.test
@@ -11,7 +11,6 @@
   }
 }
 -----
-as
 assert
 boolean
 byte
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/fin2.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/fin2.test
index 64fe8ad..f1796f0 100644
--- a/plugins/groovy/testdata/groovy/oldCompletion/keyword/fin2.test
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/fin2.test
@@ -2,7 +2,6 @@
 <caret>
 -----
 abstract
-as
 assert
 boolean
 byte
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/implements.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/implements.test
new file mode 100644
index 0000000..388b59d
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/implements.test
@@ -0,0 +1,3 @@
+class Y im<caret>
+-----
+implements
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/keywordsInParentheses.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/keywordsInParentheses.test
index 2b95e09..37025a2 100644
--- a/plugins/groovy/testdata/groovy/oldCompletion/keyword/keywordsInParentheses.test
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/keywordsInParentheses.test
@@ -1,6 +1,5 @@
 (<caret>)
 -----
-as
 boolean
 byte
 char
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/mod4.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/mod4.test
index 407e86a..4a1a022 100644
--- a/plugins/groovy/testdata/groovy/oldCompletion/keyword/mod4.test
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/mod4.test
@@ -1,7 +1,6 @@
 <caret>def foo(){}
 -----
 abstract
-as
 assert
 boolean
 byte
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/var1.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/var1.test
index c3ed6a4..c481d5d 100644
--- a/plugins/groovy/testdata/groovy/oldCompletion/keyword/var1.test
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/var1.test
@@ -9,7 +9,6 @@
 }
 -----
 abstract
-as
 assert
 boolean
 byte
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/var10.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/var10.test
index 70e3ca7..3365160 100644
--- a/plugins/groovy/testdata/groovy/oldCompletion/keyword/var10.test
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/var10.test
@@ -11,7 +11,6 @@
   }
 }
 -----
-as
 boolean
 byte
 char
diff --git a/plugins/groovy/testdata/groovy/oldCompletion/keyword/var2.test b/plugins/groovy/testdata/groovy/oldCompletion/keyword/var2.test
index 05fcbe1..d4ea980 100644
--- a/plugins/groovy/testdata/groovy/oldCompletion/keyword/var2.test
+++ b/plugins/groovy/testdata/groovy/oldCompletion/keyword/var2.test
@@ -11,7 +11,6 @@
 }
 -----
 abstract
-as
 assert
 boolean
 byte
diff --git a/plugins/groovy/testdata/groovy/refactoring/extractMethod/noContextConflicts.test b/plugins/groovy/testdata/groovy/refactoring/extractMethod/noContextConflicts.test
index 23964f5..6d59ee9 100644
--- a/plugins/groovy/testdata/groovy/refactoring/extractMethod/noContextConflicts.test
+++ b/plugins/groovy/testdata/groovy/refactoring/extractMethod/noContextConflicts.test
@@ -19,8 +19,8 @@
         testMethod()
     }
 
-    private void testMethod() {
-        use(StringCategory) {
+    private testMethod() {
+        return use(StringCategory) {
             println "TeSt".lower()
         }
     }
diff --git a/plugins/groovy/testdata/groovy/refactoring/inlineMethod/superCall.test b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/superCall.test
new file mode 100644
index 0000000..940cc34
--- /dev/null
+++ b/plugins/groovy/testdata/groovy/refactoring/inlineMethod/superCall.test
@@ -0,0 +1,33 @@
+class A {
+    def foo() {
+        A.print 'supercall'
+    }
+}
+
+class C {
+    class B extends A {
+
+        def foo() {
+            <selection>super.foo</selection>()
+
+            print 'current call'
+        }
+    }
+}
+-----
+class A {
+    def foo() {
+        A.print 'supercall'
+    }
+}
+
+class C {
+    class B extends A {
+
+        def foo() {
+            A.print('supercall')
+
+            print 'current call'
+        }
+    }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/groovy/stubs/slurper.test b/plugins/groovy/testdata/groovy/stubs/slurper.test
index 5675b9c..7d48d65 100644
--- a/plugins/groovy/testdata/groovy/stubs/slurper.test
+++ b/plugins/groovy/testdata/groovy/stubs/slurper.test
@@ -275,8 +275,10 @@
 [Groovy script]
   [Package definition]
     [Modifiers]
-  [Modifiers]
-  [Modifiers]
+  [Import statement]
+    [Modifiers]
+  [Import statement]
+    [Modifiers]
   [Class definition : ConfigSlurper]
     [Modifiers]
     [Extends clause]
diff --git a/plugins/groovy/testdata/highlighting/CircularInheritance.groovy b/plugins/groovy/testdata/highlighting/CircularInheritance.groovy
index b7d0c57..d0e3ad2 100644
--- a/plugins/groovy/testdata/highlighting/CircularInheritance.groovy
+++ b/plugins/groovy/testdata/highlighting/CircularInheritance.groovy
@@ -1,4 +1,4 @@
-<error descr="Cyclic inheritance involving 'Foo'"><error descr="Method 'invokeMethod' is not implemented">class Foo extends Bar </error></error>{}
-<error descr="Cyclic inheritance involving 'Bar'"><error descr="Method 'invokeMethod' is not implemented">class Bar extends Foo </error></error>{}
+<error descr="Cyclic inheritance involving 'Foo'"><error descr="Method 'invokeMethod' is not implemented">class Foo extends Bar</error></error> {}
+<error descr="Cyclic inheritance involving 'Bar'"><error descr="Method 'invokeMethod' is not implemented">class Bar extends Foo</error></error> {}
 
 println(new Foo())
\ No newline at end of file
diff --git a/plugins/groovy/testdata/highlighting/ConstructorWithAllParametersOptional.groovy b/plugins/groovy/testdata/highlighting/ConstructorWithAllParametersOptional.groovy
index 889f437..f3af609 100644
--- a/plugins/groovy/testdata/highlighting/ConstructorWithAllParametersOptional.groovy
+++ b/plugins/groovy/testdata/highlighting/ConstructorWithAllParametersOptional.groovy
@@ -9,6 +9,6 @@
   def Base2(int x){}
 }
 
-<error descr="There is no default constructor available in class 'Base2'">class Inheritor2 extends Base2 </error>{
+<error descr="There is no default constructor available in class 'Base2'">class Inheritor2 extends Base2</error> {
 
 }
\ No newline at end of file
diff --git a/plugins/groovy/testdata/highlighting/CyclicInheritance.groovy b/plugins/groovy/testdata/highlighting/CyclicInheritance.groovy
index 1b48c6e..43f9fc4 100644
--- a/plugins/groovy/testdata/highlighting/CyclicInheritance.groovy
+++ b/plugins/groovy/testdata/highlighting/CyclicInheritance.groovy
@@ -1,15 +1,15 @@
-<error descr="Cyclic inheritance involving 'A'"><error descr="Method 'invokeMethod' is not implemented">class A extends C </error></error>{
+<error descr="Cyclic inheritance involving 'A'"><error descr="Method 'invokeMethod' is not implemented">class A extends C</error></error> {
 
 }
 
-<error descr="Cyclic inheritance involving 'B'"><error descr="Method 'invokeMethod' is not implemented">class B extends A </error></error>{
+<error descr="Cyclic inheritance involving 'B'"><error descr="Method 'invokeMethod' is not implemented">class B extends A</error></error> {
 
 }
 
-<error descr="Cyclic inheritance involving 'C'"><error descr="Method 'invokeMethod' is not implemented">class C extends B </error></error>{
+<error descr="Cyclic inheritance involving 'C'"><error descr="Method 'invokeMethod' is not implemented">class C extends B</error></error> {
 
 }
 
-<error descr="Cyclic inheritance involving 'B'"><error descr="Method 'invokeMethod' is not implemented">class D extends B </error></error>{
+<error descr="Cyclic inheritance involving 'B'"><error descr="Method 'invokeMethod' is not implemented">class D extends B</error></error> {
 
 }
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/convertConcatenationToGstring/Dot.groovy b/plugins/groovy/testdata/intentions/convertConcatenationToGstring/Dot.groovy
index b40c523..df90ca2 100644
--- a/plugins/groovy/testdata/intentions/convertConcatenationToGstring/Dot.groovy
+++ b/plugins/groovy/testdata/intentions/convertConcatenationToGstring/Dot.groovy
@@ -1 +1,2 @@
+def test = 1
 print test<caret>+".test"
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/convertConcatenationToGstring/Dot_after.groovy b/plugins/groovy/testdata/intentions/convertConcatenationToGstring/Dot_after.groovy
index a8b09fd..38210c2 100644
--- a/plugins/groovy/testdata/intentions/convertConcatenationToGstring/Dot_after.groovy
+++ b/plugins/groovy/testdata/intentions/convertConcatenationToGstring/Dot_after.groovy
@@ -1 +1,2 @@
+def test = 1
 print "${test}.test"
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method1.groovy b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method1.groovy
new file mode 100644
index 0000000..458f95b
--- /dev/null
+++ b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method1.groovy
@@ -0,0 +1 @@
+int f<caret>oo() {}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method1_after.groovy b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method1_after.groovy
new file mode 100644
index 0000000..20c0509
--- /dev/null
+++ b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method1_after.groovy
@@ -0,0 +1 @@
+def foo() {}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method2.groovy b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method2.groovy
new file mode 100644
index 0000000..5f9b349
--- /dev/null
+++ b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method2.groovy
@@ -0,0 +1,2 @@
+@Nullable
+int f<caret>oo() {}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method2_after.groovy b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method2_after.groovy
new file mode 100644
index 0000000..9976ebc
--- /dev/null
+++ b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method2_after.groovy
@@ -0,0 +1,2 @@
+@Nullable
+def foo() {}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method3.groovy b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method3.groovy
new file mode 100644
index 0000000..9bbe853
--- /dev/null
+++ b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method3.groovy
@@ -0,0 +1,2 @@
+@Abnc public
+int f<caret>oo() {}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method3_after.groovy b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method3_after.groovy
new file mode 100644
index 0000000..a3cce56
--- /dev/null
+++ b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method3_after.groovy
@@ -0,0 +1,2 @@
+@Abnc public
+def f<caret>oo() {}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method4.groovy b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method4.groovy
new file mode 100644
index 0000000..70e3ce9
--- /dev/null
+++ b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method4.groovy
@@ -0,0 +1 @@
+@Abc def public int f<caret>oo() {}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method4_after.groovy b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method4_after.groovy
new file mode 100644
index 0000000..69b230a
--- /dev/null
+++ b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method4_after.groovy
@@ -0,0 +1 @@
+@Abc def public f<caret>oo() {}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method5.groovy b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method5.groovy
new file mode 100644
index 0000000..b88295e
--- /dev/null
+++ b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method5.groovy
@@ -0,0 +1,2 @@
+public def
+int fo<caret>o() {}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method5_after.groovy b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method5_after.groovy
new file mode 100644
index 0000000..b8f85c7
--- /dev/null
+++ b/plugins/groovy/testdata/intentions/removeExplicitTypeDeclaration/Method5_after.groovy
@@ -0,0 +1,2 @@
+public
+def fo<caret>o() {}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/sortMap/BasicMapSort.groovy b/plugins/groovy/testdata/intentions/sortMap/BasicMapSort.groovy
new file mode 100644
index 0000000..f39fa4f
--- /dev/null
+++ b/plugins/groovy/testdata/intentions/sortMap/BasicMapSort.groovy
@@ -0,0 +1 @@
+def phones = [Pet<caret>er: 45678, Max : 78564, Ann : 23467]
\ No newline at end of file
diff --git a/plugins/groovy/testdata/intentions/sortMap/BasicMapSort_after.groovy b/plugins/groovy/testdata/intentions/sortMap/BasicMapSort_after.groovy
new file mode 100644
index 0000000..3aac7db
--- /dev/null
+++ b/plugins/groovy/testdata/intentions/sortMap/BasicMapSort_after.groovy
@@ -0,0 +1,3 @@
+def phones = [Ann  : 23467,
+              Max  : 78564,
+              Peter: 45678]
\ No newline at end of file
diff --git a/plugins/groovy/testdata/mockGroovyLib2.3/groovy-all-2.3.0.jar b/plugins/groovy/testdata/mockGroovyLib2.3/groovy-all-2.3.0.jar
new file mode 100644
index 0000000..3b5173f
--- /dev/null
+++ b/plugins/groovy/testdata/mockGroovyLib2.3/groovy-all-2.3.0.jar
Binary files differ
diff --git a/plugins/groovy/testdata/optimizeImports/Commented_after.groovy b/plugins/groovy/testdata/optimizeImports/Commented_after.groovy
index 70fba0b..29d323e 100644
--- a/plugins/groovy/testdata/optimizeImports/Commented_after.groovy
+++ b/plugins/groovy/testdata/optimizeImports/Commented_after.groovy
@@ -1,4 +1,5 @@
 import javax.swing.*
+
 // preved!
 
 def frame = new JFrame()
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports.groovy
index 71eb1fe..cdbbb60 100644
--- a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports.groovy
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports.groovy
@@ -4,4 +4,5 @@
 
 class ScriptRunnerProxyy {
   private static ClassLoader scriptLoader
+  Abc f;
 }
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports2.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports2.groovy
new file mode 100644
index 0000000..62b8e2a
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports2.groovy
@@ -0,0 +1,8 @@
+import java.zzz
+import java.yyy.*
+import java.lang.ClassLoader
+
+class ScriptRunnerProxyy {
+  private static ClassLoader scriptLoader
+  private zzz f;
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports2_after.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports2_after.groovy
new file mode 100644
index 0000000..1194d38
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports2_after.groovy
@@ -0,0 +1,7 @@
+import java.yyy.*
+import java.zzz
+
+class ScriptRunnerProxyy {
+  private static ClassLoader scriptLoader
+  private zzz f;
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports3.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports3.groovy
new file mode 100644
index 0000000..6d9ff60
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports3.groovy
@@ -0,0 +1,8 @@
+import java.zzzz
+import java.yyy.*
+import java.lang.ClassLoader
+
+class ScriptRunnerProxyy {
+  private static ClassLoader scriptLoader
+  private zzz f;
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports3_after.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports3_after.groovy
new file mode 100644
index 0000000..38f1f991a5
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports3_after.groovy
@@ -0,0 +1,6 @@
+import java.yyy.*
+
+class ScriptRunnerProxyy {
+  private static ClassLoader scriptLoader
+  private zzz f;
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports4.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports4.groovy
new file mode 100644
index 0000000..f6913f4
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports4.groovy
@@ -0,0 +1,8 @@
+import java.zzz as Abc
+import java.yyy.*
+import java.lang.ClassLoader
+
+class ScriptRunnerProxyy {
+  private static ClassLoader scriptLoader
+  private Abc f;
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports4_after.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports4_after.groovy
new file mode 100644
index 0000000..b36474f
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports4_after.groovy
@@ -0,0 +1,7 @@
+import java.yyy.*
+import java.zzz as Abc
+
+class ScriptRunnerProxyy {
+  private static ClassLoader scriptLoader
+  private Abc f;
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports5.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports5.groovy
new file mode 100644
index 0000000..dcb9c90
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports5.groovy
@@ -0,0 +1,6 @@
+import java.x.Cde as Abc
+import java.x.Cde
+
+class ScriptRunnerProxyy {
+  private static Cde x
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports5_after.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports5_after.groovy
new file mode 100644
index 0000000..293f042
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports5_after.groovy
@@ -0,0 +1,5 @@
+import java.x.Cde
+
+class ScriptRunnerProxyy {
+  private static Cde x
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports6.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports6.groovy
new file mode 100644
index 0000000..416cbc1
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports6.groovy
@@ -0,0 +1,6 @@
+import java.x.Cde as Abc
+import java.x.Cde
+
+class ScriptRunnerProxyy {
+  private static Abc x
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports6_after.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports6_after.groovy
new file mode 100644
index 0000000..5c94d50
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports6_after.groovy
@@ -0,0 +1,5 @@
+import java.x.Cde as Abc
+
+class ScriptRunnerProxyy {
+  private static Abc x
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports7.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports7.groovy
new file mode 100644
index 0000000..6cbf4a2d
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports7.groovy
@@ -0,0 +1,7 @@
+import java.x.Cde as Abc
+import java.x.Cde
+
+class ScriptRunnerProxyy {
+  private static Cde x
+  private static Abc y
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports7_after.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports7_after.groovy
new file mode 100644
index 0000000..6cbf4a2d
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports7_after.groovy
@@ -0,0 +1,7 @@
+import java.x.Cde as Abc
+import java.x.Cde
+
+class ScriptRunnerProxyy {
+  private static Cde x
+  private static Abc y
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports8.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports8.groovy
new file mode 100644
index 0000000..dd0b3f6
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports8.groovy
@@ -0,0 +1,4 @@
+import static abc.X.foo
+import static abc.X.bar
+
+print foo()
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports8_after.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports8_after.groovy
new file mode 100644
index 0000000..b3eafc4
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports8_after.groovy
@@ -0,0 +1,3 @@
+import static abc.X.foo
+
+print foo()
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports9.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports9.groovy
new file mode 100644
index 0000000..1fb427b
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports9.groovy
@@ -0,0 +1,4 @@
+import static abc.X.foo as bar
+import static abc.X.baz as xyz
+
+print bar()
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports9_after.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports9_after.groovy
new file mode 100644
index 0000000..0549ca7
--- /dev/null
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports9_after.groovy
@@ -0,0 +1,3 @@
+import static abc.X.foo as bar
+
+print bar()
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports_after.groovy b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports_after.groovy
index 352121354..2fcf294 100644
--- a/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports_after.groovy
+++ b/plugins/groovy/testdata/optimizeImports/DontRemoveRedImports_after.groovy
@@ -1,6 +1,6 @@
-import java.zzz
 import java.yyy.*
 
 class ScriptRunnerProxyy {
   private static ClassLoader scriptLoader
+  Abc f;
 }
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/JavaUtilString.groovy b/plugins/groovy/testdata/optimizeImports/JavaUtilString.groovy
deleted file mode 100644
index 82a136d..0000000
--- a/plugins/groovy/testdata/optimizeImports/JavaUtilString.groovy
+++ /dev/null
@@ -1,9 +0,0 @@
-import java.util.String
-
-class GrEnum {
-
-  {
-    new AntBuilder().delete(dir: workdir.absolutePath)
-  }
-
-}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/optimizeImports/JavaUtilString_after.groovy b/plugins/groovy/testdata/optimizeImports/JavaUtilString_after.groovy
deleted file mode 100644
index 82a136d..0000000
--- a/plugins/groovy/testdata/optimizeImports/JavaUtilString_after.groovy
+++ /dev/null
@@ -1,9 +0,0 @@
-import java.util.String
-
-class GrEnum {
-
-  {
-    new AntBuilder().delete(dir: workdir.absolutePath)
-  }
-
-}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/ann1.test b/plugins/groovy/testdata/parsing/groovy/annotations/ann1.test
index 7896c70..803951b 100644
--- a/plugins/groovy/testdata/parsing/groovy/annotations/ann1.test
+++ b/plugins/groovy/testdata/parsing/groovy/annotations/ann1.test
@@ -29,11 +29,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('b')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/ann2.test b/plugins/groovy/testdata/parsing/groovy/annotations/ann2.test
index 564bd35..b0fae49 100644
--- a/plugins/groovy/testdata/parsing/groovy/annotations/ann2.test
+++ b/plugins/groovy/testdata/parsing/groovy/annotations/ann2.test
@@ -40,9 +40,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/ann3.test b/plugins/groovy/testdata/parsing/groovy/annotations/ann3.test
index 9b42636..f7645a0 100644
--- a/plugins/groovy/testdata/parsing/groovy/annotations/ann3.test
+++ b/plugins/groovy/testdata/parsing/groovy/annotations/ann3.test
@@ -9,9 +9,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('A')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -21,9 +21,9 @@
             PsiElement(@)('@')
             Reference element
               PsiElement(identifier)('Nullable')
-            PsiWhiteSpace(' ')
             Annotation arguments
               <empty list>
+          PsiWhiteSpace(' ')
           PsiElement(def)('def')
         PsiWhiteSpace(' ')
         Type element
diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/ann4.test b/plugins/groovy/testdata/parsing/groovy/annotations/ann4.test
index df85630..2718b61 100644
--- a/plugins/groovy/testdata/parsing/groovy/annotations/ann4.test
+++ b/plugins/groovy/testdata/parsing/groovy/annotations/ann4.test
@@ -26,11 +26,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/ann7.test b/plugins/groovy/testdata/parsing/groovy/annotations/ann7.test
index fb003a0..b48fc30 100644
--- a/plugins/groovy/testdata/parsing/groovy/annotations/ann7.test
+++ b/plugins/groovy/testdata/parsing/groovy/annotations/ann7.test
@@ -30,11 +30,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('GroovyClass')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/annotations/classLiteral.test b/plugins/groovy/testdata/parsing/groovy/annotations/classLiteral.test
index a9cdf2d..f7692a14 100644
--- a/plugins/groovy/testdata/parsing/groovy/annotations/classLiteral.test
+++ b/plugins/groovy/testdata/parsing/groovy/annotations/classLiteral.test
@@ -24,11 +24,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('b')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/comments/error1205.test b/plugins/groovy/testdata/parsing/groovy/comments/error1205.test
index 8035ba6..5206e22 100644
--- a/plugins/groovy/testdata/parsing/groovy/comments/error1205.test
+++ b/plugins/groovy/testdata/parsing/groovy/comments/error1205.test
@@ -10,11 +10,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('A')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/closures/param6.test b/plugins/groovy/testdata/parsing/groovy/expressions/closures/param6.test
index 075c6b3..37bed96 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/closures/param6.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/closures/param6.test
@@ -32,9 +32,9 @@
         Literal
           PsiElement(Integer)('3')
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/closures/param7.test b/plugins/groovy/testdata/parsing/groovy/expressions/closures/param7.test
index 9f0ec7b..a918012 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/closures/param7.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/closures/param7.test
@@ -11,9 +11,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/path/method/method13.test b/plugins/groovy/testdata/parsing/groovy/expressions/path/method/method13.test
index 19e07d1..86db5c7 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/path/method/method13.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/path/method/method13.test
@@ -12,9 +12,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n   ')
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/path/typeVsExpr.test b/plugins/groovy/testdata/parsing/groovy/expressions/path/typeVsExpr.test
index 9a94767..c498a14 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/path/typeVsExpr.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/path/typeVsExpr.test
@@ -13,9 +13,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/references/ref8.test b/plugins/groovy/testdata/parsing/groovy/expressions/references/ref8.test
new file mode 100644
index 0000000..d2d4cc4
--- /dev/null
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/references/ref8.test
@@ -0,0 +1,26 @@
+'abc'
+   {
+     print 2
+   }
+-----
+Groovy script
+  Method call
+    Reference expression
+      PsiElement(string)(''abc'')
+    Arguments
+      <empty list>
+    PsiElement(new line)('\n   ')
+    Closable block
+      PsiElement({)('{')
+      PsiWhiteSpace('\n     ')
+      Parameter list
+        <empty list>
+      Call expression
+        Reference expression
+          PsiElement(identifier)('print')
+        PsiWhiteSpace(' ')
+        Command arguments
+          Literal
+            PsiElement(Integer)('2')
+      PsiElement(new line)('\n   ')
+      PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex24.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex24.test
new file mode 100644
index 0000000..b5833d5
--- /dev/null
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex24.test
@@ -0,0 +1,47 @@
+print (/cde $this abc $this $+/)
+print (/cde $package pack/)
+-----
+Groovy script
+  Method call
+    Reference expression
+      PsiElement(identifier)('print')
+    PsiWhiteSpace(' ')
+    Arguments
+      PsiElement(()('(')
+      Compound regular expression
+        PsiElement(regex begin)('/')
+        GrStringContentImpl(GString content element)
+          PsiElement(regex content)('cde ')
+        GString injection
+          PsiElement($)('$')
+          Reference expression
+            PsiElement(this)('this')
+        GrStringContentImpl(GString content element)
+          PsiElement(regex content)(' abc ')
+        GString injection
+          PsiElement($)('$')
+          Reference expression
+            PsiElement(this)('this')
+        GrStringContentImpl(GString content element)
+          PsiElement(regex content)(' $+')
+        PsiElement(regex end)('/')
+      PsiElement())(')')
+  PsiElement(new line)('\n')
+  Method call
+    Reference expression
+      PsiElement(identifier)('print')
+    PsiWhiteSpace(' ')
+    Arguments
+      PsiElement(()('(')
+      Compound regular expression
+        PsiElement(regex begin)('/')
+        GrStringContentImpl(GString content element)
+          PsiElement(regex content)('cde ')
+        GString injection
+          PsiElement($)('$')
+          PsiErrorElement:Identifier or code block expected
+            PsiElement(package)('package')
+        GrStringContentImpl(GString content element)
+          PsiElement(regex content)(' pack')
+        PsiElement(regex end)('/')
+      PsiElement())(')')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex25.test b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex25.test
new file mode 100644
index 0000000..c87b812
--- /dev/null
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/regex/regex25.test
@@ -0,0 +1,47 @@
+print ($/cde $this abc $this $+/$)
+print ($/cde $package pack/$)
+-----
+Groovy script
+  Method call
+    Reference expression
+      PsiElement(identifier)('print')
+    PsiWhiteSpace(' ')
+    Arguments
+      PsiElement(()('(')
+      Compound regular expression
+        PsiElement($/ regex begin)('$/')
+        GrStringContentImpl(GString content element)
+          PsiElement($/ regex content)('cde ')
+        GString injection
+          PsiElement($)('$')
+          Reference expression
+            PsiElement(this)('this')
+        GrStringContentImpl(GString content element)
+          PsiElement($/ regex content)(' abc ')
+        GString injection
+          PsiElement($)('$')
+          Reference expression
+            PsiElement(this)('this')
+        GrStringContentImpl(GString content element)
+          PsiElement($/ regex content)(' $+')
+        PsiElement($/ regex end)('/$')
+      PsiElement())(')')
+  PsiElement(new line)('\n')
+  Method call
+    Reference expression
+      PsiElement(identifier)('print')
+    PsiWhiteSpace(' ')
+    Arguments
+      PsiElement(()('(')
+      Compound regular expression
+        PsiElement($/ regex begin)('$/')
+        GrStringContentImpl(GString content element)
+          PsiElement($/ regex content)('cde ')
+        GString injection
+          PsiElement($)('$')
+          PsiErrorElement:Identifier or code block expected
+            PsiElement(package)('package')
+        GrStringContentImpl(GString content element)
+          PsiElement($/ regex content)(' pack')
+        PsiElement($/ regex end)('/$')
+      PsiElement())(')')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/super/qualifiedSuper.test b/plugins/groovy/testdata/parsing/groovy/expressions/super/qualifiedSuper.test
index df0c2b6..1749c57 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/super/qualifiedSuper.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/super/qualifiedSuper.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('X')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -28,9 +28,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n        ')
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/super/super.test b/plugins/groovy/testdata/parsing/groovy/expressions/super/super.test
index e6dcf1e..9038561 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/super/super.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/super/super.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('X')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -28,9 +28,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n        ')
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/this/qualifiedThis.test b/plugins/groovy/testdata/parsing/groovy/expressions/this/qualifiedThis.test
index bdf617e..a16ce315 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/this/qualifiedThis.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/this/qualifiedThis.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('X')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -28,9 +28,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n        ')
diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/this/this.test b/plugins/groovy/testdata/parsing/groovy/expressions/this/this.test
index 068199e..8a07aed 100644
--- a/plugins/groovy/testdata/parsing/groovy/expressions/this/this.test
+++ b/plugins/groovy/testdata/parsing/groovy/expressions/this/this.test
@@ -30,9 +30,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n        ')
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/err1.test b/plugins/groovy/testdata/parsing/groovy/generics/err1.test
index 9fa0c15..5d5bbc0 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/err1.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/err1.test
@@ -36,11 +36,11 @@
         Type extends bounds list
           <empty list>
       PsiElement(>)('>')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/err2.test b/plugins/groovy/testdata/parsing/groovy/generics/err2.test
index d9abd0e..7d97b4d 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/err2.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/err2.test
@@ -29,11 +29,11 @@
         Type extends bounds list
           <empty list>
       PsiElement(>)('>')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/err3.test b/plugins/groovy/testdata/parsing/groovy/generics/err3.test
index 0356c86..274b2b8 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/err3.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/err3.test
@@ -10,11 +10,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('A')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/err4.test b/plugins/groovy/testdata/parsing/groovy/generics/err4.test
index 67281e6..572d106 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/err4.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/err4.test
@@ -9,11 +9,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('A')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/genmethod1.test b/plugins/groovy/testdata/parsing/groovy/generics/genmethod1.test
index 353896f..3b9fb06 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/genmethod1.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/genmethod1.test
@@ -18,9 +18,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/genmethod2.test b/plugins/groovy/testdata/parsing/groovy/generics/genmethod2.test
index d96d79f..21224e5 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/genmethod2.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/genmethod2.test
@@ -16,11 +16,11 @@
         Type extends bounds list
           <empty list>
       PsiElement(>)('>')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n')
@@ -45,9 +45,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/genmethod3.test b/plugins/groovy/testdata/parsing/groovy/generics/genmethod3.test
index ea2dce1..5798bb1 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/genmethod3.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/genmethod3.test
@@ -16,9 +16,9 @@
         Type extends bounds list
           <empty list>
       PsiElement(>)('>')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n')
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/genmethod4.test b/plugins/groovy/testdata/parsing/groovy/generics/genmethod4.test
index bc6e2c1..9a4c6f8 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/genmethod4.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/genmethod4.test
@@ -22,9 +22,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/genmethod5.test b/plugins/groovy/testdata/parsing/groovy/generics/genmethod5.test
index 3b08b5c..6f43c2e 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/genmethod5.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/genmethod5.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('A')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -40,9 +40,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/typeargs1.test b/plugins/groovy/testdata/parsing/groovy/generics/typeargs1.test
index 83bf489..58e8901 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/typeargs1.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/typeargs1.test
@@ -25,11 +25,11 @@
                   PsiElement(identifier)('S')
               PsiElement(>)('>')
       PsiElement(>)('>')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/typeparam1.test b/plugins/groovy/testdata/parsing/groovy/generics/typeparam1.test
index 2d31e1e..0b8013c 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/typeparam1.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/typeparam1.test
@@ -15,11 +15,11 @@
         Type extends bounds list
           <empty list>
       PsiElement(>)('>')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/typeparam2.test b/plugins/groovy/testdata/parsing/groovy/generics/typeparam2.test
index 7da8c21..771cfb8 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/typeparam2.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/typeparam2.test
@@ -23,11 +23,11 @@
           Reference element
             PsiElement(identifier)('U')
       PsiElement(>)('>')
-    PsiWhiteSpace('  ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace('  ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/generics/typeparam3.test b/plugins/groovy/testdata/parsing/groovy/generics/typeparam3.test
index 75dbf33..91c1578 100644
--- a/plugins/groovy/testdata/parsing/groovy/generics/typeparam3.test
+++ b/plugins/groovy/testdata/parsing/groovy/generics/typeparam3.test
@@ -48,11 +48,11 @@
           PsiErrorElement:Type expected
             <empty list>
       PsiElement(>)('>')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/packaging/pack3.test b/plugins/groovy/testdata/parsing/groovy/packaging/pack3.test
index bd24b1f..179df1e 100644
--- a/plugins/groovy/testdata/parsing/groovy/packaging/pack3.test
+++ b/plugins/groovy/testdata/parsing/groovy/packaging/pack3.test
@@ -7,16 +7,14 @@
     Modifiers
       <empty list>
     PsiElement(package)('package')
-    PsiErrorElement:Identifier expected
-      <empty list>
-  PsiWhiteSpace(' ')
-  Reference expression
-    Reference expression
-      Reference expression
-        PsiElement(identifier)('a')
+    PsiWhiteSpace(' ')
+    Reference element
+      Reference element
+        Reference element
+          PsiElement(identifier)('a')
+        PsiElement(.)('.')
+        PsiElement(new line)('\n')
+        PsiElement(identifier)('b')
       PsiElement(.)('.')
       PsiElement(new line)('\n')
-      PsiElement(identifier)('b')
-    PsiElement(.)('.')
-    PsiElement(new line)('\n')
-    PsiElement(identifier)('c')
\ No newline at end of file
+      PsiElement(identifier)('c')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/branch/ret1.test b/plugins/groovy/testdata/parsing/groovy/statements/branch/ret1.test
index 6cd59bd..82f5112 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/branch/ret1.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/branch/ret1.test
@@ -12,11 +12,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('MyMath')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n   ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/class_initializers/class_init1.test b/plugins/groovy/testdata/parsing/groovy/statements/class_initializers/class_init1.test
index 801c54e..f81d7a7 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/class_initializers/class_init1.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/class_initializers/class_init1.test
@@ -14,11 +14,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('A')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/class_initializers/stat_block.test b/plugins/groovy/testdata/parsing/groovy/statements/class_initializers/stat_block.test
index f49c328..ff07ff1 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/class_initializers/stat_block.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/class_initializers/stat_block.test
@@ -15,11 +15,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('A')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/declaration/GRVY-1451.test b/plugins/groovy/testdata/parsing/groovy/statements/declaration/GRVY-1451.test
index ff33007..86430f4 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/declaration/GRVY-1451.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/declaration/GRVY-1451.test
@@ -7,11 +7,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('BacklogItem')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace(' ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/declaration/decl11.test b/plugins/groovy/testdata/parsing/groovy/statements/declaration/decl11.test
index 84f7138..08db040 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/declaration/decl11.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/declaration/decl11.test
@@ -30,11 +30,9 @@
         PsiElement(identifier)('gory')
     PsiErrorElement:')' expected
       <empty list>
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
-  PsiErrorElement:';' or new line expected
-    <empty list>
+  PsiWhiteSpace(' ')
   Reference expression
     PsiElement(identifier)('other')
   PsiErrorElement:';' or new line expected
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/declaration/nl_trows.test b/plugins/groovy/testdata/parsing/groovy/statements/declaration/nl_trows.test
index b7d3cac..591de4e 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/declaration/nl_trows.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/declaration/nl_trows.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('Foos')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n\t')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/for/for13.test b/plugins/groovy/testdata/parsing/groovy/statements/for/for13.test
new file mode 100644
index 0000000..305e2ead
--- /dev/null
+++ b/plugins/groovy/testdata/parsing/groovy/statements/for/for13.test
@@ -0,0 +1,31 @@
+for(i : 5 ?: 5) {
+
+}
+-----
+Groovy script
+  For statement
+    PsiElement(for)('for')
+    PsiElement(()('(')
+    In clause
+      Parameter
+        Modifiers
+          <empty list>
+        PsiElement(identifier)('i')
+      PsiWhiteSpace(' ')
+      PsiElement(:)(':')
+      PsiWhiteSpace(' ')
+      Elvis expression
+        Literal
+          PsiElement(Integer)('5')
+        PsiWhiteSpace(' ')
+        PsiElement(?:)('?:')
+        PsiWhiteSpace(' ')
+        Literal
+          PsiElement(Integer)('5')
+    PsiElement())(')')
+    PsiWhiteSpace(' ')
+    Block statement
+      Open block
+        PsiElement({)('{')
+        PsiWhiteSpace('\n\n')
+        PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/ifRecovery.test b/plugins/groovy/testdata/parsing/groovy/statements/ifRecovery.test
index 4214ae1..fe03750 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/ifRecovery.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/ifRecovery.test
@@ -12,9 +12,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/imports/imp8.test b/plugins/groovy/testdata/parsing/groovy/statements/imports/imp8.test
new file mode 100644
index 0000000..f20b09b
--- /dev/null
+++ b/plugins/groovy/testdata/parsing/groovy/statements/imports/imp8.test
@@ -0,0 +1,56 @@
+import a.;
+import a.b.;
+import;
+import a.b.c
+-----
+Groovy script
+  Import statement
+    Modifiers
+      <empty list>
+    PsiElement(import)('import')
+    PsiWhiteSpace(' ')
+    Reference element
+      Reference element
+        PsiElement(identifier)('a')
+      PsiElement(.)('.')
+      PsiErrorElement:Identifier expected
+        <empty list>
+  PsiElement(;)(';')
+  PsiElement(new line)('\n')
+  Import statement
+    Modifiers
+      <empty list>
+    PsiElement(import)('import')
+    PsiWhiteSpace(' ')
+    Reference element
+      Reference element
+        Reference element
+          PsiElement(identifier)('a')
+        PsiElement(.)('.')
+        PsiElement(identifier)('b')
+      PsiElement(.)('.')
+      PsiErrorElement:Identifier expected
+        <empty list>
+  PsiElement(;)(';')
+  PsiElement(new line)('\n')
+  Import statement
+    Modifiers
+      <empty list>
+    PsiElement(import)('import')
+    PsiErrorElement:package or class name expected
+      <empty list>
+  PsiElement(;)(';')
+  PsiElement(new line)('\n')
+  Import statement
+    Modifiers
+      <empty list>
+    PsiElement(import)('import')
+    PsiWhiteSpace(' ')
+    Reference element
+      Reference element
+        Reference element
+          PsiElement(identifier)('a')
+        PsiElement(.)('.')
+        PsiElement(identifier)('b')
+      PsiElement(.)('.')
+      PsiElement(identifier)('c')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/loop/while5.test b/plugins/groovy/testdata/parsing/groovy/statements/loop/while5.test
deleted file mode 100644
index f70711c..0000000
--- a/plugins/groovy/testdata/parsing/groovy/statements/loop/while5.test
+++ /dev/null
@@ -1,36 +0,0 @@
-while (def A a = 2+3){doo()}
------
-Groovy script
-  WHILE statement
-    PsiElement(while)('while')
-    PsiWhiteSpace(' ')
-    PsiElement(()('(')
-    Variable definitions
-      Modifiers
-        PsiElement(def)('def')
-      PsiWhiteSpace(' ')
-      Type element
-        Reference element
-          PsiElement(identifier)('A')
-      PsiWhiteSpace(' ')
-      PsiElement(identifier)('a')
-      PsiWhiteSpace(' ')
-      PsiElement(=)('=')
-      PsiWhiteSpace(' ')
-      Additive expression
-        Literal
-          PsiElement(Integer)('2')
-        PsiElement(+)('+')
-        Literal
-          PsiElement(Integer)('3')
-    PsiElement())(')')
-    Block statement
-      Open block
-        PsiElement({)('{')
-        Method call
-          Reference expression
-            PsiElement(identifier)('doo')
-          Arguments
-            PsiElement(()('(')
-            PsiElement())(')')
-        PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/methods/method3.test b/plugins/groovy/testdata/parsing/groovy/statements/methods/method3.test
index 4dd51bd..959149e 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/methods/method3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/methods/method3.test
@@ -14,9 +14,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/methods/method4.test b/plugins/groovy/testdata/parsing/groovy/statements/methods/method4.test
index 49d0241..67945eb 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/methods/method4.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/methods/method4.test
@@ -31,9 +31,9 @@
         PsiWhiteSpace(' ')
         PsiElement(identifier)('b')
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -44,11 +44,11 @@
         PsiElement(class)('class')
         PsiWhiteSpace(' ')
         PsiElement(identifier)('a')
-        PsiWhiteSpace(' ')
         Extends clause
           <empty list>
         Implements clause
           <empty list>
+        PsiWhiteSpace(' ')
         Type definition body
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/multiple_assign/without_assign.test b/plugins/groovy/testdata/parsing/groovy/statements/multiple_assign/without_assign.test
new file mode 100644
index 0000000..4402e22
--- /dev/null
+++ b/plugins/groovy/testdata/parsing/groovy/statements/multiple_assign/without_assign.test
@@ -0,0 +1,47 @@
+def a = 5
+def b = 5
+print ((a, b))
+-----
+Groovy script
+  Variable definitions
+    Modifiers
+      PsiElement(def)('def')
+    PsiWhiteSpace(' ')
+    Variable
+      PsiElement(identifier)('a')
+      PsiWhiteSpace(' ')
+      PsiElement(=)('=')
+      PsiWhiteSpace(' ')
+      Literal
+        PsiElement(Integer)('5')
+  PsiElement(new line)('\n')
+  Variable definitions
+    Modifiers
+      PsiElement(def)('def')
+    PsiWhiteSpace(' ')
+    Variable
+      PsiElement(identifier)('b')
+      PsiWhiteSpace(' ')
+      PsiElement(=)('=')
+      PsiWhiteSpace(' ')
+      Literal
+        PsiElement(Integer)('5')
+  PsiElement(new line)('\n')
+  Method call
+    Reference expression
+      PsiElement(identifier)('print')
+    PsiWhiteSpace(' ')
+    Arguments
+      PsiElement(()('(')
+      Tuple Assignment Expression
+        PsiElement(()('(')
+        Reference expression
+          PsiElement(identifier)('a')
+        PsiElement(,)(',')
+        PsiWhiteSpace(' ')
+        Reference expression
+          PsiElement(identifier)('b')
+        PsiElement())(')')
+      PsiErrorElement:'=' expected
+        <empty list>
+      PsiElement())(')')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/semicolonsOnDifferentLines.test b/plugins/groovy/testdata/parsing/groovy/statements/semicolonsOnDifferentLines.test
index 69e04e6..c33ffe2 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/semicolonsOnDifferentLines.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/semicolonsOnDifferentLines.test
@@ -15,9 +15,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/top_methods/method3.test b/plugins/groovy/testdata/parsing/groovy/statements/top_methods/method3.test
index 4dd51bd..959149e 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/top_methods/method3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/top_methods/method3.test
@@ -14,9 +14,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/top_methods/method4.test b/plugins/groovy/testdata/parsing/groovy/statements/top_methods/method4.test
index 49d0241..67945eb 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/top_methods/method4.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/top_methods/method4.test
@@ -31,9 +31,9 @@
         PsiWhiteSpace(' ')
         PsiElement(identifier)('b')
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -44,11 +44,11 @@
         PsiElement(class)('class')
         PsiWhiteSpace(' ')
         PsiElement(identifier)('a')
-        PsiWhiteSpace(' ')
         Extends clause
           <empty list>
         Implements clause
           <empty list>
+        PsiWhiteSpace(' ')
         Type definition body
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/try_catch/try5.test b/plugins/groovy/testdata/parsing/groovy/statements/try_catch/try5.test
index be148f4..cf90904 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/try_catch/try5.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/try_catch/try5.test
@@ -16,9 +16,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/tuples/nestedTupleUnsupp.test b/plugins/groovy/testdata/parsing/groovy/statements/tuples/nestedTupleUnsupp.test
index cc3ac6d..a304e07 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/tuples/nestedTupleUnsupp.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/tuples/nestedTupleUnsupp.test
@@ -16,7 +16,7 @@
       Reference expression
         PsiElement(identifier)('b')
       PsiElement())(')')
-    PsiErrorElement:')' expected
+    PsiErrorElement:'=' expected
       <empty list>
   PsiErrorElement:Unexpected symbol
     PsiElement(,)(',')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/tuples/tupleInClass.test b/plugins/groovy/testdata/parsing/groovy/statements/tuples/tupleInClass.test
index f3918a9..236ffde 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/tuples/tupleInClass.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/tuples/tupleInClass.test
@@ -9,11 +9,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('A')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/abstr.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/abstr.test
index 9add238..52f0f94 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/abstr.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/abstr.test
@@ -8,11 +8,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('C')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class1.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class1.test
index e8c7394..5dce63e 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class1.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class1.test
@@ -9,11 +9,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -24,9 +24,9 @@
         PsiElement(interface)('interface')
         PsiWhiteSpace(' ')
         PsiElement(identifier)('a')
-        PsiWhiteSpace(' ')
         Extends clause
           <empty list>
+        PsiWhiteSpace(' ')
         Type definition body
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class2.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class2.test
index 004be1e..e07e639 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class2.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class2.test
@@ -7,11 +7,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class3.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class3.test
index 2673c07..695866e 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class3.test
@@ -9,11 +9,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -27,9 +27,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class4.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class4.test
index 0cf7fc1..169a31a 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class4.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class4.test
@@ -9,11 +9,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('b')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n ')
@@ -41,9 +41,9 @@
             PsiWhiteSpace(' ')
             PsiElement(identifier)('b')
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class5.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class5.test
index ffcbfcd3..63188eb 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class5.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class5.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('b')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n ')
@@ -40,9 +40,9 @@
             PsiWhiteSpace(' ')
             PsiElement(identifier)('b')
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n  ')
@@ -52,9 +52,9 @@
             PsiElement(interface)('interface')
             PsiWhiteSpace(' ')
             PsiElement(identifier)('a')
-            PsiWhiteSpace(' ')
             Extends clause
               <empty list>
+            PsiWhiteSpace(' ')
             Type definition body
               PsiElement({)('{')
               PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class6.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class6.test
index 10cd522..86f034b 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class6.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class6.test
@@ -14,9 +14,9 @@
       PsiWhiteSpace(' ')
       Reference element
         PsiElement(identifier)('b')
-    PsiWhiteSpace(' ')
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class7.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class7.test
index 8742568..53b54b8 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class7.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/class7.test
@@ -8,9 +8,9 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Implements clause
       PsiElement(implements)('implements')
       PsiWhiteSpace(' ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/errors/classerr1.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/errors/classerr1.test
index 21da981..ccc6e03 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/errors/classerr1.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/errors/classerr1.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/errors/classerr2.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/errors/classerr2.test
index 95f6273..9fc4b4d 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/errors/classerr2.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/errors/classerr2.test
@@ -14,11 +14,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('d')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -72,9 +72,9 @@
                       PsiElement(@)('@')
                       Reference element
                         PsiElement(identifier)('Property')
-                      PsiWhiteSpace(' ')
                       Annotation arguments
                         <empty list>
+                    PsiWhiteSpace(' ')
                     PsiElement(def)('def')
                   PsiWhiteSpace(' ')
                   PsiElement(identifier)('a')
@@ -83,9 +83,9 @@
                   Parameter list
                     <empty list>
                   PsiElement())(')')
-                  PsiWhiteSpace(' ')
                   Throw clause
                     <empty list>
+                  PsiWhiteSpace(' ')
                   Open block
                     PsiElement({)('{')
                     PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/errors/classerr3.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/errors/classerr3.test
index b3c89314..56e42d8 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/errors/classerr3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/classes/errors/classerr3.test
@@ -9,11 +9,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/construct12.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/construct12.test
index ca80a43..a9ed2a9 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/construct12.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/construct12.test
@@ -9,11 +9,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('Greet')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -28,9 +28,9 @@
               <empty list>
             PsiElement(identifier)('who')
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace(' ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor1.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor1.test
index 71dbd1b..1725b16 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor1.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor1.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('s')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -29,9 +29,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor11.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor11.test
index 69d5f59..981c3534 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor11.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor11.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('map')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -27,9 +27,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace('   ')
         Throw clause
           <empty list>
+        PsiWhiteSpace('   ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor13.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor13.test
index a7f629f..0d0f94ae 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor13.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor13.test
@@ -10,11 +10,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -49,9 +49,9 @@
               <empty list>
             PsiElement(identifier)('p')
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace(' ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor14.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor14.test
index 977db0d..9a953b9 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor14.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor14.test
@@ -17,11 +17,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('ComparableFoo')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -49,9 +49,9 @@
             PsiWhiteSpace(' ')
             PsiElement(identifier)('theValue')
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
@@ -81,9 +81,9 @@
               <empty list>
             PsiElement(identifier)('anotherFoo')
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor15.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor15.test
index 028ebfa..7f9b5b4 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor15.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor15.test
@@ -10,11 +10,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('LogPipeBuilder')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor2.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor2.test
index 9cffe8e..e733643 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor2.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor2.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('w')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -31,9 +31,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor3.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor3.test
index 833dd7e..eab2d95 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor3.test
@@ -11,9 +11,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('s')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -27,9 +27,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor4.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor4.test
index 4e0b6c2..7163673 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor4.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor4.test
@@ -10,11 +10,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -44,9 +44,9 @@
             PsiWhiteSpace(' ')
             PsiElement(identifier)('B')
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiElement(})('}')
@@ -61,9 +61,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           Method call
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor5.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor5.test
index 9576bb3..26be7fa 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor5.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor5.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -36,9 +36,9 @@
             PsiWhiteSpace(' ')
             PsiElement(identifier)('s')
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor6.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor6.test
index c3a9c0d..af748b4 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor6.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor6.test
@@ -12,11 +12,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('s')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -30,9 +30,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor7.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor7.test
index f0d9c26..890437f 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor7.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor7.test
@@ -35,9 +35,9 @@
             PsiWhiteSpace(' ')
             PsiElement(identifier)('s')
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor8.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor8.test
index c984b68..b26eeab 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor8.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor8.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('s')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor9.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor9.test
index 488c59c..edd3d1a 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor9.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/constructors/constructor9.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('s')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum1.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum1.test
index a02dd73..af05977 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum1.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum1.test
@@ -9,9 +9,9 @@
     PsiElement(enum)('enum')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum3.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum3.test
index 2d23952..13ed41c 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum3.test
@@ -42,16 +42,16 @@
               PsiElement(@)('@')
               Reference element
                 PsiElement(identifier)('NotNull')
-              PsiWhiteSpace(' ')
               Annotation arguments
                 <empty list>
+            PsiWhiteSpace(' ')
             Annotation
               PsiElement(@)('@')
               Reference element
                 PsiElement(identifier)('Property')
-              PsiWhiteSpace(' ')
               Annotation arguments
                 <empty list>
+          PsiWhiteSpace(' ')
           PsiElement(identifier)('item1')
           PsiWhiteSpace(' ')
           Arguments
@@ -75,11 +75,11 @@
                 PsiElement(class)('class')
                 PsiWhiteSpace(' ')
                 PsiElement(identifier)('a')
-                PsiWhiteSpace(' ')
                 Extends clause
                   <empty list>
                 Implements clause
                   <empty list>
+                PsiWhiteSpace(' ')
                 Type definition body
                   PsiElement({)('{')
                   PsiElement(})('}')
@@ -135,9 +135,9 @@
                 Parameter list
                   <empty list>
                 PsiElement())(')')
-                PsiWhiteSpace(' ')
                 Throw clause
                   <empty list>
+                PsiWhiteSpace(' ')
                 Open block
                   PsiElement({)('{')
                   PsiWhiteSpace('\n       ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum4.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum4.test
index 13cf12a..dde30e3 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum4.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum4.test
@@ -33,9 +33,9 @@
               PsiElement(@)('@')
               Reference element
                 PsiElement(identifier)('Nullable')
-              PsiWhiteSpace(' ')
               Annotation arguments
                 <empty list>
+          PsiWhiteSpace(' ')
           PsiElement(identifier)('foo')
           PsiWhiteSpace(' ')
           Arguments
@@ -74,9 +74,9 @@
               PsiElement(@)('@')
               Reference element
                 PsiElement(identifier)('Nullable')
-              PsiWhiteSpace(' ')
               Annotation arguments
                 <empty list>
+          PsiWhiteSpace(' ')
           PsiElement(identifier)('bar')
           PsiWhiteSpace(' ')
           Arguments
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum5.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum5.test
index ae66289..1f2d2e8 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum5.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum5.test
@@ -11,9 +11,9 @@
     PsiElement(enum)('enum')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('A')
-    PsiWhiteSpace(' ')
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum6.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum6.test
index 9f031af..2ed2a21 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum6.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum6.test
@@ -9,9 +9,9 @@
     PsiElement(enum)('enum')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('B')
-    PsiWhiteSpace(' ')
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum7.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum7.test
index 6d2db33..af31a42 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum7.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/enums/enum7.test
@@ -9,9 +9,9 @@
     PsiElement(enum)('enum')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('A')
-    PsiWhiteSpace(' ')
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -22,9 +22,9 @@
               PsiElement(@)('@')
               Reference element
                 PsiElement(identifier)('Property')
-              PsiWhiteSpace(' ')
               Annotation arguments
                 <empty list>
+          PsiWhiteSpace(' ')
           PsiElement(identifier)('a')
       PsiElement(new line)('\n')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/errors/interfaceerr1.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/errors/interfaceerr1.test
index fb84a2e..21d7f1c 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/errors/interfaceerr1.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/errors/interfaceerr1.test
@@ -13,9 +13,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('q')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -29,9 +29,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('   ')
@@ -47,9 +47,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/errors/interfaceerr2.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/errors/interfaceerr2.test
index 98ef391..c1387ce 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/errors/interfaceerr2.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/errors/interfaceerr2.test
@@ -11,9 +11,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/errors/interfaceerr3.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/errors/interfaceerr3.test
index 7422d06..d4c1bf7 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/errors/interfaceerr3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/errors/interfaceerr3.test
@@ -11,9 +11,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface1.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface1.test
index 1ca010d..dd0568a 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface1.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface1.test
@@ -7,9 +7,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface2.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface2.test
index 4c7d332..860d520 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface2.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface2.test
@@ -8,9 +8,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface3.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface3.test
index ed1baf7..75c29ad 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface3.test
@@ -9,9 +9,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -22,9 +22,9 @@
         PsiElement(interface)('interface')
         PsiWhiteSpace(' ')
         PsiElement(identifier)('b')
-        PsiWhiteSpace(' ')
         Extends clause
           <empty list>
+        PsiWhiteSpace(' ')
         Type definition body
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface4.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface4.test
index 3a7fcdc..03b91bf 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface4.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface4.test
@@ -9,9 +9,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -22,9 +22,9 @@
         PsiElement(interface)('interface')
         PsiWhiteSpace(' ')
         PsiElement(identifier)('d')
-        PsiWhiteSpace(' ')
         Extends clause
           <empty list>
+        PsiWhiteSpace(' ')
         Type definition body
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface5.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface5.test
index ab946b6..2a6fdaa 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface5.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/interface5.test
@@ -10,9 +10,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/member3.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/member3.test
index 5571293..0712061 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/member3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/member3.test
@@ -10,9 +10,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member1.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member1.test
index b9862c7..feb71f0 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member1.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member1.test
@@ -9,9 +9,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('b')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -25,9 +25,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member2.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member2.test
index f19dbaf..6760b82 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member2.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member2.test
@@ -9,9 +9,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member3.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member3.test
index 7c6111e..89f9e7e 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member3.test
@@ -10,9 +10,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member4.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member4.test
index 923ed09..54f4e75 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member4.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member4.test
@@ -13,9 +13,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('A')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -57,9 +57,9 @@
             PsiWhiteSpace(' ')
             PsiElement(identifier)('s')
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n\n  ')
@@ -71,11 +71,11 @@
         PsiElement(class)('class')
         PsiWhiteSpace(' ')
         PsiElement(identifier)('B')
-        PsiWhiteSpace(' ')
         Extends clause
           <empty list>
         Implements clause
           <empty list>
+        PsiWhiteSpace(' ')
         Type definition body
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member5.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member5.test
index 741f16a..baeac2b 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member5.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member5.test
@@ -10,9 +10,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -23,9 +23,9 @@
         PsiElement(interface)('interface')
         PsiWhiteSpace(' ')
         PsiElement(identifier)('b')
-        PsiWhiteSpace(' ')
         Extends clause
           <empty list>
+        PsiWhiteSpace(' ')
         Type definition body
           PsiElement({)('{')
           PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member6.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member6.test
index 0122399..323c0a3 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member6.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/member6.test
@@ -9,9 +9,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/memeber7.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/memeber7.test
index 7cb721c..26caf6b 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/memeber7.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/interfaces/members/memeber7.test
@@ -12,9 +12,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -58,9 +58,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method2.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method2.test
index c8b1836..e1098b7 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method2.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method2.test
@@ -9,11 +9,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -29,9 +29,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method3.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method3.test
index b73c64c..55b423d 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method3.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method3.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -40,9 +40,9 @@
             PsiWhiteSpace(' ')
             PsiElement(identifier)('y')
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
@@ -53,9 +53,9 @@
             PsiElement(interface)('interface')
             PsiWhiteSpace(' ')
             PsiElement(identifier)('d')
-            PsiWhiteSpace(' ')
             Extends clause
               <empty list>
+            PsiWhiteSpace(' ')
             Type definition body
               PsiElement({)('{')
               PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method4.test b/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method4.test
index 83b0d0111..4b023ab 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method4.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/typedef/methods/method4.test
@@ -9,11 +9,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/statements/unnamedField.test b/plugins/groovy/testdata/parsing/groovy/statements/unnamedField.test
index e50e140..4ce246a 100644
--- a/plugins/groovy/testdata/parsing/groovy/statements/unnamedField.test
+++ b/plugins/groovy/testdata/parsing/groovy/statements/unnamedField.test
@@ -9,11 +9,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('Steps')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n   ')
diff --git a/plugins/groovy/testdata/parsing/groovy/types/ann_def1.test b/plugins/groovy/testdata/parsing/groovy/types/ann_def1.test
index 3c87ee3..932deee 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/ann_def1.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/ann_def1.test
@@ -24,11 +24,11 @@
         PsiElement(class)('class')
         PsiWhiteSpace(' ')
         PsiElement(identifier)('foo')
-        PsiWhiteSpace(' ')
         Extends clause
           <empty list>
         Implements clause
           <empty list>
+        PsiWhiteSpace(' ')
         Type definition body
           PsiElement({)('{')
           PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/types/ann_def2.test b/plugins/groovy/testdata/parsing/groovy/types/ann_def2.test
index 5a8b687..ff2f4de 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/ann_def2.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/ann_def2.test
@@ -23,11 +23,11 @@
         PsiElement(class)('class')
         PsiWhiteSpace(' ')
         PsiElement(identifier)('foo')
-        PsiWhiteSpace(' ')
         Extends clause
           <empty list>
         Implements clause
           <empty list>
+        PsiWhiteSpace(' ')
         Type definition body
           PsiElement({)('{')
           PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/types/default1.test b/plugins/groovy/testdata/parsing/groovy/types/default1.test
index 275ba92..94cc6ec 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/default1.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/default1.test
@@ -22,9 +22,9 @@
             PsiElement(@)('@')
             Reference element
               PsiElement(identifier)('ann')
-            PsiWhiteSpace(' ')
             Annotation arguments
               <empty list>
+        PsiWhiteSpace(' ')
         Built in type
           PsiElement(int)('int')
         PsiWhiteSpace(' ')
@@ -41,10 +41,10 @@
             PsiElement(@)('@')
             Reference element
               PsiElement(identifier)('Bar')
-            PsiWhiteSpace(' ')
             Annotation arguments
               <empty list>
         Throw clause
           <empty list>
+      PsiWhiteSpace(' ')
       PsiElement(new line)('\n')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/default2.test b/plugins/groovy/testdata/parsing/groovy/types/default2.test
index abfc413..05a31b6 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/default2.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/default2.test
@@ -22,9 +22,9 @@
             PsiElement(@)('@')
             Reference element
               PsiElement(identifier)('ann')
-            PsiWhiteSpace(' ')
             Annotation arguments
               <empty list>
+        PsiWhiteSpace(' ')
         Built in type
           PsiElement(int)('int')
         PsiWhiteSpace(' ')
diff --git a/plugins/groovy/testdata/parsing/groovy/types/incorrectParam1.test b/plugins/groovy/testdata/parsing/groovy/types/incorrectParam1.test
new file mode 100644
index 0000000..b3f0b8a
--- /dev/null
+++ b/plugins/groovy/testdata/parsing/groovy/types/incorrectParam1.test
@@ -0,0 +1,28 @@
+def foo(A. B) {}
+-----
+Groovy script
+  Method
+    Modifiers
+      PsiElement(def)('def')
+    PsiWhiteSpace(' ')
+    PsiElement(identifier)('foo')
+    PsiElement(()('(')
+    Parameter list
+      Modifiers
+        <empty list>
+      Type element
+        Reference element
+          Reference element
+            PsiElement(identifier)('A')
+          PsiElement(.)('.')
+          PsiWhiteSpace(' ')
+          PsiElement(identifier)('B')
+      PsiErrorElement:Identifier expected
+        <empty list>
+    PsiElement())(')')
+    Throw clause
+      <empty list>
+    PsiWhiteSpace(' ')
+    Open block
+      PsiElement({)('{')
+      PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/incorrectParam3.test b/plugins/groovy/testdata/parsing/groovy/types/incorrectParam3.test
new file mode 100644
index 0000000..ccfc130
--- /dev/null
+++ b/plugins/groovy/testdata/parsing/groovy/types/incorrectParam3.test
@@ -0,0 +1,38 @@
+def foo(A. b, A c) {}
+-----
+Groovy script
+  Method
+    Modifiers
+      PsiElement(def)('def')
+    PsiWhiteSpace(' ')
+    PsiElement(identifier)('foo')
+    PsiElement(()('(')
+    Parameter list
+      Modifiers
+        <empty list>
+      Type element
+        Reference element
+          Reference element
+            PsiElement(identifier)('A')
+          PsiElement(.)('.')
+          PsiWhiteSpace(' ')
+          PsiElement(identifier)('b')
+      PsiErrorElement:Identifier expected
+        <empty list>
+      PsiElement(,)(',')
+      PsiWhiteSpace(' ')
+      Parameter
+        Modifiers
+          <empty list>
+        Type element
+          Reference element
+            PsiElement(identifier)('A')
+        PsiWhiteSpace(' ')
+        PsiElement(identifier)('c')
+    PsiElement())(')')
+    Throw clause
+      <empty list>
+    PsiWhiteSpace(' ')
+    Open block
+      PsiElement({)('{')
+      PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/incorrectParameter2.test b/plugins/groovy/testdata/parsing/groovy/types/incorrectParameter2.test
new file mode 100644
index 0000000..19f23eb
--- /dev/null
+++ b/plugins/groovy/testdata/parsing/groovy/types/incorrectParameter2.test
@@ -0,0 +1,38 @@
+def foo(A a, A. b) {}
+-----
+Groovy script
+  Method
+    Modifiers
+      PsiElement(def)('def')
+    PsiWhiteSpace(' ')
+    PsiElement(identifier)('foo')
+    PsiElement(()('(')
+    Parameter list
+      Parameter
+        Modifiers
+          <empty list>
+        Type element
+          Reference element
+            PsiElement(identifier)('A')
+        PsiWhiteSpace(' ')
+        PsiElement(identifier)('a')
+      PsiElement(,)(',')
+      PsiWhiteSpace(' ')
+      Modifiers
+        <empty list>
+      Type element
+        Reference element
+          Reference element
+            PsiElement(identifier)('A')
+          PsiElement(.)('.')
+          PsiWhiteSpace(' ')
+          PsiElement(identifier)('b')
+      PsiErrorElement:Identifier expected
+        <empty list>
+    PsiElement())(')')
+    Throw clause
+      <empty list>
+    PsiWhiteSpace(' ')
+    Open block
+      PsiElement({)('{')
+      PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/interfaceWithGroovyDoc.test b/plugins/groovy/testdata/parsing/groovy/types/interfaceWithGroovyDoc.test
index 5f78881..4d0bb50 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/interfaceWithGroovyDoc.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/interfaceWithGroovyDoc.test
@@ -12,9 +12,9 @@
     PsiElement(interface)('interface')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('Usage')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/types/newlineBeforeExtends.test b/plugins/groovy/testdata/parsing/groovy/types/newlineBeforeExtends.test
index 9c9b9ab..93ded07 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/newlineBeforeExtends.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/newlineBeforeExtends.test
@@ -9,11 +9,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('Super')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
@@ -37,9 +37,9 @@
       PsiWhiteSpace(' ')
       Reference element
         PsiElement(identifier)('Super')
-    PsiWhiteSpace(' ')
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/staticInitializer.test b/plugins/groovy/testdata/parsing/groovy/types/staticInitializer.test
index a39f75e..cbeb25f 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/staticInitializer.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/staticInitializer.test
@@ -17,11 +17,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('StaticDemo')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/parsing/groovy/types/type1.test b/plugins/groovy/testdata/parsing/groovy/types/type1.test
index 5d8bcab..38f63bd 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/type1.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/type1.test
@@ -24,9 +24,9 @@
         PsiWhiteSpace(' ')
         PsiElement(identifier)('x')
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/type10.test b/plugins/groovy/testdata/parsing/groovy/types/type10.test
index 614873b..8c0f7e2 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/type10.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/type10.test
@@ -51,9 +51,9 @@
         PsiWhiteSpace(' ')
         PsiElement(identifier)('a')
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/type11.test b/plugins/groovy/testdata/parsing/groovy/types/type11.test
index 1796e18..e529b66 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/type11.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/type11.test
@@ -51,9 +51,9 @@
         PsiWhiteSpace(' ')
         PsiElement(identifier)('a')
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -67,9 +67,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiElement(})('}')
diff --git a/plugins/groovy/testdata/parsing/groovy/types/type13.test b/plugins/groovy/testdata/parsing/groovy/types/type13.test
index cfd0c2d..d472d3460 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/type13.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/type13.test
@@ -11,11 +11,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('A')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -32,9 +32,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n\n    ')
diff --git a/plugins/groovy/testdata/parsing/groovy/types/type14.test b/plugins/groovy/testdata/parsing/groovy/types/type14.test
new file mode 100644
index 0000000..2f2bcba
--- /dev/null
+++ b/plugins/groovy/testdata/parsing/groovy/types/type14.test
@@ -0,0 +1,32 @@
+def foo() throws java.
+lang.RuntimeException {
+}
+-----
+Groovy script
+  Method
+    Modifiers
+      PsiElement(def)('def')
+    PsiWhiteSpace(' ')
+    PsiElement(identifier)('foo')
+    PsiElement(()('(')
+    Parameter list
+      <empty list>
+    PsiElement())(')')
+    PsiWhiteSpace(' ')
+    Throw clause
+      PsiElement(throws)('throws')
+      PsiWhiteSpace(' ')
+      Reference element
+        Reference element
+          Reference element
+            PsiElement(identifier)('java')
+          PsiElement(.)('.')
+          PsiElement(new line)('\n')
+          PsiElement(identifier)('lang')
+        PsiElement(.)('.')
+        PsiElement(identifier)('RuntimeException')
+    PsiWhiteSpace(' ')
+    Open block
+      PsiElement({)('{')
+      PsiWhiteSpace('\n')
+      PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/type15.test b/plugins/groovy/testdata/parsing/groovy/types/type15.test
new file mode 100644
index 0000000..387614b
--- /dev/null
+++ b/plugins/groovy/testdata/parsing/groovy/types/type15.test
@@ -0,0 +1,40 @@
+def foo() throws java
+.lang.RuntimeException {
+}
+-----
+Groovy script
+  Method
+    Modifiers
+      PsiElement(def)('def')
+    PsiWhiteSpace(' ')
+    PsiElement(identifier)('foo')
+    PsiElement(()('(')
+    Parameter list
+      <empty list>
+    PsiElement())(')')
+    PsiWhiteSpace(' ')
+    Throw clause
+      PsiElement(throws)('throws')
+      PsiWhiteSpace(' ')
+      Reference element
+        PsiElement(identifier)('java')
+  PsiElement(new line)('\n')
+  PsiErrorElement:Unexpected symbol
+    PsiElement(.)('.')
+  PsiErrorElement:';' or new line expected
+    <empty list>
+  Method call
+    Reference expression
+      Reference expression
+        PsiElement(identifier)('lang')
+      PsiElement(.)('.')
+      PsiElement(identifier)('RuntimeException')
+    PsiWhiteSpace(' ')
+    Arguments
+      <empty list>
+    Closable block
+      PsiElement({)('{')
+      PsiWhiteSpace('\n')
+      Parameter list
+        <empty list>
+      PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/type5.test b/plugins/groovy/testdata/parsing/groovy/types/type5.test
index 4ba5da4..bb5938e 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/type5.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/type5.test
@@ -32,9 +32,9 @@
         PsiWhiteSpace(' ')
         PsiElement(identifier)('f')
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/type6.test b/plugins/groovy/testdata/parsing/groovy/types/type6.test
index a143aed..5abf351 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/type6.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/type6.test
@@ -37,9 +37,9 @@
         PsiWhiteSpace(' ')
         PsiElement(identifier)('f')
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/type7.test b/plugins/groovy/testdata/parsing/groovy/types/type7.test
index 5baedd29..39ac712 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/type7.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/type7.test
@@ -40,9 +40,9 @@
         PsiWhiteSpace(' ')
         PsiElement(identifier)('f')
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/type8.test b/plugins/groovy/testdata/parsing/groovy/types/type8.test
index 4d3dd04..75fc7cb 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/type8.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/type8.test
@@ -31,9 +31,9 @@
         PsiWhiteSpace(' ')
         PsiElement(identifier)('b')
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/parsing/groovy/types/type9.test b/plugins/groovy/testdata/parsing/groovy/types/type9.test
index 800e749..b070bca 100644
--- a/plugins/groovy/testdata/parsing/groovy/types/type9.test
+++ b/plugins/groovy/testdata/parsing/groovy/types/type9.test
@@ -26,9 +26,9 @@
         PsiWhiteSpace(' ')
         PsiElement(identifier)('args')
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiElement(})('}')
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/closure.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/closure.java
index 79aa62b..769c8bd 100644
--- a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/closure.java
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/closure.java
@@ -1,5 +1,5 @@
 java.util.ArrayList<java.lang.Integer> list = new java.util.ArrayList<java.lang.Integer>(java.util.Arrays.asList(1, 2, 3));
-org.codehaus.groovy.runtime.DefaultGroovyMethods.each(list, new groovy.lang.Closure<java.lang.Void>(this, this) {
+org.codehaus.groovy.runtime.DefaultGroovyMethods.each(list, new groovy.lang.Closure<java.lang.Object>(this, this) {
 public void doCall(java.lang.Integer it) {
 print(it);
 }
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/emptyList.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/emptyList.java
index f1283b8..8f64cd1 100644
--- a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/emptyList.java
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/emptyList.java
@@ -1,3 +1,3 @@
-java.util.ArrayList<java.lang.Object> list = new java.util.ArrayList<java.lang.Object>();
+java.util.ArrayList list = new java.util.ArrayList();
 java.lang.Integer[] arr = new java.lang.Integer[0];
 java.util.List<java.lang.String> strings = new java.util.ArrayList<java.lang.String>();
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/emptyMap.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/emptyMap.java
index ea2a48f..75eabcd 100644
--- a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/emptyMap.java
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/emptyMap.java
@@ -1,2 +1,2 @@
-java.util.Map<java.lang.Object, java.lang.Object> map = new java.util.Map<java.lang.Object, java.lang.Object>();
+java.util.Map map = new java.util.Map();
 print(map.get(1));
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/propSelection.groovy b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/propSelection.groovy
new file mode 100644
index 0000000..0073667
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/propSelection.groovy
@@ -0,0 +1 @@
+print p."a$c"
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/propSelection.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/propSelection.java
new file mode 100644
index 0000000..0347871
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/propSelection.java
@@ -0,0 +1 @@
+print(this.getBinding().getProperty("p")."a$c");
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch.groovy b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch.groovy
new file mode 100644
index 0000000..c5e703c
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch.groovy
@@ -0,0 +1,13 @@
+String[] commands = ['abc']
+for (String command : commands) {
+  switch (command) {
+    case "abc":
+      print 1
+    case "start":
+      return 4
+    case "next":
+      continue;
+    default:
+      return 0;
+  }
+}
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch.java
new file mode 100644
index 0000000..dafdae9
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/codeBlock/switch.java
@@ -0,0 +1,17 @@
+java.lang.String[] commands = new java.lang.String[]{"abc"};
+for(java.lang.String command : commands){
+if (org.codehaus.groovy.runtime.DefaultGroovyMethods.isCase("abc", command)) {
+print(1);
+return 4;
+}
+else if (org.codehaus.groovy.runtime.DefaultGroovyMethods.isCase("start", command)) {
+return 4;
+}
+else if (org.codehaus.groovy.runtime.DefaultGroovyMethods.isCase("next", command)) {
+continue;
+}
+else {
+return 0;
+}
+}
+
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/closureInUse.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/closureInUse.java
index 93ca27e..4812e82 100644
--- a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/closureInUse.java
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/closureInUse.java
@@ -12,7 +12,7 @@
 public java.lang.Object run() {
 
 
-return org.codehaus.groovy.runtime.DefaultGroovyMethods.use(this, IntCat.class, new groovy.lang.Closure<java.lang.Void>(this, this) {
+return org.codehaus.groovy.runtime.DefaultGroovyMethods.use(this, IntCat.class, new groovy.lang.Closure<java.lang.Object>(this, this) {
 public void doCall(java.lang.Object it) {
 IntCat.call(2);
 IntCat.call(2, "a");
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/dynamicMethodsAccess.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/dynamicMethodsAccess.java
index 61cfcc9..6a5310f 100644
--- a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/dynamicMethodsAccess.java
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/dynamicMethodsAccess.java
@@ -8,7 +8,7 @@
 org.codehaus.groovy.runtime.DefaultGroovyMethods.invokeMethod(s, "bar", new java.lang.Object[]{4});
 org.codehaus.groovy.runtime.DefaultGroovyMethods.print(this, org.codehaus.groovy.runtime.DefaultGroovyMethods.invokeMethod(s, "bar", new java.lang.Object[]{5}));
 
-return org.codehaus.groovy.runtime.DefaultGroovyMethods.invokeMethod(s, "anme", new java.util.ArrayList<java.lang.Object>());
+return org.codehaus.groovy.runtime.DefaultGroovyMethods.invokeMethod(s, "anme", new java.util.ArrayList());
 }
 
 }
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/hash.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/hash.java
index 5b94cbc..92d6fb7 100644
--- a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/hash.java
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/hash.java
@@ -42,7 +42,7 @@
 
 long start = java.lang.System.currentTimeMillis();
 
-org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(f, MB, new groovy.lang.Closure<java.lang.Void>(this, this) {
+org.codehaus.groovy.runtime.DefaultGroovyMethods.eachByte(f, MB, new groovy.lang.Closure<java.lang.Object>(this, this) {
 public void doCall(java.lang.Byte[] buf, int bytesRead) {
 messageDigest.update(buf, 0, bytesRead);
 }
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/refInClosureInScript.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/refInClosureInScript.java
index 0c17a66..3956feec 100644
--- a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/refInClosureInScript.java
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/refInClosureInScript.java
@@ -6,7 +6,7 @@
 public java.lang.Object run() {
 final groovy.lang.Reference<java.lang.Integer> foo = new groovy.lang.Reference<java.lang.Integer>(2);
 
-org.codehaus.groovy.runtime.DefaultGroovyMethods.times(3, new groovy.lang.Closure<java.lang.Void>(this, this) {
+org.codehaus.groovy.runtime.DefaultGroovyMethods.times(3, new groovy.lang.Closure<java.lang.Object>(this, this) {
 public void doCall(java.lang.Integer it) {
 foo.set(foo.get()++);
 foo.set(foo.get() + 2);
diff --git a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/reflectedMethodWithEllipsis.java b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/reflectedMethodWithEllipsis.java
index 3abffed..6ae1849 100644
--- a/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/reflectedMethodWithEllipsis.java
+++ b/plugins/groovy/testdata/refactoring/convertGroovyToJava/file/reflectedMethodWithEllipsis.java
@@ -2,7 +2,7 @@
 public void foo(java.util.Map args, java.lang.String a, java.lang.String... b) {}
 
 public void foo(java.lang.String a, java.lang.String... b) {
-foo(new java.util.LinkedHashMap<java.lang.Object, java.lang.Object>(), a, b);
+foo(new java.util.LinkedHashMap(), a, b);
 }
 
 }
diff --git a/plugins/groovy/testdata/refactoring/introduceConstant/FieldWithClassName.groovy b/plugins/groovy/testdata/refactoring/introduceConstant/FieldWithClassName.groovy
new file mode 100644
index 0000000..bbb493f
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/introduceConstant/FieldWithClassName.groovy
@@ -0,0 +1,5 @@
+class CONST {
+    def foo() {
+        print <selection>2</selection>
+    }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/introduceConstant/FieldWithClassName_after.groovy b/plugins/groovy/testdata/refactoring/introduceConstant/FieldWithClassName_after.groovy
new file mode 100644
index 0000000..d9c0210a
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/introduceConstant/FieldWithClassName_after.groovy
@@ -0,0 +1,7 @@
+class CONST {
+    public static final int CONST = 2
+
+    def foo() {
+        print CONST
+    }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/introduceConstant/LocalVarRef.groovy b/plugins/groovy/testdata/refactoring/introduceConstant/LocalVarRef.groovy
new file mode 100644
index 0000000..f0244173
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/introduceConstant/LocalVarRef.groovy
@@ -0,0 +1,11 @@
+class X {
+    def foo() {
+        def ad = 6
+
+        print <selection>ad</selection>
+        print ad
+        print "abc"
+
+        print 5
+    }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/introduceConstant/LocalVarRef_after.groovy b/plugins/groovy/testdata/refactoring/introduceConstant/LocalVarRef_after.groovy
new file mode 100644
index 0000000..02032b3
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/introduceConstant/LocalVarRef_after.groovy
@@ -0,0 +1,12 @@
+class X {
+    public static final int CONST = 6
+
+    def foo() {
+
+        print CONST
+        print CONST
+        print "abc"
+
+        print 5
+    }
+}
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/move/moveClass/staticImport/after/p2/C1.groovy b/plugins/groovy/testdata/refactoring/move/moveClass/staticImport/after/p2/C1.groovy
index 6edb229..c07883e 100644
--- a/plugins/groovy/testdata/refactoring/move/moveClass/staticImport/after/p2/C1.groovy
+++ b/plugins/groovy/testdata/refactoring/move/moveClass/staticImport/after/p2/C1.groovy
@@ -1,6 +1,6 @@
 package p2
 
-import static C1.E.e
+import static p2.C1.E.e
 
 class C1 {
   def foo() {
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/dollarSlashyWithDollar.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/dollarSlashyWithDollar.groovy
new file mode 100644
index 0000000..b8cc532
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/dollarSlashyWithDollar.groovy
@@ -0,0 +1 @@
+$/abc$<selection> </selection>cde/$
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/dollarSlashyWithDollar_after.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/dollarSlashyWithDollar_after.groovy
new file mode 100644
index 0000000..cd02c98
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/dollarSlashyWithDollar_after.groovy
@@ -0,0 +1 @@
+"abc\$" + $/ /$ + $/cde/$
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/slashyWithSlash.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/slashyWithSlash.groovy
new file mode 100644
index 0000000..3ede018
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/slashyWithSlash.groovy
@@ -0,0 +1 @@
+/ab\<selection>c</selection>/
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/slashyWithSlashInsideExtractedPart.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/slashyWithSlashInsideExtractedPart.groovy
new file mode 100644
index 0000000..3063235
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/slashyWithSlashInsideExtractedPart.groovy
@@ -0,0 +1 @@
+/a<selection>b\</selection>cd/
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/slashyWithSlashInsideExtractedPart_after.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/slashyWithSlashInsideExtractedPart_after.groovy
new file mode 100644
index 0000000..c07f6f4
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/slashyWithSlashInsideExtractedPart_after.groovy
@@ -0,0 +1 @@
+/a/ + "b\\" + /cd/
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/slashyWithSlash_after.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/slashyWithSlash_after.groovy
new file mode 100644
index 0000000..6466fb1
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/slashyWithSlash_after.groovy
@@ -0,0 +1 @@
+"ab\\" + /c/
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromDollarSlashyString.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromDollarSlashyString.groovy
new file mode 100644
index 0000000..c223f7e
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromDollarSlashyString.groovy
@@ -0,0 +1 @@
+($/a<selection>b</selection>c/$)
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromDollarSlashyString_after.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromDollarSlashyString_after.groovy
new file mode 100644
index 0000000..190c4e5
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromDollarSlashyString_after.groovy
@@ -0,0 +1 @@
+($/a/$ + $/b/$ + $/c/$)
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromDoubleQuotes.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromDoubleQuotes.groovy
new file mode 100644
index 0000000..b6f2ecf
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromDoubleQuotes.groovy
@@ -0,0 +1 @@
+"a<selection>b</selection>c"
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromDoubleQuotes_after.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromDoubleQuotes_after.groovy
new file mode 100644
index 0000000..3cbc0c6
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromDoubleQuotes_after.groovy
@@ -0,0 +1 @@
+"a" + "b" + "c"
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromQuote.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromQuote.groovy
new file mode 100644
index 0000000..47f8c77
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromQuote.groovy
@@ -0,0 +1 @@
+'a<selection>b</selection>c'
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromQuote_after.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromQuote_after.groovy
new file mode 100644
index 0000000..db53737
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromQuote_after.groovy
@@ -0,0 +1 @@
+'a' + 'b' + 'c'
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromSlashyString.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromSlashyString.groovy
new file mode 100644
index 0000000..554cd15
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromSlashyString.groovy
@@ -0,0 +1 @@
+(/a<selection>b</selection>c/)
\ No newline at end of file
diff --git a/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromSlashyString_after.groovy b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromSlashyString_after.groovy
new file mode 100644
index 0000000..6da090b
--- /dev/null
+++ b/plugins/groovy/testdata/refactoring/stringExtracting/stringExtractingFromSlashyString_after.groovy
@@ -0,0 +1 @@
+(/a/ + /b/ + /c/)
\ No newline at end of file
diff --git a/plugins/groovy/testdata/reparse/MultilineToNormalString.txt b/plugins/groovy/testdata/reparse/MultilineToNormalString.txt
index 5f0d6d9..cacf4d0 100644
--- a/plugins/groovy/testdata/reparse/MultilineToNormalString.txt
+++ b/plugins/groovy/testdata/reparse/MultilineToNormalString.txt
@@ -6,11 +6,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -23,9 +23,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
@@ -62,9 +62,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
@@ -88,11 +88,11 @@
     PsiElement(class)('class')
     PsiWhiteSpace(' ')
     PsiElement(identifier)('a')
-    PsiWhiteSpace(' ')
     Extends clause
       <empty list>
     Implements clause
       <empty list>
+    PsiWhiteSpace(' ')
     Type definition body
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -105,9 +105,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
@@ -131,9 +131,9 @@
         Parameter list
           <empty list>
         PsiElement())(')')
-        PsiWhiteSpace(' ')
         Throw clause
           <empty list>
+        PsiWhiteSpace(' ')
         Open block
           PsiElement({)('{')
           PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/reparse/NoVariableName.txt b/plugins/groovy/testdata/reparse/NoVariableName.txt
index bb56d59..6f25d60 100644
--- a/plugins/groovy/testdata/reparse/NoVariableName.txt
+++ b/plugins/groovy/testdata/reparse/NoVariableName.txt
@@ -9,9 +9,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -87,9 +87,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/reparse/OpeningParenthesisAtBlockStart.txt b/plugins/groovy/testdata/reparse/OpeningParenthesisAtBlockStart.txt
index 43602fd..74b0541 100644
--- a/plugins/groovy/testdata/reparse/OpeningParenthesisAtBlockStart.txt
+++ b/plugins/groovy/testdata/reparse/OpeningParenthesisAtBlockStart.txt
@@ -9,9 +9,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -65,9 +65,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/reparse/SwitchCaseDef.txt b/plugins/groovy/testdata/reparse/SwitchCaseDef.txt
index 41bf992..5271429 100644
--- a/plugins/groovy/testdata/reparse/SwitchCaseDef.txt
+++ b/plugins/groovy/testdata/reparse/SwitchCaseDef.txt
@@ -9,9 +9,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -54,9 +54,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/reparse/SwitchCaseDo.txt b/plugins/groovy/testdata/reparse/SwitchCaseDo.txt
index 04a40ba..8da1cbb 100644
--- a/plugins/groovy/testdata/reparse/SwitchCaseDo.txt
+++ b/plugins/groovy/testdata/reparse/SwitchCaseDo.txt
@@ -9,9 +9,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -54,9 +54,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/reparse/SwitchCaseDot.txt b/plugins/groovy/testdata/reparse/SwitchCaseDot.txt
index aff0d03..3234681 100644
--- a/plugins/groovy/testdata/reparse/SwitchCaseDot.txt
+++ b/plugins/groovy/testdata/reparse/SwitchCaseDot.txt
@@ -9,9 +9,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -80,9 +80,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/reparse/SwitchCaseFor.txt b/plugins/groovy/testdata/reparse/SwitchCaseFor.txt
index ad25f48..8bdf684 100644
--- a/plugins/groovy/testdata/reparse/SwitchCaseFor.txt
+++ b/plugins/groovy/testdata/reparse/SwitchCaseFor.txt
@@ -9,9 +9,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -54,9 +54,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/reparse/SwitchCaseIf.txt b/plugins/groovy/testdata/reparse/SwitchCaseIf.txt
index 7bcdcd5..51a023e 100644
--- a/plugins/groovy/testdata/reparse/SwitchCaseIf.txt
+++ b/plugins/groovy/testdata/reparse/SwitchCaseIf.txt
@@ -9,9 +9,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -54,9 +54,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/reparse/SwitchCaseSwitch.txt b/plugins/groovy/testdata/reparse/SwitchCaseSwitch.txt
index ee9d4f2..2f55349 100644
--- a/plugins/groovy/testdata/reparse/SwitchCaseSwitch.txt
+++ b/plugins/groovy/testdata/reparse/SwitchCaseSwitch.txt
@@ -9,9 +9,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -54,9 +54,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/reparse/SwitchCaseWhile.txt b/plugins/groovy/testdata/reparse/SwitchCaseWhile.txt
index 3d5863f..dadec26 100644
--- a/plugins/groovy/testdata/reparse/SwitchCaseWhile.txt
+++ b/plugins/groovy/testdata/reparse/SwitchCaseWhile.txt
@@ -9,9 +9,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -54,9 +54,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/reparse/SwitchRParen.txt b/plugins/groovy/testdata/reparse/SwitchRParen.txt
index 7401dde..732ccb2 100644
--- a/plugins/groovy/testdata/reparse/SwitchRParen.txt
+++ b/plugins/groovy/testdata/reparse/SwitchRParen.txt
@@ -9,9 +9,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
@@ -79,9 +79,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n    ')
diff --git a/plugins/groovy/testdata/reparse/SynchronizedRParen.txt b/plugins/groovy/testdata/reparse/SynchronizedRParen.txt
index 80a5095..200ce23 100644
--- a/plugins/groovy/testdata/reparse/SynchronizedRParen.txt
+++ b/plugins/groovy/testdata/reparse/SynchronizedRParen.txt
@@ -9,9 +9,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -65,9 +65,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
diff --git a/plugins/groovy/testdata/reparse/WhileRParen.txt b/plugins/groovy/testdata/reparse/WhileRParen.txt
index 5df4d40..04c21f5 100644
--- a/plugins/groovy/testdata/reparse/WhileRParen.txt
+++ b/plugins/groovy/testdata/reparse/WhileRParen.txt
@@ -9,9 +9,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')
@@ -65,9 +65,9 @@
     Parameter list
       <empty list>
     PsiElement())(')')
-    PsiWhiteSpace(' ')
     Throw clause
       <empty list>
+    PsiWhiteSpace(' ')
     Open block
       PsiElement({)('{')
       PsiWhiteSpace('\n  ')