Merge branch 'master' of git.labs.intellij.net:idea/community
authorYann Cébron <yann@yc.local>
Thu, 22 Jul 2010 17:06:08 +0000 (19:06 +0200)
committerYann Cébron <yann@yc.local>
Thu, 22 Jul 2010 17:06:08 +0000 (19:06 +0200)
233 files changed:
community-resources/src/idea_community_about.png
community-resources/src/idea_community_logo.png
java/compiler/impl/src/com/intellij/compiler/impl/StateCache.java
java/java-impl/src/com/intellij/lang/java/parser/DeclarationParser.java [new file with mode: 0644]
java/java-impl/src/com/intellij/lang/java/parser/ExpressionParser.java [new file with mode: 0644]
java/java-impl/src/com/intellij/lang/java/parser/JavaParser.java [new file with mode: 0644]
java/java-impl/src/com/intellij/lang/java/parser/JavaParserUtil.java [new file with mode: 0644]
java/java-impl/src/com/intellij/lang/java/parser/ReferenceParser.java [new file with mode: 0644]
java/java-impl/src/com/intellij/psi/impl/java/stubs/JavaClassReferenceListElementType.java
java/java-impl/src/com/intellij/psi/impl/java/stubs/JavaStubElementType.java
java/java-impl/src/com/intellij/psi/impl/source/tree/JavaElementType.java
java/java-impl/src/com/intellij/refactoring/OptimizeImportsRefactoringHelper.java
java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java
java/java-impl/src/com/intellij/refactoring/convertToInstanceMethod/ConvertToInstanceMethodProcessor.java
java/java-impl/src/com/intellij/refactoring/introduceParameter/IntroduceParameterProcessor.java
java/java-impl/src/com/intellij/refactoring/move/moveMembers/MoveMembersProcessor.java
java/java-tests/java-tests.iml
java/java-tests/testData/psi/parser-partial/annotations/Array.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/annotations/Complex.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/annotations/FirstNameMissed.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/annotations/Marker.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/annotations/Multiple.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/annotations/Nested.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/annotations/ParameterizedAnnotation.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/annotations/QualifiedAnnotation.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/annotations/Simple0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/annotations/Simple1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer2.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer3.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer4.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer5.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer6.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer7.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Assignment0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Assignment1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Cast.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Cond0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Cond1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Cond2.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Cond3.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/CondOr0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/CondOr1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ExprList0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ExprList1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ExprList2.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ExprList3.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ExprList4.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ExprList5.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ExprList6.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/GE.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/IllegalWildcard.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/IncompleteCast.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/InstanceOf0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/InstanceOf1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New10.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New11.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New12.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New13.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New14.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New2.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New3.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New4.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New5.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New6.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New7.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New8.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/New9.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/NewInExprList.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Not0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Not1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Or0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Or1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Parenth0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/Parenth1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/PinesInReferenceExpression0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/PinesInReferenceExpression1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/PrimitiveClassObjectAccess.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/ShiftRight.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/expressions/SuperMethodCallTypeParameterList.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/Reference0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/Reference1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/Reference2.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/Type0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/Type1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/Type2.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/Type3.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/Type4.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/TypeParams0.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/TypeParams1.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/TypeParams2.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/TypeParams3.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/TypeParams4.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/TypeParams5.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/TypeParams6.txt [new file with mode: 0644]
java/java-tests/testData/psi/parser-partial/references/TypeParams7.txt [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/JavaTestUtil.java
java/java-tests/testSrc/com/intellij/lang/java/parser/JavaParsingTestCase.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/lang/java/parser/partial/AnnotationParserTest.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ReferenceParserTest.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/refactoring/IntroduceParameterTest.java
java/jsp-base-openapi/src/com/intellij/psi/jsp/BaseJspFile.java
java/openapi/src/com/intellij/psi/tree/java/IJavaElementType.java
platform/bootstrap/src/com/intellij/idea/Main.java
platform/lang-api/src/com/intellij/lang/PsiBuilderUtil.java [new file with mode: 0644]
platform/lang-api/src/com/intellij/openapi/projectRoots/JdkUtil.java
platform/lang-api/src/com/intellij/psi/impl/ElementBase.java
platform/lang-api/src/com/intellij/ui/ComputableIcon.java [new file with mode: 0644]
platform/lang-impl/src/com/intellij/find/findUsages/PsiElement2UsageTargetAdapter.java
platform/lang-impl/src/com/intellij/ide/PsiCopyPasteManager.java
platform/lang-impl/src/com/intellij/ide/actions/CreateFromTemplateAction.java
platform/lang-impl/src/com/intellij/ide/fileTemplates/FileTemplateUtil.java
platform/lang-impl/src/com/intellij/lang/impl/PsiBuilderImpl.java
platform/lang-impl/src/com/intellij/refactoring/lang/ExtractIncludeDialog.java
platform/lang-impl/src/com/intellij/refactoring/move/FileReferenceContextUtil.java
platform/lang-impl/src/com/intellij/ui/DeferredIconImpl.java
platform/lang-impl/src/com/intellij/ui/IconDeferrerImpl.java
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java
platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java
platform/lang-impl/testSrc/com/intellij/lang/LightPsiBuilderTest.java
platform/platform-api/src/com/intellij/execution/configurations/GeneralCommandLine.java
platform/platform-api/src/com/intellij/openapi/vfs/VfsUtil.java
platform/platform-api/src/com/intellij/patterns/ObjectPattern.java
platform/platform-api/src/com/intellij/patterns/StringPattern.java
platform/platform-api/src/com/intellij/psi/tree/IElementType.java
platform/platform-impl/src/com/intellij/ide/XmlRpcServerImpl.java
platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/UpdateChecker.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeGlassPaneImpl.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/Stripe.java
platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java
platform/platform-resources-en/src/messages/RefactoringBundle.properties
platform/platform-resources-en/src/messages/XmlErrorMessages.properties
platform/platform-resources/src/DefaultColorSchemesManager.xml
platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java
platform/testFramework/src/com/intellij/testFramework/ParsingTestCase.java
platform/testFramework/src/com/intellij/testFramework/fixtures/CodeInsightFixtureTestCase.java
platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java
platform/usageView/src/com/intellij/usages/ReadWriteAccessUsageInfo2UsageAdapter.java
platform/usageView/src/com/intellij/usages/UsageInfo2UsageAdapter.java
platform/usageView/src/com/intellij/usages/impl/rules/FileGroupingRule.java
platform/util/src/com/intellij/openapi/util/ClassLoaderUtil.java [new file with mode: 0644]
platform/util/src/com/intellij/util/io/PersistentHashMap.java
platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTracker.java
plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/TemporaryPlacesInjector.java
plugins/IntelliLang/xml-support/org/intellij/plugins/intelliLang/inject/xml/XmlLanguageInjector.java
plugins/IntelliLang/xml-support/resources/xmlInjections.xml
plugins/eclipse/testData/modification/libAddLibSource/expected/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libAddLibSource/expected/ws-internals.eml [new file with mode: 0644]
plugins/eclipse/testData/modification/libAddLibSource/jars/test-2.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libAddLibSource/jars/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libAddLibSource/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libAddLibSource/test/.project [new file with mode: 0644]
plugins/eclipse/testData/modification/libAddVarSource/expected/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libAddVarSource/expected/ws-internals.eml [new file with mode: 0644]
plugins/eclipse/testData/modification/libAddVarSource/jars/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libAddVarSource/srcvariableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libAddVarSource/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libAddVarSource/test/.project [new file with mode: 0644]
plugins/eclipse/testData/modification/libReplaceVarSource/expected/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libReplaceVarSource/expected/ws-internals.eml [new file with mode: 0644]
plugins/eclipse/testData/modification/libReplaceVarSource/jars/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libReplaceVarSource/srcvariableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libReplaceVarSource/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libReplaceVarSource/test/.project [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddLibSource/expected/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddLibSource/expected/ws-internals.eml [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddLibSource/jars/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddLibSource/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddLibSource/test/.project [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddLibSource/variableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddVarSource/expected/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddVarSource/expected/ws-internals.eml [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddVarSource/jars/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddVarSource/srcvariableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddVarSource/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddVarSource/test/.project [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarAddVarSource/variableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceLibSource/expected/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceLibSource/expected/ws-internals.eml [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceLibSource/jars/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceLibSource/srcvariableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceLibSource/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceLibSource/test/.project [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceLibSource/variableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceVarSource/expected/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceVarSource/expected/ws-internals.eml [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceVarSource/srcvariableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceVarSource/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceVarSource/test/.project [new file with mode: 0644]
plugins/eclipse/testData/modification/libvarReplaceVarSource/variableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/varAddLibSource/expected/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/varAddLibSource/expected/ws-internals.eml [new file with mode: 0644]
plugins/eclipse/testData/modification/varAddLibSource/jars/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/varAddLibSource/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/varAddLibSource/test/.project [new file with mode: 0644]
plugins/eclipse/testData/modification/varAddLibSource/variableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/varAddVarSource/expected/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/varAddVarSource/expected/ws-internals.eml [new file with mode: 0644]
plugins/eclipse/testData/modification/varAddVarSource/srcvariableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/varAddVarSource/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/varAddVarSource/test/.project [new file with mode: 0644]
plugins/eclipse/testData/modification/varAddVarSource/variableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/varReplaceLibSource/expected/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/varReplaceLibSource/expected/ws-internals.eml [new file with mode: 0644]
plugins/eclipse/testData/modification/varReplaceLibSource/jars/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/varReplaceLibSource/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/varReplaceLibSource/test/.project [new file with mode: 0644]
plugins/eclipse/testData/modification/varReplaceLibSource/variableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/varReplaceVarSource/expected/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/varReplaceVarSource/expected/ws-internals.eml [new file with mode: 0644]
plugins/eclipse/testData/modification/varReplaceVarSource/srcvariableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testData/modification/varReplaceVarSource/test/.classpath [new file with mode: 0644]
plugins/eclipse/testData/modification/varReplaceVarSource/test/.project [new file with mode: 0644]
plugins/eclipse/testData/modification/varReplaceVarSource/variableidea/test.jar [new file with mode: 0644]
plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseLibrariesModificationsTest.java
plugins/groovy/src/org/intellij/plugins/intelliLang/inject/groovy/PatternEditorContextMembersProvider.java
plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/params/GrParameterImpl.java
plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/GroovyRefactoringSupportProvider.java
plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/changeSignature/GrChangeSignatureConflictSearcher.java
plugins/groovy/test/org/jetbrains/plugins/groovy/intentions/ConvertJavaStyleArrayCreationTest.java
plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/introduceParameter/IntroduceParameterTest.java
plugins/relaxng/src/org/intellij/plugins/relaxNG/model/resolve/RelaxSymbolIndex.java
xml/impl/src/com/intellij/codeInsight/daemon/impl/analysis/XmlHighlightVisitor.java
xml/impl/src/com/intellij/lang/xml/XmlFoldingBuilder.java
xml/impl/src/com/intellij/psi/impl/source/xml/XmlProcessingInstructionImpl.java
xml/impl/src/com/intellij/xml/util/XmlUtil.java
xml/openapi/src/com/intellij/psi/XmlElementVisitor.java

index caf2b6292be699df9961cbf58cd9b9141640aad3..af11f5f8ee3940faa1389fb318d9a1df943e216f 100644 (file)
Binary files a/community-resources/src/idea_community_about.png and b/community-resources/src/idea_community_about.png differ
index 2a43165ee623f871f0bbc83e8341d9174f465700..3bb7994bedda75a79263e5604690e2cae9394006 100644 (file)
Binary files a/community-resources/src/idea_community_logo.png and b/community-resources/src/idea_community_logo.png differ
index f3551da2cb7b973c78ceee07e1e872d31c06e973..bd56b6653b91ef84dc96852a99cdae15daf5fc6e 100644 (file)
@@ -15,7 +15,6 @@
  */
 package com.intellij.compiler.impl;
 
-import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.util.io.DataExternalizer;
 import com.intellij.util.io.EnumeratorStringDescriptor;
 import com.intellij.util.io.PersistentHashMap;
@@ -55,12 +54,7 @@ public abstract class StateCache<T> {
     }
     catch (IOException ignored) {
     }
-    final String baseName = myBaseFile.getName();
-    for (File file : myBaseFile.getParentFile().listFiles()) {
-      if (file.getName().startsWith(baseName)) {
-        FileUtil.delete(file);
-      }
-    }
+    PersistentHashMap.deleteFilesStartingWith(myBaseFile);
     try {
       myMap = createMap(myBaseFile);
     }
@@ -108,4 +102,4 @@ public abstract class StateCache<T> {
     });
   }
 
-}
\ No newline at end of file
+}
diff --git a/java/java-impl/src/com/intellij/lang/java/parser/DeclarationParser.java b/java/java-impl/src/com/intellij/lang/java/parser/DeclarationParser.java
new file mode 100644 (file)
index 0000000..268e9c2
--- /dev/null
@@ -0,0 +1,437 @@
+/*
+ * Copyright 2000-2010 JetBrains s.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 com.intellij.lang.java.parser;
+
+import com.intellij.codeInsight.daemon.JavaErrorMessages;
+import com.intellij.lang.LighterASTNode;
+import com.intellij.lang.PsiBuilder;
+import com.intellij.psi.JavaTokenType;
+import com.intellij.psi.impl.source.tree.ElementType;
+import com.intellij.psi.impl.source.tree.JavaElementType;
+import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.tree.ILazyParseableElementType;
+import com.intellij.psi.tree.TokenSet;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import static com.intellij.lang.PsiBuilderUtil.expect;
+import static com.intellij.lang.java.parser.JavaParserUtil.*;
+
+
+public class DeclarationParser {
+  public enum Context {
+    FILE, CLASS, CODE_BLOCK, ANNOTATION_INTERFACE
+  }
+
+  private static final TokenSet AFTER_END_DECLARATION_SET = TokenSet.create(JavaElementType.FIELD, JavaElementType.METHOD);
+
+  private DeclarationParser() { }
+
+  @Nullable
+  public static PsiBuilder.Marker parseClassBodyWithBraces(final PsiBuilder builder, final boolean isAnnotation, final boolean isEnum) {
+    if (builder.getTokenType() != JavaTokenType.LBRACE) return null;
+
+    final PsiBuilder.Marker marker = builder.mark();
+    marker.drop();
+    builder.advanceLexer();
+
+    if (isEnum) {
+      parseEnumConstants(builder);
+    }
+    parseClassBodyDeclarations(builder, isAnnotation);
+
+    expectOrError(builder, JavaTokenType.RBRACE, JavaErrorMessages.message("expected.rbrace"));
+
+    return marker;
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseClassFromKeyword(final PsiBuilder builder, final PsiBuilder.Marker start,
+                                                        final boolean isAnnotation) {
+    // todo: implement
+    throw new UnsupportedOperationException(builder.toString() + start + isAnnotation);
+  }
+
+  private static void parseEnumConstants(final PsiBuilder builder) {
+    while (builder.getTokenType() != null) {
+      if (expect(builder, JavaTokenType.SEMICOLON)) {
+        return;
+      }
+
+      if (builder.getTokenType() == JavaTokenType.PRIVATE_KEYWORD || builder.getTokenType() == JavaTokenType.PROTECTED_KEYWORD) {
+        error(builder, JavaErrorMessages.message("expected.semicolon"));
+        return;
+      }
+
+      final PsiBuilder.Marker enumConstant = parseEnumConstant(builder);
+      if (enumConstant == null) {
+        error(builder, JavaErrorMessages.message("expected.identifier"));
+      }
+
+      if (!expect(builder, JavaTokenType.COMMA)) {
+        if (builder.getTokenType() != null && builder.getTokenType() != JavaTokenType.SEMICOLON) {
+          error(builder, JavaErrorMessages.message("expected.comma.or.semicolon"));
+        }
+      }
+    }
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseEnumConstant(final PsiBuilder builder) {
+    final PsiBuilder.Marker constant = builder.mark();
+
+    parseModifierList(builder);
+
+    if (expect(builder, JavaTokenType.IDENTIFIER)) {
+      if (builder.getTokenType() == JavaTokenType.LPARENTH) {
+        ExpressionParser.parseArgumentList(builder);
+      }
+      else {
+        emptyElement(builder, JavaElementType.EXPRESSION_LIST);
+      }
+
+      if (builder.getTokenType() == JavaTokenType.LBRACE) {
+        final PsiBuilder.Marker constantInit = builder.mark();
+        parseClassBodyWithBraces(builder, false, false);
+        constantInit.done(JavaElementType.ENUM_CONSTANT_INITIALIZER);
+      }
+
+      constant.done(JavaElementType.ENUM_CONSTANT);
+      return constant;
+    }
+    else {
+      constant.rollbackTo();
+      return null;
+    }
+  }
+
+  private static void parseClassBodyDeclarations(final PsiBuilder builder, final boolean isAnnotation) {
+    final Context context = isAnnotation ? Context.ANNOTATION_INTERFACE : Context.CLASS;
+
+    PsiBuilder.Marker invalidElements = null;
+    while (true) {
+      final IElementType tokenType = builder.getTokenType();
+      if (tokenType == null || tokenType == JavaTokenType.RBRACE) break;
+
+      if (tokenType == JavaTokenType.SEMICOLON) {
+        if (invalidElements != null) {
+          invalidElements.error(JavaErrorMessages.message("unexpected.token"));
+          invalidElements = null;
+        }
+        builder.advanceLexer();
+        continue;
+      }
+
+      final PsiBuilder.Marker declaration = parseDeclaration(builder, context);
+      if (declaration != null) {
+        if (invalidElements != null) {
+          invalidElements.errorBefore(JavaErrorMessages.message("unexpected.token"), declaration);
+          invalidElements = null;
+        }
+        continue;
+      }
+
+      if (invalidElements == null) {
+        invalidElements = builder.mark();
+      }
+
+      // adding a reference, not simple tokens allows "Browse ..." to work well
+      final PsiBuilder.Marker ref = ReferenceParser.parseJavaCodeReference(builder, true, true, false);
+      if (ref == null) {
+        builder.advanceLexer();
+      }
+    }
+
+    if (invalidElements != null) {
+      invalidElements.error(JavaErrorMessages.message("unexpected.token"));
+    }
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseDeclaration(final PsiBuilder builder, final Context context) {
+    final IElementType tokenType = builder.getTokenType();
+    if (tokenType == null) return null;
+
+    if (tokenType == JavaTokenType.LBRACE) {
+      if (context == Context.FILE || context == Context.CODE_BLOCK) return null;
+    }
+    else if (tokenType == JavaTokenType.IDENTIFIER || ElementType.PRIMITIVE_TYPE_BIT_SET.contains(tokenType)) {
+      if (context == Context.FILE) return null;
+    }
+    else if (tokenType instanceof ILazyParseableElementType) {
+      final PsiBuilder.Marker declaration = builder.mark();
+      declaration.drop();
+      builder.advanceLexer();
+      return declaration;
+    }
+    else if (!ElementType.MODIFIER_BIT_SET.contains(tokenType) &&
+             !ElementType.CLASS_KEYWORD_BIT_SET.contains(tokenType) &&
+             tokenType != JavaTokenType.AT &&
+             (context == Context.CODE_BLOCK || tokenType != JavaTokenType.LT)) {
+      return null;
+    }
+
+    final PsiBuilder.Marker declaration = builder.mark();
+
+    final PsiBuilder.Marker modList = parseModifierList(builder);
+
+    if (expect(builder, JavaTokenType.AT)) {
+      if (tokenType == JavaTokenType.INTERFACE_KEYWORD) {
+        return parseClassFromKeyword(builder, declaration, true);
+      }
+      else {
+        declaration.rollbackTo();
+        return null;
+      }
+    }
+    else if (ElementType.CLASS_KEYWORD_BIT_SET.contains(tokenType)) {
+      final PsiBuilder.Marker root = parseClassFromKeyword(builder, declaration, false);
+
+      if (context == Context.FILE) {
+        // todo: append following declarations to root
+        boolean declarationsAfterEnd = false;
+
+        while (builder.getTokenType() != null && builder.getTokenType() != JavaTokenType.RBRACE) {
+          final PsiBuilder.Marker position = builder.mark();
+          final PsiBuilder.Marker element = parseDeclaration(builder, Context.CLASS);
+          if (element != null && AFTER_END_DECLARATION_SET.contains(((LighterASTNode)element).getTokenType())) {
+            if (!declarationsAfterEnd) {
+              element.precede().error(JavaErrorMessages.message("expected.class.or.interface"));
+            }
+            declarationsAfterEnd = true;
+            position.drop();
+          }
+          else {
+            position.rollbackTo();
+            break;
+          }
+        }
+
+        if (declarationsAfterEnd) {
+          expectOrError(builder, JavaTokenType.RBRACE, JavaErrorMessages.message("expected.rbrace"));
+        }
+      }
+      return root;
+    }
+
+    PsiBuilder.Marker typeParams = null;
+    if (builder.getTokenType() == JavaTokenType.LT) {
+      typeParams = ReferenceParser.parseTypeParameters(builder);
+    }
+
+    if (context == Context.FILE) {
+      if (typeParams == null) {
+        error(builder, JavaErrorMessages.message("expected.class.or.interface"));
+      }
+      else {
+        typeParams.precede().errorBefore(JavaErrorMessages.message("expected.class.or.interface"), typeParams);
+      }
+      declaration.drop();
+      return modList;
+    }
+
+    // todo: implement
+    throw new UnsupportedOperationException(builder.toString() + context);
+  }
+
+  @NotNull
+  private static PsiBuilder.Marker parseModifierList(final PsiBuilder builder) {
+    final PsiBuilder.Marker modList = builder.mark();
+
+    while (true) {
+      final IElementType tokenType = builder.getTokenType();
+      if (tokenType == null) break;
+      if (ElementType.MODIFIER_BIT_SET.contains(tokenType)) {
+        builder.advanceLexer();
+      }
+      else if (tokenType == JavaTokenType.AT) {
+        final PsiBuilder.Marker pos = builder.mark();
+        builder.advanceLexer();
+        final IElementType nextTokenType = builder.getTokenType();
+        pos.rollbackTo();
+        if (ElementType.KEYWORD_BIT_SET.contains(nextTokenType)) {
+          break;
+        }
+        parseAnnotation(builder);
+      }
+      else {
+        break;
+      }
+    }
+
+    modList.done(JavaElementType.MODIFIER_LIST);
+    return modList;
+  }
+
+  @Nullable
+  public static PsiBuilder.Marker parseAnnotations(final PsiBuilder builder) {
+    PsiBuilder.Marker firstAnno = null;
+
+    while (builder.getTokenType() == JavaTokenType.AT) {
+      final PsiBuilder.Marker anno = parseAnnotation(builder);
+      if (firstAnno == null) firstAnno = anno;
+    }
+
+    return firstAnno;
+  }
+
+  @NotNull
+  private static PsiBuilder.Marker parseAnnotation(final PsiBuilder builder) {
+    final PsiBuilder.Marker anno = builder.mark();
+    builder.advanceLexer();
+
+    final PsiBuilder.Marker classRef = ReferenceParser.parseJavaCodeReference(builder, true, false, false);
+    if (classRef == null) {
+      error(builder, JavaErrorMessages.message("expected.class.reference"));
+    }
+
+    parseAnnotationParameterList(builder);
+
+    anno.done(JavaElementType.ANNOTATION);
+    return anno;
+  }
+
+  @NotNull
+  private static PsiBuilder.Marker parseAnnotationParameterList(final PsiBuilder builder) {
+    PsiBuilder.Marker list = builder.mark();
+
+    if (!expect(builder, JavaTokenType.LPARENTH)) {
+      list.done(JavaElementType.ANNOTATION_PARAMETER_LIST);
+      return list;
+    }
+
+    if (expect(builder, JavaTokenType.RPARENTH)) {
+      list.done(JavaElementType.ANNOTATION_PARAMETER_LIST);
+      return list;
+    }
+
+    final boolean isFirstParamNamed = parseAnnotationParameter(builder, true);
+    boolean isFirstParamWarned = false;
+
+    boolean afterBad = false;
+    while (true) {
+      final IElementType tokenType = builder.getTokenType();
+      if (tokenType == null) {
+        error(builder, JavaErrorMessages.message("expected.parameter"));
+        break;
+      }
+      else if (expect(builder, JavaTokenType.RPARENTH)) {
+        break;
+      }
+      else if (tokenType == JavaTokenType.COMMA) {
+        final PsiBuilder.Marker errorStart = builder.mark();
+        final PsiBuilder.Marker errorEnd = builder.mark();
+        builder.advanceLexer();
+        final boolean hasParamName = parseAnnotationParameter(builder, false);
+        if (!isFirstParamNamed && hasParamName && !isFirstParamWarned) {
+          errorStart.errorBefore(JavaErrorMessages.message("annotation.name.is.missing"), errorEnd);
+          isFirstParamWarned = true;
+        }
+        else {
+          errorStart.drop();
+        }
+        errorEnd.drop();
+      }
+      else if (!afterBad) {
+        error(builder, JavaErrorMessages.message("expected.comma.or.rparen"));
+        builder.advanceLexer();
+        afterBad = true;
+      }
+      else {
+        afterBad = false;
+        parseAnnotationParameter(builder, false);
+      }
+    }
+
+    list.done(JavaElementType.ANNOTATION_PARAMETER_LIST);
+    return list;
+  }
+
+  private static boolean parseAnnotationParameter(final PsiBuilder builder, final boolean mayBeSimple) {
+    PsiBuilder.Marker pair = builder.mark();
+
+    if (mayBeSimple) {
+      final PsiBuilder.Marker value = parseAnnotationValue(builder);
+      if (value != null && builder.getTokenType() != JavaTokenType.EQ) {
+        pair.done(JavaElementType.NAME_VALUE_PAIR);
+        return false;
+      }
+
+      pair.rollbackTo();
+      pair = builder.mark();
+    }
+
+    final boolean hasName = expectOrError(builder, JavaTokenType.IDENTIFIER, JavaErrorMessages.message("expected.identifier"));
+
+    expectOrError(builder, JavaTokenType.EQ, JavaErrorMessages.message("expected.eq"));
+
+    parseAnnotationValue(builder);
+
+    pair.done(JavaElementType.NAME_VALUE_PAIR);
+
+    return hasName;
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseAnnotationValue(final PsiBuilder builder) {
+    final PsiBuilder.Marker result;
+
+    final IElementType tokenType = builder.getTokenType();
+    if (tokenType == JavaTokenType.AT) {
+      result = parseAnnotation(builder);
+    }
+    else if (tokenType == JavaTokenType.LBRACE) {
+      result = parseAnnotationArrayInitializer(builder);
+    }
+    else {
+      result = ExpressionParser.parseConditional(builder);
+    }
+
+    if (result == null) {
+      error(builder, JavaErrorMessages.message("expected.value"));
+    }
+    return result;
+  }
+
+  @NotNull
+  private static PsiBuilder.Marker parseAnnotationArrayInitializer(final PsiBuilder builder) {
+    final PsiBuilder.Marker annoArray = builder.mark();
+    builder.advanceLexer();
+
+    if (expect(builder, JavaTokenType.RBRACE)) {
+      annoArray.done(JavaElementType.ANNOTATION_ARRAY_INITIALIZER);
+      return annoArray;
+    }
+
+    parseAnnotationValue(builder);
+
+    while (true) {
+      if (expect(builder, JavaTokenType.RBRACE)) {
+        break;
+      }
+      else if (expect(builder, JavaTokenType.COMMA)) {
+        parseAnnotationValue(builder);
+      }
+      else {
+        error(builder, JavaErrorMessages.message("expected.rbrace"));
+        break;
+      }
+    }
+
+    annoArray.done(JavaElementType.ANNOTATION_ARRAY_INITIALIZER);
+    return annoArray;
+  }
+}
diff --git a/java/java-impl/src/com/intellij/lang/java/parser/ExpressionParser.java b/java/java-impl/src/com/intellij/lang/java/parser/ExpressionParser.java
new file mode 100644 (file)
index 0000000..b649997
--- /dev/null
@@ -0,0 +1,852 @@
+/*
+ * Copyright 2000-2010 JetBrains s.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 com.intellij.lang.java.parser;
+
+import com.intellij.codeInsight.daemon.JavaErrorMessages;
+import com.intellij.lang.PsiBuilder;
+import com.intellij.lang.PsiBuilderUtil;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.util.Pair;
+import com.intellij.psi.JavaTokenType;
+import com.intellij.psi.TokenType;
+import com.intellij.psi.impl.source.tree.ElementType;
+import com.intellij.psi.impl.source.tree.JavaElementType;
+import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.tree.TokenSet;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import static com.intellij.lang.java.parser.JavaParserUtil.areTypeAnnotationsSupported;
+import static com.intellij.lang.java.parser.JavaParserUtil.error;
+
+
+public class ExpressionParser {
+  private static final Logger LOG = Logger.getInstance("#com.intellij.lang.java.parser.ExpressionParser");
+
+  private enum ExprType {
+    CONDITIONAL_OR, CONDITIONAL_AND, OR, XOR, AND, EQUALITY, RELATIONAL, SHIFT, ADDITIVE, MULTIPLICATIVE, UNARY, TYPE
+  }
+
+  private static final TokenSet ASSIGNMENT_OPS = TokenSet.create(
+    JavaTokenType.EQ, JavaTokenType.ASTERISKEQ, JavaTokenType.DIVEQ, JavaTokenType.PERCEQ, JavaTokenType.PLUSEQ, JavaTokenType.MINUSEQ,
+    JavaTokenType.LTLTEQ, JavaTokenType.GTGTEQ, JavaTokenType.GTGTGTEQ, JavaTokenType.ANDEQ, JavaTokenType.OREQ, JavaTokenType.XOREQ);
+  private static final TokenSet RELATIONAL_OPS = TokenSet.create(JavaTokenType.LT, JavaTokenType.GT, JavaTokenType.LE, JavaTokenType.GE);
+  private static final TokenSet POSTFIX_OPS = TokenSet.create(JavaTokenType.PLUSPLUS, JavaTokenType.MINUSMINUS);
+  private static final TokenSet PREF_ARITHMETIC_OPS = TokenSet.orSet(POSTFIX_OPS, TokenSet.create(JavaTokenType.PLUS, JavaTokenType.MINUS));
+  private static final TokenSet PREFIX_OPS = TokenSet.orSet(PREF_ARITHMETIC_OPS, TokenSet.create(JavaTokenType.TILDE, JavaTokenType.EXCL));
+  private static final TokenSet LITERALS = TokenSet.create(
+    JavaTokenType.TRUE_KEYWORD, JavaTokenType.FALSE_KEYWORD, JavaTokenType.NULL_KEYWORD, JavaTokenType.INTEGER_LITERAL,
+    JavaTokenType.LONG_LITERAL, JavaTokenType.FLOAT_LITERAL, JavaTokenType.DOUBLE_LITERAL, JavaTokenType.CHARACTER_LITERAL,
+    JavaTokenType.STRING_LITERAL);
+  private static final TokenSet CONDITIONAL_OR_OPS = TokenSet.create(JavaTokenType.OROR);
+  private static final TokenSet CONDITIONAL_AND_OPS = TokenSet.create(JavaTokenType.ANDAND);
+  private static final TokenSet OR_OPS = TokenSet.create(JavaTokenType.OR);
+  private static final TokenSet XOR_OPS = TokenSet.create(JavaTokenType.XOR);
+  private static final TokenSet AND_OPS = TokenSet.create(JavaTokenType.AND);
+  private static final TokenSet EQUALITY_OPS = TokenSet.create(JavaTokenType.EQEQ, JavaTokenType.NE);
+  private static final TokenSet SHIFT_OPS = TokenSet.create(JavaTokenType.LTLT, JavaTokenType.GTGT, JavaTokenType.GTGTGT);
+  private static final TokenSet ADDITIVE_OPS = TokenSet.create(JavaTokenType.PLUS, JavaTokenType.MINUS);
+  private static final TokenSet MULTIPLICATIVE_OPS = TokenSet.create(JavaTokenType.ASTERISK, JavaTokenType.DIV, JavaTokenType.PERC);
+  private static final TokenSet ARGS_LIST_END = TokenSet.create(JavaTokenType.RPARENTH, JavaTokenType.RBRACE, JavaTokenType.RBRACKET);
+  private static final TokenSet ARGS_LIST_CONTINUE = TokenSet.create(
+    JavaTokenType.IDENTIFIER, TokenType.BAD_CHARACTER, JavaTokenType.COMMA, JavaTokenType.INTEGER_LITERAL, JavaTokenType.STRING_LITERAL);
+
+  private ExpressionParser() { }
+
+  @Nullable
+  public static PsiBuilder.Marker parse(final PsiBuilder builder) {
+    return parseAssignment(builder);
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseAssignment(final PsiBuilder builder) {
+    final PsiBuilder.Marker left = parseConditional(builder);
+    if (left == null) return null;
+
+    final IElementType tokenType = getGtTokenType(builder);
+    if (ASSIGNMENT_OPS.contains(tokenType)) {
+      final PsiBuilder.Marker assignment = left.precede();
+      advanceGtToken(builder, tokenType);
+
+      final PsiBuilder.Marker right = parse(builder);
+      if (right == null) {
+        error(builder, JavaErrorMessages.message("expected.expression"));
+      }
+
+      assignment.done(JavaElementType.ASSIGNMENT_EXPRESSION);
+      return assignment;
+    }
+
+    return left;
+  }
+
+  @Nullable
+  public static PsiBuilder.Marker parseConditional(final PsiBuilder builder) {
+    final PsiBuilder.Marker condition = parseExpression(builder, ExprType.CONDITIONAL_OR);
+    if (condition == null) return null;
+
+    if (builder.getTokenType() != JavaTokenType.QUEST) return condition;
+    final PsiBuilder.Marker ternary = condition.precede();
+    builder.advanceLexer();
+
+    final PsiBuilder.Marker truePart = parse(builder);
+    if (truePart == null) {
+      error(builder, JavaErrorMessages.message("expected.expression"));
+      ternary.done(JavaElementType.CONDITIONAL_EXPRESSION);
+      return ternary;
+    }
+
+    if (builder.getTokenType() != JavaTokenType.COLON) {
+      error(builder, JavaErrorMessages.message("expected.colon"));
+      ternary.done(JavaElementType.CONDITIONAL_EXPRESSION);
+      return ternary;
+    }
+    builder.advanceLexer();
+
+    final PsiBuilder.Marker falsePart = parseConditional(builder);
+    if (falsePart == null) {
+      error(builder, JavaErrorMessages.message("expected.expression"));
+      ternary.done(JavaElementType.CONDITIONAL_EXPRESSION);
+      return ternary;
+    }
+
+    ternary.done(JavaElementType.CONDITIONAL_EXPRESSION);
+    return ternary;
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseExpression(final PsiBuilder builder, final ExprType type) {
+    switch (type) {
+      case CONDITIONAL_OR:
+        return parseBinary(builder, ExprType.CONDITIONAL_AND, CONDITIONAL_OR_OPS);
+
+      case CONDITIONAL_AND:
+        return parseBinary(builder, ExprType.OR, CONDITIONAL_AND_OPS);
+
+      case OR:
+        return parseBinary(builder, ExprType.XOR, OR_OPS);
+
+      case XOR:
+        return parseBinary(builder, ExprType.AND, XOR_OPS);
+
+      case AND:
+        return parseBinary(builder, ExprType.EQUALITY, AND_OPS);
+
+      case EQUALITY:
+        return parseBinary(builder, ExprType.RELATIONAL, EQUALITY_OPS);
+
+      case RELATIONAL:
+        return parseRelational(builder);
+
+      case SHIFT:
+        return parseBinary(builder, ExprType.ADDITIVE, SHIFT_OPS);
+
+      case ADDITIVE:
+        return parseBinary(builder, ExprType.MULTIPLICATIVE, ADDITIVE_OPS);
+
+      case MULTIPLICATIVE:
+        return parseBinary(builder, ExprType.UNARY, MULTIPLICATIVE_OPS);
+
+      case UNARY:
+        return parseUnary(builder);
+
+      case TYPE:
+        final ReferenceParser.TypeInfo typeInfo = ReferenceParser.parseType(builder);
+        return typeInfo != null ? typeInfo.marker : null;
+
+      default:
+        LOG.error("Unexpected type: " + type);
+        return null;
+    }
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseBinary(final PsiBuilder builder, final ExprType type, final TokenSet ops) {
+    PsiBuilder.Marker left = parseExpression(builder, type);
+    if (left == null) return null;
+
+    while (true) {
+      final IElementType tokenType = getGtTokenType(builder);
+      if (tokenType == null || !ops.contains(tokenType)) break;
+
+      final PsiBuilder.Marker binary = left.precede();
+      advanceGtToken(builder, tokenType);
+
+      final PsiBuilder.Marker right = parseExpression(builder, type);
+      if (right == null) {
+        error(builder, JavaErrorMessages.message("expected.expression"));
+        binary.done(JavaElementType.BINARY_EXPRESSION);
+        return binary;
+      }
+
+      binary.done(JavaElementType.BINARY_EXPRESSION);
+      left = binary;
+    }
+
+    return left;
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseRelational(final PsiBuilder builder) {
+    PsiBuilder.Marker left = parseExpression(builder, ExprType.SHIFT);
+    if (left == null) return null;
+
+    while (true) {
+      final IElementType toCreate;
+      final ExprType toParse;
+      final IElementType tokenType = getGtTokenType(builder);
+      if (RELATIONAL_OPS.contains(tokenType)) {
+        toCreate = JavaElementType.BINARY_EXPRESSION;
+        toParse = ExprType.SHIFT;
+      }
+      else if (tokenType == JavaTokenType.INSTANCEOF_KEYWORD) {
+        toCreate = JavaElementType.INSTANCE_OF_EXPRESSION;
+        toParse = ExprType.TYPE;
+      }
+      else {
+        break;
+      }
+
+      final PsiBuilder.Marker expression = left.precede();
+      builder.advanceLexer();
+
+      final PsiBuilder.Marker right = parseExpression(builder, toParse);
+      if (right == null) {
+        error(builder, toParse == ExprType.TYPE ?
+                      JavaErrorMessages.message("expected.type") : JavaErrorMessages.message("expected.expression"));
+        expression.done(toCreate);
+        return expression;
+      }
+
+      expression.done(toCreate);
+      left = expression;
+    }
+
+    return left;
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseUnary(final PsiBuilder builder) {
+    final IElementType tokenType = builder.getTokenType();
+
+    if (PREFIX_OPS.contains(tokenType)) {
+      final PsiBuilder.Marker unary = builder.mark();
+      builder.advanceLexer();
+
+      final PsiBuilder.Marker operand = parseUnary(builder);
+      if (operand == null) {
+        error(builder, JavaErrorMessages.message("expected.expression"));
+      }
+
+      unary.done(JavaElementType.PREFIX_EXPRESSION);
+      return unary;
+    }
+    else if (tokenType == JavaTokenType.LPARENTH) {
+      final PsiBuilder.Marker typeCast = builder.mark();
+      builder.advanceLexer();
+
+      final ReferenceParser.TypeInfo typeInfo = ReferenceParser.parseType(builder);
+
+      if (typeInfo == null || builder.getTokenType() != JavaTokenType.RPARENTH) {
+        typeCast.rollbackTo();
+        return parsePostfix(builder);
+      }
+      builder.advanceLexer();
+
+      if (PREF_ARITHMETIC_OPS.contains(builder.getTokenType())) {
+        if (!typeInfo.isPrimitive) {
+          typeCast.rollbackTo();
+          return parsePostfix(builder);
+        }
+      }
+
+      final PsiBuilder.Marker expr = parseUnary(builder);
+      if (expr == null) {
+        if (!typeInfo.isParameterized) {
+          typeCast.rollbackTo();
+          return parsePostfix(builder);
+        }
+        else {
+          error(builder, JavaErrorMessages.message("expected.expression"));
+        }
+      }
+
+      typeCast.done(JavaElementType.TYPE_CAST_EXPRESSION);
+      return typeCast;
+    }
+    else {
+      return parsePostfix(builder);
+    }
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parsePostfix(final PsiBuilder builder) {
+    PsiBuilder.Marker operand = parsePrimary(builder, false);
+    if (operand == null) return null;
+
+    while (POSTFIX_OPS.contains(builder.getTokenType())) {
+      final PsiBuilder.Marker postfix = operand.precede();
+      builder.advanceLexer();
+      postfix.done(JavaElementType.POSTFIX_EXPRESSION);
+      operand = postfix;
+    }
+
+    return operand;
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parsePrimary(final PsiBuilder builder, final boolean planB) {
+    PsiBuilder.Marker startMarker = builder.mark();
+
+    final Pair<PsiBuilder.Marker, IElementType> exprTypePair = parsePrimaryExpressionStart(builder);
+    if (exprTypePair == null) {
+      startMarker.drop();
+      return null;
+    }
+
+    PsiBuilder.Marker expr = exprTypePair.first;
+    IElementType exprType = exprTypePair.second;
+
+    while (true) {
+      final IElementType tokenType = builder.getTokenType();
+      if (tokenType == JavaTokenType.DOT) {
+        final PsiBuilder.Marker dotPos = builder.mark();
+        builder.advanceLexer();
+
+        final IElementType dotTokenType = builder.getTokenType();
+        if (dotTokenType == JavaTokenType.CLASS_KEYWORD && exprType == JavaElementType.REFERENCE_EXPRESSION) {
+          if (planB) {
+            error(builder, JavaErrorMessages.message("expected.identifier"));
+            PsiBuilderUtil.drop(startMarker, dotPos);
+            return expr;
+          }
+
+          final PsiBuilder.Marker copy = startMarker.precede();
+          startMarker.rollbackTo();
+
+          final PsiBuilder.Marker classObjAccess = parseClassObjectAccess(builder);
+          if (classObjAccess == null) {
+            copy.rollbackTo();
+            return parsePrimary(builder, true);
+          }
+
+          startMarker = copy;
+          expr = classObjAccess;
+          exprType = JavaElementType.CLASS_OBJECT_ACCESS_EXPRESSION;
+        }
+        else if (dotTokenType == JavaTokenType.NEW_KEYWORD) {
+          dotPos.drop();
+          expr = parseNew(builder, expr);
+          exprType = JavaElementType.NEW_EXPRESSION;
+        }
+        else if ((dotTokenType == JavaTokenType.THIS_KEYWORD || dotTokenType == JavaTokenType.SUPER_KEYWORD) &&
+                 exprType == JavaElementType.REFERENCE_EXPRESSION) {
+          if (planB) {
+            dotPos.rollbackTo();
+            startMarker.drop();
+            return expr;
+          }
+
+          final PsiBuilder.Marker copy = startMarker.precede();
+          startMarker.rollbackTo();
+
+          final PsiBuilder.Marker ref = ReferenceParser.parseJavaCodeReference(builder, false, true, false);
+          if (ref == null || builder.getTokenType() != JavaTokenType.DOT) {
+            copy.rollbackTo();
+            return parsePrimary(builder, true);
+          }
+          builder.advanceLexer();
+
+          if (builder.getTokenType() != dotTokenType) {
+            copy.rollbackTo();
+            return parsePrimary(builder, true);
+          }
+          builder.advanceLexer();
+
+          startMarker = copy;
+          exprType = dotTokenType == JavaTokenType.THIS_KEYWORD ? JavaElementType.THIS_EXPRESSION : JavaElementType.SUPER_EXPRESSION;
+          expr = ref.precede();
+          expr.done(exprType);
+        }
+        else if (dotTokenType == JavaTokenType.SUPER_KEYWORD) {
+          dotPos.drop();
+          final PsiBuilder.Marker refExpr = expr.precede();
+          builder.advanceLexer();
+          refExpr.done(exprType = JavaElementType.REFERENCE_EXPRESSION);
+          expr = refExpr;
+        }
+        else {
+          dotPos.drop();
+          final PsiBuilder.Marker refExpr = expr.precede();
+          ReferenceParser.parseReferenceParameterList(builder, false);
+
+          if (!JavaParserUtil.expectOrError(builder, JavaTokenType.IDENTIFIER, JavaErrorMessages.message("expected.identifier"))) {
+            refExpr.done(JavaElementType.REFERENCE_EXPRESSION);
+            startMarker.drop();
+            return refExpr;
+          }
+
+          refExpr.done(exprType = JavaElementType.REFERENCE_EXPRESSION);
+          expr = refExpr;
+        }
+      }
+      else if (tokenType == JavaTokenType.LPARENTH) {
+        if (exprType != JavaElementType.REFERENCE_EXPRESSION) {
+          if (exprType == JavaElementType.SUPER_EXPRESSION) {
+            if (planB) {
+              startMarker.drop();
+              return expr;
+            }
+
+            final PsiBuilder.Marker copy = startMarker.precede();
+            startMarker.rollbackTo();
+
+            final Pair<PsiBuilder.Marker, IElementType> qualifier = parsePrimaryExpressionStart(builder);
+            if (qualifier != null) {
+              final PsiBuilder.Marker refExpr = qualifier.first.precede();
+              if (builder.getTokenType() == JavaTokenType.DOT) {
+                builder.advanceLexer();
+                if (builder.getTokenType() == JavaTokenType.SUPER_KEYWORD) {
+                  builder.advanceLexer();
+                  refExpr.done(exprType = JavaElementType.REFERENCE_EXPRESSION);
+                  expr = refExpr;
+                  startMarker = copy;
+                  continue;
+                }
+              }
+            }
+
+            copy.rollbackTo();
+            return parsePrimary(builder, true);
+          }
+          else {
+            startMarker.drop();
+            return expr;
+          }
+        }
+
+        final PsiBuilder.Marker callExpr = expr.precede();
+        parseArgumentList(builder);
+        callExpr.done(exprType = JavaElementType.METHOD_CALL_EXPRESSION);
+        expr = callExpr;
+      }
+      else if (tokenType == JavaTokenType.LBRACKET) {
+        if (planB) {
+          startMarker.drop();
+          return expr;
+        }
+
+        builder.advanceLexer();
+
+        if (builder.getTokenType() == JavaTokenType.RBRACKET && exprType == JavaElementType.REFERENCE_EXPRESSION) {
+          final PsiBuilder.Marker copy = startMarker.precede();
+          startMarker.rollbackTo();
+
+          final PsiBuilder.Marker classObjAccess = parseClassObjectAccess(builder);
+          if (classObjAccess == null) {
+            copy.rollbackTo();
+            return parsePrimary(builder, true);
+          }
+
+          startMarker = copy;
+          expr = classObjAccess;
+          exprType = JavaElementType.CLASS_OBJECT_ACCESS_EXPRESSION;
+        }
+        else {
+          final PsiBuilder.Marker arrayAccess = expr.precede();
+
+          final PsiBuilder.Marker index = parse(builder);
+          if (index == null) {
+            error(builder, JavaErrorMessages.message("expected.expression"));
+            arrayAccess.done(JavaElementType.ARRAY_ACCESS_EXPRESSION);
+            startMarker.drop();
+            return arrayAccess;
+          }
+
+          if (builder.getTokenType() != JavaTokenType.RBRACKET) {
+            error(builder, JavaErrorMessages.message("expected.rbracket"));
+            arrayAccess.done(JavaElementType.ARRAY_ACCESS_EXPRESSION);
+            startMarker.drop();
+            return arrayAccess;
+          }
+          builder.advanceLexer();
+
+          arrayAccess.done(exprType = JavaElementType.ARRAY_ACCESS_EXPRESSION);
+          expr = arrayAccess;
+        }
+      }
+      else {
+        startMarker.drop();
+        return expr;
+      }
+    }
+  }
+
+  @Nullable
+  private static Pair<PsiBuilder.Marker, IElementType> parsePrimaryExpressionStart(final PsiBuilder builder) {
+    IElementType tokenType = builder.getTokenType();
+
+    if (LITERALS.contains(tokenType)) {
+      final PsiBuilder.Marker literal = builder.mark();
+      builder.advanceLexer();
+      literal.done(JavaElementType.LITERAL_EXPRESSION);
+      return Pair.create(literal, JavaElementType.LITERAL_EXPRESSION);
+    }
+    if (tokenType == JavaTokenType.LPARENTH) {
+      final PsiBuilder.Marker parenth = builder.mark();
+      builder.advanceLexer();
+
+      final PsiBuilder.Marker inner = parse(builder);
+      if (inner == null) {
+        error(builder, JavaErrorMessages.message("expected.expression"));
+      }
+
+      JavaParserUtil.expectOrError(builder, JavaTokenType.RPARENTH, JavaErrorMessages.message("expected.rparen"));
+
+      parenth.done(JavaElementType.PARENTH_EXPRESSION);
+      return Pair.create(parenth, JavaElementType.PARENTH_EXPRESSION);
+    }
+    if (tokenType == JavaTokenType.LBRACE) {
+      final PsiBuilder.Marker arrayInit = parseArrayInitializer(builder);
+      return arrayInit != null ? Pair.create(arrayInit, JavaElementType.ARRAY_INITIALIZER_EXPRESSION) : null;
+    }
+
+    PsiBuilder.Marker annotation = null;
+    final PsiBuilder.Marker beforeAnnotation = builder.mark();
+    if (tokenType == JavaTokenType.AT) {
+      annotation = DeclarationParser.parseAnnotations(builder);
+      tokenType = builder.getTokenType();
+    }
+
+    if (tokenType == JavaTokenType.IDENTIFIER) {
+      final PsiBuilder.Marker refExpr;
+      if (annotation != null) {
+        final PsiBuilder.Marker refParam = annotation.precede();
+        refParam.doneBefore(JavaElementType.REFERENCE_PARAMETER_LIST, annotation);
+        refExpr = refParam.precede();
+      }
+      else {
+        refExpr = builder.mark();
+        builder.mark().done(JavaElementType.REFERENCE_PARAMETER_LIST);
+      }
+
+      builder.advanceLexer();
+      refExpr.done(JavaElementType.REFERENCE_EXPRESSION);
+      beforeAnnotation.drop();
+      return Pair.create(refExpr, JavaElementType.REFERENCE_EXPRESSION);
+    }
+
+    if (annotation != null) {
+      beforeAnnotation.rollbackTo();
+      tokenType = builder.getTokenType();
+    }
+    else {
+      beforeAnnotation.drop();
+    }
+
+    if (tokenType == JavaTokenType.THIS_KEYWORD) {
+      final PsiBuilder.Marker expr = builder.mark();
+      builder.mark().done(JavaElementType.REFERENCE_PARAMETER_LIST);
+      builder.advanceLexer();
+      final IElementType type = builder.getTokenType() != JavaTokenType.LPARENTH ?
+                                JavaElementType.THIS_EXPRESSION : JavaElementType.REFERENCE_EXPRESSION;
+      expr.done(type);
+      return Pair.create(expr, type);
+    }
+    if (tokenType == JavaTokenType.SUPER_KEYWORD) {
+      final PsiBuilder.Marker expr = builder.mark();
+      builder.mark().done(JavaElementType.REFERENCE_PARAMETER_LIST);
+      builder.advanceLexer();
+      final IElementType type = builder.getTokenType() != JavaTokenType.LPARENTH ?
+                                JavaElementType.SUPER_EXPRESSION : JavaElementType.REFERENCE_EXPRESSION;
+      expr.done(type);
+      return Pair.create(expr, type);
+    }
+    if (tokenType == JavaTokenType.NEW_KEYWORD) {
+      final PsiBuilder.Marker newExpr = parseNew(builder, null);
+      return Pair.create(newExpr, JavaElementType.NEW_EXPRESSION);
+    }
+    if (ElementType.PRIMITIVE_TYPE_BIT_SET.contains(tokenType)) {
+      final PsiBuilder.Marker classObjAccess = parseClassObjectAccess(builder);
+      return classObjAccess != null ? Pair.create(classObjAccess, JavaElementType.CLASS_OBJECT_ACCESS_EXPRESSION) : null;
+    }
+
+    return null;
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseArrayInitializer(final PsiBuilder builder) {
+    if (builder.getTokenType() != JavaTokenType.LBRACE) return null;
+
+    final PsiBuilder.Marker arrayInit = builder.mark();
+    builder.advanceLexer();
+
+    boolean expressionMissed = false;
+    PsiBuilder.Marker lastComma = null;
+    while (true) {
+      if (builder.getTokenType() == JavaTokenType.RBRACE) {
+        builder.advanceLexer();
+        break;
+      }
+
+      if (builder.getTokenType() == null) {
+        error(builder, JavaErrorMessages.message("expected.rbrace"));
+        break;
+      }
+
+      if (expressionMissed && lastComma != null) {
+        // before comma must be an expression
+        lastComma.precede().errorBefore(JavaErrorMessages.message("expected.expression"), lastComma);
+        lastComma.drop();
+        lastComma = null;
+      }
+
+      final PsiBuilder.Marker arg = parse(builder);
+      if (arg == null) {
+        if (builder.getTokenType() == JavaTokenType.COMMA) {
+          expressionMissed = true;
+          lastComma = builder.mark();
+        }
+        else {
+          error(builder, JavaErrorMessages.message("expected.rbrace"));
+          break;
+        }
+      }
+
+      final IElementType tokenType = builder.getTokenType();
+      if (tokenType == JavaTokenType.COMMA) {
+        builder.advanceLexer();
+      }
+      else if (tokenType != JavaTokenType.RBRACE) {
+        error(builder, JavaErrorMessages.message("expected.comma"));
+      }
+    }
+
+    if (lastComma != null) {
+      lastComma.drop();
+    }
+
+    arrayInit.done(JavaElementType.ARRAY_INITIALIZER_EXPRESSION);
+    return arrayInit;
+  }
+
+  @NotNull
+  private static PsiBuilder.Marker parseNew(final PsiBuilder builder, final PsiBuilder.Marker start) {
+    final PsiBuilder.Marker newExpr = (start != null ? start.precede() : builder.mark());
+    builder.advanceLexer();
+
+    ReferenceParser.parseReferenceParameterList(builder, false);
+
+    final PsiBuilder.Marker refOrType;
+    final boolean parseAnnotations = areTypeAnnotationsSupported(builder) && builder.getTokenType() == JavaTokenType.AT;
+
+    final IElementType tokenType = builder.getTokenType();
+    if (tokenType == JavaTokenType.IDENTIFIER || parseAnnotations) {
+      refOrType = ReferenceParser.parseJavaCodeReference(builder, true, true, parseAnnotations);
+      if (refOrType == null) {
+        error(builder, JavaErrorMessages.message("expected.identifier"));
+        newExpr.done(JavaElementType.NEW_EXPRESSION);
+        return newExpr;
+      }
+    }
+    else if (ElementType.PRIMITIVE_TYPE_BIT_SET.contains(tokenType)) {
+      refOrType = null;
+      builder.advanceLexer();
+    }
+    else {
+      error(builder, JavaErrorMessages.message("expected.identifier"));
+      newExpr.done(JavaElementType.NEW_EXPRESSION);
+      return newExpr;
+    }
+
+    if (refOrType != null && builder.getTokenType() == JavaTokenType.LPARENTH) {
+      parseArgumentList(builder);
+      if (builder.getTokenType() == JavaTokenType.LBRACE) {
+        final PsiBuilder.Marker classElement = refOrType.precede();
+        DeclarationParser.parseClassBodyWithBraces(builder, false, false);
+        classElement.done(JavaElementType.ANONYMOUS_CLASS);
+      }
+    }
+    else {
+      if (builder.getTokenType() != JavaTokenType.LBRACKET) {
+        error(builder, refOrType == null ?
+                      JavaErrorMessages.message("expected.lbracket") : JavaErrorMessages.message("expected.lparen.or.lbracket"));
+        newExpr.done(JavaElementType.NEW_EXPRESSION);
+        return newExpr;
+      }
+
+      int bracketCount = 0;
+      int dimCount = 0;
+      while (true) {
+        if (builder.getTokenType() != JavaTokenType.LBRACKET) break;
+        builder.advanceLexer();
+
+        if (bracketCount == dimCount) {
+          final PsiBuilder.Marker dimExpr = parse(builder);
+          if (dimExpr != null) {
+            dimCount++;
+          }
+        }
+        bracketCount++;
+
+        if (!JavaParserUtil.expectOrError(builder, JavaTokenType.RBRACKET, JavaErrorMessages.message("expected.rbracket"))) {
+          newExpr.done(JavaElementType.NEW_EXPRESSION);
+          return newExpr;
+        }
+      }
+
+      if (dimCount == 0) {
+        if (builder.getTokenType() == JavaTokenType.LBRACE) {
+          parseArrayInitializer(builder);
+        }
+        else {
+          error(builder, JavaErrorMessages.message("expected.array.initializer"));
+        }
+      }
+    }
+
+    newExpr.done(JavaElementType.NEW_EXPRESSION);
+    return newExpr;
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseClassObjectAccess(final PsiBuilder builder) {
+    final PsiBuilder.Marker expr = builder.mark();
+
+    final PsiBuilder.Marker type = ReferenceParser.parseType(builder, false, false);
+    if (type == null) {
+      expr.drop();
+      return null;
+    }
+
+    if (builder.getTokenType() != JavaTokenType.DOT) {
+      expr.rollbackTo();
+      return null;
+    }
+    builder.advanceLexer();
+
+    if (builder.getTokenType() != JavaTokenType.CLASS_KEYWORD) {
+      expr.rollbackTo();
+      return null;
+    }
+    builder.advanceLexer();
+
+    expr.done(JavaElementType.CLASS_OBJECT_ACCESS_EXPRESSION);
+    return expr;
+  }
+
+  @NotNull
+  public static PsiBuilder.Marker parseArgumentList(final PsiBuilder builder) {
+    final PsiBuilder.Marker list = builder.mark();
+    builder.advanceLexer();
+
+    boolean first = true;
+    while (true) {
+      final IElementType tokenType = builder.getTokenType();
+      if (first && (ARGS_LIST_END.contains(tokenType) || builder.eof())) break;
+      if (!first && !ARGS_LIST_CONTINUE.contains(tokenType)) break;
+
+      boolean hasError = false;
+      if (!first) {
+        if (builder.getTokenType() == JavaTokenType.COMMA) {
+          builder.advanceLexer();
+        }
+        else {
+          hasError = true;
+          error(builder, JavaErrorMessages.message("expected.comma.or.rparen"));
+          emptyExpression(builder);
+        }
+      }
+      first = false;
+
+      final PsiBuilder.Marker arg = parse(builder);
+      if (arg == null) {
+        if (!hasError) {
+          error(builder, JavaErrorMessages.message("expected.expression"));
+          emptyExpression(builder);
+        }
+        if (!ARGS_LIST_CONTINUE.contains(builder.getTokenType())) break;
+        if (builder.getTokenType() != JavaTokenType.COMMA && !builder.eof()) {
+          builder.advanceLexer();
+        }
+      }
+    }
+
+    JavaParserUtil.expectOrError(builder, JavaTokenType.RPARENTH, JavaErrorMessages.message("expected.rparen"));
+
+    list.done(JavaElementType.EXPRESSION_LIST);
+    return list;
+  }
+
+  private static void emptyExpression(final PsiBuilder builder) {
+    builder.mark().done(JavaElementType.EMPTY_EXPRESSION);
+  }
+
+  @Nullable
+  private static IElementType getGtTokenType(final PsiBuilder builder) {
+    final PsiBuilder.Marker sp = builder.mark();
+
+    IElementType tokenType = builder.getTokenType();
+    if (tokenType == JavaTokenType.GT) {
+      builder.advanceLexer();
+      if (builder.getTokenType() == JavaTokenType.GT) {
+        builder.advanceLexer();
+        if (builder.getTokenType() == JavaTokenType.GT) {
+          builder.advanceLexer();
+          if (builder.getTokenType() == JavaTokenType.EQ) {
+            tokenType = JavaTokenType.GTGTGTEQ;
+          }
+          else {
+            tokenType = JavaTokenType.GTGTGT;
+          }
+        }
+        else if (builder.getTokenType() == JavaTokenType.EQ) {
+          tokenType = JavaTokenType.GTGTEQ;
+        }
+        else {
+          tokenType = JavaTokenType.GTGT;
+        }
+      }
+    }
+
+    sp.rollbackTo();
+    return tokenType;
+  }
+
+  private static void advanceGtToken(final PsiBuilder builder, final IElementType type) {
+    final PsiBuilder.Marker gtToken = builder.mark();
+
+    if (type == JavaTokenType.GTGTGTEQ) {
+      PsiBuilderUtil.advance(builder, 4);
+    }
+    else if (type == JavaTokenType.GTGTGT) {
+      PsiBuilderUtil.advance(builder, 3);
+    }
+    else if (type == JavaTokenType.GTGTEQ) {
+      PsiBuilderUtil.advance(builder, 3);
+    }
+    else if (type == JavaTokenType.GTGT) {
+      PsiBuilderUtil.advance(builder, 2);
+    }
+    else {
+      gtToken.drop();
+      builder.advanceLexer();
+      return;
+    }
+
+    gtToken.collapse(type);
+  }
+}
diff --git a/java/java-impl/src/com/intellij/lang/java/parser/JavaParser.java b/java/java-impl/src/com/intellij/lang/java/parser/JavaParser.java
new file mode 100644 (file)
index 0000000..b06bf22
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2000-2010 JetBrains s.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 com.intellij.lang.java.parser;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.lang.PsiBuilder;
+import com.intellij.lang.PsiParser;
+import com.intellij.pom.java.LanguageLevel;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
+
+import static com.intellij.lang.java.parser.JavaParserUtil.setLanguageLevel;
+
+
+public class JavaParser implements PsiParser {
+  private final LanguageLevel myLanguageLevel;
+
+  public JavaParser(final LanguageLevel languageLevel) {
+    myLanguageLevel = languageLevel;
+  }
+
+  @NotNull
+  public ASTNode parse(final IElementType rootType, final PsiBuilder builder) {
+    final PsiBuilder.Marker root = builder.mark();
+    setLanguageLevel(builder, myLanguageLevel);
+
+    // parse
+
+    root.done(rootType);
+    return builder.getTreeBuilt();
+  }
+}
diff --git a/java/java-impl/src/com/intellij/lang/java/parser/JavaParserUtil.java b/java/java-impl/src/com/intellij/lang/java/parser/JavaParserUtil.java
new file mode 100644 (file)
index 0000000..73937f3
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2000-2010 JetBrains s.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 com.intellij.lang.java.parser;
+
+import com.intellij.lang.PsiBuilder;
+import com.intellij.lang.PsiBuilderUtil;
+import com.intellij.openapi.util.Key;
+import com.intellij.pom.java.LanguageLevel;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
+
+
+public class JavaParserUtil {
+  private static final Key<LanguageLevel> LANG_LEVEL_KEY = Key.create("JavaParserUtil.LanguageLevel");
+
+  private JavaParserUtil() { }
+
+  public static void setLanguageLevel(final PsiBuilder builder, final LanguageLevel level) {
+    builder.putUserData(LANG_LEVEL_KEY, level);
+  }
+
+  public static boolean areTypeAnnotationsSupported(final PsiBuilder builder) {
+    final LanguageLevel level = getLanguageLevel(builder);
+    return level.isAtLeast(LanguageLevel.JDK_1_7);
+  }
+
+  @NotNull
+  private static LanguageLevel getLanguageLevel(final PsiBuilder builder) {
+    final LanguageLevel level = builder.getUserData(LANG_LEVEL_KEY);
+    assert level != null;
+    return level;
+  }
+
+  // used instead of PsiBuilder.error() as it drops all but first subsequent error messages
+  public static void error(final PsiBuilder builder, final String message) {
+    builder.mark().error(message);
+  }
+
+  public static boolean expectOrError(final PsiBuilder builder, final IElementType expectedType, final String errorMessage) {
+    if (!PsiBuilderUtil.expect(builder, expectedType)) {
+      error(builder, errorMessage);
+      return false;
+    }
+    return true;
+  }
+
+  public static void emptyElement(final PsiBuilder builder, final IElementType type) {
+    builder.mark().done(type);
+  }
+}
diff --git a/java/java-impl/src/com/intellij/lang/java/parser/ReferenceParser.java b/java/java-impl/src/com/intellij/lang/java/parser/ReferenceParser.java
new file mode 100644 (file)
index 0000000..8831468
--- /dev/null
@@ -0,0 +1,294 @@
+/*
+ * Copyright 2000-2010 JetBrains s.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 com.intellij.lang.java.parser;
+
+import com.intellij.codeInsight.daemon.JavaErrorMessages;
+import com.intellij.lang.PsiBuilder;
+import com.intellij.psi.JavaTokenType;
+import com.intellij.psi.impl.source.tree.ElementType;
+import com.intellij.psi.impl.source.tree.JavaElementType;
+import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.tree.TokenSet;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import static com.intellij.lang.PsiBuilderUtil.expect;
+import static com.intellij.lang.PsiBuilderUtil.nextTokenType;
+import static com.intellij.lang.java.parser.JavaParserUtil.*;
+
+
+public class ReferenceParser {
+  public static class TypeInfo {
+    public boolean isPrimitive = false;
+    public boolean isParameterized = false;
+    public boolean isArray = false;
+    public PsiBuilder.Marker marker = null;
+  }
+
+  private static final TokenSet WILDCARD_KEYWORD_SET = TokenSet.create(JavaTokenType.EXTENDS_KEYWORD, JavaTokenType.SUPER_KEYWORD);
+
+  private ReferenceParser() { }
+
+  @Nullable
+  public static TypeInfo parseType(final PsiBuilder builder) {
+    return parseTypeWithInfo(builder, true, true);
+  }
+
+  @Nullable
+  public static PsiBuilder.Marker parseType(final PsiBuilder builder, final boolean eatLastDot, final boolean wildcard) {
+    final TypeInfo typeInfo = parseTypeWithInfo(builder, eatLastDot, wildcard);
+    return typeInfo != null ? typeInfo.marker : null;
+  }
+
+  @Nullable
+  private static TypeInfo parseTypeWithInfo(final PsiBuilder builder, final boolean eatLastDot, final boolean wildcard) {
+    if (builder.getTokenType() == null) return null;
+
+    final TypeInfo typeInfo = new TypeInfo();
+
+    final boolean annotationsSupported = areTypeAnnotationsSupported(builder);
+    PsiBuilder.Marker type = builder.mark();
+    if (annotationsSupported) {
+      DeclarationParser.parseAnnotations(builder);
+    }
+
+    final IElementType tokenType = builder.getTokenType();
+    if (expect(builder, ElementType.PRIMITIVE_TYPE_BIT_SET)) {
+      typeInfo.isPrimitive = true;
+    }
+    else if (tokenType == JavaTokenType.IDENTIFIER) {
+      parseJavaCodeReference(builder, eatLastDot, true, annotationsSupported, typeInfo);
+    }
+    else if (wildcard && tokenType == JavaTokenType.QUEST) {
+      type.drop();
+      typeInfo.marker = parseWildcardType(builder);
+      return typeInfo.marker != null ? typeInfo : null;
+    }
+    else {
+      type.drop();
+      return null;
+    }
+
+    while (true) {
+      if (annotationsSupported) {
+        DeclarationParser.parseAnnotations(builder);
+      }
+      type.done(JavaElementType.TYPE);
+
+      if (!expect(builder, JavaTokenType.LBRACKET)) {
+        break;
+      }
+      typeInfo.isArray = true;
+      if (!expectOrError(builder, JavaTokenType.RBRACKET, JavaErrorMessages.message("expected.rbracket"))) {
+        break;
+      }
+
+      type = type.precede();
+    }
+
+    typeInfo.marker = type;
+    return typeInfo;
+  }
+
+  @NotNull
+  private static PsiBuilder.Marker parseWildcardType(final PsiBuilder builder) {
+    final PsiBuilder.Marker type = builder.mark();
+    builder.advanceLexer();
+
+    if (expect(builder, WILDCARD_KEYWORD_SET)) {
+      final PsiBuilder.Marker boundType = parseType(builder, true, false);
+      if (boundType == null) {
+        error(builder, JavaErrorMessages.message("expected.type"));
+      }
+    }
+
+    type.done(JavaElementType.TYPE);
+    return type;
+  }
+
+  @Nullable
+  public static PsiBuilder.Marker parseJavaCodeReference(final PsiBuilder builder, final boolean eatLastDot,
+                                                         final boolean parameterList, final boolean annotations) {
+    return parseJavaCodeReference(builder, eatLastDot, parameterList, annotations, new TypeInfo());
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseJavaCodeReference(final PsiBuilder builder, final boolean eatLastDot,
+                                                          final boolean parameterList, final boolean annotations,
+                                                          final TypeInfo typeInfo) {
+    PsiBuilder.Marker refElement = builder.mark();
+
+    if (annotations) {
+      DeclarationParser.parseAnnotations(builder);
+    }
+
+    if (!expect(builder, JavaTokenType.IDENTIFIER)) {
+      refElement.rollbackTo();
+      return null;
+    }
+
+    if (parameterList) {
+      typeInfo.isParameterized = (builder.getTokenType() == JavaTokenType.LT);
+      parseReferenceParameterList(builder, true);
+    }
+    else {
+      emptyElement(builder, JavaElementType.REFERENCE_PARAMETER_LIST);
+    }
+
+    boolean hasIdentifier;
+    while (builder.getTokenType() == JavaTokenType.DOT) {
+      refElement.done(JavaElementType.JAVA_CODE_REFERENCE);
+
+      final PsiBuilder.Marker dotPos = builder.mark();
+      builder.advanceLexer();
+
+      if (expect(builder, JavaTokenType.IDENTIFIER)) {
+        hasIdentifier = true;
+      }
+      else {
+        if (!eatLastDot) {
+          dotPos.rollbackTo();
+          return refElement;
+        }
+        hasIdentifier = false;
+      }
+      dotPos.drop();
+
+      refElement = refElement.precede();
+
+      if (!hasIdentifier) {
+        error(builder, JavaErrorMessages.message("expected.identifier"));
+        break;
+      }
+
+      if (parameterList) {
+        typeInfo.isParameterized = (builder.getTokenType() == JavaTokenType.LT);
+        parseReferenceParameterList(builder, true);
+      }
+      else {
+        emptyElement(builder, JavaElementType.REFERENCE_PARAMETER_LIST);
+      }
+    }
+
+    refElement.done(JavaElementType.JAVA_CODE_REFERENCE);
+    return refElement;
+  }
+
+  @NotNull
+  public static PsiBuilder.Marker parseReferenceParameterList(final PsiBuilder builder, final boolean wildcard) {
+    final PsiBuilder.Marker list = builder.mark();
+    if (!expect(builder, JavaTokenType.LT)) {
+      list.done(JavaElementType.REFERENCE_PARAMETER_LIST);
+      return list;
+    }
+
+    while (true) {
+      final PsiBuilder.Marker type = parseType(builder, true, wildcard);
+      if (type == null) {
+        error(builder, JavaErrorMessages.message("expected.identifier"));
+      }
+
+      if (expect(builder, JavaTokenType.GT)) {
+        break;
+      }
+      else if (!expectOrError(builder, JavaTokenType.COMMA, JavaErrorMessages.message("expected.gt.or.comma"))) {
+        break;
+      }
+    }
+
+    list.done(JavaElementType.REFERENCE_PARAMETER_LIST);
+    return list;
+  }
+
+  @NotNull
+  public static PsiBuilder.Marker parseTypeParameters(final PsiBuilder builder) {
+    final PsiBuilder.Marker list = builder.mark();
+    if (!expect(builder, JavaTokenType.LT)) {
+      list.done(JavaElementType.TYPE_PARAMETER_LIST);
+      return list;
+    }
+
+    while (true) {
+      final PsiBuilder.Marker param = parseTypeParameter(builder);
+      if (param == null) {
+        error(builder, JavaErrorMessages.message("expected.type.parameter"));
+      }
+      if (!expect(builder, JavaTokenType.COMMA)) {
+        break;
+      }
+    }
+
+    if (!expect(builder, JavaTokenType.GT)) {
+      // hack for completion
+      if (builder.getTokenType() == JavaTokenType.IDENTIFIER) {
+        if (nextTokenType(builder) == JavaTokenType.GT) {
+          final PsiBuilder.Marker errorElement = builder.mark();
+          builder.advanceLexer();
+          errorElement.error(JavaErrorMessages.message("unexpected.identifier"));
+          builder.advanceLexer();
+        }
+        else {
+          error(builder, JavaErrorMessages.message("expected.gt"));
+        }
+      }
+      else {
+        error(builder, JavaErrorMessages.message("expected.gt"));
+      }
+    }
+
+    list.done(JavaElementType.TYPE_PARAMETER_LIST);
+    return list;
+  }
+
+  @Nullable
+  private static PsiBuilder.Marker parseTypeParameter(final PsiBuilder builder) {
+    final PsiBuilder.Marker param = builder.mark();
+
+    DeclarationParser.parseAnnotations(builder);
+    if (!expect(builder, JavaTokenType.IDENTIFIER)) {
+      param.rollbackTo();
+      return null;
+    }
+
+    if (expect(builder, JavaTokenType.EXTENDS_KEYWORD)) {
+      parseReferenceList(builder, JavaElementType.EXTENDS_BOUND_LIST, JavaTokenType.AND);
+    }
+    else {
+      emptyElement(builder, JavaElementType.EXTENDS_BOUND_LIST);
+    }
+
+    param.done(JavaElementType.TYPE_PARAMETER);
+    return param;
+  }
+
+  @NotNull
+  private static PsiBuilder.Marker parseReferenceList(final PsiBuilder builder, final IElementType type, final IElementType delimiter) {
+    final PsiBuilder.Marker element = builder.mark();
+
+    while (true) {
+      final PsiBuilder.Marker classReference = parseJavaCodeReference(builder, true, true, true);
+      if (classReference == null) {
+        error(builder, JavaErrorMessages.message("expected.identifier"));
+      }
+      if (!expect(builder, delimiter)) {
+        break;
+      }
+    }
+
+    element.done(type);
+    return element;
+  }
+}
index c349bef30c798b233e67a0e01c83adc72e6e74a1..058f529610ffebdaa09973a915314a883371afe9 100644 (file)
@@ -42,7 +42,7 @@ import java.io.IOException;
 
 public class JavaClassReferenceListElementType extends JavaStubElementType<PsiClassReferenceListStub, PsiReferenceList> {
   public JavaClassReferenceListElementType(@NotNull @NonNls String id) {
-    super(id);
+    super(id, true);
   }
 
   public PsiReferenceList createPsi(final PsiClassReferenceListStub stub) {
index 9bcab4f8d55b0e020fa6dff42fa715ee84c346d3..bcf07816f068b32852ca2bf4decea7faa7b5d062 100644 (file)
@@ -29,8 +29,15 @@ import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 
 public abstract class JavaStubElementType<StubT extends StubElement, PsiT extends PsiElement> extends IStubElementType<StubT, PsiT> {
+  private final boolean myLeftBound;
+
   protected JavaStubElementType(@NotNull @NonNls final String debugName) {
+    this(debugName, false);
+  }
+
+  protected JavaStubElementType(@NotNull @NonNls final String debugName, final boolean leftBound) {
     super(debugName, StdFileTypes.JAVA != null ? StdFileTypes.JAVA.getLanguage() : null);
+    myLeftBound = leftBound;
   }
 
   public String getExternalId() {
@@ -47,4 +54,9 @@ public abstract class JavaStubElementType<StubT extends StubElement, PsiT extend
   }
 
   public abstract PsiT createPsi(ASTNode node);
+
+  @Override
+  public boolean isLeftBound() {
+    return myLeftBound;
+  }
 }
\ No newline at end of file
index e2193055a412a7593e59de75c7a1ea5f244fb8a9..b2968fa8dbef906a9b69690b0be9192a655dea05 100644 (file)
@@ -69,7 +69,7 @@ public interface JavaElementType {
 
   IElementType IMPORT_STATIC_REFERENCE = new IJavaElementType("IMPORT_STATIC_REFERENCE");
   IElementType TYPE = new IJavaElementType("TYPE");
-  IElementType REFERENCE_PARAMETER_LIST = new IJavaElementType("REFERENCE_PARAMETER_LIST");
+  IElementType REFERENCE_PARAMETER_LIST = new IJavaElementType("REFERENCE_PARAMETER_LIST", true);
   IElementType JAVA_CODE_REFERENCE = new IJavaElementType("JAVA_CODE_REFERENCE");
   IElementType PACKAGE_STATEMENT = new IJavaElementType("PACKAGE_STATEMENT");
 
@@ -120,7 +120,7 @@ public interface JavaElementType {
 
   IElementType ANNOTATION_ARRAY_INITIALIZER = new IJavaElementType("ANNOTATION_ARRAY_INITIALIZER");
   IElementType NAME_VALUE_PAIR = new IJavaElementType("NAME_VALUE_PAIR");
-  IElementType ANNOTATION_PARAMETER_LIST = new IJavaElementType("ANNOTATION_PARAMETER_LIST");
+  IElementType ANNOTATION_PARAMETER_LIST = new IJavaElementType("ANNOTATION_PARAMETER_LIST", true);
   IElementType METHOD_RECEIVER = new IJavaElementType("METHOD_RECEIVER");
 
   ILazyParseableElementType CODE_BLOCK = new IErrorCounterReparseableElementType("CODE_BLOCK", StdLanguages.JAVA) {
index 08719452aab84e418d7fccc0bd7c4689b33c68d5..3a495b7816be978c76202e791a5907bf9fdf8fd2 100644 (file)
@@ -48,11 +48,16 @@ public class OptimizeImportsRefactoringHelper implements RefactoringHelper<Set<P
   }
 
   public void performOperation(final Project project, final Set<PsiJavaFile> javaFiles) {
-    ApplicationManager.getApplication().runWriteAction(new Runnable() {
+    PsiManager.getInstance(project).performActionWithFormatterDisabled(new Runnable() {
       public void run() {
-        PsiDocumentManager.getInstance(project).commitAllDocuments();
+        ApplicationManager.getApplication().runWriteAction(new Runnable() {
+          public void run() {
+            PsiDocumentManager.getInstance(project).commitAllDocuments();
+          }
+        });
       }
     });
+
     final Set<SmartPsiElementPointer<PsiImportStatementBase>> redundants = new HashSet<SmartPsiElementPointer<PsiImportStatementBase>>();
     final Runnable findRedundantImports = new Runnable() {
       public void run() {
index cd8ff0b67273bdebd95b2ad8305000a2568e012e..4bc0184be9a70564d630846d7eba6ab6f07bf867 100644 (file)
@@ -819,7 +819,7 @@ public class JavaChangeSignatureUsageProcessor implements ChangeSignatureUsagePr
             if (!JavaPsiFacade.getInstance(element.getProject()).getResolveHelper()
               .isAccessible(method, modifierList, element, accessObjectClass, null)) {
               String message =
-                RefactoringBundle.message("0.with.1.visibility.is.not.accesible.from.2",
+                RefactoringBundle.message("0.with.1.visibility.is.not.accessible.from.2",
                                           RefactoringUIUtil.getDescription(method, true),
                                           myChangeInfo.getNewVisibility(),
                                           RefactoringUIUtil.getDescription(ConflictsUtil.getContainer(element), true));
index d0e9c6c0db7e3fcd172a981516aca9d65e4d8488..0b28044344e0c74c819419120794cb27279e10ed 100644 (file)
@@ -200,7 +200,7 @@ public class ConvertToInstanceMethodProcessor extends BaseRefactoringProcessor {
         }
         if (!JavaResolveUtil.isAccessible(myMethod, myTargetClass, copy, call, accessObjectClass, null)) {
           final String newVisibility = myNewVisibility == null ? VisibilityUtil.getVisibilityStringToDisplay(myMethod) : myNewVisibility;
-          String message = RefactoringBundle.message("0.with.1.visibility.is.not.accesible.from.2",
+          String message = RefactoringBundle.message("0.with.1.visibility.is.not.accessible.from.2",
                                                      RefactoringUIUtil.getDescription(myMethod, true), newVisibility,
                                                      RefactoringUIUtil.getDescription(ConflictsUtil.getContainer(call), true));
           conflicts.putValue(myMethod, message);
index c21a50c78698236716691c924eacf9ee5b6afd64..a0f83301939dbdb21807e88d4637b762123e2b0a 100644 (file)
@@ -268,7 +268,7 @@ public class IntroduceParameterProcessor extends BaseRefactoringProcessor implem
                   !JavaPsiFacade.getInstance(myProject).getResolveHelper().isAccessible((PsiMember)element, place, null)) {
                 String message =
                   RefactoringBundle.message(
-                    "0.is.not.accesible.from.1.value.for.introduced.parameter.in.that.method.call.will.be.incorrect",
+                    "0.is.not.accessible.from.1.value.for.introduced.parameter.in.that.method.call.will.be.incorrect",
                     RefactoringUIUtil.getDescription(element, true),
                     RefactoringUIUtil.getDescription(ConflictsUtil.getContainer(place), true));
                 conflicts.putValue(element, message);
index bc6d43828c3b163f6c9040ae4147172acbab4b02..3fd190737da0200a9d403e2b0c4062e861e6d9e0 100644 (file)
@@ -21,7 +21,6 @@
 package com.intellij.refactoring.move.moveMembers;
 
 import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector;
-import com.intellij.lang.LanguageExtension;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Ref;
@@ -282,7 +281,7 @@ public class MoveMembersProcessor extends BaseRefactoringProcessor {
             if (!JavaResolveUtil.isAccessible(member, myTargetClass, modifierListCopies.get(member), element, accessObjectClass, null)) {
               newVisibility = newVisibility == null ? VisibilityUtil.getVisibilityStringToDisplay(member) : newVisibility;
               String message =
-                CommonRefactoringUtil.capitalize(RefactoringBundle.message("0.with.1.visibility.is.not.accesible.from.2", RefactoringUIUtil.getDescription(member, false),
+                CommonRefactoringUtil.capitalize(RefactoringBundle.message("0.with.1.visibility.is.not.accessible.from.2", RefactoringUIUtil.getDescription(member, false),
                                           newVisibility, RefactoringUIUtil.getDescription(ConflictsUtil.getContainer(element), true)));
               conflicts.putValue(member, message);
             }
index 6a5f10524cf32d8724f73e8aa65e26b97b6ccccd..d18da953d9a76bcfa3363c82252184398265e82d 100644 (file)
@@ -3,7 +3,7 @@
   <component name="NewModuleRootManager" inherit-compiler-output="true">
     <exclude-output />
     <content url="file://$MODULE_DIR$">
-      <sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
diff --git a/java/java-tests/testData/psi/parser-partial/annotations/Array.txt b/java/java-tests/testData/psi/parser-partial/annotations/Array.txt
new file mode 100644 (file)
index 0000000..5525213
--- /dev/null
@@ -0,0 +1,20 @@
+PsiJavaFile:Array.java
+  PsiAnnotation
+    PsiJavaToken:AT('@')
+    PsiJavaCodeReferenceElement:Endorsers
+      PsiIdentifier:Endorsers('Endorsers')
+      PsiReferenceParameterList
+        <empty list>
+    PsiAnnotationParameterList
+      PsiJavaToken:LPARENTH('(')
+      PsiNameValuePair
+        PsiArrayInitializerMemberValue:{"Children", "Unscrupulous dentists"}
+          PsiJavaToken:LBRACE('{')
+          PsiLiteralExpression:"Children"
+            PsiJavaToken:STRING_LITERAL('"Children"')
+          PsiJavaToken:COMMA(',')
+          PsiWhiteSpace(' ')
+          PsiLiteralExpression:"Unscrupulous dentists"
+            PsiJavaToken:STRING_LITERAL('"Unscrupulous dentists"')
+          PsiJavaToken:RBRACE('}')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/annotations/Complex.txt b/java/java-tests/testData/psi/parser-partial/annotations/Complex.txt
new file mode 100644 (file)
index 0000000..5211c0a
--- /dev/null
@@ -0,0 +1,22 @@
+PsiJavaFile:Complex.java
+  PsiAnnotation
+    PsiJavaToken:AT('@')
+    PsiJavaCodeReferenceElement:Author
+      PsiIdentifier:Author('Author')
+      PsiReferenceParameterList
+        <empty list>
+    PsiAnnotationParameterList
+      PsiJavaToken:LPARENTH('(')
+      PsiNameValuePair
+        PsiIdentifier:first('first')
+        PsiJavaToken:EQ('=')
+        PsiLiteralExpression:"Eugene"
+          PsiJavaToken:STRING_LITERAL('"Eugene"')
+      PsiJavaToken:COMMA(',')
+      PsiWhiteSpace(' ')
+      PsiNameValuePair
+        PsiIdentifier:second('second')
+        PsiJavaToken:EQ('=')
+        PsiLiteralExpression:"Wampirchik"
+          PsiJavaToken:STRING_LITERAL('"Wampirchik"')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/annotations/FirstNameMissed.txt b/java/java-tests/testData/psi/parser-partial/annotations/FirstNameMissed.txt
new file mode 100644 (file)
index 0000000..711c2fa
--- /dev/null
@@ -0,0 +1,26 @@
+PsiJavaFile:FirstNameMissed.java
+  PsiAnnotation
+    PsiJavaToken:AT('@')
+    PsiJavaCodeReferenceElement:Anno
+      PsiIdentifier:Anno('Anno')
+      PsiReferenceParameterList
+        <empty list>
+    PsiAnnotationParameterList
+      PsiJavaToken:LPARENTH('(')
+      PsiNameValuePair
+        PsiReferenceExpression:value1
+          PsiReferenceParameterList
+            <empty list>
+          PsiIdentifier:value1('value1')
+      PsiErrorElement:Annotation attribute must be of the form 'name=value'
+        <empty list>
+      PsiJavaToken:COMMA(',')
+      PsiWhiteSpace(' ')
+      PsiNameValuePair
+        PsiIdentifier:param2('param2')
+        PsiJavaToken:EQ('=')
+        PsiReferenceExpression:value2
+          PsiReferenceParameterList
+            <empty list>
+          PsiIdentifier:value2('value2')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/annotations/Marker.txt b/java/java-tests/testData/psi/parser-partial/annotations/Marker.txt
new file mode 100644 (file)
index 0000000..ca28bc4
--- /dev/null
@@ -0,0 +1,9 @@
+PsiJavaFile:Marker.java
+  PsiAnnotation
+    PsiJavaToken:AT('@')
+    PsiJavaCodeReferenceElement:Preliminary
+      PsiIdentifier:Preliminary('Preliminary')
+      PsiReferenceParameterList
+        <empty list>
+    PsiAnnotationParameterList
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/annotations/Multiple.txt b/java/java-tests/testData/psi/parser-partial/annotations/Multiple.txt
new file mode 100644 (file)
index 0000000..5ef2baf
--- /dev/null
@@ -0,0 +1,26 @@
+PsiJavaFile:Multiple.java
+  PsiAnnotation
+    PsiJavaToken:AT('@')
+    PsiJavaCodeReferenceElement:Preliminary
+      PsiIdentifier:Preliminary('Preliminary')
+      PsiReferenceParameterList
+        <empty list>
+    PsiAnnotationParameterList
+      <empty list>
+  PsiWhiteSpace(' ')
+  PsiAnnotation
+    PsiJavaToken:AT('@')
+    PsiJavaCodeReferenceElement:Other
+      PsiIdentifier:Other('Other')
+      PsiReferenceParameterList
+        <empty list>
+    PsiAnnotationParameterList
+      PsiJavaToken:LPARENTH('(')
+      PsiNameValuePair
+        PsiIdentifier:name('name')
+        PsiJavaToken:EQ('=')
+        PsiReferenceExpression:value
+          PsiReferenceParameterList
+            <empty list>
+          PsiIdentifier:value('value')
+      PsiJavaToken:RPARENTH(')')
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/parser-partial/annotations/Nested.txt b/java/java-tests/testData/psi/parser-partial/annotations/Nested.txt
new file mode 100644 (file)
index 0000000..e8cfe44
--- /dev/null
@@ -0,0 +1,32 @@
+PsiJavaFile:Nested.java
+  PsiAnnotation
+    PsiJavaToken:AT('@')
+    PsiJavaCodeReferenceElement:Author
+      PsiIdentifier:Author('Author')
+      PsiReferenceParameterList
+        <empty list>
+    PsiAnnotationParameterList
+      PsiJavaToken:LPARENTH('(')
+      PsiNameValuePair
+        PsiAnnotation
+          PsiJavaToken:AT('@')
+          PsiJavaCodeReferenceElement:Name
+            PsiIdentifier:Name('Name')
+            PsiReferenceParameterList
+              <empty list>
+          PsiAnnotationParameterList
+            PsiJavaToken:LPARENTH('(')
+            PsiNameValuePair
+              PsiIdentifier:first('first')
+              PsiJavaToken:EQ('=')
+              PsiLiteralExpression:"Eugene"
+                PsiJavaToken:STRING_LITERAL('"Eugene"')
+            PsiJavaToken:COMMA(',')
+            PsiWhiteSpace(' ')
+            PsiNameValuePair
+              PsiIdentifier:second('second')
+              PsiJavaToken:EQ('=')
+              PsiLiteralExpression:"Wampirchik"
+                PsiJavaToken:STRING_LITERAL('"Wampirchik"')
+            PsiJavaToken:RPARENTH(')')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/annotations/ParameterizedAnnotation.txt b/java/java-tests/testData/psi/parser-partial/annotations/ParameterizedAnnotation.txt
new file mode 100644 (file)
index 0000000..a184313
--- /dev/null
@@ -0,0 +1,13 @@
+PsiJavaFile:ParameterizedAnnotation.java
+  PsiAnnotation
+    PsiJavaToken:AT('@')
+    PsiJavaCodeReferenceElement:Nullable
+      PsiIdentifier:Nullable('Nullable')
+      PsiReferenceParameterList
+        <empty list>
+    PsiAnnotationParameterList
+      <empty list>
+  PsiErrorElement:Unparsed tokens
+    PsiJavaToken:LT('<')
+    PsiIdentifier:T('T')
+    PsiJavaToken:GT('>')
diff --git a/java/java-tests/testData/psi/parser-partial/annotations/QualifiedAnnotation.txt b/java/java-tests/testData/psi/parser-partial/annotations/QualifiedAnnotation.txt
new file mode 100644 (file)
index 0000000..d73ddfe
--- /dev/null
@@ -0,0 +1,24 @@
+PsiJavaFile:QualifiedAnnotation.java
+  PsiAnnotation
+    PsiJavaToken:AT('@')
+    PsiJavaCodeReferenceElement:org.jetbrains.annotations.Nullable
+      PsiJavaCodeReferenceElement:org.jetbrains.annotations
+        PsiJavaCodeReferenceElement:org.jetbrains
+          PsiJavaCodeReferenceElement:org
+            PsiIdentifier:org('org')
+            PsiReferenceParameterList
+              <empty list>
+          PsiJavaToken:DOT('.')
+          PsiIdentifier:jetbrains('jetbrains')
+          PsiReferenceParameterList
+            <empty list>
+        PsiJavaToken:DOT('.')
+        PsiIdentifier:annotations('annotations')
+        PsiReferenceParameterList
+          <empty list>
+      PsiJavaToken:DOT('.')
+      PsiIdentifier:Nullable('Nullable')
+      PsiReferenceParameterList
+        <empty list>
+    PsiAnnotationParameterList
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/annotations/Simple0.txt b/java/java-tests/testData/psi/parser-partial/annotations/Simple0.txt
new file mode 100644 (file)
index 0000000..486549b
--- /dev/null
@@ -0,0 +1,13 @@
+PsiJavaFile:Simple0.java
+  PsiAnnotation
+    PsiJavaToken:AT('@')
+    PsiJavaCodeReferenceElement:Copyright
+      PsiIdentifier:Copyright('Copyright')
+      PsiReferenceParameterList
+        <empty list>
+    PsiAnnotationParameterList
+      PsiJavaToken:LPARENTH('(')
+      PsiNameValuePair
+        PsiLiteralExpression:"bla-bla-bla"
+          PsiJavaToken:STRING_LITERAL('"bla-bla-bla"')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/annotations/Simple1.txt b/java/java-tests/testData/psi/parser-partial/annotations/Simple1.txt
new file mode 100644 (file)
index 0000000..078d069
--- /dev/null
@@ -0,0 +1,15 @@
+PsiJavaFile:Simple1.java
+  PsiAnnotation
+    PsiJavaToken:AT('@')
+    PsiJavaCodeReferenceElement:Copyright
+      PsiIdentifier:Copyright('Copyright')
+      PsiReferenceParameterList
+        <empty list>
+    PsiAnnotationParameterList
+      PsiJavaToken:LPARENTH('(')
+      PsiNameValuePair
+        PsiReferenceExpression:treatedAsValue
+          PsiReferenceParameterList
+            <empty list>
+          PsiIdentifier:treatedAsValue('treatedAsValue')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer0.txt b/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer0.txt
new file mode 100644 (file)
index 0000000..508d0da
--- /dev/null
@@ -0,0 +1,5 @@
+PsiJavaFile:ArrayInitializer0.java
+  PsiArrayInitializerExpression:{ }
+    PsiJavaToken:LBRACE('{')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:RBRACE('}')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer1.txt b/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer1.txt
new file mode 100644 (file)
index 0000000..23a7143
--- /dev/null
@@ -0,0 +1,8 @@
+PsiJavaFile:ArrayInitializer1.java
+  PsiArrayInitializerExpression:{ 1 }
+    PsiJavaToken:LBRACE('{')
+    PsiWhiteSpace(' ')
+    PsiLiteralExpression:1
+      PsiJavaToken:INTEGER_LITERAL('1')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:RBRACE('}')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer2.txt b/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer2.txt
new file mode 100644 (file)
index 0000000..35a40ad
--- /dev/null
@@ -0,0 +1,9 @@
+PsiJavaFile:ArrayInitializer2.java
+  PsiArrayInitializerExpression:{ 1, }
+    PsiJavaToken:LBRACE('{')
+    PsiWhiteSpace(' ')
+    PsiLiteralExpression:1
+      PsiJavaToken:INTEGER_LITERAL('1')
+    PsiJavaToken:COMMA(',')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:RBRACE('}')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer3.txt b/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer3.txt
new file mode 100644 (file)
index 0000000..71af49d
--- /dev/null
@@ -0,0 +1,11 @@
+PsiJavaFile:ArrayInitializer3.java
+  PsiArrayInitializerExpression:{ 1,2 }
+    PsiJavaToken:LBRACE('{')
+    PsiWhiteSpace(' ')
+    PsiLiteralExpression:1
+      PsiJavaToken:INTEGER_LITERAL('1')
+    PsiJavaToken:COMMA(',')
+    PsiLiteralExpression:2
+      PsiJavaToken:INTEGER_LITERAL('2')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:RBRACE('}')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer4.txt b/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer4.txt
new file mode 100644 (file)
index 0000000..e8b34eb
--- /dev/null
@@ -0,0 +1,13 @@
+PsiJavaFile:ArrayInitializer4.java
+  PsiArrayInitializerExpression:{ 1 2 }
+    PsiJavaToken:LBRACE('{')
+    PsiWhiteSpace(' ')
+    PsiLiteralExpression:1
+      PsiJavaToken:INTEGER_LITERAL('1')
+    PsiErrorElement:',' expected
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiLiteralExpression:2
+      PsiJavaToken:INTEGER_LITERAL('2')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:RBRACE('}')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer5.txt b/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer5.txt
new file mode 100644 (file)
index 0000000..4613ecc
--- /dev/null
@@ -0,0 +1,12 @@
+PsiJavaFile:ArrayInitializer5.java
+  PsiArrayInitializerExpression:{ { }
+    PsiJavaToken:LBRACE('{')
+    PsiWhiteSpace(' ')
+    PsiArrayInitializerExpression:{ }
+      PsiJavaToken:LBRACE('{')
+      PsiWhiteSpace(' ')
+      PsiJavaToken:RBRACE('}')
+    PsiErrorElement:',' expected
+      <empty list>
+    PsiErrorElement:'}' expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer6.txt b/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer6.txt
new file mode 100644 (file)
index 0000000..6dba1a6
--- /dev/null
@@ -0,0 +1,7 @@
+PsiJavaFile:ArrayInitializer6.java
+  PsiArrayInitializerExpression:{  ,  }
+    PsiJavaToken:LBRACE('{')
+    PsiWhiteSpace('  ')
+    PsiJavaToken:COMMA(',')
+    PsiWhiteSpace('  ')
+    PsiJavaToken:RBRACE('}')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer7.txt b/java/java-tests/testData/psi/parser-partial/expressions/ArrayInitializer7.txt
new file mode 100644 (file)
index 0000000..c33132b
--- /dev/null
@@ -0,0 +1,16 @@
+PsiJavaFile:ArrayInitializer7.java
+  PsiArrayInitializerExpression:{  ,  , 7 }
+    PsiJavaToken:LBRACE('{')
+    PsiErrorElement:Expression expected
+      <empty list>
+    PsiWhiteSpace('  ')
+    PsiJavaToken:COMMA(',')
+    PsiErrorElement:Expression expected
+      <empty list>
+    PsiWhiteSpace('  ')
+    PsiJavaToken:COMMA(',')
+    PsiWhiteSpace(' ')
+    PsiLiteralExpression:7
+      PsiJavaToken:INTEGER_LITERAL('7')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:RBRACE('}')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Assignment0.txt b/java/java-tests/testData/psi/parser-partial/expressions/Assignment0.txt
new file mode 100644 (file)
index 0000000..92a8e70
--- /dev/null
@@ -0,0 +1,11 @@
+PsiJavaFile:Assignment0.java
+  PsiAssignmentExpression:a = 0
+    PsiReferenceExpression:a
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:a('a')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:EQ('=')
+    PsiWhiteSpace(' ')
+    PsiLiteralExpression:0
+      PsiJavaToken:INTEGER_LITERAL('0')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Assignment1.txt b/java/java-tests/testData/psi/parser-partial/expressions/Assignment1.txt
new file mode 100644 (file)
index 0000000..be4001e
--- /dev/null
@@ -0,0 +1,10 @@
+PsiJavaFile:Assignment1.java
+  PsiAssignmentExpression:a =
+    PsiReferenceExpression:a
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:a('a')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:EQ('=')
+    PsiErrorElement:Expression expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Cast.txt b/java/java-tests/testData/psi/parser-partial/expressions/Cast.txt
new file mode 100644 (file)
index 0000000..8bcbe79
--- /dev/null
@@ -0,0 +1,13 @@
+PsiJavaFile:Cast.java
+  PsiTypeCastExpression:(Type)var
+    PsiJavaToken:LPARENTH('(')
+    PsiTypeElement:Type
+      PsiJavaCodeReferenceElement:Type
+        PsiIdentifier:Type('Type')
+        PsiReferenceParameterList
+          <empty list>
+    PsiJavaToken:RPARENTH(')')
+    PsiReferenceExpression:var
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:var('var')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Cond0.txt b/java/java-tests/testData/psi/parser-partial/expressions/Cond0.txt
new file mode 100644 (file)
index 0000000..291ac31
--- /dev/null
@@ -0,0 +1,16 @@
+PsiJavaFile:Cond0.java
+  PsiConditionalExpression:cond ? true : false
+    PsiReferenceExpression:cond
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:cond('cond')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:QUEST('?')
+    PsiWhiteSpace(' ')
+    PsiLiteralExpression:true
+      PsiJavaToken:TRUE_KEYWORD('true')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:COLON(':')
+    PsiWhiteSpace(' ')
+    PsiLiteralExpression:false
+      PsiJavaToken:FALSE_KEYWORD('false')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Cond1.txt b/java/java-tests/testData/psi/parser-partial/expressions/Cond1.txt
new file mode 100644 (file)
index 0000000..544ddce
--- /dev/null
@@ -0,0 +1,10 @@
+PsiJavaFile:Cond1.java
+  PsiConditionalExpression:cond ?
+    PsiReferenceExpression:cond
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:cond('cond')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:QUEST('?')
+    PsiErrorElement:Expression expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Cond2.txt b/java/java-tests/testData/psi/parser-partial/expressions/Cond2.txt
new file mode 100644 (file)
index 0000000..95e7e68
--- /dev/null
@@ -0,0 +1,13 @@
+PsiJavaFile:Cond2.java
+  PsiConditionalExpression:cond ? true
+    PsiReferenceExpression:cond
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:cond('cond')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:QUEST('?')
+    PsiWhiteSpace(' ')
+    PsiLiteralExpression:true
+      PsiJavaToken:TRUE_KEYWORD('true')
+    PsiErrorElement:':' expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Cond3.txt b/java/java-tests/testData/psi/parser-partial/expressions/Cond3.txt
new file mode 100644 (file)
index 0000000..50f9d82
--- /dev/null
@@ -0,0 +1,15 @@
+PsiJavaFile:Cond3.java
+  PsiConditionalExpression:cond ? true :
+    PsiReferenceExpression:cond
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:cond('cond')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:QUEST('?')
+    PsiWhiteSpace(' ')
+    PsiLiteralExpression:true
+      PsiJavaToken:TRUE_KEYWORD('true')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:COLON(':')
+    PsiErrorElement:Expression expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/CondOr0.txt b/java/java-tests/testData/psi/parser-partial/expressions/CondOr0.txt
new file mode 100644 (file)
index 0000000..a2405e2
--- /dev/null
@@ -0,0 +1,21 @@
+PsiJavaFile:CondOr0.java
+  PsiBinaryExpression:a || b || c
+    PsiBinaryExpression:a || b
+      PsiReferenceExpression:a
+        PsiReferenceParameterList
+          <empty list>
+        PsiIdentifier:a('a')
+      PsiWhiteSpace(' ')
+      PsiJavaToken:OROR('||')
+      PsiWhiteSpace(' ')
+      PsiReferenceExpression:b
+        PsiReferenceParameterList
+          <empty list>
+        PsiIdentifier:b('b')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:OROR('||')
+    PsiWhiteSpace(' ')
+    PsiReferenceExpression:c
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:c('c')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/CondOr1.txt b/java/java-tests/testData/psi/parser-partial/expressions/CondOr1.txt
new file mode 100644 (file)
index 0000000..fd17bd9
--- /dev/null
@@ -0,0 +1,10 @@
+PsiJavaFile:CondOr1.java
+  PsiBinaryExpression:a ||
+    PsiReferenceExpression:a
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:a('a')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:OROR('||')
+    PsiErrorElement:Expression expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ExprList0.txt b/java/java-tests/testData/psi/parser-partial/expressions/ExprList0.txt
new file mode 100644 (file)
index 0000000..19dfe39
--- /dev/null
@@ -0,0 +1,14 @@
+PsiJavaFile:ExprList0.java
+  PsiMethodCallExpression:f(1,2)
+    PsiReferenceExpression:f
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:f('f')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiLiteralExpression:1
+        PsiJavaToken:INTEGER_LITERAL('1')
+      PsiJavaToken:COMMA(',')
+      PsiLiteralExpression:2
+        PsiJavaToken:INTEGER_LITERAL('2')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ExprList1.txt b/java/java-tests/testData/psi/parser-partial/expressions/ExprList1.txt
new file mode 100644 (file)
index 0000000..1b27165
--- /dev/null
@@ -0,0 +1,10 @@
+PsiJavaFile:ExprList1.java
+  PsiMethodCallExpression:f(
+    PsiReferenceExpression:f
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:f('f')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiErrorElement:')' expected
+        <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ExprList2.txt b/java/java-tests/testData/psi/parser-partial/expressions/ExprList2.txt
new file mode 100644 (file)
index 0000000..ac5a13b
--- /dev/null
@@ -0,0 +1,12 @@
+PsiJavaFile:ExprList2.java
+  PsiMethodCallExpression:f(1
+    PsiReferenceExpression:f
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:f('f')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiLiteralExpression:1
+        PsiJavaToken:INTEGER_LITERAL('1')
+      PsiErrorElement:')' expected
+        <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ExprList3.txt b/java/java-tests/testData/psi/parser-partial/expressions/ExprList3.txt
new file mode 100644 (file)
index 0000000..8ab3cbd
--- /dev/null
@@ -0,0 +1,17 @@
+PsiJavaFile:ExprList3.java
+  PsiMethodCallExpression:f(1,
+    PsiReferenceExpression:f
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:f('f')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiLiteralExpression:1
+        PsiJavaToken:INTEGER_LITERAL('1')
+      PsiJavaToken:COMMA(',')
+      PsiErrorElement:Expression expected
+        <empty list>
+      PsiExpression(empty)
+        <empty list>
+      PsiErrorElement:')' expected
+        <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ExprList4.txt b/java/java-tests/testData/psi/parser-partial/expressions/ExprList4.txt
new file mode 100644 (file)
index 0000000..0f1d533
--- /dev/null
@@ -0,0 +1,16 @@
+PsiJavaFile:ExprList4.java
+  PsiMethodCallExpression:f(1,)
+    PsiReferenceExpression:f
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:f('f')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiLiteralExpression:1
+        PsiJavaToken:INTEGER_LITERAL('1')
+      PsiJavaToken:COMMA(',')
+      PsiErrorElement:Expression expected
+        <empty list>
+      PsiExpression(empty)
+        <empty list>
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ExprList5.txt b/java/java-tests/testData/psi/parser-partial/expressions/ExprList5.txt
new file mode 100644 (file)
index 0000000..79db76b
--- /dev/null
@@ -0,0 +1,19 @@
+PsiJavaFile:ExprList5.java
+  PsiMethodCallExpression:f(1,,2)
+    PsiReferenceExpression:f
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:f('f')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiLiteralExpression:1
+        PsiJavaToken:INTEGER_LITERAL('1')
+      PsiJavaToken:COMMA(',')
+      PsiErrorElement:Expression expected
+        <empty list>
+      PsiExpression(empty)
+        <empty list>
+      PsiJavaToken:COMMA(',')
+      PsiLiteralExpression:2
+        PsiJavaToken:INTEGER_LITERAL('2')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ExprList6.txt b/java/java-tests/testData/psi/parser-partial/expressions/ExprList6.txt
new file mode 100644 (file)
index 0000000..4afa082
--- /dev/null
@@ -0,0 +1,16 @@
+PsiJavaFile:ExprList6.java
+  PsiMethodCallExpression:f(,2)
+    PsiReferenceExpression:f
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:f('f')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiErrorElement:Expression expected
+        <empty list>
+      PsiExpression(empty)
+        <empty list>
+      PsiJavaToken:COMMA(',')
+      PsiLiteralExpression:2
+        PsiJavaToken:INTEGER_LITERAL('2')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/GE.txt b/java/java-tests/testData/psi/parser-partial/expressions/GE.txt
new file mode 100644 (file)
index 0000000..08e3dce
--- /dev/null
@@ -0,0 +1,17 @@
+PsiJavaFile:GE.java
+  PsiAssignmentExpression:x >>>= 8 >> 2
+    PsiReferenceExpression:x
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:x('x')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:GTGTGTEQ('>>>=')
+    PsiWhiteSpace(' ')
+    PsiBinaryExpression:8 >> 2
+      PsiLiteralExpression:8
+        PsiJavaToken:INTEGER_LITERAL('8')
+      PsiWhiteSpace(' ')
+      PsiJavaToken:GTGT('>>')
+      PsiWhiteSpace(' ')
+      PsiLiteralExpression:2
+        PsiJavaToken:INTEGER_LITERAL('2')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/IllegalWildcard.txt b/java/java-tests/testData/psi/parser-partial/expressions/IllegalWildcard.txt
new file mode 100644 (file)
index 0000000..563280a
--- /dev/null
@@ -0,0 +1,24 @@
+PsiJavaFile:IllegalWildcard.java
+  PsiConditionalExpression:this.<?
+    PsiReferenceExpression:this.<
+      PsiThisExpression:this
+        PsiReferenceParameterList
+          <empty list>
+        PsiKeyword:this('this')
+      PsiJavaToken:DOT('.')
+      PsiReferenceParameterList
+        PsiJavaToken:LT('<')
+        PsiErrorElement:Identifier expected
+          <empty list>
+        PsiErrorElement:'>' or ',' expected.
+          <empty list>
+      PsiErrorElement:Identifier expected
+        <empty list>
+    PsiJavaToken:QUEST('?')
+    PsiErrorElement:Expression expected
+      <empty list>
+  PsiErrorElement:Unparsed tokens
+    PsiJavaToken:GT('>')
+    PsiIdentifier:foo('foo')
+    PsiJavaToken:LPARENTH('(')
+    PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/IncompleteCast.txt b/java/java-tests/testData/psi/parser-partial/expressions/IncompleteCast.txt
new file mode 100644 (file)
index 0000000..5346de1
--- /dev/null
@@ -0,0 +1,26 @@
+PsiJavaFile:IncompleteCast.java
+  PsiMethodCallExpression:f((ArrayList<String>) )
+    PsiReferenceExpression:f
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:f('f')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiTypeCastExpression:(ArrayList<String>)
+        PsiJavaToken:LPARENTH('(')
+        PsiTypeElement:ArrayList<String>
+          PsiJavaCodeReferenceElement:ArrayList<String>
+            PsiIdentifier:ArrayList('ArrayList')
+            PsiReferenceParameterList
+              PsiJavaToken:LT('<')
+              PsiTypeElement:String
+                PsiJavaCodeReferenceElement:String
+                  PsiIdentifier:String('String')
+                  PsiReferenceParameterList
+                    <empty list>
+              PsiJavaToken:GT('>')
+        PsiJavaToken:RPARENTH(')')
+        PsiErrorElement:Expression expected
+          <empty list>
+      PsiWhiteSpace(' ')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/InstanceOf0.txt b/java/java-tests/testData/psi/parser-partial/expressions/InstanceOf0.txt
new file mode 100644 (file)
index 0000000..02bbba1
--- /dev/null
@@ -0,0 +1,14 @@
+PsiJavaFile:InstanceOf0.java
+  PsiInstanceofExpression:a instanceof String
+    PsiReferenceExpression:a
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:a('a')
+    PsiWhiteSpace(' ')
+    PsiKeyword:instanceof('instanceof')
+    PsiWhiteSpace(' ')
+    PsiTypeElement:String
+      PsiJavaCodeReferenceElement:String
+        PsiIdentifier:String('String')
+        PsiReferenceParameterList
+          <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/InstanceOf1.txt b/java/java-tests/testData/psi/parser-partial/expressions/InstanceOf1.txt
new file mode 100644 (file)
index 0000000..42ac3f1
--- /dev/null
@@ -0,0 +1,10 @@
+PsiJavaFile:InstanceOf1.java
+  PsiInstanceofExpression:a instanceof
+    PsiReferenceExpression:a
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:a('a')
+    PsiWhiteSpace(' ')
+    PsiKeyword:instanceof('instanceof')
+    PsiErrorElement:Type expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New0.txt b/java/java-tests/testData/psi/parser-partial/expressions/New0.txt
new file mode 100644 (file)
index 0000000..cef9e9c
--- /dev/null
@@ -0,0 +1,13 @@
+PsiJavaFile:New0.java
+  PsiNewExpression:new A()
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiJavaCodeReferenceElement:A
+      PsiIdentifier:A('A')
+      PsiReferenceParameterList
+        <empty list>
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiJavaToken:RPARENTH(')')
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New1.txt b/java/java-tests/testData/psi/parser-partial/expressions/New1.txt
new file mode 100644 (file)
index 0000000..76aa9b7
--- /dev/null
@@ -0,0 +1,16 @@
+PsiJavaFile:New1.java
+  PsiNewExpression:new A[1][]
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiJavaCodeReferenceElement:A
+      PsiIdentifier:A('A')
+      PsiReferenceParameterList
+        <empty list>
+    PsiJavaToken:LBRACKET('[')
+    PsiLiteralExpression:1
+      PsiJavaToken:INTEGER_LITERAL('1')
+    PsiJavaToken:RBRACKET(']')
+    PsiJavaToken:LBRACKET('[')
+    PsiJavaToken:RBRACKET(']')
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New10.txt b/java/java-tests/testData/psi/parser-partial/expressions/New10.txt
new file mode 100644 (file)
index 0000000..b720658
--- /dev/null
@@ -0,0 +1,12 @@
+PsiJavaFile:New10.java
+  PsiNewExpression:new int
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiKeyword:int('int')
+    PsiErrorElement:'[' expected
+      <empty list>
+  PsiErrorElement:Unparsed tokens
+    PsiJavaToken:LPARENTH('(')
+    PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New11.txt b/java/java-tests/testData/psi/parser-partial/expressions/New11.txt
new file mode 100644 (file)
index 0000000..59a4685
--- /dev/null
@@ -0,0 +1,15 @@
+PsiJavaFile:New11.java
+  PsiNewExpression:new String[0
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiJavaCodeReferenceElement:String
+      PsiIdentifier:String('String')
+      PsiReferenceParameterList
+        <empty list>
+    PsiJavaToken:LBRACKET('[')
+    PsiLiteralExpression:0
+      PsiJavaToken:INTEGER_LITERAL('0')
+    PsiErrorElement:']' expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New12.txt b/java/java-tests/testData/psi/parser-partial/expressions/New12.txt
new file mode 100644 (file)
index 0000000..b0e669a
--- /dev/null
@@ -0,0 +1,15 @@
+PsiJavaFile:New12.java
+  PsiNewExpression:new int[1][2]
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiKeyword:int('int')
+    PsiJavaToken:LBRACKET('[')
+    PsiLiteralExpression:1
+      PsiJavaToken:INTEGER_LITERAL('1')
+    PsiJavaToken:RBRACKET(']')
+    PsiJavaToken:LBRACKET('[')
+    PsiLiteralExpression:2
+      PsiJavaToken:INTEGER_LITERAL('2')
+    PsiJavaToken:RBRACKET(']')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New13.txt b/java/java-tests/testData/psi/parser-partial/expressions/New13.txt
new file mode 100644 (file)
index 0000000..c00cca2
--- /dev/null
@@ -0,0 +1,19 @@
+PsiJavaFile:New13.java
+  PsiNewExpression:new int[1][][
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiKeyword:int('int')
+    PsiJavaToken:LBRACKET('[')
+    PsiLiteralExpression:1
+      PsiJavaToken:INTEGER_LITERAL('1')
+    PsiJavaToken:RBRACKET(']')
+    PsiJavaToken:LBRACKET('[')
+    PsiJavaToken:RBRACKET(']')
+    PsiJavaToken:LBRACKET('[')
+    PsiErrorElement:']' expected
+      <empty list>
+  PsiErrorElement:Unparsed tokens
+    PsiJavaToken:INTEGER_LITERAL('2')
+    PsiJavaToken:RBRACKET(']')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New14.txt b/java/java-tests/testData/psi/parser-partial/expressions/New14.txt
new file mode 100644 (file)
index 0000000..9761d79
--- /dev/null
@@ -0,0 +1,18 @@
+PsiJavaFile:New14.java
+  PsiNewExpression:Q.new A()
+    PsiReferenceExpression:Q
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:Q('Q')
+    PsiJavaToken:DOT('.')
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiJavaCodeReferenceElement:A
+      PsiIdentifier:A('A')
+      PsiReferenceParameterList
+        <empty list>
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New2.txt b/java/java-tests/testData/psi/parser-partial/expressions/New2.txt
new file mode 100644 (file)
index 0000000..f5b075d
--- /dev/null
@@ -0,0 +1,14 @@
+PsiJavaFile:New2.java
+  PsiNewExpression:new A[]
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiJavaCodeReferenceElement:A
+      PsiIdentifier:A('A')
+      PsiReferenceParameterList
+        <empty list>
+    PsiJavaToken:LBRACKET('[')
+    PsiJavaToken:RBRACKET(']')
+    PsiErrorElement:Array initializer expected
+      <empty list>
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New3.txt b/java/java-tests/testData/psi/parser-partial/expressions/New3.txt
new file mode 100644 (file)
index 0000000..e545cdb
--- /dev/null
@@ -0,0 +1,18 @@
+PsiJavaFile:New3.java
+  PsiNewExpression:new A[][
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiJavaCodeReferenceElement:A
+      PsiIdentifier:A('A')
+      PsiReferenceParameterList
+        <empty list>
+    PsiJavaToken:LBRACKET('[')
+    PsiJavaToken:RBRACKET(']')
+    PsiJavaToken:LBRACKET('[')
+    PsiErrorElement:']' expected
+      <empty list>
+  PsiErrorElement:Unparsed tokens
+    PsiJavaToken:INTEGER_LITERAL('1')
+    PsiJavaToken:RBRACKET(']')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New4.txt b/java/java-tests/testData/psi/parser-partial/expressions/New4.txt
new file mode 100644 (file)
index 0000000..a2ff51e
--- /dev/null
@@ -0,0 +1,19 @@
+PsiJavaFile:New4.java
+  PsiNewExpression:new A[][]{null}
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiJavaCodeReferenceElement:A
+      PsiIdentifier:A('A')
+      PsiReferenceParameterList
+        <empty list>
+    PsiJavaToken:LBRACKET('[')
+    PsiJavaToken:RBRACKET(']')
+    PsiJavaToken:LBRACKET('[')
+    PsiJavaToken:RBRACKET(']')
+    PsiArrayInitializerExpression:{null}
+      PsiJavaToken:LBRACE('{')
+      PsiLiteralExpression:null
+        PsiJavaToken:NULL_KEYWORD('null')
+      PsiJavaToken:RBRACE('}')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New5.txt b/java/java-tests/testData/psi/parser-partial/expressions/New5.txt
new file mode 100644 (file)
index 0000000..3770613
--- /dev/null
@@ -0,0 +1,18 @@
+PsiJavaFile:New5.java
+  PsiNewExpression:new A[1]
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiJavaCodeReferenceElement:A
+      PsiIdentifier:A('A')
+      PsiReferenceParameterList
+        <empty list>
+    PsiJavaToken:LBRACKET('[')
+    PsiLiteralExpression:1
+      PsiJavaToken:INTEGER_LITERAL('1')
+    PsiJavaToken:RBRACKET(']')
+  PsiErrorElement:Unparsed tokens
+    PsiJavaToken:LBRACE('{')
+    PsiJavaToken:NULL_KEYWORD('null')
+    PsiJavaToken:RBRACE('}')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New6.txt b/java/java-tests/testData/psi/parser-partial/expressions/New6.txt
new file mode 100644 (file)
index 0000000..d767c90
--- /dev/null
@@ -0,0 +1,7 @@
+PsiJavaFile:New6.java
+  PsiNewExpression:new
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiErrorElement:Identifier expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New7.txt b/java/java-tests/testData/psi/parser-partial/expressions/New7.txt
new file mode 100644 (file)
index 0000000..85e4bb3
--- /dev/null
@@ -0,0 +1,12 @@
+PsiJavaFile:New7.java
+  PsiNewExpression:new A
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiJavaCodeReferenceElement:A
+      PsiIdentifier:A('A')
+      PsiReferenceParameterList
+        <empty list>
+    PsiErrorElement:'(' or '[' expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New8.txt b/java/java-tests/testData/psi/parser-partial/expressions/New8.txt
new file mode 100644 (file)
index 0000000..2a02fd4
--- /dev/null
@@ -0,0 +1,13 @@
+PsiJavaFile:New8.java
+  PsiNewExpression:new A[
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiJavaCodeReferenceElement:A
+      PsiIdentifier:A('A')
+      PsiReferenceParameterList
+        <empty list>
+    PsiJavaToken:LBRACKET('[')
+    PsiErrorElement:']' expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/New9.txt b/java/java-tests/testData/psi/parser-partial/expressions/New9.txt
new file mode 100644 (file)
index 0000000..58ede5b
--- /dev/null
@@ -0,0 +1,9 @@
+PsiJavaFile:New9.java
+  PsiNewExpression:new int
+    PsiKeyword:new('new')
+    PsiReferenceParameterList
+      <empty list>
+    PsiWhiteSpace(' ')
+    PsiKeyword:int('int')
+    PsiErrorElement:'[' expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/NewInExprList.txt b/java/java-tests/testData/psi/parser-partial/expressions/NewInExprList.txt
new file mode 100644 (file)
index 0000000..49b9fb6
--- /dev/null
@@ -0,0 +1,15 @@
+PsiJavaFile:NewInExprList.java
+  PsiMethodCallExpression:call(new)
+    PsiReferenceExpression:call
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:call('call')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiNewExpression:new
+        PsiKeyword:new('new')
+        PsiReferenceParameterList
+          <empty list>
+        PsiErrorElement:Identifier expected
+          <empty list>
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Not0.txt b/java/java-tests/testData/psi/parser-partial/expressions/Not0.txt
new file mode 100644 (file)
index 0000000..6c6b6ca
--- /dev/null
@@ -0,0 +1,9 @@
+PsiJavaFile:Not0.java
+  PsiPrefixExpression:!!a
+    PsiJavaToken:EXCL('!')
+    PsiPrefixExpression:!a
+      PsiJavaToken:EXCL('!')
+      PsiReferenceExpression:a
+        PsiReferenceParameterList
+          <empty list>
+        PsiIdentifier:a('a')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Not1.txt b/java/java-tests/testData/psi/parser-partial/expressions/Not1.txt
new file mode 100644 (file)
index 0000000..cad5dba
--- /dev/null
@@ -0,0 +1,5 @@
+PsiJavaFile:Not1.java
+  PsiPrefixExpression:!
+    PsiJavaToken:EXCL('!')
+    PsiErrorElement:Expression expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Or0.txt b/java/java-tests/testData/psi/parser-partial/expressions/Or0.txt
new file mode 100644 (file)
index 0000000..20bd748
--- /dev/null
@@ -0,0 +1,21 @@
+PsiJavaFile:Or0.java
+  PsiBinaryExpression:a | b | c
+    PsiBinaryExpression:a | b
+      PsiReferenceExpression:a
+        PsiReferenceParameterList
+          <empty list>
+        PsiIdentifier:a('a')
+      PsiWhiteSpace(' ')
+      PsiJavaToken:OR('|')
+      PsiWhiteSpace(' ')
+      PsiReferenceExpression:b
+        PsiReferenceParameterList
+          <empty list>
+        PsiIdentifier:b('b')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:OR('|')
+    PsiWhiteSpace(' ')
+    PsiReferenceExpression:c
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:c('c')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Or1.txt b/java/java-tests/testData/psi/parser-partial/expressions/Or1.txt
new file mode 100644 (file)
index 0000000..68894ea
--- /dev/null
@@ -0,0 +1,10 @@
+PsiJavaFile:Or1.java
+  PsiBinaryExpression:a |
+    PsiReferenceExpression:a
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:a('a')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:OR('|')
+    PsiErrorElement:Expression expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Parenth0.txt b/java/java-tests/testData/psi/parser-partial/expressions/Parenth0.txt
new file mode 100644 (file)
index 0000000..33befc6
--- /dev/null
@@ -0,0 +1,8 @@
+PsiJavaFile:Parenth0.java
+  PsiParenthesizedExpression:(c)
+    PsiJavaToken:LPARENTH('(')
+    PsiReferenceExpression:c
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:c('c')
+    PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/Parenth1.txt b/java/java-tests/testData/psi/parser-partial/expressions/Parenth1.txt
new file mode 100644 (file)
index 0000000..ceefc93
--- /dev/null
@@ -0,0 +1,15 @@
+PsiJavaFile:Parenth1.java
+  PsiPostfixExpression:(this).f--
+    PsiReferenceExpression:(this).f
+      PsiParenthesizedExpression:(this)
+        PsiJavaToken:LPARENTH('(')
+        PsiThisExpression:this
+          PsiReferenceParameterList
+            <empty list>
+          PsiKeyword:this('this')
+        PsiJavaToken:RPARENTH(')')
+      PsiJavaToken:DOT('.')
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:f('f')
+    PsiJavaToken:MINUSMINUS('--')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/PinesInReferenceExpression0.txt b/java/java-tests/testData/psi/parser-partial/expressions/PinesInReferenceExpression0.txt
new file mode 100644 (file)
index 0000000..b824ee1
--- /dev/null
@@ -0,0 +1,22 @@
+PsiJavaFile:PinesInReferenceExpression0.java
+  PsiMethodCallExpression:Collections.<String>sort(null)
+    PsiReferenceExpression:Collections.<String>sort
+      PsiReferenceExpression:Collections
+        PsiReferenceParameterList
+          <empty list>
+        PsiIdentifier:Collections('Collections')
+      PsiJavaToken:DOT('.')
+      PsiReferenceParameterList
+        PsiJavaToken:LT('<')
+        PsiTypeElement:String
+          PsiJavaCodeReferenceElement:String
+            PsiIdentifier:String('String')
+            PsiReferenceParameterList
+              <empty list>
+        PsiJavaToken:GT('>')
+      PsiIdentifier:sort('sort')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiLiteralExpression:null
+        PsiJavaToken:NULL_KEYWORD('null')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/PinesInReferenceExpression1.txt b/java/java-tests/testData/psi/parser-partial/expressions/PinesInReferenceExpression1.txt
new file mode 100644 (file)
index 0000000..5b821fd
--- /dev/null
@@ -0,0 +1,22 @@
+PsiJavaFile:PinesInReferenceExpression1.java
+  PsiMethodCallExpression:this.<String>sort(null)
+    PsiReferenceExpression:this.<String>sort
+      PsiThisExpression:this
+        PsiReferenceParameterList
+          <empty list>
+        PsiKeyword:this('this')
+      PsiJavaToken:DOT('.')
+      PsiReferenceParameterList
+        PsiJavaToken:LT('<')
+        PsiTypeElement:String
+          PsiJavaCodeReferenceElement:String
+            PsiIdentifier:String('String')
+            PsiReferenceParameterList
+              <empty list>
+        PsiJavaToken:GT('>')
+      PsiIdentifier:sort('sort')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiLiteralExpression:null
+        PsiJavaToken:NULL_KEYWORD('null')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/PrimitiveClassObjectAccess.txt b/java/java-tests/testData/psi/parser-partial/expressions/PrimitiveClassObjectAccess.txt
new file mode 100644 (file)
index 0000000..d8bdbaf
--- /dev/null
@@ -0,0 +1,6 @@
+PsiJavaFile:PrimitiveClassObjectAccess.java
+  PsiClassObjectAccessExpression:int.class
+    PsiTypeElement:int
+      PsiKeyword:int('int')
+    PsiJavaToken:DOT('.')
+    PsiKeyword:class('class')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall0.txt b/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall0.txt
new file mode 100644 (file)
index 0000000..6b22700
--- /dev/null
@@ -0,0 +1,22 @@
+PsiJavaFile:QualifiedSuperMethodCall0.java
+  PsiMethodCallExpression:new D().super(0)
+    PsiReferenceExpression:new D().super
+      PsiNewExpression:new D()
+        PsiKeyword:new('new')
+        PsiReferenceParameterList
+          <empty list>
+        PsiWhiteSpace(' ')
+        PsiJavaCodeReferenceElement:D
+          PsiIdentifier:D('D')
+          PsiReferenceParameterList
+            <empty list>
+        PsiExpressionList
+          PsiJavaToken:LPARENTH('(')
+          PsiJavaToken:RPARENTH(')')
+      PsiJavaToken:DOT('.')
+      PsiKeyword:super('super')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiLiteralExpression:0
+        PsiJavaToken:INTEGER_LITERAL('0')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall1.txt b/java/java-tests/testData/psi/parser-partial/expressions/QualifiedSuperMethodCall1.txt
new file mode 100644 (file)
index 0000000..c08eb71
--- /dev/null
@@ -0,0 +1,14 @@
+PsiJavaFile:QualifiedSuperMethodCall1.java
+  PsiMethodCallExpression:d.super(0)
+    PsiReferenceExpression:d.super
+      PsiReferenceExpression:d
+        PsiReferenceParameterList
+          <empty list>
+        PsiIdentifier:d('d')
+      PsiJavaToken:DOT('.')
+      PsiKeyword:super('super')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiLiteralExpression:0
+        PsiJavaToken:INTEGER_LITERAL('0')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/ShiftRight.txt b/java/java-tests/testData/psi/parser-partial/expressions/ShiftRight.txt
new file mode 100644 (file)
index 0000000..86d9fc6
--- /dev/null
@@ -0,0 +1,11 @@
+PsiJavaFile:ShiftRight.java
+  PsiAssignmentExpression:x >>= 2
+    PsiReferenceExpression:x
+      PsiReferenceParameterList
+        <empty list>
+      PsiIdentifier:x('x')
+    PsiWhiteSpace(' ')
+    PsiJavaToken:GTGTEQ('>>=')
+    PsiWhiteSpace(' ')
+    PsiLiteralExpression:2
+      PsiJavaToken:INTEGER_LITERAL('2')
diff --git a/java/java-tests/testData/psi/parser-partial/expressions/SuperMethodCallTypeParameterList.txt b/java/java-tests/testData/psi/parser-partial/expressions/SuperMethodCallTypeParameterList.txt
new file mode 100644 (file)
index 0000000..b17a757
--- /dev/null
@@ -0,0 +1,9 @@
+PsiJavaFile:SuperMethodCallTypeParameterList.java
+  PsiMethodCallExpression:super()
+    PsiReferenceExpression:super
+      PsiReferenceParameterList
+        <empty list>
+      PsiKeyword:super('super')
+    PsiExpressionList
+      PsiJavaToken:LPARENTH('(')
+      PsiJavaToken:RPARENTH(')')
diff --git a/java/java-tests/testData/psi/parser-partial/references/Reference0.txt b/java/java-tests/testData/psi/parser-partial/references/Reference0.txt
new file mode 100644 (file)
index 0000000..3768b9f
--- /dev/null
@@ -0,0 +1,5 @@
+PsiJavaFile:Reference0.java
+  PsiJavaCodeReferenceElement:a
+    PsiIdentifier:a('a')
+    PsiReferenceParameterList
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/references/Reference1.txt b/java/java-tests/testData/psi/parser-partial/references/Reference1.txt
new file mode 100644 (file)
index 0000000..9e9dbbe
--- /dev/null
@@ -0,0 +1,9 @@
+PsiJavaFile:Reference1.java
+  PsiJavaCodeReferenceElement:a.
+    PsiJavaCodeReferenceElement:a
+      PsiIdentifier:a('a')
+      PsiReferenceParameterList
+        <empty list>
+    PsiJavaToken:DOT('.')
+    PsiErrorElement:Identifier expected
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/references/Reference2.txt b/java/java-tests/testData/psi/parser-partial/references/Reference2.txt
new file mode 100644 (file)
index 0000000..d32c5bc
--- /dev/null
@@ -0,0 +1,10 @@
+PsiJavaFile:Reference2.java
+  PsiJavaCodeReferenceElement:a.b
+    PsiJavaCodeReferenceElement:a
+      PsiIdentifier:a('a')
+      PsiReferenceParameterList
+        <empty list>
+    PsiJavaToken:DOT('.')
+    PsiIdentifier:b('b')
+    PsiReferenceParameterList
+      <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/references/Type0.txt b/java/java-tests/testData/psi/parser-partial/references/Type0.txt
new file mode 100644 (file)
index 0000000..a9b9e8b
--- /dev/null
@@ -0,0 +1,3 @@
+PsiJavaFile:Type0.java
+  PsiTypeElement:int
+    PsiKeyword:int('int')
diff --git a/java/java-tests/testData/psi/parser-partial/references/Type1.txt b/java/java-tests/testData/psi/parser-partial/references/Type1.txt
new file mode 100644 (file)
index 0000000..286e9f1
--- /dev/null
@@ -0,0 +1,11 @@
+PsiJavaFile:Type1.java
+  PsiTypeElement:a.b
+    PsiJavaCodeReferenceElement:a.b
+      PsiJavaCodeReferenceElement:a
+        PsiIdentifier:a('a')
+        PsiReferenceParameterList
+          <empty list>
+      PsiJavaToken:DOT('.')
+      PsiIdentifier:b('b')
+      PsiReferenceParameterList
+        <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/references/Type2.txt b/java/java-tests/testData/psi/parser-partial/references/Type2.txt
new file mode 100644 (file)
index 0000000..7234dbb
--- /dev/null
@@ -0,0 +1,6 @@
+PsiJavaFile:Type2.java
+  PsiTypeElement:int[]
+    PsiTypeElement:int
+      PsiKeyword:int('int')
+    PsiJavaToken:LBRACKET('[')
+    PsiJavaToken:RBRACKET(']')
diff --git a/java/java-tests/testData/psi/parser-partial/references/Type3.txt b/java/java-tests/testData/psi/parser-partial/references/Type3.txt
new file mode 100644 (file)
index 0000000..8f4c284
--- /dev/null
@@ -0,0 +1,9 @@
+PsiJavaFile:Type3.java
+  PsiTypeElement:int[]
+    PsiTypeElement:int
+      PsiKeyword:int('int')
+    PsiJavaToken:LBRACKET('[')
+    PsiJavaToken:RBRACKET(']')
+  PsiJavaToken:LBRACKET('[')
+  PsiErrorElement:']' expected
+    <empty list>
diff --git a/java/java-tests/testData/psi/parser-partial/references/Type4.txt b/java/java-tests/testData/psi/parser-partial/references/Type4.txt
new file mode 100644 (file)
index 0000000..5159f57
--- /dev/null
@@ -0,0 +1,24 @@
+PsiJavaFile:Type4.java
+  PsiTypeElement:Map<String,List<String>>
+    PsiJavaCodeReferenceElement:Map<String,List<String>>
+      PsiIdentifier:Map('Map')
+      PsiReferenceParameterList
+        PsiJavaToken:LT('<')
+        PsiTypeElement:String
+          PsiJavaCodeReferenceElement:String
+            PsiIdentifier:String('String')
+            PsiReferenceParameterList
+              <empty list>
+        PsiJavaToken:COMMA(',')
+        PsiTypeElement:List<String>
+          PsiJavaCodeReferenceElement:List<String>
+            PsiIdentifier:List('List')
+            PsiReferenceParameterList
+              PsiJavaToken:LT('<')
+              PsiTypeElement:String
+                PsiJavaCodeReferenceElement:String
+                  PsiIdentifier:String('String')
+                  PsiReferenceParameterList
+                    <empty list>
+              PsiJavaToken:GT('>')
+        PsiJavaToken:GT('>')
diff --git a/java/java-tests/testData/psi/parser-partial/references/TypeParams0.txt b/java/java-tests/testData/psi/parser-partial/references/TypeParams0.txt
new file mode 100644 (file)
index 0000000..508d8cd
--- /dev/null
@@ -0,0 +1,8 @@
+PsiJavaFile:TypeParams0.java
+  PsiTypeParameterList
+    PsiJavaToken:LT('<')
+    PsiTypeParameter:T
+      PsiIdentifier:T('T')
+      PsiElement(EXTENDS_BOUND_LIST)
+        <empty list>
+    PsiJavaToken:GT('>')
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/parser-partial/references/TypeParams1.txt b/java/java-tests/testData/psi/parser-partial/references/TypeParams1.txt
new file mode 100644 (file)
index 0000000..0dd4209
--- /dev/null
@@ -0,0 +1,14 @@
+PsiJavaFile:TypeParams1.java
+  PsiTypeParameterList
+    PsiJavaToken:LT('<')
+    PsiTypeParameter:T
+      PsiIdentifier:T('T')
+      PsiElement(EXTENDS_BOUND_LIST)
+        <empty list>
+    PsiJavaToken:COMMA(',')
+    PsiWhiteSpace(' ')
+    PsiTypeParameter:U
+      PsiIdentifier:U('U')
+      PsiElement(EXTENDS_BOUND_LIST)
+        <empty list>
+    PsiJavaToken:GT('>')
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/parser-partial/references/TypeParams2.txt b/java/java-tests/testData/psi/parser-partial/references/TypeParams2.txt
new file mode 100644 (file)
index 0000000..16ac8be
--- /dev/null
@@ -0,0 +1,9 @@
+PsiJavaFile:TypeParams2.java
+  PsiTypeParameterList
+    PsiJavaToken:LT('<')
+    PsiTypeParameter:T
+      PsiIdentifier:T('T')
+      PsiElement(EXTENDS_BOUND_LIST)
+        <empty list>
+    PsiErrorElement:'>' expected.
+      <empty list>
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/parser-partial/references/TypeParams3.txt b/java/java-tests/testData/psi/parser-partial/references/TypeParams3.txt
new file mode 100644 (file)
index 0000000..b24e366
--- /dev/null
@@ -0,0 +1,11 @@
+PsiJavaFile:TypeParams3.java
+  PsiTypeParameterList
+    PsiJavaToken:LT('<')
+    PsiTypeParameter:T
+      PsiIdentifier:T('T')
+      PsiElement(EXTENDS_BOUND_LIST)
+        <empty list>
+    PsiWhiteSpace(' ')
+    PsiErrorElement:Unexpected identifier
+      PsiIdentifier:hack('hack')
+    PsiJavaToken:GT('>')
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/parser-partial/references/TypeParams4.txt b/java/java-tests/testData/psi/parser-partial/references/TypeParams4.txt
new file mode 100644 (file)
index 0000000..3f60da4
--- /dev/null
@@ -0,0 +1,12 @@
+PsiJavaFile:TypeParams4.java
+  PsiTypeParameterList
+    PsiJavaToken:LT('<')
+    PsiTypeParameter:T
+      PsiIdentifier:T('T')
+      PsiElement(EXTENDS_BOUND_LIST)
+        <empty list>
+    PsiErrorElement:'>' expected.
+      <empty list>
+  PsiWhiteSpace(' ')
+  PsiErrorElement:Unparsed tokens
+    PsiIdentifier:hack('hack')
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/parser-partial/references/TypeParams5.txt b/java/java-tests/testData/psi/parser-partial/references/TypeParams5.txt
new file mode 100644 (file)
index 0000000..51d776e
--- /dev/null
@@ -0,0 +1,27 @@
+PsiJavaFile:TypeParams5.java
+  PsiTypeParameterList
+    PsiJavaToken:LT('<')
+    PsiTypeParameter:T
+      PsiIdentifier:T('T')
+      PsiWhiteSpace(' ')
+      PsiKeyword:extends('extends')
+      PsiWhiteSpace(' ')
+      PsiElement(EXTENDS_BOUND_LIST)
+        PsiJavaCodeReferenceElement:X
+          PsiIdentifier:X('X')
+          PsiReferenceParameterList
+            <empty list>
+        PsiWhiteSpace(' ')
+        PsiJavaToken:AND('&')
+        PsiWhiteSpace(' ')
+        PsiJavaCodeReferenceElement:Y<Z>
+          PsiIdentifier:Y('Y')
+          PsiReferenceParameterList
+            PsiJavaToken:LT('<')
+            PsiTypeElement:Z
+              PsiJavaCodeReferenceElement:Z
+                PsiIdentifier:Z('Z')
+                PsiReferenceParameterList
+                  <empty list>
+            PsiJavaToken:GT('>')
+    PsiJavaToken:GT('>')
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/parser-partial/references/TypeParams6.txt b/java/java-tests/testData/psi/parser-partial/references/TypeParams6.txt
new file mode 100644 (file)
index 0000000..a5b46b9
--- /dev/null
@@ -0,0 +1,15 @@
+PsiJavaFile:TypeParams6.java
+  PsiTypeParameterList
+    PsiJavaToken:LT('<')
+    PsiTypeParameter:T
+      PsiIdentifier:T('T')
+      PsiElement(EXTENDS_BOUND_LIST)
+        <empty list>
+    PsiErrorElement:'>' expected.
+      <empty list>
+  PsiWhiteSpace(' ')
+  PsiErrorElement:Unparsed tokens
+    PsiIdentifier:supers('supers')
+    PsiWhiteSpace(' ')
+    PsiIdentifier:X('X')
+    PsiJavaToken:GT('>')
\ No newline at end of file
diff --git a/java/java-tests/testData/psi/parser-partial/references/TypeParams7.txt b/java/java-tests/testData/psi/parser-partial/references/TypeParams7.txt
new file mode 100644 (file)
index 0000000..f3cf019
--- /dev/null
@@ -0,0 +1,20 @@
+PsiJavaFile:TypeParams7.java
+  PsiTypeParameterList
+    PsiJavaToken:LT('<')
+    PsiTypeParameter:T
+      PsiIdentifier:T('T')
+      PsiWhiteSpace(' ')
+      PsiKeyword:extends('extends')
+      PsiWhiteSpace(' ')
+      PsiElement(EXTENDS_BOUND_LIST)
+        PsiJavaCodeReferenceElement:X
+          PsiIdentifier:X('X')
+          PsiReferenceParameterList
+            <empty list>
+    PsiJavaToken:COMMA(',')
+    PsiWhiteSpace(' ')
+    PsiTypeParameter:Y
+      PsiIdentifier:Y('Y')
+      PsiElement(EXTENDS_BOUND_LIST)
+        <empty list>
+    PsiJavaToken:GT('>')
\ No newline at end of file
index daf0b57289d8a82e03063ab6491ddc1352f5f646..7e9c239d60ab4828c226125fd26daae15c134da8 100644 (file)
@@ -1,6 +1,12 @@
 package com.intellij;
 
+import com.intellij.lang.PsiBuilder;
+import com.intellij.lang.impl.PsiBuilderImpl;
+import com.intellij.lang.java.parser.JavaParserUtil;
+import com.intellij.lexer.JavaLexer;
 import com.intellij.openapi.application.ex.PathManagerEx;
+import com.intellij.pom.java.LanguageLevel;
+import com.intellij.psi.JavaTokenType;
 
 /**
  * @author yole
@@ -13,4 +19,12 @@ public class JavaTestUtil {
   public static String getJavaTestDataPath() {
     return PathManagerEx.getTestDataPath();
   }
+
+  public static PsiBuilder getJavaBuilder(final String source) {
+    final LanguageLevel languageLevel = LanguageLevel.HIGHEST;
+    final JavaLexer lexer = new JavaLexer(languageLevel);
+    final PsiBuilder builder = new PsiBuilderImpl(lexer, JavaTokenType.WHITESPACE_BIT_SET, JavaTokenType.COMMENT_BIT_SET, source);
+    JavaParserUtil.setLanguageLevel(builder, languageLevel);
+    return builder;
+  }
 }
diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/JavaParsingTestCase.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/JavaParsingTestCase.java
new file mode 100644 (file)
index 0000000..15874f8
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2000-2010 JetBrains s.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 com.intellij.lang.java.parser;
+
+import com.intellij.lang.PsiBuilder;
+import com.intellij.psi.impl.DebugUtil;
+import com.intellij.psi.impl.source.tree.JavaElementType;
+import com.intellij.testFramework.IdeaTestCase;
+import com.intellij.testFramework.ParsingTestCase;
+import org.jetbrains.annotations.NonNls;
+
+import java.io.IOException;
+
+import static com.intellij.JavaTestUtil.getJavaBuilder;
+
+
+public abstract class JavaParsingTestCase extends ParsingTestCase {
+  @SuppressWarnings({"JUnitTestCaseWithNonTrivialConstructors"})
+  public JavaParsingTestCase(@NonNls final String dataPath) {
+    super(dataPath, "java");
+    IdeaTestCase.initPlatformPrefix();
+  }
+
+  protected interface Parser {
+    void parse(PsiBuilder builder);
+  }
+
+  protected void doParserTest(final String text, final Parser parser) {
+    final String name = getTestName(false);
+
+    final PsiBuilder builder = getJavaBuilder(text);
+    final PsiBuilder.Marker root = builder.mark();
+
+    parser.parse(builder);
+
+    if (builder.getTokenType() != null) {
+      final PsiBuilder.Marker unparsed = builder.mark();
+      while (builder.getTokenType() != null) builder.advanceLexer();
+      unparsed.error("Unparsed tokens");
+    }
+
+    root.done(JavaElementType.JAVA_FILE);
+
+    final String raw = DebugUtil.treeToString(builder.getTreeBuilt(), false);
+    final String tree = raw.replaceFirst("com.intellij.psi.util.PsiUtilBase\\S+", "PsiJavaFile:" + name + ".java");
+    try {
+      checkResult(name + ".txt", tree);
+    }
+    catch (IOException e) {
+      throw new RuntimeException(e);
+    }
+  }
+}
diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/AnnotationParserTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/AnnotationParserTest.java
new file mode 100644 (file)
index 0000000..f5dcb83
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2000-2010 JetBrains s.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 com.intellij.lang.java.parser.partial;
+
+import com.intellij.lang.PsiBuilder;
+import com.intellij.lang.java.parser.DeclarationParser;
+import com.intellij.lang.java.parser.JavaParsingTestCase;
+
+
+public class AnnotationParserTest extends JavaParsingTestCase {
+  public AnnotationParserTest() {
+    super("parser-partial/annotations");
+  }
+
+  public void testMarker() { doParserTest("@Preliminary"); }
+  public void testSimple0() { doParserTest("@Copyright(\"bla-bla-bla\")"); }
+  public void testSimple1() { doParserTest("@Copyright(treatedAsValue)"); }
+  public void testComplex() { doParserTest("@Author(first=\"Eugene\", second=\"Wampirchik\")"); }
+  public void testMultiple() { doParserTest("@Preliminary @Other(name=value)"); }
+  public void testArray() { doParserTest("@Endorsers({\"Children\", \"Unscrupulous dentists\"})"); }
+  public void testNested() { doParserTest("@Author(@Name(first=\"Eugene\", second=\"Wampirchik\"))"); }
+  public void testQualifiedAnnotation() { doParserTest("@org.jetbrains.annotations.Nullable"); }
+
+  public void testParameterizedAnnotation () { doParserTest("@Nullable<T>"); }
+  public void testFirstNameMissed() { doParserTest("@Anno(value1, param2=value2)"); }
+
+  private void doParserTest(final String text) {
+    doParserTest(text, new Parser() {
+      public void parse(final PsiBuilder builder) {
+        DeclarationParser.parseAnnotations(builder);
+      }
+    });
+  }
+}
diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ExpressionParserTest.java
new file mode 100644 (file)
index 0000000..340c962
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2000-2010 JetBrains s.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 com.intellij.lang.java.parser.partial;
+
+import com.intellij.lang.PsiBuilder;
+import com.intellij.lang.java.parser.ExpressionParser;
+import com.intellij.lang.java.parser.JavaParsingTestCase;
+
+
+public class ExpressionParserTest extends JavaParsingTestCase {
+  public ExpressionParserTest() {
+    super("parser-partial/expressions");
+  }
+
+  public void testAssignment0() { doParserTest("a = 0"); }
+  public void testAssignment1() { doParserTest("a ="); }
+
+  public void testCond0() { doParserTest("cond ? true : false"); }
+  public void testCond1() { doParserTest("cond ?"); }
+  public void testCond2() { doParserTest("cond ? true"); }
+  public void testCond3() { doParserTest("cond ? true :"); }
+
+  public void testCondOr0() { doParserTest("a || b || c"); }
+  public void testCondOr1() { doParserTest("a ||"); }
+
+  public void testOr0() { doParserTest("a | b | c"); }
+  public void testOr1() { doParserTest("a |"); }
+
+  public void testInstanceOf0() { doParserTest("a instanceof String"); }
+  public void testInstanceOf1() { doParserTest("a instanceof"); }
+
+  public void testNot0() { doParserTest("!!a"); }
+  public void testNot1() { doParserTest("!"); }
+
+  public void testCast() { doParserTest("(Type)var"); }
+
+  public void testParenth0() { doParserTest("(c)"); }
+  public void testParenth1() { doParserTest("(this).f--"); }
+
+  public void testNewInExprList() { doParserTest("call(new)"); }
+
+  public void testNew0() { doParserTest("new A()"); }
+  public void testNew1() { doParserTest("new A[1][]"); }
+  public void testNew2() { doParserTest("new A[]"); }
+  public void testNew3() { doParserTest("new A[][1]"); }
+  public void testNew4() { doParserTest("new A[][]{null}"); }
+  public void testNew5() { doParserTest("new A[1]{null}"); }
+  public void testNew6() { doParserTest("new"); }
+  public void testNew7() { doParserTest("new A"); }
+  public void testNew8() { doParserTest("new A["); }
+  public void testNew9() { doParserTest("new int"); }
+  public void testNew10() { doParserTest("new int()"); }
+  public void testNew11() { doParserTest("new String[0"); }
+  public void testNew12() { doParserTest("new int[1][2]"); }
+  public void testNew13() { doParserTest("new int[1][][2]"); }
+  public void testNew14() { doParserTest("Q.new A()"); }
+
+  public void testExprList0() { doParserTest("f(1,2)"); }
+  public void testExprList1() { doParserTest("f("); }
+  public void testExprList2() { doParserTest("f(1"); }
+  public void testExprList3() { doParserTest("f(1,"); }
+  public void testExprList4() { doParserTest("f(1,)"); }
+  public void testExprList5() { doParserTest("f(1,,2)"); }
+  public void testExprList6() { doParserTest("f(,2)"); }
+
+  public void testArrayInitializer0() { doParserTest("{ }"); }
+  public void testArrayInitializer1() { doParserTest("{ 1 }"); }
+  public void testArrayInitializer2() { doParserTest("{ 1, }"); }
+  public void testArrayInitializer3() { doParserTest("{ 1,2 }"); }
+  public void testArrayInitializer4() { doParserTest("{ 1 2 }"); }
+  public void testArrayInitializer5() { doParserTest("{ { }"); }
+  public void testArrayInitializer6() { doParserTest("{  ,  }"); }
+  public void testArrayInitializer7() { doParserTest("{  ,  , 7 }"); }
+
+  public void testPinesInReferenceExpression0() { doParserTest("Collections.<String>sort(null)"); }
+  public void testPinesInReferenceExpression1() { doParserTest("this.<String>sort(null)"); }
+
+  public void testGE() { doParserTest("x >>>= 8 >> 2"); }
+
+  public void testIncompleteCast() { doParserTest("f((ArrayList<String>) )"); }
+  public void testShiftRight() { doParserTest("x >>= 2"); }
+
+  public void testIllegalWildcard() { doParserTest("this.<?>foo()"); }
+
+  public void testQualifiedSuperMethodCall0() { doParserTest("new D().super(0)"); }
+  public void testQualifiedSuperMethodCall1() { doParserTest("d.super(0)"); }
+  public void testSuperMethodCallTypeParameterList() { doParserTest("super()"); }
+  public void testPrimitiveClassObjectAccess() { doParserTest("int.class"); }
+
+  private void doParserTest(final String text) {
+    doParserTest(text, new Parser() {
+      public void parse(final PsiBuilder builder) {
+        ExpressionParser.parse(builder);
+      }
+    });
+  }
+}
diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ReferenceParserTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/partial/ReferenceParserTest.java
new file mode 100644 (file)
index 0000000..da5651b
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2000-2010 JetBrains s.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 com.intellij.lang.java.parser.partial;
+
+import com.intellij.lang.PsiBuilder;
+import com.intellij.lang.java.parser.JavaParsingTestCase;
+import com.intellij.lang.java.parser.ReferenceParser;
+
+
+public class ReferenceParserTest extends JavaParsingTestCase {
+  public ReferenceParserTest() {
+    super("parser-partial/references");
+  }
+
+  public void testReference0() { doRefParserTest("a", false); }
+  public void testReference1() { doRefParserTest("a.", true); }
+  public void testReference2() { doRefParserTest("a.b", false); }
+
+  public void testType0() { doTypeParserTest("int", false); }
+  public void testType1() { doTypeParserTest("a.b", false); }
+  public void testType2() { doTypeParserTest("int[]", false); }
+  public void testType3() { doTypeParserTest("int[][", false); }
+  public void testType4() { doTypeParserTest("Map<String,List<String>>", false); }
+
+  public void testTypeParams0() { doTypeParamsParserTest("<T>"); }
+  public void testTypeParams1() { doTypeParamsParserTest("<T, U>"); }
+  public void testTypeParams2() { doTypeParamsParserTest("<T"); }
+  public void testTypeParams3() { doTypeParamsParserTest("<T hack>"); }
+  public void testTypeParams4() { doTypeParamsParserTest("<T hack"); }
+  public void testTypeParams5() { doTypeParamsParserTest("<T extends X & Y<Z>>"); }
+  public void testTypeParams6() { doTypeParamsParserTest("<T supers X>"); }
+  public void testTypeParams7() { doTypeParamsParserTest("<T extends X, Y>"); }
+
+  private void doRefParserTest(final String text, final boolean incomplete) {
+    doParserTest(text, new Parser() {
+      public void parse(final PsiBuilder builder) {
+        ReferenceParser.parseJavaCodeReference(builder, incomplete, false, false);
+      }
+    });
+  }
+
+  private void doTypeParserTest(final String text, final boolean incomplete) {
+    doParserTest(text, new Parser() {
+      public void parse(final PsiBuilder builder) {
+        ReferenceParser.parseType(builder, incomplete, false);
+      }
+    });
+  }
+
+  private void doTypeParamsParserTest(final String text) {
+    doParserTest(text, new Parser() {
+      public void parse(final PsiBuilder builder) {
+        ReferenceParser.parseTypeParameters(builder);
+      }
+    });
+  }
+}
index 983646c4829366ba34e9fed9cd04fc19f540dd6a..697f07edcf98baf8fa1100db466c375f7fb62156 100644 (file)
@@ -78,7 +78,7 @@ public class IntroduceParameterTest extends LightCodeInsightTestCase {
   }
 
   public void testThisSubstitutionInQualifier() throws Exception {
-    doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false, "field <b><code>Test.i</code></b> is not accesible from method <b><code>XTest.n()</code></b>. Value for introduced parameter in that method call will be incorrect.");
+    doTest(IntroduceParameterRefactoring.REPLACE_FIELDS_WITH_GETTERS_NONE, false, false, false, false, "field <b><code>Test.i</code></b> is not accessible from method <b><code>XTest.n()</code></b>. Value for introduced parameter in that method call will be incorrect.");
   }
 
   public void testFieldAccess() throws Exception {
index 2327d9b7ad54272dc3afe4b24ded6ee85d0ee863..08e182bfc84269cfe5e3fad682fd0f2a554d51fc 100644 (file)
@@ -32,7 +32,7 @@ public interface BaseJspFile extends XmlFile {
   boolean isTagPage();
 
   XmlTag[] getDirectiveTags(JspDirectiveKind directiveKind, final boolean searchInIncludes);
-  XmlTag createDirective(XmlTag context, JspDirectiveKind page);
+  XmlTag createDirective(XmlTag context, JspDirectiveKind directiveKind);
 
   PsiFile getBaseLanguageRoot();
   /**
@@ -43,4 +43,4 @@ public interface BaseJspFile extends XmlFile {
 
   @NotNull
   JspxFileViewProvider getViewProvider();
-}
\ No newline at end of file
+}
index 7e2f0277cd7a53d028b04defe37374ed73c6eee0..54e9d45167fb72a077fc4cc2c550625e1ef8d567 100644 (file)
@@ -20,7 +20,19 @@ import com.intellij.psi.tree.IElementType;
 import org.jetbrains.annotations.NonNls;
 
 public class IJavaElementType extends IElementType {
+  private final boolean myLeftBound;
+
   public IJavaElementType(@NonNls String debugName) {
+    this(debugName, false);
+  }
+
+  public IJavaElementType(@NonNls final String debugName, final boolean leftBound) {
     super(debugName, StdFileTypes.JAVA != null ? StdFileTypes.JAVA.getLanguage() : null);
+    myLeftBound = leftBound;
+  }
+
+  @Override
+  public boolean isLeftBound() {
+    return myLeftBound;
   }
 }
\ No newline at end of file
index d5f730c3d059ae9a831cb9104fadc1c62c8e963f..1a858c42dc2af4e59b6612a81a98ede95b5b7e11 100644 (file)
@@ -81,7 +81,7 @@ public class Main {
       if (ideaHomeDir == null) return false;
 
       String platform = System.getProperty("idea.platform.prefix", "idea");
-      String patchFileName = "jetbrains.patch.jar." + platform;
+      String patchFileName = ("jetbrains.patch.jar." + platform).toLowerCase();
       File patchFile = new File(System.getProperty("java.io.tmpdir"), patchFileName);
 
       if (!patchFile.exists()) return false;
diff --git a/platform/lang-api/src/com/intellij/lang/PsiBuilderUtil.java b/platform/lang-api/src/com/intellij/lang/PsiBuilderUtil.java
new file mode 100644 (file)
index 0000000..279d061
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2000-2010 JetBrains s.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 com.intellij.lang;
+
+import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.tree.TokenSet;
+import org.jetbrains.annotations.Nullable;
+
+
+public class PsiBuilderUtil {
+  private PsiBuilderUtil() { }
+
+  /**
+   * Returns type of next token.
+   *
+   * @param builder PSI builder to operate on.
+   * @return type of next token or null, if the builder is at the end of token stream
+   */
+  @Nullable
+  public static IElementType nextTokenType(final PsiBuilder builder) {
+    if (builder.getTokenType() == null) return null;
+    final PsiBuilder.Marker sp = builder.mark();
+    builder.advanceLexer();
+    final IElementType result = builder.getTokenType();
+    sp.rollbackTo();
+    return result;
+  }
+
+  /**
+   * Checks if tokens in token stream form expected sequence.
+   *
+   * @param builder PSI builder to operate on.
+   * @param tokenTypes expected elements.
+   * @return true if tokens form expected sequence, false otherwise
+   */
+  public static boolean lookAhead(final PsiBuilder builder, final IElementType... tokenTypes) {
+    if (tokenTypes.length == 0) return true;
+
+    if (!tokenTypes[0].equals(builder.getTokenType())) return false;
+
+    if (tokenTypes.length == 1) return true;
+
+    final PsiBuilder.Marker rb = builder.mark();
+    builder.advanceLexer();
+    int i = 1;
+    while (!builder.eof() && i < tokenTypes.length && tokenTypes[i].equals(builder.getTokenType())) {
+      builder.advanceLexer();
+      i++;
+    }
+    rb.rollbackTo();
+    return i == tokenTypes.length;
+  }
+
+  /**
+   * Advances lexer by given number of tokens (but not beyond the end of token stream).
+   *
+   * @param builder PSI builder to operate on.
+   * @param count number of tokens to skip.
+   */
+  public static void advance(final PsiBuilder builder, final int count) {
+    for (int i=0; i<count && !builder.eof(); i++) {
+      builder.getTokenType();
+      builder.advanceLexer();
+    }
+  }
+
+  /**
+   * Advances lexer if current token is of expected type, does nothing otherwise.
+   *
+   * @param builder PSI builder to operate on.
+   * @param expectedType expected token.
+   * @return true if token matches, false otherwise.
+   */
+  public static boolean expect(final PsiBuilder builder, final IElementType expectedType) {
+    if (builder.getTokenType() == expectedType) {
+      builder.advanceLexer();
+      return true;
+    }
+    return false;
+  }
+
+  /**
+   * Advances lexer if current token is of expected type, does nothing otherwise.
+   *
+   * @param builder PSI builder to operate on.
+   * @param expectedTypes expected token types.
+   * @return true if token matches, false otherwise.
+   */
+  public static boolean expect(final PsiBuilder builder, final TokenSet expectedTypes) {
+    if (expectedTypes.contains(builder.getTokenType())) {
+      builder.advanceLexer();
+      return true;
+    }
+    return false;
+  }
+
+  /**
+   * Release group of allocated markers.
+   *
+   * @param markers markers to drop.
+   */
+  public static void drop(final PsiBuilder.Marker... markers) {
+    for (PsiBuilder.Marker marker : markers) {
+      marker.drop();
+    }
+  }
+}
index a24c1ae311c33cdb951a64ff5df6d7e786e770a5..232d1e33cb294a87cf9ffa2374fa1dd393d38443 100644 (file)
@@ -143,7 +143,7 @@ public class JdkUtil {
       Charset charset = javaParameters.getCharset();
       if (charset == null) charset = EncodingManager.getInstance().getDefaultCharset();
       if (charset == null) charset = CharsetToolkit.getDefaultSystemCharset();
-      commandLine.setCharset(charset);
+      commandLine.setCharsetAndAddJavaParameter(charset);
     }
 
     final Map<String, String> env = javaParameters.getEnv();
index 5761eb060bc7633f99985a208f58971655759814..e6b780129a25ad1f20f03c148827fc0d00123440 100644 (file)
@@ -83,17 +83,28 @@ public abstract class ElementBase extends UserDataHolderBase implements Iconable
       baseIcon = myBaseIcon.get(flags);
     }
 
-    return IconDeferrer.getInstance().defer(baseIcon, new ElementIconRequest(psiElement,flags), new Function<ElementIconRequest, Icon>() {
-      public Icon fun(ElementIconRequest request) {
-        if (!request.getElement().isValid()) return null;
-
-        final Icon providersIcon = PsiIconUtil.getProvidersIcon(request.getElement(), request.getFlags());
-        if (providersIcon != null) {
-          return providersIcon instanceof RowIcon ? (RowIcon)providersIcon : createLayeredIcon(providersIcon, request.getFlags());
+    if (isToDeferIconLoading()) {
+      return IconDeferrer.getInstance().defer(baseIcon, new ElementIconRequest(psiElement, flags), new Function<ElementIconRequest, Icon>() {
+        public Icon fun(ElementIconRequest request) {
+          return computeIconNow(request.getElement(), request.getFlags());
         }
-        return getElementIcon(request.getFlags());
-      }
-    });
+      });
+    } else {
+      return computeIconNow(psiElement, flags);
+    }
+  }
+
+  protected boolean isToDeferIconLoading() {
+    return true;
+  }
+
+  private Icon computeIconNow(PsiElement element, int flags) {
+    if (!element.isValid()) return null;
+    final Icon providersIcon = PsiIconUtil.getProvidersIcon(element, flags);
+    if (providersIcon != null) {
+      return providersIcon instanceof RowIcon ? (RowIcon)providersIcon : createLayeredIcon(providersIcon, flags);
+    }
+    return getElementIcon(flags);
   }
 
   protected Icon computeBaseIcon(int flags) {
diff --git a/platform/lang-api/src/com/intellij/ui/ComputableIcon.java b/platform/lang-api/src/com/intellij/ui/ComputableIcon.java
new file mode 100644 (file)
index 0000000..1bcf2a3
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2000-2010 JetBrains s.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 com.intellij.ui;
+
+import com.intellij.navigation.ItemPresentation;
+import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.vfs.VirtualFile;
+import com.intellij.psi.meta.PsiPresentableMetaData;
+
+import javax.swing.*;
+
+public class ComputableIcon {
+
+  private Icon myIcon;
+  private Computable<Icon> myEvaluator;
+  private boolean myEvaluated;
+
+  public ComputableIcon(Computable<Icon> evaluator) {
+    myEvaluator = evaluator;
+  }
+
+  public Icon getIcon() {
+    if (!myEvaluated) {
+      myIcon = myEvaluator.compute();
+      myEvaluator = null;
+      myEvaluated = true;
+    }
+
+    return myIcon;
+  }
+
+  public static ComputableIcon create(final Icon icon) {
+    return new ComputableIcon(new Computable<Icon>() {
+      @Override
+      public Icon compute() {
+        return icon;
+      }
+    });
+  }
+
+  public static ComputableIcon create(final ItemPresentation presentation, final boolean isOpen) {
+    return new ComputableIcon(new Computable<Icon>() {
+      @Override
+      public Icon compute() {
+        return presentation.getIcon(isOpen);
+      }
+    });
+  }
+
+  public static ComputableIcon create(final PsiPresentableMetaData data) {
+    return new ComputableIcon(new Computable<Icon>() {
+      @Override
+      public Icon compute() {
+        return data.getIcon();
+      }
+    });
+  }
+
+  public static ComputableIcon create(final VirtualFile file) {
+    return new ComputableIcon(new Computable<Icon>() {
+      @Override
+      public Icon compute() {
+        return file.getIcon();
+      }
+    });
+  }
+}
index 8e2fa77fb07b122a3d47d3b838b484a0a255e67f..0b945f1708d445b9a040a433461112c6863a8310 100644 (file)
@@ -37,6 +37,7 @@ import com.intellij.psi.meta.PsiPresentableMetaData;
 import com.intellij.psi.search.LocalSearchScope;
 import com.intellij.psi.search.SearchScope;
 import com.intellij.psi.search.searches.ReferencesSearch;
+import com.intellij.ui.ComputableIcon;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewUtil;
 import com.intellij.usages.PsiElementUsageTarget;
@@ -180,8 +181,8 @@ public class PsiElement2UsageTargetAdapter implements PsiElementUsageTarget, Typ
 
   private class MyItemPresentation implements ItemPresentation {
     private String myPresentableText;
-    private Icon myIconOpen;
-    private Icon myIconClosed;
+    private ComputableIcon myIconOpen;
+    private ComputableIcon myIconClosed;
 
     public MyItemPresentation() {
       update();
@@ -191,8 +192,8 @@ public class PsiElement2UsageTargetAdapter implements PsiElementUsageTarget, Typ
       final PsiElement element = getElement();
       if (element != null) {
         final ItemPresentation presentation = ((NavigationItem)element).getPresentation();
-        myIconOpen = presentation != null ? presentation.getIcon(true) : null;
-        myIconClosed = presentation != null ? presentation.getIcon(false) : null;
+        myIconOpen = presentation != null ? ComputableIcon.create(presentation, true) : null;
+        myIconClosed = presentation != null ? ComputableIcon.create(presentation, false) : null;
         myPresentableText = UsageViewUtil.createNodeText(element);
         if (myIconOpen == null || myIconClosed == null) {
           if (element instanceof PsiMetaOwner) {
@@ -200,16 +201,16 @@ public class PsiElement2UsageTargetAdapter implements PsiElementUsageTarget, Typ
             final PsiMetaData metaData = psiMetaOwner.getMetaData();
             if (metaData instanceof PsiPresentableMetaData) {
               final PsiPresentableMetaData psiPresentableMetaData = (PsiPresentableMetaData)metaData;
-              if (myIconOpen == null) myIconOpen = psiPresentableMetaData.getIcon();
-              if (myIconClosed == null) myIconClosed = psiPresentableMetaData.getIcon();
+              if (myIconOpen == null) myIconOpen = ComputableIcon.create(psiPresentableMetaData);
+              if (myIconClosed == null) myIconClosed = ComputableIcon.create(psiPresentableMetaData);
             }
           }
           else if (element instanceof PsiFile) {
             final PsiFile psiFile = (PsiFile)element;
             final VirtualFile virtualFile = psiFile.getVirtualFile();
             if (virtualFile != null) {
-              myIconOpen = virtualFile.getIcon();
-              myIconClosed = virtualFile.getIcon();
+              myIconOpen = ComputableIcon.create(virtualFile);
+              myIconClosed = ComputableIcon.create(virtualFile);
             }
           }
         }
@@ -229,7 +230,7 @@ public class PsiElement2UsageTargetAdapter implements PsiElementUsageTarget, Typ
     }
 
     public Icon getIcon(boolean open) {
-      return open ? myIconOpen : myIconClosed;
+      return open ? myIconOpen.getIcon() : myIconClosed.getIcon();
     }
   }
 }
index 799a6fb0a5b5f46d7f6bec97526701177ac6666a..4c69bfccff8fc7b92017072c3df7ea65a6551525 100644 (file)
 
 package com.intellij.ide;
 
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.ide.CopyPasteManager;
 import com.intellij.openapi.util.Comparing;
+import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -199,22 +201,31 @@ public class PsiCopyPasteManager {
         return getDataAsText();
       }
       if (DataFlavor.javaFileListFlavor.equals(flavor)) {
-        return asFileList(myDataProxy.getElements());
+        ApplicationManager.getApplication().runReadAction(new Computable<List<File>>() {
+          @Override
+          public List<File> compute() {
+            return asFileList(myDataProxy.getElements());
+          }
+        });
       }
       return null;
     }
 
     @Nullable
     private String getDataAsText() {
-      List<String> names = new ArrayList<String>();
-      for (PsiElement element : myDataProxy.getElements()) {
-        if (element instanceof PsiNamedElement) {
-          String name = ((PsiNamedElement) element).getName();
-          if (name != null) {
-            names.add(name);
+      final List<String> names = new ArrayList<String>();
+      ApplicationManager.getApplication().runReadAction(new Runnable() {
+        public void run() {
+          for (PsiElement element : myDataProxy.getElements()) {
+            if (element instanceof PsiNamedElement) {
+              String name = ((PsiNamedElement) element).getName();
+              if (name != null) {
+                names.add(name);
+              }
+            }
           }
         }
-      }
+      });
       if (names.isEmpty()) {
         return null;
       }
index 0ea583945b6e5c69c40dec2991aa008035976d6b..edca8c915d144572e1fd5bca2e7697c92e52a396 100644 (file)
@@ -24,6 +24,7 @@ import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.fileEditor.FileEditorManager;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Ref;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.PsiDirectory;
 import com.intellij.psi.PsiElement;
@@ -85,6 +86,7 @@ public abstract class CreateFromTemplateAction<T extends PsiElement> extends AnA
     final CreateFileFromTemplateDialog.Builder builder = CreateFileFromTemplateDialog.createDialog(project);
     buildDialog(project, dir, builder);
 
+    final Ref<String> selectedTemplateName = Ref.create(null);
     final T createdElement =
       builder.show(getErrorTitle(), getDefaultTemplateName(dir), new CreateFileFromTemplateDialog.FileCreator<T>() {
         public void checkBeforeCreate(@NotNull String name, @NotNull String templateName) {
@@ -92,6 +94,7 @@ public abstract class CreateFromTemplateAction<T extends PsiElement> extends AnA
         }
 
         public T createFile(@NotNull String name, @NotNull String templateName) {
+          selectedTemplateName.set(templateName);
           return CreateFromTemplateAction.this.createFile(name, templateName, dir);
         }
 
@@ -102,9 +105,13 @@ public abstract class CreateFromTemplateAction<T extends PsiElement> extends AnA
       });
     if (createdElement != null) {
       view.selectElement(createdElement);
+      postProcesss(createdElement, selectedTemplateName.get());
     }
   }
 
+  protected void postProcesss(T createdElement, String templateName) {
+  }
+
   @Nullable
   protected abstract T createFile(String name, String templateName, PsiDirectory dir);
 
index 38d26627d5e82f4979d87d12a34dd4526622bb32..e7d9109ff31ef5fc66ae118af64d6e999008a787 100644 (file)
@@ -29,6 +29,8 @@ import com.intellij.openapi.fileTypes.FileTypes;
 import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.util.ClassLoaderUtil;
+import com.intellij.openapi.util.ThrowableComputable;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.PsiDirectory;
 import com.intellij.psi.PsiElement;
@@ -232,6 +234,14 @@ public class FileTemplateUtil{
                                               @NonNls @Nullable final String fileName,
                                               @Nullable Properties props,
                                               @NotNull final PsiDirectory directory) throws Exception {
+    return createFromTemplate(template, fileName, props, directory, null);
+  }
+
+  public static PsiElement createFromTemplate(@NotNull final FileTemplate template,
+                                              @NonNls @Nullable final String fileName,
+                                              @Nullable Properties props,
+                                              @NotNull final PsiDirectory directory,
+                                              @Nullable ClassLoader classLoader) throws Exception {
     @NotNull final Project project = directory.getProject();
     if (props == null) {
       props = FileTemplateManager.getInstance().getDefaultProperties();
@@ -256,7 +266,15 @@ public class FileTemplateUtil{
         props.setProperty(FileTemplate.ATTRIBUTE_PACKAGE_NAME, FileTemplate.ATTRIBUTE_PACKAGE_NAME);
       }
     }
-    String mergedText = template.getText(props);
+
+    final Properties props_ = props;
+    String mergedText = ClassLoaderUtil.runWithClassLoader(classLoader != null ? classLoader : FileTemplateUtil.class.getClassLoader(),
+                                                           new ThrowableComputable<String, IOException>() {
+                                                             @Override
+                                                             public String compute() throws IOException {
+                                                               return template.getText(props_);
+                                                             }
+                                                           });
     final String templateText = StringUtil.convertLineSeparators(mergedText);
     final Exception[] commandException = new Exception[1];
     final PsiElement[] result = new PsiElement[1];
index 7a55ed3f5969b76196645c78fb581c5b49825087..86cb6a17fbb6f5c9a6a12b657405223ef29f65c9 100644 (file)
@@ -384,6 +384,7 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
   private static class DoneMarker extends ProductionMarker {
     public StartMarker myStart;
     public boolean myCollapse = false;
+    public boolean myTieToTheLeft = false;
 
     public DoneMarker() {}
 
@@ -567,20 +568,6 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
     START_MARKERS.recycle((StartMarker)marker);
   }
 
-  @SuppressWarnings({"SuspiciousMethodCalls"})
-  public void doneBefore(Marker marker, Marker before) {
-    doValidityChecks(marker, before);
-
-    int beforeIndex = myProduction.lastIndexOf(before);
-
-    DoneMarker doneMarker = DONE_MARKERS.alloc();
-    doneMarker.myLexemeIndex = ((StartMarker)before).myLexemeIndex;
-    doneMarker.myStart = (StartMarker)marker;
-
-    ((StartMarker)marker).myDoneMarker = doneMarker;
-    myProduction.add(beforeIndex, doneMarker);
-  }
-
   @SuppressWarnings({"SuspiciousMethodCalls"})
   public void drop(Marker marker) {
     final boolean removed = myProduction.remove(myProduction.lastIndexOf(marker)) == marker;
@@ -594,6 +581,8 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
     doValidityChecks(marker, null);
 
     DoneWithErrorMarker doneMarker = new DoneWithErrorMarker((StartMarker)marker, myCurrentLexeme, message);
+    doneMarker.myTieToTheLeft = isEmpty(((StartMarker)marker).myLexemeIndex, myCurrentLexeme);
+
     ((StartMarker)marker).myDoneMarker = doneMarker;
     myProduction.add(doneMarker);
   }
@@ -604,8 +593,9 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
 
     int beforeIndex = myProduction.lastIndexOf(before);
 
-    DoneWithErrorMarker doneMarker = new DoneWithErrorMarker((StartMarker)marker, myCurrentLexeme, message);
-    doneMarker.myLexemeIndex = ((StartMarker)before).myLexemeIndex;
+    DoneWithErrorMarker doneMarker = new DoneWithErrorMarker((StartMarker)marker, ((StartMarker)before).myLexemeIndex, message);
+    doneMarker.myTieToTheLeft = isEmpty(((StartMarker)marker).myLexemeIndex, ((StartMarker)before).myLexemeIndex);
+
     ((StartMarker)marker).myDoneMarker = doneMarker;
     myProduction.add(beforeIndex, doneMarker);
   }
@@ -616,11 +606,37 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
     DoneMarker doneMarker = DONE_MARKERS.alloc();
     doneMarker.myStart = (StartMarker)marker;
     doneMarker.myLexemeIndex = myCurrentLexeme;
+    doneMarker.myTieToTheLeft = doneMarker.myStart.myType.isLeftBound() &&
+                                isEmpty(((StartMarker)marker).myLexemeIndex, myCurrentLexeme);
 
     ((StartMarker)marker).myDoneMarker = doneMarker;
     myProduction.add(doneMarker);
   }
 
+  @SuppressWarnings({"SuspiciousMethodCalls"})
+  public void doneBefore(Marker marker, Marker before) {
+    doValidityChecks(marker, before);
+
+    int beforeIndex = myProduction.lastIndexOf(before);
+
+    DoneMarker doneMarker = DONE_MARKERS.alloc();
+    doneMarker.myLexemeIndex = ((StartMarker)before).myLexemeIndex;
+    doneMarker.myStart = (StartMarker)marker;
+    doneMarker.myTieToTheLeft = doneMarker.myStart.myType.isLeftBound() &&
+                                isEmpty(((StartMarker)marker).myLexemeIndex, ((StartMarker)before).myLexemeIndex);
+
+    ((StartMarker)marker).myDoneMarker = doneMarker;
+    myProduction.add(beforeIndex, doneMarker);
+  }
+
+  private boolean isEmpty(final int startIdx, final int endIdx) {
+    for (int i = startIdx; i < endIdx; i++) {
+      final IElementType token = myLexTypes[i];
+      if (!myWhitespaces.contains(token) && !myComments.contains(token)) return false;
+    }
+    return true;
+  }
+
   public void collapse(final Marker marker) {
     done(marker);
     ((StartMarker)marker).myDoneMarker.myCollapse = true;
@@ -779,25 +795,36 @@ public class PsiBuilderImpl extends UserDataHolderBase implements PsiBuilder {
     for (int i = 1; i < fProduction.size() - 1; i++) {
       ProductionMarker item = fProduction.get(i);
 
-      if (item instanceof StartMarker) {
+      if (item instanceof StartMarker && ((StartMarker)item).myDoneMarker == null) {
+        LOG.error(UNBALANCED_MESSAGE);
+      }
+
+      if (item instanceof StartMarker && ((StartMarker)item).myDoneMarker.myTieToTheLeft) {
+        int prevProductionLexIndex = fProduction.get(i - 1).myLexemeIndex;
+        IElementType prevTokenType;
+        while (item.myLexemeIndex > prevProductionLexIndex &&
+               item.myLexemeIndex - 1 < myLexemeCount &&
+               (myWhitespaces.contains(prevTokenType = myLexTypes[item.myLexemeIndex - 1]) ||
+                myComments.contains(prevTokenType))) {
+          item.myLexemeIndex--;
+        }
+        ((StartMarker)item).myDoneMarker.myLexemeIndex = item.myLexemeIndex;
+      }
+      else if (item instanceof StartMarker) {
         IElementType nextTokenType;
         while (item.myLexemeIndex < myLexemeCount &&
-               ( myWhitespaces.contains(nextTokenType = myLexTypes[item.myLexemeIndex]) ||
-                 myComments.contains(nextTokenType)
-               )
-              ) {
+               (myWhitespaces.contains(nextTokenType = myLexTypes[item.myLexemeIndex]) ||
+                myComments.contains(nextTokenType))) {
           item.myLexemeIndex++;
         }
       }
       else if (item instanceof DoneMarker || item instanceof ErrorItem) {
         int prevProductionLexIndex = fProduction.get(i - 1).myLexemeIndex;
         IElementType prevTokenType;
-
-        while (item.myLexemeIndex > prevProductionLexIndex && item.myLexemeIndex - 1 < myLexemeCount &&
-               ( myWhitespaces.contains(prevTokenType = myLexTypes[item.myLexemeIndex - 1]) ||
-                 myComments.contains(prevTokenType)
-               )
-              ) {
+        while (item.myLexemeIndex > prevProductionLexIndex &&
+               item.myLexemeIndex - 1 < myLexemeCount &&
+               (myWhitespaces.contains(prevTokenType = myLexTypes[item.myLexemeIndex - 1]) ||
+                myComments.contains(prevTokenType))) {
           item.myLexemeIndex--;
         }
       }
index 8eb29eb36e6e08faf6a11eaf64aa792668efcc84..b7f52a6293e9cad094a206ef8ad650c7da95d355 100644 (file)
@@ -50,7 +50,7 @@ public class ExtractIncludeDialog extends DialogWrapper {
   private JTextField myNameField;
   private final PsiDirectory myCurrentDirectory;
   private static final String REFACTORING_NAME = RefactoringBundle.message("extractIncludeFile.name");
-  private final String myExtension;
+  protected final String myExtension;
   protected JLabel myTargetDirLabel;
 
   public PsiDirectory getTargetDirectory() {
@@ -60,7 +60,8 @@ public class ExtractIncludeDialog extends DialogWrapper {
   private PsiDirectory myTargetDirectory;
 
   public String getTargetFileName () {
-    return myNameField.getText().trim() + "." + myExtension;
+    String name = myNameField.getText().trim();
+    return name.contains(".") ? name: name + "." + myExtension;
   }
 
   public ExtractIncludeDialog(final PsiDirectory currentDirectory, final String extension) {
@@ -116,7 +117,7 @@ public class ExtractIncludeDialog extends DialogWrapper {
   }
 
   protected String getNameLabel() {
-    return RefactoringBundle.message("name.for.extracted.include.file");
+    return RefactoringBundle.message("name.for.extracted.include.file", myExtension);
   }
 
   private void validateOKButton() {
index dcef9296759c203f192f0c366e9b51335e4454e0..cc4286bdf47db00adddfd1db09ac0a9ea609e098 100644 (file)
@@ -78,12 +78,11 @@ public class FileReferenceContextUtil {
         if (!range.intersects(element.getTextRange())) return;
         String text = element.getText();
         PsiFileSystemItem item = map.get(text);
-        element = bindElement(element, item);
-        if (element != null) {
-          element.acceptChildren(this);
-        }
+        element.putCopyableUserData(REF_FILE_SYSTEM_ITEM_KEY, item);
+        element.acceptChildren(this);
       }
     });
+    decodeFileReferences(element);
   }
 
   private static PsiElement bindElement(PsiElement element, PsiFileSystemItem item) {
index 11c207c331544dd1932786ccbfde99b721fe8be3..5394ffab149c392353be5713e2e7fa57e7ac8059 100644 (file)
@@ -39,12 +39,15 @@ import java.util.Set;
 public class DeferredIconImpl<T> implements DeferredIcon {
   private static final RepaintScheduler ourRepaintScheduler = new RepaintScheduler();
   private volatile Icon myDelegateIcon;
-  private final Function<T, Icon> myEvaluator;
+  private Function<T, Icon> myEvaluator;
   private volatile boolean myIsScheduled = false;
-  private final T myParam;
+  private T myParam;
   private WeakReference<Component> myLastTarget = null;
   private static final EmptyIcon EMPTY_ICON = new EmptyIcon(16, 16);
   private boolean myNeedReadAction;
+  private boolean myDone;
+
+  private Disposer<T> myDisposer;
 
   public DeferredIconImpl(Icon baseIcon, T param, Function<T, Icon> evaluator) {
     this(baseIcon, param, true, evaluator);
@@ -64,7 +67,7 @@ public class DeferredIconImpl<T> implements DeferredIcon {
   public void paintIcon(final Component c, final Graphics g, final int x, final int y) {
     myDelegateIcon.paintIcon(c, g, x, y);
 
-    if (!myIsScheduled) {
+    if (!myIsScheduled && !isDone()) {
       myIsScheduled = true;
 
       final Ref<Component> target = new Ref<Component>(null);
@@ -109,6 +112,8 @@ public class DeferredIconImpl<T> implements DeferredIcon {
           //noinspection SSBasedInspection
           SwingUtilities.invokeLater(new Runnable() {
             public void run() {
+              setDone();
+
               Component actualTarget = target.get();
               if (SwingUtilities.getWindowAncestor(actualTarget) == null) {
                 actualTarget = paintingParent.get();
@@ -151,6 +156,16 @@ public class DeferredIconImpl<T> implements DeferredIcon {
     }
   }
 
+  private void setDone() {
+    if (myDisposer != null) {
+      myDisposer.dispose(myParam);
+    }
+
+    myDone = true;
+    myEvaluator = null;
+    myParam = null;
+  }
+
   public Icon evaluate() {
     final Icon[] evaluated = new Icon[1];
     final Runnable runnable = new Runnable() {
@@ -208,12 +223,8 @@ public class DeferredIconImpl<T> implements DeferredIcon {
     return myDelegateIcon.getIconHeight();
   }
 
-  public void invalidate() {
-    myIsScheduled = false;
-    Component lastTarget = myLastTarget != null ? myLastTarget.get() : null;
-    if (lastTarget != null) {
-      lastTarget.repaint();
-    }
+  public boolean isDone() {
+    return myDone;
   }
 
   private static class RepaintScheduler {
@@ -258,4 +269,16 @@ public class DeferredIconImpl<T> implements DeferredIcon {
     }
   }
 
+
+  public DeferredIconImpl setDisposer(Disposer<T> disposer) {
+    myDisposer = disposer;
+    return this;
+  }
+
+  public interface Disposer<T> {
+
+    void dispose(T key);
+
+  }
+
 }
index 8b20c8c0444d6ec5998714506373fd278a43a3fa..884c6e6506f2b2c6d063b571d874fab2264be0d9 100644 (file)
@@ -45,18 +45,6 @@ public class IconDeferrerImpl extends IconDeferrer {
 
   public IconDeferrerImpl(MessageBus bus) {
     final MessageBusConnection connection = bus.connect();
-    connection.setDefaultHandler(new MessageHandler() {
-      public void handle(final Method event, final Object... params) {
-        invalidateAllIcons();
-      }
-    });
-
-    connection.subscribe(ProjectTopics.MODIFICATION_TRACKER, new PsiModificationTracker.Listener() {
-      public void modificationCountChanged() {
-        invalidateAllIcons();
-      }
-    });
-
     connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
       public void before(final List<? extends VFileEvent> events) {
       }
@@ -79,16 +67,6 @@ public class IconDeferrerImpl extends IconDeferrer {
     }
   }
 
-  private void invalidateAllIcons() {
-    synchronized (LOCK) {
-      for (Icon icon : myIconsCache.values()) {
-        if (icon instanceof DeferredIconImpl) {
-          ((DeferredIconImpl)icon).invalidate();
-        }
-      }
-    }
-  }
-
   public <T> Icon defer(final Icon base, final T param, final Function<T, Icon> f) {
     if (myEvaluationIsInProgress.get().booleanValue()) {
       return f.fun(param);
@@ -97,7 +75,14 @@ public class IconDeferrerImpl extends IconDeferrer {
     synchronized (LOCK) {
       Icon result = myIconsCache.get(param);
       if (result == null) {
-        result = new DeferredIconImpl<T>(base, param, f);
+        result = new DeferredIconImpl<T>(base, param, f).setDisposer(new DeferredIconImpl.Disposer<T>() {
+          @Override
+          public void dispose(T key) {
+            synchronized (LOCK) {
+              myIconsCache.remove(key);
+            }
+          }
+        });
         myIconsCache.put(param, result);
       }
 
index acbdcebd68bad8ab42756aed185b0aa865fe9cc9..701ae442da7f6fda0f6d8c7d23c46e6519cf1088 100644 (file)
@@ -21,7 +21,6 @@ import com.intellij.concurrency.JobScheduler;
 import com.intellij.history.LocalHistory;
 import com.intellij.ide.caches.CacheUpdater;
 import com.intellij.lang.ASTNode;
-import com.intellij.openapi.application.Application;
 import com.intellij.openapi.application.ApplicationAdapter;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.PathManager;
@@ -108,6 +107,7 @@ public class FileBasedIndex implements ApplicationComponent {
   private final ChangedFilesCollector myChangedFilesCollector;
 
   private final List<IndexableFileSet> myIndexableSets = ContainerUtil.createEmptyCOWList();
+  private final Map<IndexableFileSet, Project> myIndexableSetToProjectMap = new HashMap<IndexableFileSet, Project>();
 
   public static final int OK = 1;
   public static final int REQUIRES_REBUILD = 2;
@@ -281,7 +281,7 @@ public class FileBasedIndex implements ApplicationComponent {
 
       myVfManager.addVirtualFileListener(myChangedFilesCollector);
 
-      registerIndexableSet(new AdditionalIndexableFileSet());
+      registerIndexableSet(new AdditionalIndexableFileSet(), null);
     }
     finally {
       ShutDownTracker.getInstance().registerShutdownTask(new Runnable() {
@@ -958,8 +958,7 @@ public class FileBasedIndex implements ApplicationComponent {
         }
       };
 
-      final Application application = ApplicationManager.getApplication();
-      if (cleanupOnly || application.isUnitTestMode()) {
+      if (cleanupOnly || myIsUnitTestMode) {
         rebuildRunnable.run();
       }
       else {
@@ -1238,10 +1237,18 @@ public class FileBasedIndex implements ApplicationComponent {
   }
 
   public Collection<VirtualFile> getFilesToUpdate(final Project project) {
-    final ProjectFileIndex projectIndex = ProjectRootManager.getInstance(project).getFileIndex();
     return ContainerUtil.findAll(myChangedFilesCollector.getAllFilesToUpdate(), new Condition<VirtualFile>() {
       public boolean value(VirtualFile virtualFile) {
-        return projectIndex.isInContent(virtualFile);
+        for (IndexableFileSet set : myIndexableSets) {
+          final Project proj = myIndexableSetToProjectMap.get(set);
+          if (proj != null && !proj.equals(project)) {
+            continue; // skip this set as associated with a different project
+          }
+          if (set.isInSet(virtualFile)) {
+            return true;
+          }
+        }
+        return false;
       }
     });
   }
@@ -1436,8 +1443,9 @@ public class FileBasedIndex implements ApplicationComponent {
     }
 
     private void markDirty(final VirtualFileEvent event) {
-      cleanProcessedFlag(event.getFile());
-      iterateIndexableFiles(event.getFile(), new Processor<VirtualFile>() {
+      final VirtualFile eventFile = event.getFile();
+      cleanProcessedFlag(eventFile);
+      iterateIndexableFiles(eventFile, new Processor<VirtualFile>() {
         public boolean process(final VirtualFile file) {
           FileContent fileContent = null;
           // handle 'content-less' indices separately
@@ -1838,13 +1846,15 @@ public class FileBasedIndex implements ApplicationComponent {
     return new UnindexedFilesFinder();
   }
 
-  public void registerIndexableSet(IndexableFileSet set) {
+  public void registerIndexableSet(IndexableFileSet set, @Nullable Project project) {
     myIndexableSets.add(set);
+    myIndexableSetToProjectMap.put(set, project);
   }
 
   public void removeIndexableSet(IndexableFileSet set) {
     myChangedFilesCollector.forceUpdate(null, null, true);
     myIndexableSets.remove(set);
+    myIndexableSetToProjectMap.remove(set);
   }
 
   @Nullable
index 4dcee4416e012f25e71c79d72174bdd6f96e6517..73604f7878d7a66c2422ba928f029f42dd196ab4 100644 (file)
@@ -57,7 +57,7 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple
           startupManager.registerCacheUpdater(rootsChangeUpdater);
           rootManager.registerRootsChangeUpdater(rootsChangeUpdater);
           rootManager.registerRefreshUpdater(refreshUpdater);
-          myIndex.registerIndexableSet(FileBasedIndexProjectHandler.this);
+          myIndex.registerIndexableSet(FileBasedIndexProjectHandler.this, project);
           projectManager.addProjectManagerListener(project, new ProjectManagerAdapter() {
             public void projectClosing(Project project) {
               rootManager.unregisterRefreshUpdater(refreshUpdater);
index 111228759fff8d00df9ef3003f7366388e0694d4..0a4b82ab3e45a4b09ad0a0456d7e3eea1b8ffad0 100644 (file)
@@ -33,8 +33,13 @@ public class LightPsiBuilderTest {
   private static final IElementType ROOT = new IElementType("ROOT", Language.ANY);
   private static final IElementType LETTER = new IElementType("LETTER", Language.ANY);
   private static final IElementType DIGIT = new IElementType("DIGIT", Language.ANY);
+  private static final IElementType WHITESPACE = new IElementType("WHITESPACE", Language.ANY);
   private static final IElementType OTHER = new IElementType("OTHER", Language.ANY);
   private static final IElementType COLLAPSED = new IElementType("COLLAPSED", Language.ANY);
+  private static final IElementType LEFT_BOUND = new IElementType("LEFT_BOUND", Language.ANY) {
+    public boolean isLeftBound() { return true; }
+  };
+  private static final TokenSet WHITESPACE_SET = TokenSet.create(WHITESPACE);
 
   @Test
   public void testPlain() {
@@ -154,7 +159,8 @@ public class LightPsiBuilderTest {
                    builder.mark();
                    first.done(LETTER);
                  }
-               });
+               },
+               "Another not done marker added after this one. Must be done before this.");
   }
 
   @Test
@@ -168,7 +174,8 @@ public class LightPsiBuilderTest {
                    second.precede();
                    first.doneBefore(LETTER, second);
                  }
-               });
+               },
+               "Another not done marker added after this one. Must be done before this.");
   }
 
   @Test
@@ -181,7 +188,95 @@ public class LightPsiBuilderTest {
                    final PsiBuilder.Marker second = builder.mark();
                    second.doneBefore(LETTER, first);
                  }
-               });
+               },
+               "'Before' marker precedes this one.");
+  }
+
+  @Test
+  public void testWhitespaceTrimming() throws Exception {
+    doTest(" a b ",
+           new Parser() {
+             public void parse(PsiBuilder builder) {
+               PsiBuilder.Marker marker = builder.mark();
+               builder.advanceLexer();
+               marker.done(OTHER);
+               marker = builder.mark();
+               builder.advanceLexer();
+               marker.done(OTHER);
+               builder.advanceLexer();
+             }
+           },
+           "Element(ROOT)\n" +
+           "  PsiWhiteSpace(' ')\n" +
+           "  Element(OTHER)\n" +
+           "    PsiElement(LETTER)('a')\n" +
+           "  PsiWhiteSpace(' ')\n" +
+           "  Element(OTHER)\n" +
+           "    PsiElement(LETTER)('b')\n" +
+           "  PsiWhiteSpace(' ')\n");
+  }
+
+  @Test
+  public void testWhitespaceBalancingByErrors() throws Exception {
+    doTest("a b c",
+           new Parser() {
+             public void parse(PsiBuilder builder) {
+               PsiBuilder.Marker marker = builder.mark();
+               builder.advanceLexer();
+               builder.error("error 1");
+               marker.done(OTHER);
+               marker = builder.mark();
+               builder.advanceLexer();
+               builder.mark().error("error 2");
+               marker.done(OTHER);
+               marker = builder.mark();
+               builder.advanceLexer();
+               marker.error("error 3");
+             }
+           },
+           "Element(ROOT)\n" +
+           "  Element(OTHER)\n" +
+           "    PsiElement(LETTER)('a')\n" +
+           "    PsiErrorElement:error 1\n" +
+           "      <empty list>\n" +
+           "  PsiWhiteSpace(' ')\n" +
+           "  Element(OTHER)\n" +
+           "    PsiElement(LETTER)('b')\n" +
+           "    PsiErrorElement:error 2\n" +
+           "      <empty list>\n" +
+           "  PsiWhiteSpace(' ')\n" +
+           "  PsiErrorElement:error 3\n" +
+           "    PsiElement(LETTER)('c')\n");
+  }
+
+  @Test
+  public void testWhitespaceBalancingByEmptyComposites() throws Exception {
+    doTest("a b c",
+           new Parser() {
+             public void parse(PsiBuilder builder) {
+               PsiBuilder.Marker marker = builder.mark();
+               builder.advanceLexer();
+               builder.mark().done(OTHER);
+               marker.done(OTHER);
+               marker = builder.mark();
+               builder.advanceLexer();
+               builder.mark().done(LEFT_BOUND);
+               marker.done(OTHER);
+               builder.advanceLexer();
+             }
+           },
+           "Element(ROOT)\n" +
+           "  Element(OTHER)\n" +
+           "    PsiElement(LETTER)('a')\n" +
+           "    PsiWhiteSpace(' ')\n" +
+           "    Element(OTHER)\n" +
+           "      <empty list>\n" +
+           "  Element(OTHER)\n" +
+           "    PsiElement(LETTER)('b')\n" +
+           "    Element(LEFT_BOUND)\n" +
+           "      <empty list>\n" +
+           "  PsiWhiteSpace(' ')\n" +
+           "  PsiElement(LETTER)('c')\n");
   }
 
   private interface Parser {
@@ -189,15 +284,15 @@ public class LightPsiBuilderTest {
   }
 
   private static void doTest(final String text, final Parser parser, final String expected) {
-    final PsiBuilder builder = new PsiBuilderImpl(new MyTestLexer(), TokenSet.EMPTY, TokenSet.EMPTY, text);
+    final PsiBuilder builder = new PsiBuilderImpl(new MyTestLexer(), WHITESPACE_SET, TokenSet.EMPTY, text);
     final PsiBuilder.Marker rootMarker = builder.mark();
     parser.parse(builder);
     rootMarker.done(ROOT);
     final ASTNode root = builder.getTreeBuilt();
-    assertEquals(expected, DebugUtil.nodeTreeToString(root, true));
+    assertEquals(expected, DebugUtil.nodeTreeToString(root, false));
   }
 
-  private static void doFailTest(final String text, final Parser parser) {
+  private static void doFailTest(final String text, final Parser parser, final String expected) {
     final PrintStream std = System.err;
     //noinspection IOResourceOpenedButNotSafelyClosed
     System.setErr(new PrintStream(new NullStream()));
@@ -209,8 +304,7 @@ public class LightPsiBuilderTest {
         fail("should fail");
       }
       catch (AssertionError e) {
-        //System.out.println("caught: " + e);
-        if ("should fail".equals(e.getMessage())) throw e;
+        assertEquals(expected, e.getMessage());
       }
     }
     finally {
@@ -234,18 +328,11 @@ public class LightPsiBuilderTest {
     }
 
     public IElementType getTokenType() {
-      if (myIndex >= myBufferEnd) {
-        return null;
-      }
-      else if (Character.isDigit(myBuffer.charAt(myIndex))) {
-        return DIGIT;
-      }
-      else if (Character.isLetter(myBuffer.charAt(myIndex))) {
-        return LETTER;
-      }
-      else {
-        return OTHER;
-      }
+      if (myIndex >= myBufferEnd) return null;
+      else if (Character.isLetter(myBuffer.charAt(myIndex))) return LETTER;
+      else if (Character.isDigit(myBuffer.charAt(myIndex))) return DIGIT;
+      else if (Character.isWhitespace(myBuffer.charAt(myIndex))) return WHITESPACE;
+      else return OTHER;
     }
 
     public int getTokenStart() {
index 2f956a7c7a59065fe3733a24baf522569ecccecb..9012cb85beb883cff5ce5e631cc9df7478c93005 100644 (file)
@@ -59,6 +59,10 @@ public class GeneralCommandLine {
 
   public void setCharset(@NotNull Charset charset) {
     myCharset = charset;
+  }
+
+  public void setCharsetAndAddJavaParameter(@NotNull Charset charset) {
+    myCharset = charset;
     addParameter("-Dfile.encoding=" + charset.name());
   }
 
index 8ed063a63bbf2349a1aac08a57f029f79b4c3a3c..a76d0a3738a516a355d5feaa85f7eb73247c6903 100644 (file)
@@ -658,8 +658,8 @@ public class VfsUtil {
   }
 
   @Nullable
-  public static VirtualFile createDirectoryIfMissing(@NotNull String dir) throws IOException {
-    return doCreateDirectoriesIfMissing(FileUtil.toSystemIndependentName(dir));
+  public static VirtualFile createDirectoryIfMissing(@NotNull String directoryPath) throws IOException {
+    return doCreateDirectoriesIfMissing(FileUtil.toSystemIndependentName(directoryPath));
   }
 
   private static VirtualFile doCreateDirectoriesIfMissing(String dir) throws IOException {
index 7ae7407d1be1a0c87c60abd05a08f92d207b5c88..328a420cd87e6539fe4f2cd6d1969fc8050c4c09 100644 (file)
@@ -18,6 +18,7 @@ package com.intellij.patterns;
 import com.intellij.openapi.util.Condition;
 import com.intellij.openapi.util.Key;
 import com.intellij.util.InstanceofCheckerGenerator;
+import com.intellij.util.PairProcessor;
 import com.intellij.util.ProcessingContext;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -68,9 +69,10 @@ public abstract class ObjectPattern<T, Self extends ObjectPattern<T, Self>> impl
   }
 
   public Self and(final ElementPattern pattern) {
-    return with(new PatternCondition<T>("and") {
-      public boolean accepts(@NotNull final T t, final ProcessingContext context) {
-        return pattern.getCondition().accepts(t, context);
+    return with(new PatternConditionPlus<T, T>("and", pattern) {
+      @Override
+      public boolean processValues(T t, ProcessingContext context, PairProcessor<T, ProcessingContext> processor) {
+        return processor.process(t, context);
       }
     });
   }
index c313dc48abaff158085766e3d46bffd1b07e845c..648ad01fda34ae86ebc619dc7dcb81e49b5eccdf 100644 (file)
@@ -72,6 +72,18 @@ public class StringPattern extends ObjectPattern<String, StringPattern> {
     });
   }
 
+  @NotNull
+  public StringPattern containsChars(@NonNls @NotNull final String s) {
+    return with(new PatternCondition<String>("containsChars") {
+      public boolean accepts(@NotNull final String str, final ProcessingContext context) {
+        for (int i=0, len=s.length(); i<len; i++) {
+          if (str.indexOf(s.charAt(i))>-1) return true;
+        }
+        return false;
+      }
+    });
+  }
+
   @NotNull
   public StringPattern matches(@NonNls @NotNull final String s) {
     final String escaped = StringUtil.escapeToRegexp(s);
index eac5aee9b638ccd94a9d5519ebc13ec53c6d59bb..3815860c1331f96e1b10ee396b9f1ec09206a6d6 100644 (file)
@@ -32,7 +32,6 @@ import java.util.List;
  * @see com.intellij.lexer.Lexer#getTokenType()
  * @see com.intellij.lang.ASTNode#getElementType()
  */
-
 public class IElementType {
   private static final Logger LOG = Logger.getInstance("#com.intellij.psi.tree.IElementType");
 
@@ -46,9 +45,8 @@ public class IElementType {
   /**
    * Default enumeration predicate which matches all token types.
    *
-   * @see #enumerate(com.intellij.psi.tree.IElementType.Predicate)
+   * @see #enumerate(Predicate)
    */
-
   public static final Predicate TRUE = new Predicate() {
     public boolean matches(IElementType type) {
       return true;
@@ -89,7 +87,6 @@ public class IElementType {
    * @param debugName the name of the element type, used for debugging purposes.
    * @param language  the language with which the element type is associated.
    */
-
   public IElementType(@NotNull @NonNls String debugName, @Nullable Language language) {
     this(debugName, language, true);
   }
@@ -98,6 +95,7 @@ public class IElementType {
     myDebugName = debugName;
     myLanguage = language == null ? Language.ANY : language;
     if (register) {
+      //noinspection AssignmentToStaticFieldFromInstanceMethod
       myIndex = ourCounter++;
       LOG.assertTrue(ourCounter < MAX_INDEXED_TYPES, "Too many element types registered. Out of (short) range.");
       synchronized (ourRegistry) {
@@ -114,7 +112,6 @@ public class IElementType {
    *
    * @return the associated language.
    */
-
   @NotNull
   public Language getLanguage() {
     return myLanguage;
@@ -126,7 +123,6 @@ public class IElementType {
    *
    * @return the element type index.
    */
-
   public final short getIndex() {
     return myIndex;
   }
@@ -138,10 +134,9 @@ public class IElementType {
   /**
    * Returns the element type registered at the specified index.
    *
-   * @param idx the indx for which the element type should be returned.
+   * @param idx the index for which the element type should be returned.
    * @return the element type at the specified index.
    */
-
   public static IElementType find(short idx) {
     synchronized (ourRegistry) {
       if (idx == 0) return ourRegistry.get(0); // We've changed FIRST_TOKEN_INDEX from 0 to 1. This is just for old plugins to avoid crashes.  
@@ -152,10 +147,34 @@ public class IElementType {
   /**
    * Predicate for matching element types.
    *
-   * @see IElementType#enumerate(com.intellij.psi.tree.IElementType.Predicate)
+   * @see IElementType#enumerate(Predicate)
    */
-
   public interface Predicate {
     boolean matches(IElementType type);
   }
+
+  /**
+   * Controls whitespace balancing behavior of PsiBuilder.
+   * <p>By default, empty composite elements (containing no children) are bounded to the right neighbour, forming following tree:
+   * <pre>
+   *  [previous_element]
+   *  [whitespace]
+   *  [empty_element]
+   *    &lt;empty&gt;
+   *  [next_element]
+   * </pre>
+   * <p>Left-bound elements are bounded to the left neighbour instead:
+   * <pre>
+   *  [previous_element]
+   *  [empty_element]
+   *    &lt;empty&gt;
+   *  [whitespace]
+   *  [next_element]
+   * </pre>
+   * <p>See {@linkplain com.intellij.lang.impl.PsiBuilderImpl#prepareLightTree()} for details.
+   * @return true if empty elements of this type should be bound to the left.
+   */
+  public boolean isLeftBound() {
+    return false;
+  }
 }
\ No newline at end of file
index c3250f103fd645a750e89d28f00d74d18d2dc897..cd2abe9c19bc5be9824a77c7e812a2b47c9c2998 100644 (file)
@@ -25,7 +25,6 @@ import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.IOException;
-import java.net.BindException;
 import java.net.ServerSocket;
 
 /**
@@ -83,7 +82,7 @@ public class XmlRpcServerImpl implements XmlRpcServer, ApplicationComponent {
           detectedPortNumber = port;
           return true;
         }
-        catch (BindException ignored) {
+        catch (IOException ignored) {
         }
       }
 
@@ -92,11 +91,9 @@ public class XmlRpcServerImpl implements XmlRpcServer, ApplicationComponent {
         socket = new ServerSocket(0);
         detectedPortNumber = socket.getLocalPort();
         return true;
-      } catch (BindException ignored) {
       }
-    }
-    catch (IOException e) {
-      LOG.info(e);
+      catch (IOException ignored) {
+      }
     }
     finally {
       if (socket != null) {
index 048b9a60a07ca17e229acf3c57fd5f6f704a64ff..ac6279697c6f7f402914a27dd0e5018b93515612 100644 (file)
@@ -459,7 +459,7 @@ public final class UpdateChecker {
     OutputStream out = null;
 
     String platform = System.getProperty("idea.platform.prefix", "idea");
-    String patchFileName = "jetbrains.patch.jar." + platform;
+    String patchFileName = ("jetbrains.patch.jar." + platform).toLowerCase();
     File patchFile = new File(FileUtil.getTempDirectory(), patchFileName);
 
     try {
index a062c97e31c3dff78419f593e34dc436f5f4da3c..cae992565a2b76c7ed806eed5fddd190e917f0b5 100644 (file)
@@ -124,17 +124,18 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
         cursor = myListener2Cursor.values().iterator().next();
 
         final Point point = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), myRootPane.getContentPane());
-        final Component target =
+        Component target =
             SwingUtilities.getDeepestComponentAt(myRootPane.getContentPane().getParent(), point.x, point.y);
 
+
+        target = getCompWithCursor(target);
+
         restoreLastComponent(target);
 
         if (target != null) {
           if (myLastCursorComponent != target) {
             myLastCursorComponent = target;
-            if (target.isCursorSet()) {
-              myLastOriginalCursor = target.getCursor();
-            } 
+            myLastOriginalCursor = target.getCursor();
           }
 
           if (cursor != null && !cursor.equals(target.getCursor())) {
@@ -157,6 +158,16 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
     }
   }
 
+  private Component getCompWithCursor(Component c) {
+    Component eachParentWithCursor = c;
+    while (eachParentWithCursor != null) {
+      if (eachParentWithCursor.isCursorSet()) return eachParentWithCursor;
+      eachParentWithCursor = eachParentWithCursor.getParent();
+    }
+
+    return null;
+  }
+
   private void restoreLastComponent(Component newC) {
     if (myLastCursorComponent != null && myLastCursorComponent != newC) {
       myLastCursorComponent.setCursor(myLastOriginalCursor);
index dcdc87cd49f70798a2872cc9256e2d5d7fb23332..b293b8c60e7c5d07312e29f48657523b84cd9c07 100644 (file)
@@ -117,13 +117,15 @@ final class Stripe extends JPanel{
 
   private LayoutData recomputeBounds(boolean setBounds, Dimension toFitWith, boolean noDrop) {
     final LayoutData data = new LayoutData();
+    final int horizontaloffset = getHeight();
+
     data.eachY = 0;
     data.size = new Dimension();
     data.gap = 1;
     data.horizontal = isHorizontal();
     data.dragInsertPosition = -1;
     if (data.horizontal) {
-      data.eachX = myManager.getToolWindowsPane().getHorizontalInsetX();
+      data.eachX = horizontaloffset;
     } else {
       data.eachX = 0;
     }
@@ -146,7 +148,7 @@ final class Stripe extends JPanel{
     if (toFitWith != null) {
       LayoutData layoutData = recomputeBounds(false, null, true);
       if (data.horizontal) {
-        gap = toFitWith.width - myManager.getToolWindowsPane().getHorizontalInsetX() - layoutData.size.width - data.eachX ;
+        gap = toFitWith.width - horizontaloffset - layoutData.size.width - data.eachX ;
       }
       else {
         gap = toFitWith.height - layoutData.size.height - data.eachY;
index 8a482f4a477fdb622c1cd294070377dadfc9e68f..b57153a369afbad926955b07341e9966bf9d901c 100644 (file)
@@ -1171,11 +1171,6 @@ final class ToolWindowsPane extends JLayeredPane implements Disposable {
     }
   }
 
-//todo
-  static int getHorizontalInsetX() {
-    return 19;
-  }
-
   public void setStripesOverlayed(boolean stripesOverlayed) {
     myStripesOverlayed = stripesOverlayed;
     updateToolStripesVisibility();
index 031d2b333c239d71c37ecbcd71e2c40c8b0c0531..59da84ef90b8f997f4f532b9e801fe2c5dc452f2 100644 (file)
@@ -87,7 +87,7 @@ javadoc.for.abstracts=JavaDoc for abstracts
 extractIncludeFile.name=Extract Include File
 file.already.exist=File {0} already exists
 file.already.exist.title=Extract Include File
-name.for.extracted.include.file=&Name for extracted include file (without extension):
+name.for.extracted.include.file=&Name for extracted include file (default extension: {0})
 extract.to.directory=Extract to &directory:
 select.target.directory=Select target directory
 select.target.directory.description=The file will be created in this directory
@@ -247,7 +247,7 @@ method.does.not.have.a.body=Method {0} does not have a body.
 method.has.an.empty.body=Method {0} has an empty body.
 idea.has.not.found.any.code.that.can.be.replaced.with.method.call={0} has not found any code that can be replaced with method call
 method.duplicates.found.message={0, choice, 1#1 code fragment|2#{0,number} code fragments} found
-0.with.1.visibility.is.not.accesible.from.2={0} with {1} visibility won''t be accesible from {2}
+0.with.1.visibility.is.not.accessible.from.2={0} with {1} visibility won''t be accessible from {2}
 0.contains.call.with.null.argument.for.parameter.1={0} contains call with null argument for parameter {1}
 no.members.selected=No members selected
 0.already.exists.in.the.target.class={0} already exists in the target class.
@@ -283,7 +283,7 @@ refactoring.cannot.be.performed=Refactoring cannot be performed
 there.is.already.a.0.it.will.conflict.with.an.introduced.parameter=There is already a {0}. It will conflict with an introduced parameter
 introduce.parameter.command=Introducing parameter to {0}
 parameter.initializer.contains.0.but.not.all.calls.to.method.are.in.its.class=Parameter initializer contains {0}, but not all calls to method are in its class.
-0.is.not.accesible.from.1.value.for.introduced.parameter.in.that.method.call.will.be.incorrect={0} is not accesible from {1}. Value for introduced parameter in that method call will be incorrect.
+0.is.not.accessible.from.1.value.for.introduced.parameter.in.that.method.call.will.be.incorrect={0} is not accessible from {1}. Value for introduced parameter in that method call will be incorrect.
 use.interface.superclass.in.instanceof=Use interface/superclass in instanceof
 introduce.parameter.to.method=Introduce parameter to method:
 introduced.variable.will.conflict.with.0=Introduced variable will conflict with {0}
index af35e58f9cee389e7e542fb37178ec2374e47480..4ab6cd49b655674be80c7e876d381c5c9fac1a33 100644 (file)
@@ -74,3 +74,4 @@ xml.parsing.closing.tag.name.missing=Closing tag name missing
 xml.parsing.closing.tag.is.not.done=Closing tag is not done
 attribute.should.be.preceded.with.space=There should be a space between attribute and previous attribute
 cdata.end.should.not.appear.in.content.unless.to.mark.end.of.cdata.section=Character sequence ']]>' must not appear in content unless used to mark the end of a CDATA section
+xml.declaration.should.precede.all.document.content=Xml declaration should precede all document content
index c9c317cbce691c24e501ce3ed192180d9a17e117..506679ad17a4a74508b157eb7c2b96d5e07d6718 100644 (file)
         </value>
       </option>
 
-      <option name="DIFF_INSERTED">
+      <option name="DIFF_CONFLICT">
         <value>
           <option name="FOREGROUND"/>
-          <option name="BACKGROUND" value="baeeba"/>
+          <option name="BACKGROUND" value="ffc8bd"/>
           <option name="EFFECT_COLOR"/>
-          <option name="ERROR_STRIPE_COLOR" value="4ced4d"/>
+          <option name="ERROR_STRIPE_COLOR" value="ff6647"/>
         </value>
       </option>
 
-      <option name="DIFF_MODIFIED">
+      <option name="DIFF_DELETED">
         <value>
           <option name="FOREGROUND"/>
-          <option name="BACKGROUND" value="bccff9"/>
+          <option name="BACKGROUND" value="cbcbcb"/>
           <option name="EFFECT_COLOR"/>
-          <option name="ERROR_STRIPE_COLOR" value="5186fe"/>
+          <option name="ERROR_STRIPE_COLOR" value="747474"/>
         </value>
       </option>
 
-      <option name="DIFF_CONFLICT">
+      <option name="DIFF_INSERTED">
         <value>
           <option name="FOREGROUND"/>
-          <option name="BACKGROUND" value="ffc8bd"/>
+          <option name="BACKGROUND" value="baeeba"/>
           <option name="EFFECT_COLOR"/>
-          <option name="ERROR_STRIPE_COLOR" value="eb5e42"/>
+          <option name="ERROR_STRIPE_COLOR" value="1e201"/>
+        </value>
+      </option>
+
+      <option name="DIFF_MODIFIED">
+        <value>
+          <option name="FOREGROUND"/>
+          <option name="BACKGROUND" value="bccff9"/>
+          <option name="EFFECT_COLOR"/>
+          <option name="ERROR_STRIPE_COLOR" value="3471ff"/>
         </value>
       </option>
 
         </value>
       </option>
 
-      <option name="DIFF_DELETED">
-        <value>
-          <option name="FOREGROUND"/>
-          <option name="BACKGROUND" value="cbcbcb"/>
-          <option name="EFFECT_COLOR"/>
-          <option name="ERROR_STRIPE_COLOR" value="747474"/>
-
-        </value>
-      </option>
-
       <option name="PARAMETER_ATTRIBUTES">
         <value>
           <option name="FOREGROUND"/>
index 1a84a64c55dbbbf739fa7faac384fd5747a082fc..7b9616400c2ae3df7e1af6d89c7bfc5c5d04f9d8 100644 (file)
@@ -225,7 +225,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
               iterator.processFile(file);
             }
           }
-        });
+        }, null);
 
         final ModuleRootManager rootManager = ModuleRootManager.getInstance(ourModule);
 
index cea036ac61e48615bf7a1f71dab8bbfefe2247c9..a8ae528855fd68cbfab1e078e608cbb498096533 100644 (file)
@@ -53,17 +53,22 @@ public abstract class ParsingTestCase extends LightPlatformTestCase {
     return false;
   }
 
-  protected void doTest(boolean checkResult) throws Exception {
+  protected void doTest(boolean checkResult) {
     String name = getTestName(false);
-    String text = loadFile(name + "." + myFileExt);
-    myFile = createPsiFile(name, text);
-    myFile.accept(new PsiRecursiveElementVisitor(){});
-    assertEquals(text, myFile.getText());
-    if (checkResult){
-      checkResult(name + ".txt", myFile);
+    try {
+      String text = loadFile(name + "." + myFileExt);
+      myFile = createPsiFile(name, text);
+      myFile.accept(new PsiRecursiveElementVisitor(){});
+      assertEquals(text, myFile.getText());
+      if (checkResult){
+        checkResult(name + ".txt", myFile);
+      }
+      else{
+        toParseTreeText(myFile, includeRanges());
+      }
     }
-    else{
-      toParseTreeText(myFile, includeRanges());
+    catch (IOException e) {
+      throw new RuntimeException(e);
     }
   }
 
index d08ecca169efbd75ef27249ea7145f4e54c2c9f7..4f737128668537a09716f7fa66ed848bf938825a 100644 (file)
@@ -19,6 +19,7 @@ import com.intellij.openapi.application.PathManager;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiFile;
 import com.intellij.testFramework.UsefulTestCase;
 import com.intellij.testFramework.builders.EmptyModuleFixtureBuilder;
 import org.jetbrains.annotations.NonNls;
@@ -83,4 +84,8 @@ public abstract class CodeInsightFixtureTestCase extends UsefulTestCase {
   protected Editor getEditor() {
     return myFixture.getEditor();
   }
+
+  protected PsiFile getFile() {
+    return myFixture.getFile();
+  }
 }
index 07b303e3a8b9aac6f7e6000171e135205a1bcf7c..51826773cf314bac88fd1749567e38c95597e482 100644 (file)
@@ -185,7 +185,7 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
           FileUtil.copy(fromFile, destFile);
         }
         catch (IOException e) {
-          throw new RuntimeException(e);
+          throw new RuntimeException("Cannot copy " + fromFile + " to " + destFile, e);
         }
       }
     }
index 43770e1d0922980a2259168392f1fca33d547a38..fa6fc2e1c612c96a9258dded78a59e1353861674 100644 (file)
@@ -15,6 +15,7 @@
  */
 package com.intellij.usages;
 
+import com.intellij.ui.ComputableIcon;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.util.Icons;
 
@@ -31,13 +32,13 @@ public class ReadWriteAccessUsageInfo2UsageAdapter extends UsageInfo2UsageAdapte
     myAccessedForReading = accessedForReading;
     myAccessedForWriting = accessedForWriting;
     if (myAccessedForReading && myAccessedForWriting) {
-      myIcon = Icons.VARIABLE_RW_ACCESS;
+      myIcon = ComputableIcon.create(Icons.VARIABLE_RW_ACCESS);
     }
     else if (myAccessedForWriting) {
-      myIcon = Icons.VARIABLE_WRITE_ACCESS;           // If icon is changed, don't forget to change UTCompositeUsageNode.getIcon();
+      myIcon = ComputableIcon.create(Icons.VARIABLE_WRITE_ACCESS);           // If icon is changed, don't forget to change UTCompositeUsageNode.getIcon();
     }
     else if (myAccessedForReading){
-      myIcon = Icons.VARIABLE_READ_ACCESS;            // If icon is changed, don't forget to change UTCompositeUsageNode.getIcon();
+      myIcon = ComputableIcon.create(Icons.VARIABLE_READ_ACCESS);            // If icon is changed, don't forget to change UTCompositeUsageNode.getIcon();
     }
   }
 
index d7bc0a6acb7a1eb11abc90a6435318ff8ec7e970..40b2bc9fa2f8fc06672e9dcb4f1ac90e18fc0c59 100644 (file)
@@ -34,6 +34,7 @@ import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.*;
+import com.intellij.ui.ComputableIcon;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usages.rules.*;
 import com.intellij.util.IncorrectOperationException;
@@ -62,7 +63,7 @@ public class UsageInfo2UsageAdapter implements UsageInModule, UsageInLibrary, Us
   private final UsageInfo myUsageInfo;
   private int myLineNumber;
   private int myOffset = -1;
-  protected Icon myIcon;
+  protected ComputableIcon myIcon;
   private String myTooltipText;
   private List<RangeMarker> myRangeMarkers = new ArrayList<RangeMarker>();
   private TextChunk[] myTextChunks;
@@ -101,7 +102,13 @@ public class UsageInfo2UsageAdapter implements UsageInModule, UsageInLibrary, Us
           myIcon = null;
         }
         else {
-          myIcon = element.getIcon(0);
+          myIcon = new ComputableIcon(new Computable<Icon>() {
+            @Override
+            public Icon compute() {
+              PsiElement psiElement = getElement();
+              return psiElement != null && psiElement.isValid() ? psiElement.getIcon(0) : null;
+            }
+          });
         }
 
         myTooltipText = myUsageInfo.getTooltipText();
@@ -374,7 +381,7 @@ public class UsageInfo2UsageAdapter implements UsageInModule, UsageInLibrary, Us
     }
 
     public Icon getIcon() {
-      return myIcon;
+      return myIcon != null ? myIcon.getIcon() : null;
     }
 
     public String getTooltipText() {
index 2c3afcb9fca4a792d8992864d1bfae73e05ae75b..6e143b75c8d9b6d5311f48ed535029bb2a832aa1 100644 (file)
@@ -18,12 +18,14 @@ package com.intellij.usages.impl.rules;
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.fileEditor.FileEditorManager;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.Iconable;
 import com.intellij.openapi.vcs.FileStatus;
 import com.intellij.openapi.vcs.FileStatusManager;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiManager;
+import com.intellij.ui.ComputableIcon;
 import com.intellij.usages.NamedPresentably;
 import com.intellij.usages.Usage;
 import com.intellij.usages.UsageGroup;
@@ -58,7 +60,7 @@ public class FileGroupingRule implements UsageGroupingRule {
     private final Project myProject;
     private final VirtualFile myFile;
     private String myPresentableName;
-    private Icon myIcon;
+    private ComputableIcon myIcon;
 
     public FileUsageGroup(Project project, VirtualFile file) {
       myProject = project;
@@ -73,7 +75,12 @@ public class FileGroupingRule implements UsageGroupingRule {
 
     public void update() {
       if (isValid()) {
-        myIcon = getIconImpl();
+        myIcon = new ComputableIcon(new Computable<Icon>() {
+          @Override
+          public Icon compute() {
+            return getIconImpl();
+          }
+        });
         myPresentableName = myFile.getName();
       }
     }
@@ -94,7 +101,7 @@ public class FileGroupingRule implements UsageGroupingRule {
     }
 
     public Icon getIcon(boolean isOpen) {
-      return myIcon;
+      return myIcon.getIcon();
     }
 
     @NotNull
diff --git a/platform/util/src/com/intellij/openapi/util/ClassLoaderUtil.java b/platform/util/src/com/intellij/openapi/util/ClassLoaderUtil.java
new file mode 100644 (file)
index 0000000..73166f8
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2000-2010 JetBrains s.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 com.intellij.openapi.util;
+
+import com.intellij.util.ThrowableRunnable;
+
+public class ClassLoaderUtil {
+  private ClassLoaderUtil() {
+  }
+
+  public static void runWithClassLoader(final ClassLoader classLoader, final Runnable runnable) {
+    final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+    try {
+      Thread.currentThread().setContextClassLoader(classLoader);
+      runnable.run();
+    }
+    finally {
+      Thread.currentThread().setContextClassLoader(oldClassLoader);
+    }
+  }
+
+  public static <T> T runWithClassLoader(final ClassLoader classLoader, final Computable<T> computable) {
+    final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+    try {
+      Thread.currentThread().setContextClassLoader(classLoader);
+      return computable.compute();
+    }
+    finally {
+      Thread.currentThread().setContextClassLoader(oldClassLoader);
+    }
+  }
+
+  public static <E extends Throwable> void runWithClassLoader(final ClassLoader classLoader, final ThrowableRunnable<E> runnable)
+    throws E {
+    final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+    try {
+      Thread.currentThread().setContextClassLoader(classLoader);
+      runnable.run();
+    }
+    finally {
+      Thread.currentThread().setContextClassLoader(oldClassLoader);
+    }
+  }
+
+  public static <T, E extends Throwable> T runWithClassLoader(final ClassLoader classLoader, final ThrowableComputable<T, E> computable)
+    throws E {
+    final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+    try {
+      Thread.currentThread().setContextClassLoader(classLoader);
+      return computable.compute();
+    }
+    finally {
+      Thread.currentThread().setContextClassLoader(oldClassLoader);
+    }
+  }
+}
index 8cf3e40ed56c69aaac2dd39b48af5206e46b4c4e..ef47ffd844a3b135d6a66482feee0ebc75993cbb 100644 (file)
@@ -119,7 +119,7 @@ public class PersistentHashMap<Key, Value> extends PersistentEnumerator<Key>{
       myValueStorage = PersistentHashMapValueStorage.create(getDataFile(myFile).getPath());
       myGarbageSize = getMetaData();
 
-      if (makesSenceToCompact()) {
+      if (makesSenseToCompact()) {
         compact();
       }
     }
@@ -136,29 +136,32 @@ public class PersistentHashMap<Key, Value> extends PersistentEnumerator<Key>{
     return myFile;
   }
 
-  private boolean makesSenceToCompact() {
-    final long filesize = getDataFile(myFile).length();
-    return filesize > 5 * 1024 * 1024 && myGarbageSize * 2 > filesize; // file is longer than 5MB and more than 50% of data is garbage
+  private boolean makesSenseToCompact() {
+    final long fileSize = getDataFile(myFile).length();
+    return fileSize > 5 * 1024 * 1024 && myGarbageSize * 2 > fileSize; // file is longer than 5MB and more than 50% of data is garbage
   }
 
   private static File checkDataFiles(final File file) {
     if (!file.exists()) {
-      final File dataFile = getDataFile(file);
-      final String baseName = dataFile.getName();
-      final File[] files = dataFile.getParentFile().listFiles(new FileFilter() {
-        public boolean accept(final File pathname) {
-          return pathname.getName().startsWith(baseName);
-        }
-      });
-      if (files != null) {
-        for (File f : files) {
-          FileUtil.delete(f);
-        }
-      }
+      deleteFilesStartingWith(getDataFile(file));
     }
     return file;
   }
 
+  public static void deleteFilesStartingWith(File prefixFile) {
+    final String baseName = prefixFile.getName();
+    final File[] files = prefixFile.getParentFile().listFiles(new FileFilter() {
+      public boolean accept(final File pathName) {
+        return pathName.getName().startsWith(baseName);
+      }
+    });
+    if (files != null) {
+      for (File f : files) {
+        FileUtil.delete(f);
+      }
+    }
+  }
+
   private static File getDataFile(final File file) {
     return new File(file.getParentFile(), file.getName() + DATA_FILE_EXTENSION);
   }
index adcd39b5dac4a241e3e88c37a45c04c59952d0c6..4aa708d5e19540eba484b9b9ecb7f2ca35b902ab 100644 (file)
@@ -201,17 +201,18 @@ public class LineStatusTracker {
   }
 
   private static TextAttributes getAttributesFor(Range range) {
-    EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
-    Color color = globalScheme.getAttributes(getEditorColorNameFor(range)).getErrorStripeColor();
-    TextAttributes textAttributes = new TextAttributes(null, color, null, EffectType.BOXED, Font.PLAIN);
-    textAttributes.setErrorStripeColor(color);
+    final EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();
+    final Color stripeColor = globalScheme.getAttributes(getEditorColorNameFor(range)).getErrorStripeColor();
+    final TextAttributes textAttributes = new TextAttributes(null, stripeColor, null, EffectType.BOXED, Font.PLAIN);
+    textAttributes.setErrorStripeColor(stripeColor);
     return textAttributes;
   }
 
   private static void paintGutterFragment(Editor editor, Graphics g, Rectangle r, TextAttributesKey diffAttributeKey) {
-    EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx();
+    final EditorGutterComponentEx gutter = ((EditorEx)editor).getGutterComponentEx();
     final Color stripeColor = editor.getColorsScheme().getAttributes(diffAttributeKey).getErrorStripeColor();
-    g.setColor(stripeColor);
+    g.setColor(brighter(stripeColor));
+
     int endX = gutter.getWhitespaceSeparatorOffset();
     int x = r.x + r.width - 2;
     int width = endX - x;
@@ -236,6 +237,21 @@ public class LineStatusTracker {
     }
   }
 
+  private static Color brighter(final Color color) {
+    final float[] hsbStripeColor = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
+
+    if (hsbStripeColor[1] < 0.02f) {
+      // color is grey
+      hsbStripeColor[2] = Math.min(1.0f, hsbStripeColor[2] * 1.3f);
+    } else {
+      // let's decrease color saturation
+      hsbStripeColor[1] *= 0.3;
+
+      // max brightness
+      hsbStripeColor[2] = 1.0f;
+    }
+    return Color.getHSBColor(hsbStripeColor[0], hsbStripeColor[1], hsbStripeColor[2]);
+  }
 
   private LineMarkerRenderer createRenderer(final Range range) {
     return new ActiveGutterRenderer() {
index 49b9d25de8d758497919c54e18d184a4d6bd0292..dfaa756395f72eeef3316e95c6f2e87fae267d48 100644 (file)
@@ -36,6 +36,12 @@ import java.util.List;
 public class TemporaryPlacesInjector implements MultiHostInjector {
 
   public static final Logger LOG = Logger.getInstance("org.intellij.plugins.intelliLang.inject.TemporaryPlacesInjector");
+  
+  private final TemporaryPlacesRegistry myRegistry;
+
+  public TemporaryPlacesInjector(TemporaryPlacesRegistry registry) {
+    myRegistry = registry;
+  }
 
   @NotNull
   public List<? extends Class<? extends PsiElement>> elementsToInjectIn() {
@@ -44,11 +50,11 @@ public class TemporaryPlacesInjector implements MultiHostInjector {
 
   public void getLanguagesToInject(@NotNull final MultiHostRegistrar registrar, @NotNull final PsiElement context) {
     final PsiLanguageInjectionHost host = (PsiLanguageInjectionHost)context;
-    final ElementManipulator<PsiLanguageInjectionHost> manipulator = ElementManipulators.getManipulator(host);
-    if (manipulator == null) return; // TODO: [gregory] there is no need to stop the world !
-    //LOG.assertTrue(manipulator != null, "No manipulator for " + host);
     final PsiLanguageInjectionHost originalHost = PsiUtilBase.getOriginalElement(host, host.getClass());
-    final List<TemporaryPlacesRegistry.TemporaryPlace> list = TemporaryPlacesRegistry.getInstance(context.getProject()).getTempInjectionsSafe(originalHost);
+    final List<TemporaryPlacesRegistry.TemporaryPlace> list = myRegistry.getTempInjectionsSafe(originalHost);
+    if (list.isEmpty()) return;
+    final ElementManipulator<PsiLanguageInjectionHost> manipulator = ElementManipulators.getManipulator(host);
+    if (manipulator == null) return;
     for (final TemporaryPlacesRegistry.TemporaryPlace place : list) {
       LOG.assertTrue(place.language != null, "Language should not be NULL");
       InjectorUtils.registerInjection(