Merge branch ultimate:plugins/yaml into community
authorValentin Fondaratov <valentin.fondaratov@jetbrains.com>
Mon, 11 Jan 2016 17:18:51 +0000 (20:18 +0300)
committerValentin Fondaratov <valentin.fondaratov@jetbrains.com>
Mon, 11 Jan 2016 17:18:51 +0000 (20:18 +0300)
245 files changed:
plugins/yaml/gen/org/jetbrains/yaml/lexer/_YAMLLexer.java [new file with mode: 0644]
plugins/yaml/resources/META-INF/plugin.xml [new file with mode: 0644]
plugins/yaml/resources/messages/YAMLBundle.properties [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLBundle.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLCodeStyleSettingsProvider.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLColorsPage.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLCommenter.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLElementGenerator.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLElementType.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLElementTypes.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLFileType.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLFileTypeLoader.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLHighlighter.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLLanguage.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLLanguageCodeStyleSettingsProvider.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLPairedBraceMatcher.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLParserDefinition.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLSyntaxHighlighter.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLSyntaxHighlighterFactory.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLTokenTypes.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/YAMLUtil.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/completion/YamlKeyCompletionInsertHandler.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/folding/YAMLFoldingBuilder.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/lexer/YAMLFlexLexer.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/lexer/yaml.flex [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/parser/YAMLParser.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLCompoundValue.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLDocument.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLFile.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLKeyValue.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLMapping.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLPsiElement.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLPsiManager.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLQuotedText.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLScalar.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLScalarList.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLScalarText.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLSequence.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLSequenceItem.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/YAMLValue.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLArrayImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockMappingImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockScalarImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockSequenceImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLCompoundValueImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLDocumentImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLFileImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLHashImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLKeyValueImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLMappingImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLPlainTextImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLPsiElementImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLQuotedTextImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarElementManipulator.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarListImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarTextImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLSequenceImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLSequenceItemImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLValueImpl.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/structureView/YAMLStructureViewBuilder.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/structureView/YAMLStructureViewElement.java [new file with mode: 0644]
plugins/yaml/src/org/jetbrains/yaml/structureView/YAMLStructureViewFactory.java [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/YAMLLexerTest.java [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/2docs.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/2docs.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/closing_braces_in_value.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/closing_braces_in_value.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/colons74100.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/colons74100.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/colorspage.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/colorspage.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/comma.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/comma.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/comments.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/comments.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/documents.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/documents.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/emptyMultiline.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/emptyMultiline.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/indentation.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/indentation.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/index.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/index.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_parens.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_parens.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_trailing_space.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_trailing_space.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_with_brackets.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_with_brackets.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/keydots.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/keydots.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/map_between_seq.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/map_between_seq.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/map_map.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/map_map.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineDoubleQuotedKey.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineDoubleQuotedKey.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineDqLiteralWithEscapedNewlines.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineDqLiteralWithEscapedNewlines.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineSingleQuotedKey.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineSingleQuotedKey.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multiline_ruby_16796.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multiline_ruby_16796.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multiline_seq.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multiline_seq.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/nested_seqs.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/nested_seqs.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/non_comment.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/non_comment.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/non_comment2.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/non_comment2.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyScalarNoDocument.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyScalarNoDocument.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyScalars.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyScalars.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyyamlkey.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyyamlkey.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/quoted_keys.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/quoted_keys.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/quoted_scalars.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/quoted_scalars.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby14738.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby14738.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby14864.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby14864.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby15402.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby15402.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby17389.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby17389.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/sample_log.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/sample_log.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/seq_seq.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/seq_seq.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/sequence_mappings.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/sequence_mappings.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/singleQuotedEscapes.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/singleQuotedEscapes.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/smallExplicitDocument.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/smallExplicitDocument.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/smallStream.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/smallStream.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/stringWithTag.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/stringWithTag.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/strings.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/strings.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/tagShorthands.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/tagShorthands.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/typed_scalar_list.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/typed_scalar_list.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/value_injection.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/value_injection.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/value_injection_2.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/value_injection_2.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/verbatimTags.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/verbatimTags.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/wrong_string_highlighting.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/wrong_string_highlighting.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/YAMLParserTest.java [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/2docs.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/AnsibleRoleElkInit.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/AnsibleRoleElkInit.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/AnsibleRoleElkMain.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/AnsibleRoleElkMain.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Balance.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/BlockMapping.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/BlockMapping.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/EmptyMultiline.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/ExplicitMaps.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/ExplicitMaps.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/HonestMultiline.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/IncompleteKey.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/IncompleteKeyInHierarchy.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/IncompleteKeyInHierarchy.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/IncompleteKeyWithWhitespace.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Indentation.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Interpolation.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/KeyValueWithEmptyLineAhead.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/KeyValueWithEmptyLineAhead.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Map_between_seq.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Map_map.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Multiline_ruby16796.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/MultipleDocsWithMappings.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/MultipleDocsWithMappings.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Ruby15345.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Ruby17389.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Sample_log.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Seq_seq.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Sequence_idea76804.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Sequence_mappings.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Spec2_27.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Spec2_27.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/StringWithTag.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/Value_injection.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/YAMLScalarContentTest.java [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuote1.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuote1.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuote2.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/doubleQuote2.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle1.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle1.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle2.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle2.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle3.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle3.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/foldedStyle4.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/literalStyle1.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/literalStyle1.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/literalStyle2.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/literalStyle2.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/literalStyle3.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/literalStyle3.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar1.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar1.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar2.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar2.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/plainScalar3.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote1.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote2.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psi/data/singleQuote2.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/YAMLMappingModificationTest.java [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/createKeyInEmptyFile.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/createKeyInEmptyFile.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/createSecondKeyLevelTwo.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/createSecondKeyLevelTwo.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/createSecondKeyLevelTwoCompact.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/createSecondKeyLevelTwoCompact.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/createSecondTopLevelKey.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/createSecondTopLevelKey.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/replaceTopLevelKey.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/replaceTopLevelKey.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/replaceValueCompoundScalar.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/replaceValueCompoundScalar.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/replaceValueScalarCompound.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/replaceValueScalarCompound.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/replaceValueScalarScalar.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/replaceValueScalarScalar.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/setValueCompound.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/setValueCompound.yml [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/setValueScalar.txt [new file with mode: 0644]
plugins/yaml/testSrc/org/jetbrains/yaml/psiModification/data/setValueScalar.yml [new file with mode: 0644]
plugins/yaml/yaml.iml [new file with mode: 0644]

diff --git a/plugins/yaml/gen/org/jetbrains/yaml/lexer/_YAMLLexer.java b/plugins/yaml/gen/org/jetbrains/yaml/lexer/_YAMLLexer.java
new file mode 100644 (file)
index 0000000..1a17259
--- /dev/null
@@ -0,0 +1,1071 @@
+/* The following code was generated by JFlex 1.4.3 on 11/23/15 4:33 PM */
+
+package org.jetbrains.yaml.lexer;
+
+import com.intellij.lexer.FlexLexer;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.yaml.YAMLTokenTypes;
+
+/* Auto generated File */
+
+/**
+ * This class is a scanner generated by 
+ * <a href="http://www.jflex.de/">JFlex</a> 1.4.3
+ * on 11/23/15 4:33 PM from the specification file
+ * <tt>/Users/valich/work/idea/plugins/yaml/src/org/jetbrains/yaml/lexer/yaml.flex</tt>
+ */
+public class _YAMLLexer implements FlexLexer, YAMLTokenTypes {
+  /** initial size of the lookahead buffer */
+  private static final int ZZ_BUFFERSIZE = 16384;
+
+  /** lexical states */
+  public static final int VALUE_OR_KEY = 6;
+  public static final int VALUE_BRACE = 8;
+  public static final int YYINITIAL = 0;
+  public static final int BRACES = 2;
+  public static final int VALUE = 4;
+  public static final int INDENT_VALUE = 10;
+
+  /**
+   * ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
+   * ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
+   *                  at the beginning of a line
+   * l is of the form l = 2*k, k a non negative integer
+   */
+  private static final int ZZ_LEXSTATE[] = { 
+     0,  0,  1,  1,  2,  2,  3,  3,  4,  4,  5, 5
+  };
+
+  /** 
+   * Translates characters to character classes
+   */
+  private static final String ZZ_CMAP_PACKED = 
+    "\11\0\1\10\1\1\2\0\1\2\22\0\1\13\1\27\1\21\1\6"+
+    "\1\25\1\17\1\26\1\22\2\25\1\26\1\32\1\4\1\12\1\25"+
+    "\1\25\12\23\1\7\1\25\1\30\1\25\1\14\1\5\1\26\6\23"+
+    "\24\24\1\31\1\20\1\11\1\0\1\25\1\3\6\23\24\24\1\15"+
+    "\1\33\1\16\1\25\u05e1\0\12\23\206\0\12\23\306\0\12\23\u019c\0"+
+    "\12\23\166\0\12\23\166\0\12\23\166\0\12\23\166\0\12\23\166\0"+
+    "\12\23\166\0\12\23\166\0\12\23\166\0\12\23\340\0\12\23\166\0"+
+    "\12\23\106\0\12\23\u0116\0\12\23\106\0\12\23\u0746\0\12\23\46\0"+
+    "\12\23\u012c\0\12\23\200\0\12\23\246\0\12\23\6\0\12\23\266\0"+
+    "\12\23\126\0\12\23\206\0\12\23\6\0\12\23\u89c6\0\12\23\u02a6\0"+
+    "\12\23\46\0\12\23\306\0\12\23\166\0\12\23\u0196\0\12\23\u5316\0"+
+    "\12\23\346\0";
+
+  /** 
+   * Translates characters to character classes
+   */
+  private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
+
+  /** 
+   * Translates DFA states to action switch labels.
+   */
+  private static final int [] ZZ_ACTION = zzUnpackAction();
+
+  private static final String ZZ_ACTION_PACKED_0 =
+    "\16\0\1\1\1\2\1\3\1\4\1\5\1\6\1\3"+
+    "\1\7\1\10\2\3\1\11\1\12\4\3\1\13\1\3"+
+    "\1\1\1\5\2\3\1\11\1\3\1\1\1\5\5\3"+
+    "\1\1\1\5\2\3\1\14\1\15\1\16\10\0\1\1"+
+    "\1\0\1\17\1\0\2\20\2\21\2\22\6\0\1\23"+
+    "\2\0\1\24\1\25\1\0\1\25\4\0\2\26\1\0"+
+    "\1\1\1\0\1\17\3\0\1\1\4\0\1\23\1\24"+
+    "\1\1\3\0\1\27\14\0\1\30\1\0\1\1\2\0"+
+    "\1\31\3\0\1\32\1\0\1\1\5\0\1\1\2\0"+
+    "\2\1\2\0\2\1\2\0\1\1\2\0\1\1\1\0"+
+    "\1\1\3\0\2\1\1\0\4\1\1\0\1\1\2\0"+
+    "\1\1";
+
+  private static int [] zzUnpackAction() {
+    int [] result = new int[170];
+    int offset = 0;
+    offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
+    return result;
+  }
+
+  private static int zzUnpackAction(String packed, int offset, int [] result) {
+    int i = 0;       /* index in packed string  */
+    int j = offset;  /* index in unpacked array */
+    int l = packed.length();
+    while (i < l) {
+      int count = packed.charAt(i++);
+      int value = packed.charAt(i++);
+      do result[j++] = value; while (--count > 0);
+    }
+    return j;
+  }
+
+
+  /** 
+   * Translates a state to a row index in the transition table
+   */
+  private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
+
+  private static final String ZZ_ROWMAP_PACKED_0 =
+    "\0\0\0\34\0\70\0\124\0\160\0\214\0\250\0\304"+
+    "\0\340\0\374\0\u0118\0\u0134\0\u0150\0\u016c\0\u0188\0\u01a4"+
+    "\0\u01a4\0\u01a4\0\u01c0\0\u01dc\0\u01f8\0\u0214\0\u01a4\0\u0230"+
+    "\0\u024c\0\u0268\0\u01a4\0\u0284\0\u02a0\0\u02bc\0\u02d8\0\u01a4"+
+    "\0\u02f4\0\u0310\0\u032c\0\u0348\0\u0364\0\u0380\0\u039c\0\u03b8"+
+    "\0\u03d4\0\u03f0\0\u03d4\0\u040c\0\u0428\0\u01c0\0\u0444\0\u0460"+
+    "\0\u047c\0\u0460\0\u0498\0\u01a4\0\u04b4\0\u04d0\0\u01a4\0\u04ec"+
+    "\0\u0508\0\u0524\0\u0540\0\u055c\0\u0578\0\u0594\0\u05b0\0\u05cc"+
+    "\0\u0188\0\u01a4\0\u05e8\0\u01a4\0\u0604\0\u01a4\0\u0620\0\u063c"+
+    "\0\u0658\0\u0674\0\u02a0\0\u040c\0\u0690\0\u06ac\0\u02bc\0\u0428"+
+    "\0\u06c8\0\u01a4\0\u06e4\0\u0700\0\u071c\0\u0738\0\u0754\0\u0770"+
+    "\0\u01a4\0\u078c\0\u07a8\0\u07c4\0\u07e0\0\u07fc\0\u0310\0\u0818"+
+    "\0\u0834\0\u0850\0\u086c\0\u03d4\0\u03b8\0\u0888\0\u01a4\0\u08a4"+
+    "\0\u08c0\0\u08dc\0\u0460\0\u0444\0\u01a4\0\u08f8\0\u0914\0\u0930"+
+    "\0\u08f8\0\u094c\0\u0968\0\u0984\0\u0524\0\u09a0\0\u09bc\0\u055c"+
+    "\0\u01a4\0\u01a4\0\u09d8\0\u09f4\0\u0a10\0\u0a2c\0\u01a4\0\u0a48"+
+    "\0\u0a64\0\u0a80\0\u01a4\0\u0a9c\0\u0ab8\0\u0ad4\0\u0af0\0\u0b0c"+
+    "\0\u0b28\0\u0b44\0\u0b60\0\u0b7c\0\u0b98\0\u0bb4\0\u0bd0\0\u0bec"+
+    "\0\u09f4\0\u0c08\0\u0c24\0\u0c40\0\u0c5c\0\u0c78\0\u0c94\0\u0cb0"+
+    "\0\u0ccc\0\u0ce8\0\u0d04\0\u0ab8\0\u0d20\0\u0d3c\0\u0d58\0\u0d74"+
+    "\0\u0b60\0\u0d90\0\u0dac\0\u0dc8\0\u0de4\0\u0e00\0\u0e1c\0\u0c78"+
+    "\0\u0e38\0\u0e54";
+
+  private static int [] zzUnpackRowMap() {
+    int [] result = new int[170];
+    int offset = 0;
+    offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
+    return result;
+  }
+
+  private static int zzUnpackRowMap(String packed, int offset, int [] result) {
+    int i = 0;  /* index in packed string  */
+    int j = offset;  /* index in unpacked array */
+    int l = packed.length();
+    while (i < l) {
+      int high = packed.charAt(i++) << 16;
+      result[j++] = high | packed.charAt(i++);
+    }
+    return j;
+  }
+
+  /** 
+   * The transition table of the DFA
+   */
+  private static final int [] ZZ_TRANS = zzUnpackTrans();
+
+  private static final String ZZ_TRANS_PACKED_0 =
+    "\1\17\1\20\2\21\1\22\1\23\1\24\1\25\1\26"+
+    "\1\27\1\30\1\26\1\31\1\32\1\33\1\34\1\17"+
+    "\1\35\1\36\3\17\1\21\1\37\1\17\1\40\1\17"+
+    "\1\41\1\42\1\20\2\21\1\22\1\43\1\24\1\44"+
+    "\1\26\1\27\1\45\1\26\1\21\1\46\1\33\1\47"+
+    "\1\42\1\35\1\36\3\42\1\21\1\37\1\42\1\40"+
+    "\1\42\1\21\1\50\1\20\2\21\1\22\1\51\1\24"+
+    "\1\52\1\26\1\27\1\53\1\26\1\31\1\32\1\33"+
+    "\1\34\1\50\1\54\1\55\3\50\1\21\1\37\1\50"+
+    "\1\40\1\50\1\41\1\17\1\20\2\21\1\22\1\23"+
+    "\1\24\1\25\1\26\1\27\1\56\1\26\1\31\1\32"+
+    "\1\33\1\34\1\17\1\35\1\36\3\17\1\21\1\37"+
+    "\1\17\1\40\1\17\1\41\1\57\1\20\2\21\1\22"+
+    "\1\60\1\24\1\61\1\26\1\27\1\62\1\26\1\31"+
+    "\1\46\1\33\1\47\1\57\1\54\1\55\3\57\1\21"+
+    "\1\37\1\57\1\40\1\57\1\41\1\63\1\64\6\63"+
+    "\1\65\2\63\1\65\20\63\27\0\1\66\5\0\1\67"+
+    "\6\0\1\70\2\0\1\70\20\0\1\71\4\0\1\72"+
+    "\1\0\1\72\2\0\1\72\5\0\1\71\2\0\3\71"+
+    "\2\0\1\71\1\0\1\71\2\0\2\67\1\0\1\67"+
+    "\3\0\2\67\1\0\1\67\1\0\2\67\12\0\1\67"+
+    "\2\0\1\73\4\0\1\74\1\0\1\74\2\0\1\74"+
+    "\5\0\1\73\2\0\3\73\2\0\1\73\1\0\1\73"+
+    "\2\0\2\67\5\0\1\67\2\0\1\67\34\0\1\75"+
+    "\52\0\1\75\1\76\2\0\3\76\1\77\1\100\1\101"+
+    "\2\76\1\101\20\76\34\0\1\17\2\0\5\17\1\0"+
+    "\2\17\1\0\20\17\1\24\1\0\32\24\1\17\1\102"+
+    "\1\0\5\17\1\103\2\17\1\103\20\17\10\0\1\26"+
+    "\2\0\1\26\20\0\1\17\1\104\1\0\5\17\1\105"+
+    "\2\17\1\105\20\17\1\0\1\106\6\0\1\107\1\0"+
+    "\1\110\1\107\16\0\1\110\16\0\1\111\33\0\1\112"+
+    "\16\0\1\113\1\114\16\113\1\115\1\116\12\113\1\117"+
+    "\1\120\20\117\1\121\11\117\1\0\1\122\3\0\3\123"+
+    "\1\124\1\0\1\125\1\124\3\0\1\126\2\0\1\123"+
+    "\2\125\2\123\1\127\1\130\1\0\1\123\2\0\1\131"+
+    "\6\0\1\132\1\0\1\133\1\132\16\0\1\133\1\0"+
+    "\1\134\2\0\1\134\1\135\1\134\1\135\1\136\1\137"+
+    "\1\135\1\134\1\137\1\134\2\135\12\134\1\135\2\134"+
+    "\1\42\2\0\1\42\1\0\3\42\2\0\1\42\1\0"+
+    "\1\42\2\0\12\42\1\0\3\42\1\102\1\0\1\42"+
+    "\1\0\3\42\1\103\1\0\1\42\1\103\1\42\2\0"+
+    "\12\42\1\0\3\42\1\104\1\0\1\42\1\0\3\42"+
+    "\1\105\1\0\1\42\1\105\1\42\2\0\12\42\1\0"+
+    "\2\42\15\0\1\140\33\0\1\141\16\0\1\142\2\0"+
+    "\3\142\1\143\1\144\1\145\2\142\1\145\20\142\1\50"+
+    "\2\0\5\50\1\0\2\50\1\0\21\50\1\102\1\0"+
+    "\5\50\1\103\2\50\1\103\20\50\20\114\1\146\1\147"+
+    "\12\114\22\120\1\150\11\120\1\151\2\0\1\151\1\152"+
+    "\1\151\1\152\1\153\1\154\1\152\1\151\1\154\1\151"+
+    "\2\152\12\151\1\152\2\151\1\57\2\0\1\57\1\0"+
+    "\3\57\2\0\1\57\1\0\1\57\2\0\12\57\1\0"+
+    "\3\57\1\102\1\0\1\57\1\0\3\57\1\103\1\0"+
+    "\1\57\1\103\1\57\2\0\12\57\1\0\2\57\1\63"+
+    "\1\0\32\63\1\0\1\155\6\0\1\65\2\0\1\65"+
+    "\25\0\3\156\2\0\1\157\4\0\1\160\2\0\1\156"+
+    "\2\157\2\156\1\161\1\162\1\0\1\156\11\0\1\70"+
+    "\2\0\1\70\20\0\1\163\2\0\1\163\1\164\1\163"+
+    "\1\164\1\165\1\71\1\164\1\163\1\71\1\163\2\164"+
+    "\12\163\1\164\2\163\1\71\2\0\1\71\1\0\3\71"+
+    "\2\0\1\71\1\0\1\71\2\0\12\71\1\0\2\71"+
+    "\1\166\2\0\3\166\1\167\1\170\1\73\2\166\1\73"+
+    "\20\166\1\73\2\0\5\73\1\0\2\73\1\0\20\73"+
+    "\12\0\1\171\17\0\1\171\1\0\1\76\2\0\4\76"+
+    "\1\100\1\101\2\76\1\101\20\76\6\0\1\17\25\0"+
+    "\1\17\2\172\5\17\1\172\2\17\1\172\20\17\10\0"+
+    "\1\103\2\0\1\103\30\0\1\105\2\0\1\105\30\0"+
+    "\1\107\2\0\1\107\21\0\1\106\6\0\1\107\2\0"+
+    "\1\107\20\0\1\173\1\0\4\173\1\0\2\173\3\0"+
+    "\1\173\2\0\12\173\1\0\2\173\1\174\1\0\3\112"+
+    "\1\175\1\112\1\175\2\112\1\175\3\112\1\176\1\112"+
+    "\1\174\2\112\3\174\2\112\1\174\1\112\1\174\1\112"+
+    "\1\113\1\114\32\113\7\0\1\177\33\0\1\177\12\0"+
+    "\1\117\12\0\1\122\3\0\3\123\1\124\1\0\1\123"+
+    "\1\124\3\0\1\126\2\0\5\123\3\0\1\123\11\0"+
+    "\1\124\2\0\1\124\21\0\1\122\3\0\3\123\1\124"+
+    "\1\0\1\125\1\124\3\0\1\126\2\0\1\123\2\125"+
+    "\2\123\1\127\2\0\1\123\24\0\1\200\15\0\3\123"+
+    "\2\0\1\123\4\0\1\126\2\0\5\123\3\0\1\123"+
+    "\5\0\4\201\1\0\2\201\4\0\1\202\2\0\6\201"+
+    "\1\0\2\201\11\0\1\132\2\0\1\132\21\0\1\131"+
+    "\6\0\1\132\2\0\1\132\20\0\1\134\2\0\1\134"+
+    "\1\135\2\134\1\136\1\137\1\135\1\134\1\137\1\134"+
+    "\2\135\12\134\1\135\2\134\6\0\1\42\25\0\1\42"+
+    "\2\203\1\42\1\203\3\42\2\203\1\42\1\203\1\42"+
+    "\2\203\12\42\1\203\2\42\1\204\1\0\4\204\1\0"+
+    "\2\204\3\0\1\204\2\0\12\204\1\0\2\204\1\205"+
+    "\1\0\3\141\1\206\1\141\1\206\2\141\1\206\3\141"+
+    "\1\207\1\141\1\205\2\141\3\205\2\141\1\205\1\141"+
+    "\1\205\1\141\1\142\2\0\4\142\1\144\1\145\2\142"+
+    "\1\145\20\142\6\0\1\50\25\0\34\114\22\0\1\120"+
+    "\11\0\1\151\2\0\1\151\1\152\2\151\1\153\1\154"+
+    "\1\152\1\151\1\154\1\151\2\152\12\151\1\152\2\151"+
+    "\6\0\1\57\32\0\3\156\2\0\1\156\4\0\1\160"+
+    "\2\0\5\156\3\0\1\156\6\0\3\156\2\0\1\157"+
+    "\4\0\1\160\2\0\1\156\2\157\2\156\1\161\2\0"+
+    "\1\156\24\0\1\210\14\0\4\211\1\0\2\211\4\0"+
+    "\1\212\2\0\6\211\1\0\2\211\1\0\1\163\2\0"+
+    "\1\163\1\164\2\163\1\165\1\71\1\164\1\163\1\71"+
+    "\1\163\2\164\12\163\1\164\2\163\6\0\1\71\25\0"+
+    "\1\166\2\0\4\166\1\170\1\73\2\166\1\73\20\166"+
+    "\6\0\1\73\25\0\1\213\1\0\3\173\1\214\1\0"+
+    "\1\144\1\173\1\0\1\214\1\173\2\0\1\215\1\173"+
+    "\1\213\2\173\3\213\2\173\1\213\1\0\1\213\1\173"+
+    "\1\216\1\0\1\112\2\216\1\217\1\220\1\175\1\221"+
+    "\1\216\1\217\1\221\2\216\1\222\15\216\1\174\1\0"+
+    "\1\112\2\174\1\217\1\174\1\217\1\112\1\174\1\217"+
+    "\1\112\2\174\1\223\15\174\1\50\4\0\1\144\1\0"+
+    "\1\144\2\0\1\144\5\0\1\50\2\0\3\50\2\0"+
+    "\1\50\1\0\1\50\24\0\1\123\14\0\4\201\1\0"+
+    "\2\201\1\0\1\224\2\0\1\202\2\0\6\201\1\0"+
+    "\2\201\24\0\1\225\10\0\1\226\1\0\3\204\1\227"+
+    "\1\0\1\153\1\204\1\0\1\227\1\204\2\0\1\230"+
+    "\1\204\1\226\2\204\3\226\2\204\1\226\1\0\1\226"+
+    "\1\204\1\231\1\0\1\141\1\231\1\232\1\233\1\232"+
+    "\1\206\1\234\1\232\1\233\1\234\1\231\1\232\1\235"+
+    "\12\231\1\232\2\231\1\205\1\0\1\141\1\205\1\141"+
+    "\1\233\1\205\1\233\2\141\1\233\1\141\1\205\1\141"+
+    "\1\207\12\205\1\141\2\205\1\57\4\0\1\153\1\0"+
+    "\1\153\2\0\1\153\5\0\1\57\2\0\3\57\2\0"+
+    "\1\57\1\0\1\57\24\0\1\156\14\0\4\211\1\0"+
+    "\2\211\1\0\1\171\2\0\1\212\2\0\6\211\1\0"+
+    "\2\211\24\0\1\236\10\0\1\237\1\0\1\173\2\237"+
+    "\1\240\1\143\1\144\1\241\1\142\1\240\1\241\2\142"+
+    "\1\242\12\237\1\142\2\237\1\213\1\0\1\173\2\213"+
+    "\1\240\1\50\1\243\1\173\1\50\1\240\1\173\2\50"+
+    "\1\244\12\213\1\50\2\213\1\50\4\0\1\144\1\0"+
+    "\1\144\2\0\1\144\3\0\1\176\1\0\1\50\2\0"+
+    "\3\50\2\0\1\50\1\0\1\50\1\0\1\216\1\0"+
+    "\1\112\2\216\1\217\1\216\1\175\1\221\1\216\1\217"+
+    "\1\221\2\216\1\222\16\216\1\0\1\112\2\216\1\217"+
+    "\1\216\1\217\1\221\1\216\1\217\1\221\2\216\1\222"+
+    "\15\216\1\174\1\0\3\112\1\175\1\174\1\175\2\112"+
+    "\1\175\3\112\1\176\1\112\1\174\2\112\3\174\2\112"+
+    "\1\174\1\112\1\174\1\112\1\142\2\0\2\142\1\243"+
+    "\1\142\1\144\1\145\1\142\1\243\1\145\21\142\2\0"+
+    "\2\142\1\243\1\143\1\144\1\145\1\142\1\243\1\145"+
+    "\20\142\1\0\1\122\6\0\1\124\2\0\1\124\43\0"+
+    "\1\201\10\0\1\245\1\0\1\204\1\245\1\246\1\247"+
+    "\1\152\1\153\1\250\1\152\1\247\1\250\1\151\1\152"+
+    "\1\251\12\245\1\152\2\245\1\226\1\0\1\204\1\226"+
+    "\1\204\1\247\1\57\1\252\1\204\1\0\1\247\1\204"+
+    "\1\57\1\0\1\230\12\226\1\0\2\226\1\57\4\0"+
+    "\1\153\1\0\1\153\2\0\1\153\3\0\1\207\1\0"+
+    "\1\57\2\0\3\57\2\0\1\57\1\0\1\57\1\0"+
+    "\1\231\1\0\1\141\1\231\1\232\1\233\1\231\1\206"+
+    "\1\234\1\232\1\233\1\234\1\231\1\232\1\235\12\231"+
+    "\1\232\2\231\1\205\1\0\3\141\1\206\1\205\1\206"+
+    "\2\141\1\206\3\141\1\207\1\141\1\205\2\141\3\205"+
+    "\2\141\1\205\1\141\1\205\1\141\1\231\1\0\1\141"+
+    "\1\231\1\232\1\233\1\231\1\233\1\234\1\232\1\233"+
+    "\1\234\1\231\1\232\1\235\12\231\1\232\2\231\1\57"+
+    "\4\0\1\153\1\57\1\153\2\0\1\153\5\0\1\57"+
+    "\2\0\3\57\2\0\1\57\1\0\1\57\24\0\1\211"+
+    "\10\0\1\237\1\0\1\173\2\237\1\240\1\142\1\144"+
+    "\1\241\1\142\1\240\1\241\2\142\1\242\12\237\1\142"+
+    "\3\237\1\0\1\173\2\237\1\240\1\142\1\243\1\241"+
+    "\1\142\1\240\1\241\2\142\1\242\12\237\1\142\2\237"+
+    "\1\142\2\0\2\142\1\243\1\142\1\144\1\145\1\142"+
+    "\1\243\1\145\2\142\1\222\16\142\2\0\4\142\1\243"+
+    "\1\145\2\142\1\145\21\142\2\0\2\142\1\243\1\143"+
+    "\1\144\1\145\1\142\1\243\1\145\2\142\1\222\15\142"+
+    "\1\245\1\0\1\204\1\245\1\246\1\247\1\151\1\153"+
+    "\1\250\1\152\1\247\1\250\1\151\1\152\1\251\12\245"+
+    "\1\152\2\245\1\226\1\0\3\204\1\227\1\57\1\153"+
+    "\1\204\1\0\1\227\1\204\2\0\1\230\1\204\1\226"+
+    "\2\204\3\226\2\204\1\226\1\0\1\226\1\204\1\245"+
+    "\1\0\1\204\1\245\1\246\1\247\1\151\1\252\1\250"+
+    "\1\152\1\247\1\250\1\151\1\152\1\251\12\245\1\152"+
+    "\2\245\1\57\4\0\1\153\1\57\1\153\2\0\1\153"+
+    "\3\0\1\207\1\0\1\57\2\0\3\57\2\0\1\57"+
+    "\1\0\1\57\1\0\1\151\2\0\1\151\1\152\2\151"+
+    "\1\252\1\154\1\152\1\151\1\154\1\151\2\152\12\151"+
+    "\1\152\2\151";
+
+  private static int [] zzUnpackTrans() {
+    int [] result = new int[3696];
+    int offset = 0;
+    offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
+    return result;
+  }
+
+  private static int zzUnpackTrans(String packed, int offset, int [] result) {
+    int i = 0;       /* index in packed string  */
+    int j = offset;  /* index in unpacked array */
+    int l = packed.length();
+    while (i < l) {
+      int count = packed.charAt(i++);
+      int value = packed.charAt(i++);
+      value--;
+      do result[j++] = value; while (--count > 0);
+    }
+    return j;
+  }
+
+
+  /* error codes */
+  private static final int ZZ_UNKNOWN_ERROR = 0;
+  private static final int ZZ_NO_MATCH = 1;
+  private static final int ZZ_PUSHBACK_2BIG = 2;
+  private static final char[] EMPTY_BUFFER = new char[0];
+  private static final int YYEOF = -1;
+  private static java.io.Reader zzReader = null; // Fake
+
+  /* error messages for the codes above */
+  private static final String ZZ_ERROR_MSG[] = {
+    "Unkown internal scanner error",
+    "Error: could not match input",
+    "Error: pushback value was too large"
+  };
+
+  /**
+   * ZZ_ATTRIBUTE[aState] contains the attributes of state <code>aState</code>
+   */
+  private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+
+  private static final String ZZ_ATTRIBUTE_PACKED_0 =
+    "\16\0\1\1\3\11\4\1\1\11\3\1\1\11\4\1"+
+    "\1\11\23\1\1\11\2\1\1\11\1\1\4\0\2\1"+
+    "\1\0\1\1\1\0\1\11\1\1\1\11\1\1\1\11"+
+    "\1\1\6\0\1\1\2\0\1\1\1\11\1\0\1\1"+
+    "\4\0\1\11\1\1\1\0\1\1\1\0\1\1\3\0"+
+    "\1\1\4\0\1\11\2\1\3\0\1\11\2\1\5\0"+
+    "\1\1\2\0\1\1\2\11\1\0\1\1\2\0\1\11"+
+    "\3\0\1\11\1\0\1\1\5\0\1\1\2\0\2\1"+
+    "\2\0\2\1\2\0\1\1\2\0\1\1\1\0\1\1"+
+    "\3\0\2\1\1\0\4\1\1\0\1\1\2\0\1\1";
+
+  private static int [] zzUnpackAttribute() {
+    int [] result = new int[170];
+    int offset = 0;
+    offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
+    return result;
+  }
+
+  private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+    int i = 0;       /* index in packed string  */
+    int j = offset;  /* index in unpacked array */
+    int l = packed.length();
+    while (i < l) {
+      int count = packed.charAt(i++);
+      int value = packed.charAt(i++);
+      do result[j++] = value; while (--count > 0);
+    }
+    return j;
+  }
+
+  /** the current state of the DFA */
+  private int zzState;
+
+  /** the current lexical state */
+  private int zzLexicalState = YYINITIAL;
+
+  /** this buffer contains the current text to be matched and is
+      the source of the yytext() string */
+  private CharSequence zzBuffer = "";
+
+  /** this buffer may contains the current text array to be matched when it is cheap to acquire it */
+  private char[] zzBufferArray;
+
+  /** the textposition at the last accepting state */
+  private int zzMarkedPos;
+
+  /** the textposition at the last state to be included in yytext */
+  private int zzPushbackPos;
+
+  /** the current text position in the buffer */
+  private int zzCurrentPos;
+
+  /** startRead marks the beginning of the yytext() string in the buffer */
+  private int zzStartRead;
+
+  /** endRead marks the last character in the buffer, that has been read
+      from input */
+  private int zzEndRead;
+
+  /**
+   * zzAtBOL == true <=> the scanner is currently at the beginning of a line
+   */
+  private boolean zzAtBOL = true;
+
+  /** zzAtEOF == true <=> the scanner is at the EOF */
+  private boolean zzAtEOF;
+
+  /** For the backwards DFA of general lookahead statements */
+  private boolean [] zzFin = new boolean [ZZ_BUFFERSIZE+1];
+
+  /** denotes if the user-EOF-code has already been executed */
+  private boolean zzEOFDone;
+
+  /* user code: */
+  private int currentLineIndent = 0;
+  private int valueIndent = -1;
+  private int braceCount = 0;
+  private IElementType valueTokenType = null;
+  private int previousState = YYINITIAL;
+
+  public boolean isCleanState() {
+    return yystate() == YYINITIAL
+      && currentLineIndent == 0
+      && braceCount == 0;
+  }
+
+  public void cleanMyState() {
+    currentLineIndent = 0;
+    braceCount = 0;
+  }
+
+  private char previousChar() {
+    return getChar(-1);
+  }
+
+  private char getChar(final int offset) {
+    final int loc = getTokenStart()  + offset;
+    return 0 <= loc && loc < zzBuffer.length() ? zzBuffer.charAt(loc) : (char) -1;
+  }
+
+  private char getCharAfter(final int offset) {
+    final int loc = getTokenEnd()  + offset;
+    return 0 <= loc && loc < zzBuffer.length() ? zzBuffer.charAt(loc) : (char) -1;
+  }
+
+  private IElementType getWhitespaceTypeAndUpdateIndent() {
+    if (isAfterEol()) {
+      currentLineIndent = yylength();
+      return INDENT;
+    }
+    else {
+      return WHITESPACE;
+    }
+  }
+
+  private boolean isAfterEol() {
+    final char prev = previousChar();
+    return prev == (char)-1 || prev == '\n';
+  }
+
+  private boolean isAfterSpace() {
+    final char prev = previousChar();
+    return prev == (char)-1 || prev == '\t' || prev == ' ';
+  }
+
+  private void yyBegin(int newState) {
+    //System.out.println("yybegin(): " + newState);
+    yybegin(newState);
+  }
+
+  private boolean startsWith(CharSequence haystack, CharSequence needle) {
+    for (int i = Math.min(haystack.length(), needle.length()) - 1; i >= 0; i--) {
+      if (haystack.charAt(i) != needle.charAt(i)) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  private IElementType tokenOrForbidden(IElementType tokenType) {
+    if (!isAfterEol() || yylength() < 3) {
+      return tokenType;
+    }
+
+    if (startsWith(yytext(), "---")) {
+      braceCount = 0;
+      yyBegin(YYINITIAL);
+      yypushback(yylength() - 3);
+      return DOCUMENT_MARKER;
+    }
+    if (startsWith(yytext(), "...")) {
+      braceCount = 0;
+      yyBegin(YYINITIAL);
+      yypushback(yylength() - 3);
+      return DOCUMENT_END;
+    }
+    return tokenType;
+  }
+
+
+  /**
+   * Creates a new scanner
+   *
+   * @param   in  the java.io.Reader to read input from.
+   */
+  public _YAMLLexer(java.io.Reader in) {
+    this.zzReader = in;
+  }
+
+
+  /** 
+   * Unpacks the compressed character translation table.
+   *
+   * @param packed   the packed character translation table
+   * @return         the unpacked character translation table
+   */
+  private static char [] zzUnpackCMap(String packed) {
+    char [] map = new char[0x10000];
+    int i = 0;  /* index in packed string  */
+    int j = 0;  /* index in unpacked array */
+    while (i < 224) {
+      int  count = packed.charAt(i++);
+      char value = packed.charAt(i++);
+      do map[j++] = value; while (--count > 0);
+    }
+    return map;
+  }
+
+  public final int getTokenStart(){
+    return zzStartRead;
+  }
+
+  public final int getTokenEnd(){
+    return getTokenStart() + yylength();
+  }
+
+  public void reset(CharSequence buffer, int start, int end,int initialState){
+    zzBuffer = buffer;
+    zzBufferArray = null;
+    zzCurrentPos = zzMarkedPos = zzStartRead = start;
+    zzPushbackPos = 0;
+    zzAtEOF  = false;
+    zzAtBOL = true;
+    zzEndRead = end;
+    yybegin(initialState);
+  }
+
+  /**
+   * Refills the input buffer.
+   *
+   * @return      <code>false</code>, iff there was new input.
+   *
+   * @exception   java.io.IOException  if any I/O-Error occurs
+   */
+  private boolean zzRefill() throws java.io.IOException {
+    return true;
+  }
+
+
+  /**
+   * Returns the current lexical state.
+   */
+  public final int yystate() {
+    return zzLexicalState;
+  }
+
+
+  /**
+   * Enters a new lexical state
+   *
+   * @param newState the new lexical state
+   */
+  public final void yybegin(int newState) {
+    zzLexicalState = newState;
+  }
+
+
+  /**
+   * Returns the text matched by the current regular expression.
+   */
+  public final CharSequence yytext() {
+    return zzBuffer.subSequence(zzStartRead, zzMarkedPos);
+  }
+
+
+  /**
+   * Returns the character at position <tt>pos</tt> from the
+   * matched text.
+   *
+   * It is equivalent to yytext().charAt(pos), but faster
+   *
+   * @param pos the position of the character to fetch.
+   *            A value from 0 to yylength()-1.
+   *
+   * @return the character at position pos
+   */
+  public final char yycharat(int pos) {
+    return zzBufferArray != null ? zzBufferArray[zzStartRead+pos]:zzBuffer.charAt(zzStartRead+pos);
+  }
+
+
+  /**
+   * Returns the length of the matched text region.
+   */
+  public final int yylength() {
+    return zzMarkedPos-zzStartRead;
+  }
+
+
+  /**
+   * Reports an error that occured while scanning.
+   *
+   * In a wellformed scanner (no or only correct usage of
+   * yypushback(int) and a match-all fallback rule) this method
+   * will only be called with things that "Can't Possibly Happen".
+   * If this method is called, something is seriously wrong
+   * (e.g. a JFlex bug producing a faulty scanner etc.).
+   *
+   * Usual syntax/scanner level error handling should be done
+   * in error fallback rules.
+   *
+   * @param   errorCode  the code of the errormessage to display
+   */
+  private void zzScanError(int errorCode) {
+    String message;
+    try {
+      message = ZZ_ERROR_MSG[errorCode];
+    }
+    catch (ArrayIndexOutOfBoundsException e) {
+      message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
+    }
+
+    throw new Error(message);
+  }
+
+
+  /**
+   * Pushes the specified amount of characters back into the input stream.
+   *
+   * They will be read again by then next call of the scanning method
+   *
+   * @param number  the number of characters to be read again.
+   *                This number must not be greater than yylength()!
+   */
+  public void yypushback(int number)  {
+    if ( number > yylength() )
+      zzScanError(ZZ_PUSHBACK_2BIG);
+
+    zzMarkedPos -= number;
+  }
+
+
+  /**
+   * Contains user EOF-code, which will be executed exactly once,
+   * when the end of file is reached
+   */
+  private void zzDoEOF() {
+    if (!zzEOFDone) {
+      zzEOFDone = true;
+    
+    }
+  }
+
+
+  /**
+   * Resumes scanning until the next regular expression is matched,
+   * the end of input is encountered or an I/O-Error occurs.
+   *
+   * @return      the next token
+   * @exception   java.io.IOException  if any I/O-Error occurs
+   */
+  public IElementType advance() throws java.io.IOException {
+    int zzInput;
+    int zzAction;
+
+    // cached fields:
+    int zzCurrentPosL;
+    int zzMarkedPosL;
+    int zzEndReadL = zzEndRead;
+    CharSequence zzBufferL = zzBuffer;
+    char[] zzBufferArrayL = zzBufferArray;
+    char [] zzCMapL = ZZ_CMAP;
+
+    int [] zzTransL = ZZ_TRANS;
+    int [] zzRowMapL = ZZ_ROWMAP;
+    int [] zzAttrL = ZZ_ATTRIBUTE;
+
+    while (true) {
+      zzMarkedPosL = zzMarkedPos;
+
+      zzAction = -1;
+
+      zzCurrentPosL = zzCurrentPos = zzStartRead = zzMarkedPosL;
+
+      zzState = ZZ_LEXSTATE[zzLexicalState];
+
+
+      zzForAction: {
+        while (true) {
+
+          if (zzCurrentPosL < zzEndReadL)
+            zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzCurrentPosL++] : zzBufferL.charAt(zzCurrentPosL++));
+          else if (zzAtEOF) {
+            zzInput = YYEOF;
+            break zzForAction;
+          }
+          else {
+            // store back cached positions
+            zzCurrentPos  = zzCurrentPosL;
+            zzMarkedPos   = zzMarkedPosL;
+            boolean eof = zzRefill();
+            // get translated positions and possibly new buffer
+            zzCurrentPosL  = zzCurrentPos;
+            zzMarkedPosL   = zzMarkedPos;
+            zzBufferL      = zzBuffer;
+            zzEndReadL     = zzEndRead;
+            if (eof) {
+              zzInput = YYEOF;
+              break zzForAction;
+            }
+            else {
+              zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzCurrentPosL++] : zzBufferL.charAt(zzCurrentPosL++));
+            }
+          }
+          int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+          if (zzNext == -1) break zzForAction;
+          zzState = zzNext;
+
+          int zzAttributes = zzAttrL[zzState];
+          if ( (zzAttributes & 1) == 1 ) {
+            zzAction = zzState;
+            zzMarkedPosL = zzCurrentPosL;
+            if ( (zzAttributes & 8) == 8 ) break zzForAction;
+          }
+
+        }
+      }
+
+      // store back cached position
+      zzMarkedPos = zzMarkedPosL;
+
+      switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
+        case 23: 
+          // lookahead expression with fixed lookahead length
+          yypushback(1);
+          { return getWhitespaceTypeAndUpdateIndent();
+          }
+        case 27: break;
+        case 7: 
+          { return getWhitespaceTypeAndUpdateIndent();
+          }
+        case 28: break;
+        case 1: 
+          { return tokenOrForbidden(TEXT);
+          }
+        case 29: break;
+        case 26: 
+          // general lookahead, find correct zzMarkedPos
+          { int zzFState = 8;
+            int zzFPos = zzStartRead;
+            if (zzFin.length <= (zzBufferArrayL != null ? zzBufferArrayL.length : zzBufferL.length())) { zzFin = new boolean[(zzBufferArrayL != null ? zzBufferArrayL.length : zzBufferL.length())+1]; }
+            boolean zzFinL[] = zzFin;
+            while (zzFState != -1 && zzFPos < zzMarkedPos) {
+              zzFinL[zzFPos] = ((zzAttrL[zzFState] & 1) == 1);
+              zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzFPos++] : zzBufferL.charAt(zzFPos++));
+              zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ];
+            }
+            if (zzFState != -1) { zzFinL[zzFPos++] = ((zzAttrL[zzFState] & 1) == 1); } 
+            while (zzFPos <= zzMarkedPos) {
+              zzFinL[zzFPos++] = false;
+            }
+
+            zzFState = 9;
+            zzFPos = zzMarkedPos;
+            while (!zzFinL[zzFPos] || (zzAttrL[zzFState] & 1) != 1) {
+              zzInput = (zzBufferArrayL != null ? zzBufferArrayL[--zzFPos] : zzBufferL.charAt(--zzFPos));
+              zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ];
+            };
+            zzMarkedPos = zzFPos;
+          }
+          { yyBegin(VALUE_BRACE);
+  return SCALAR_KEY;
+          }
+        case 30: break;
+        case 21: 
+          // general lookahead, find correct zzMarkedPos
+          { int zzFState = 6;
+            int zzFPos = zzStartRead;
+            if (zzFin.length <= (zzBufferArrayL != null ? zzBufferArrayL.length : zzBufferL.length())) { zzFin = new boolean[(zzBufferArrayL != null ? zzBufferArrayL.length : zzBufferL.length())+1]; }
+            boolean zzFinL[] = zzFin;
+            while (zzFState != -1 && zzFPos < zzMarkedPos) {
+              zzFinL[zzFPos] = ((zzAttrL[zzFState] & 1) == 1);
+              zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzFPos++] : zzBufferL.charAt(zzFPos++));
+              zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ];
+            }
+            if (zzFState != -1) { zzFinL[zzFPos++] = ((zzAttrL[zzFState] & 1) == 1); } 
+            while (zzFPos <= zzMarkedPos) {
+              zzFinL[zzFPos++] = false;
+            }
+
+            zzFState = 7;
+            zzFPos = zzMarkedPos;
+            while (!zzFinL[zzFPos] || (zzAttrL[zzFState] & 1) != 1) {
+              zzInput = (zzBufferArrayL != null ? zzBufferArrayL[--zzFPos] : zzBufferL.charAt(--zzFPos));
+              zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ];
+            };
+            zzMarkedPos = zzFPos;
+          }
+          { return TAG;
+          }
+        case 31: break;
+        case 25: 
+          { return SCALAR_KEY;
+          }
+        case 32: break;
+        case 5: 
+          { return QUESTION;
+          }
+        case 33: break;
+        case 15: 
+          { if (zzMarkedPos == zzEndRead){
+    return SCALAR_KEY;
+  }
+  yyBegin(VALUE);
+  return tokenOrForbidden(TEXT);
+          }
+        case 34: break;
+        case 9: 
+          { braceCount++;
+                                    if (braceCount != 0 && yystate() != BRACES) {
+                                      previousState = yystate();
+                                    }
+                                    yyBegin(braceCount == 0 ? previousState: BRACES);
+                                    return LBRACE;
+          }
+        case 35: break;
+        case 18: 
+          // general lookahead, find correct zzMarkedPos
+          { int zzFState = 12;
+            int zzFPos = zzStartRead;
+            if (zzFin.length <= (zzBufferArrayL != null ? zzBufferArrayL.length : zzBufferL.length())) { zzFin = new boolean[(zzBufferArrayL != null ? zzBufferArrayL.length : zzBufferL.length())+1]; }
+            boolean zzFinL[] = zzFin;
+            while (zzFState != -1 && zzFPos < zzMarkedPos) {
+              zzFinL[zzFPos] = ((zzAttrL[zzFState] & 1) == 1);
+              zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzFPos++] : zzBufferL.charAt(zzFPos++));
+              zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ];
+            }
+            if (zzFState != -1) { zzFinL[zzFPos++] = ((zzAttrL[zzFState] & 1) == 1); } 
+            while (zzFPos <= zzMarkedPos) {
+              zzFinL[zzFPos++] = false;
+            }
+
+            zzFState = 7;
+            zzFPos = zzMarkedPos;
+            while (!zzFinL[zzFPos] || (zzAttrL[zzFState] & 1) != 1) {
+              zzInput = (zzBufferArrayL != null ? zzBufferArrayL[--zzFPos] : zzBufferL.charAt(--zzFPos));
+              zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ];
+            };
+            zzMarkedPos = zzFPos;
+          }
+          { yyBegin(INDENT_VALUE);
+                                    valueIndent = currentLineIndent;
+                                    valueTokenType = SCALAR_TEXT;
+                                    return valueTokenType;
+          }
+        case 36: break;
+        case 16: 
+          // lookahead expression with fixed base length
+          zzMarkedPos = zzStartRead + 1;
+          { return COLON;
+          }
+        case 37: break;
+        case 19: 
+          { return SCALAR_DSTRING;
+          }
+        case 38: break;
+        case 14: 
+          { IElementType type = getWhitespaceTypeAndUpdateIndent();
+                                            if (currentLineIndent <= valueIndent) {
+                                              yyBegin(YYINITIAL);
+                                            }
+                                            return type;
+          }
+        case 39: break;
+        case 11: 
+          { braceCount++;
+                                    if (braceCount != 0 && yystate() != BRACES) {
+                                      previousState = yystate();
+                                    }
+                                    yyBegin(braceCount == 0 ? previousState: BRACES);
+                                    return LBRACKET;
+          }
+        case 40: break;
+        case 6: 
+          { // YAML spec: when a comment follows another syntax element,
+                                  //  it must be separated from it by space characters.
+                                  return (isAfterEol() || isAfterSpace()) ? COMMENT : TEXT;
+          }
+        case 41: break;
+        case 8: 
+          { if (braceCount == 0) {
+                                      yyBegin(VALUE);
+                                      return TEXT;
+                                    }
+                                    braceCount--;
+                                    if (yystate() == BRACES && braceCount == 0){
+                                      yyBegin(previousState);
+                                    }
+                                    return RBRACKET;
+          }
+        case 42: break;
+        case 22: 
+          // general lookahead, find correct zzMarkedPos
+          { int zzFState = 13;
+            int zzFPos = zzStartRead;
+            if (zzFin.length <= (zzBufferArrayL != null ? zzBufferArrayL.length : zzBufferL.length())) { zzFin = new boolean[(zzBufferArrayL != null ? zzBufferArrayL.length : zzBufferL.length())+1]; }
+            boolean zzFinL[] = zzFin;
+            while (zzFState != -1 && zzFPos < zzMarkedPos) {
+              zzFinL[zzFPos] = ((zzAttrL[zzFState] & 1) == 1);
+              zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzFPos++] : zzBufferL.charAt(zzFPos++));
+              zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ];
+            }
+            if (zzFState != -1) { zzFinL[zzFPos++] = ((zzAttrL[zzFState] & 1) == 1); } 
+            while (zzFPos <= zzMarkedPos) {
+              zzFinL[zzFPos++] = false;
+            }
+
+            zzFState = 7;
+            zzFPos = zzMarkedPos;
+            while (!zzFinL[zzFPos] || (zzAttrL[zzFState] & 1) != 1) {
+              zzInput = (zzBufferArrayL != null ? zzBufferArrayL[--zzFPos] : zzBufferL.charAt(--zzFPos));
+              zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ];
+            };
+            zzMarkedPos = zzFPos;
+          }
+          { yyBegin(INDENT_VALUE);
+                                    valueIndent = currentLineIndent;
+                                    valueTokenType = SCALAR_LIST;
+                                    return valueTokenType;
+          }
+        case 43: break;
+        case 17: 
+          // lookahead expression with fixed base length
+          zzMarkedPos = zzStartRead + 1;
+          { yyBegin(VALUE_OR_KEY);
+                                    return SEQUENCE_MARKER;
+          }
+        case 44: break;
+        case 20: 
+          { return SCALAR_STRING;
+          }
+        case 45: break;
+        case 3: 
+          { return TEXT;
+          }
+        case 46: break;
+        case 24: 
+          // general lookahead, find correct zzMarkedPos
+          { int zzFState = 10;
+            int zzFPos = zzStartRead;
+            if (zzFin.length <= (zzBufferArrayL != null ? zzBufferArrayL.length : zzBufferL.length())) { zzFin = new boolean[(zzBufferArrayL != null ? zzBufferArrayL.length : zzBufferL.length())+1]; }
+            boolean zzFinL[] = zzFin;
+            while (zzFState != -1 && zzFPos < zzMarkedPos) {
+              zzFinL[zzFPos] = ((zzAttrL[zzFState] & 1) == 1);
+              zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzFPos++] : zzBufferL.charAt(zzFPos++));
+              zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ];
+            }
+            if (zzFState != -1) { zzFinL[zzFPos++] = ((zzAttrL[zzFState] & 1) == 1); } 
+            while (zzFPos <= zzMarkedPos) {
+              zzFinL[zzFPos++] = false;
+            }
+
+            zzFState = 11;
+            zzFPos = zzMarkedPos;
+            while (!zzFinL[zzFPos] || (zzAttrL[zzFState] & 1) != 1) {
+              zzInput = (zzBufferArrayL != null ? zzBufferArrayL[--zzFPos] : zzBufferL.charAt(--zzFPos));
+              zzFState = zzTransL[ zzRowMapL[zzFState] + zzCMapL[zzInput] ];
+            };
+            zzMarkedPos = zzFPos;
+          }
+          { yyBegin(VALUE);
+  return SCALAR_KEY;
+          }
+        case 47: break;
+        case 2: 
+          { if (braceCount == 0) {
+                                      yyBegin(YYINITIAL);
+                                    }
+                                    currentLineIndent = 0;
+                                    return EOL;
+          }
+        case 48: break;
+        case 4: 
+          { if (braceCount > 0) {
+                                      yyBegin(BRACES);
+                                      return COMMA;
+                                    }
+                                    yyBegin(VALUE);
+                                    return TEXT;
+          }
+        case 49: break;
+        case 13: 
+          { currentLineIndent = 0;
+          return EOL;
+          }
+        case 50: break;
+        case 10: 
+          { if (braceCount == 0) {
+                                      yyBegin(VALUE);
+                                      return TEXT;
+                                    }
+                                    braceCount--;
+                                    if (yystate() == BRACES && braceCount == 0){
+                                      yyBegin(previousState);
+                                    }
+                                    return RBRACE;
+          }
+        case 51: break;
+        case 12: 
+          { if (currentLineIndent <= valueIndent) {
+                                                yypushback(yylength());
+                                                yyBegin(YYINITIAL);
+                                                break;
+                                            } else {
+                                                return valueTokenType;
+                                            }
+          }
+        case 52: break;
+        default:
+          if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
+            zzAtEOF = true;
+            zzDoEOF();
+            return null;
+          }
+          else {
+            zzScanError(ZZ_NO_MATCH);
+          }
+      }
+    }
+  }
+
+
+}
diff --git a/plugins/yaml/resources/META-INF/plugin.xml b/plugins/yaml/resources/META-INF/plugin.xml
new file mode 100644 (file)
index 0000000..935653c
--- /dev/null
@@ -0,0 +1,32 @@
+<idea-plugin version="2">
+  <name>YAML</name>
+  <id>org.jetbrains.plugins.yaml</id>
+  <vendor>JetBrains</vendor>
+  <description>YAML support</description>
+
+  <depends>com.intellij.modules.lang</depends>
+
+  <extensions defaultExtensionNs="com.intellij">
+    <!-- YAML -->
+    <lang.parserDefinition language="yaml" implementationClass="org.jetbrains.yaml.YAMLParserDefinition"/>
+    <lang.commenter language="yaml" implementationClass="org.jetbrains.yaml.YAMLCommenter"/>
+    <lang.syntaxHighlighterFactory language="yaml" implementationClass="org.jetbrains.yaml.YAMLSyntaxHighlighterFactory"/>
+    <colorSettingsPage implementation="org.jetbrains.yaml.YAMLColorsPage"/>
+    <lang.braceMatcher language="yaml" implementationClass="org.jetbrains.yaml.YAMLPairedBraceMatcher"/>
+    <lang.foldingBuilder language="yaml" implementationClass="org.jetbrains.yaml.folding.YAMLFoldingBuilder"/>
+    <fileTypeFactory implementation="org.jetbrains.yaml.YAMLFileTypeLoader"/>
+    <editor.backspaceModeOverride language="yaml" implementationClass="com.intellij.codeInsight.editorActions.SmartBackspaceDisabler"/>
+    <lang.psiStructureViewFactory language="yaml" implementationClass="org.jetbrains.yaml.structureView.YAMLStructureViewFactory"/>
+    <langCodeStyleSettingsProvider implementation="org.jetbrains.yaml.YAMLLanguageCodeStyleSettingsProvider"/>
+    <codeStyleSettingsProvider implementation="org.jetbrains.yaml.YAMLCodeStyleSettingsProvider"/>
+    
+    <psi.treeChangePreprocessor implementation="org.jetbrains.yaml.psi.YAMLPsiManager"/>
+
+    <projectService serviceImplementation="org.jetbrains.yaml.YAMLElementGenerator"/>
+
+    <lang.elementManipulator forClass="org.jetbrains.yaml.psi.YAMLScalar"
+                             implementationClass="org.jetbrains.yaml.psi.impl.YAMLScalarElementManipulator"/>
+  </extensions>
+
+
+</idea-plugin>
\ No newline at end of file
diff --git a/plugins/yaml/resources/messages/YAMLBundle.properties b/plugins/yaml/resources/messages/YAMLBundle.properties
new file mode 100644 (file)
index 0000000..d9f67d7
--- /dev/null
@@ -0,0 +1,15 @@
+filetype.description.yaml=YAML files
+
+color.settings.yaml.name=YAML
+color.settings.yaml.key=Key
+color.settings.yaml.string=String
+color.settings.yaml.dstring=Double quoted string
+color.settings.yaml.scalar.list='|' block
+color.settings.yaml.scalar.text='>' block
+color.settings.yaml.text=Text
+color.settings.yaml.sign=Sign: brace, comma, etc
+color.settings.yaml.comment=Comment
+
+new.name.conflicts.with=Key conflicts with existing one: ''{0}''
+rename.same.name=Same name
+rename.wrong.name=Wrong name
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLBundle.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLBundle.java
new file mode 100644 (file)
index 0000000..bc2e52c
--- /dev/null
@@ -0,0 +1,43 @@
+package org.jetbrains.yaml;
+
+import com.intellij.CommonBundle;
+import com.intellij.reference.SoftReference;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.PropertyKey;
+
+import java.lang.ref.Reference;
+import java.util.ResourceBundle;
+
+/**
+ * @author oleg
+ */
+public class YAMLBundle {
+
+  public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) {
+    return CommonBundle.message(getBundle(), key, params);
+  }
+
+  private static Reference<ResourceBundle> ourBundle;
+  @NonNls
+  private static final String BUNDLE = "messages.YAMLBundle";
+
+  private YAMLBundle() {
+  }
+
+  /*
+     * This method added for jruby access
+     */
+  public static String message(@PropertyKey(resourceBundle = BUNDLE) String key) {
+    return CommonBundle.message(getBundle(), key);
+  }
+
+  private static ResourceBundle getBundle() {
+    ResourceBundle bundle = SoftReference.dereference(ourBundle);
+    if (bundle == null) {
+      bundle = ResourceBundle.getBundle(BUNDLE);
+      ourBundle = new SoftReference<ResourceBundle>(bundle);
+    }
+    return bundle;
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLCodeStyleSettingsProvider.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLCodeStyleSettingsProvider.java
new file mode 100644 (file)
index 0000000..38edabc
--- /dev/null
@@ -0,0 +1,42 @@
+package org.jetbrains.yaml;
+
+import com.intellij.application.options.CodeStyleAbstractConfigurable;
+import com.intellij.application.options.CodeStyleAbstractPanel;
+import com.intellij.application.options.TabbedLanguageCodeStylePanel;
+import com.intellij.openapi.options.Configurable;
+import com.intellij.psi.codeStyle.CodeStyleSettings;
+import com.intellij.psi.codeStyle.CodeStyleSettingsProvider;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author oleg
+ */
+public class YAMLCodeStyleSettingsProvider extends CodeStyleSettingsProvider {
+  @NotNull
+  @Override
+  public Configurable createSettingsPage(final CodeStyleSettings settings, final CodeStyleSettings originalSettings) {
+    return new CodeStyleAbstractConfigurable(settings, originalSettings, YAMLLanguage.INSTANCE.getDisplayName()) {
+      @Override
+      protected CodeStyleAbstractPanel createPanel(final CodeStyleSettings settings) {
+        final CodeStyleSettings currentSettings = getCurrentSettings();
+        final CodeStyleSettings settings1 = settings;
+        return new TabbedLanguageCodeStylePanel(YAMLLanguage.INSTANCE, currentSettings, settings1) {
+          @Override
+            protected void initTabs(final CodeStyleSettings settings) {
+              addIndentOptionsTab(settings);
+            }
+        };
+      }
+
+      @Override
+      public String getHelpTopic() {
+        return "reference.settingsdialog.codestyle.yaml";
+      }
+    };
+  }
+
+  @Override
+  public String getConfigurableDisplayName() {
+    return YAMLLanguage.INSTANCE.getDisplayName();
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLColorsPage.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLColorsPage.java
new file mode 100644 (file)
index 0000000..30c5429
--- /dev/null
@@ -0,0 +1,86 @@
+package org.jetbrains.yaml;
+
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.editor.colors.TextAttributesKey;
+import com.intellij.openapi.fileTypes.SyntaxHighlighter;
+import com.intellij.openapi.options.colors.AttributesDescriptor;
+import com.intellij.openapi.options.colors.ColorDescriptor;
+import com.intellij.openapi.options.colors.ColorSettingsPage;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author oleg
+ */
+public class YAMLColorsPage implements ColorSettingsPage {
+
+  private static final String DEMO_TEXT = "---\n" +
+                                          "# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html\n" +
+                                          "static_sidebar:\n" +
+                                          "  id: \"foo\"\n" +
+                                          "  name: 'side_bar'\n" +
+                                          "  staged_position: 1\n" +
+                                          "  blog_id: 1\n" +
+                                          "  config: |+\n" +
+                                          "    --- !map:HashWithIndifferentAccess\n" +
+                                          "      title: Static Sidebar\n" +
+                                          "      body: The body of a static sidebar\n" +
+                                          "  type: StaticSidebar\n" +
+                                          "  type: > some_type_here";
+
+  private static final AttributesDescriptor[] ATTRS = new AttributesDescriptor[]{
+      new AttributesDescriptor(YAMLBundle.message("color.settings.yaml.key"), YAMLHighlighter.SCALAR_KEY),
+      new AttributesDescriptor(YAMLBundle.message("color.settings.yaml.string"), YAMLHighlighter.SCALAR_STRING),
+      new AttributesDescriptor(YAMLBundle.message("color.settings.yaml.dstring"), YAMLHighlighter.SCALAR_DSTRING),
+      new AttributesDescriptor(YAMLBundle.message("color.settings.yaml.scalar.list"), YAMLHighlighter.SCALAR_LIST),
+      new AttributesDescriptor(YAMLBundle.message("color.settings.yaml.scalar.text"), YAMLHighlighter.SCALAR_TEXT),
+      new AttributesDescriptor(YAMLBundle.message("color.settings.yaml.text"), YAMLHighlighter.TEXT),
+      new AttributesDescriptor(YAMLBundle.message("color.settings.yaml.sign"), YAMLHighlighter.SIGN),
+      new AttributesDescriptor(YAMLBundle.message("color.settings.yaml.comment"), YAMLHighlighter.COMMENT)
+  };
+
+  // Empty still
+  private static final Map<String, TextAttributesKey> ADDITIONAL_HIGHLIGHT_DESCRIPTORS = new HashMap<String, TextAttributesKey>();
+
+  private static final ColorDescriptor[] COLORS = new ColorDescriptor[0];
+
+  @Nullable
+  public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() {
+    return ADDITIONAL_HIGHLIGHT_DESCRIPTORS;
+  }
+
+  @NotNull
+  public String getDisplayName() {
+    return YAMLBundle.message("color.settings.yaml.name");
+  }
+
+  @NotNull
+  public Icon getIcon() {
+    return AllIcons.Nodes.DataTables;
+  }
+
+  @NotNull
+  public AttributesDescriptor[] getAttributeDescriptors() {
+    return ATTRS;
+  }
+
+  @NotNull
+  public ColorDescriptor[] getColorDescriptors() {
+    return COLORS;
+  }
+
+  @NotNull
+  public SyntaxHighlighter getHighlighter() {
+    return new YAMLSyntaxHighlighter();
+  }
+
+  @NotNull
+  public String getDemoText() {
+    return DEMO_TEXT;
+  }
+
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLCommenter.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLCommenter.java
new file mode 100644 (file)
index 0000000..0522ab4
--- /dev/null
@@ -0,0 +1,34 @@
+package org.jetbrains.yaml;
+
+import com.intellij.lang.Commenter;
+import org.jetbrains.annotations.NonNls;
+
+/**
+ * @author Roman Chernyatchik
+ */
+public class YAMLCommenter implements Commenter {
+  @NonNls
+  private static final String LINE_COMMENT_PREFIX = "#";
+
+  public String getLineCommentPrefix() {
+    return LINE_COMMENT_PREFIX;
+  }
+
+  public String getBlockCommentPrefix() {
+    // N/A
+    return null;
+  }
+
+  public String getBlockCommentSuffix() {
+    // N/A
+    return null;
+  }
+
+  public String getCommentedBlockCommentPrefix() {
+    return null;
+  }
+
+  public String getCommentedBlockCommentSuffix() {
+    return null;
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLElementGenerator.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLElementGenerator.java
new file mode 100644 (file)
index 0000000..bd82eeb
--- /dev/null
@@ -0,0 +1,88 @@
+package org.jetbrains.yaml;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiFileFactory;
+import com.intellij.psi.TokenType;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.LocalTimeCounter;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.psi.YAMLFile;
+import org.jetbrains.yaml.psi.YAMLKeyValue;
+
+import java.util.List;
+
+/**
+ * @author traff
+ */
+public class YAMLElementGenerator {
+  private final Project myProject;
+
+  public YAMLElementGenerator(Project project) {
+    myProject = project;
+  }
+
+  public static YAMLElementGenerator getInstance(Project project) {
+    return ServiceManager.getService(project, YAMLElementGenerator.class);
+  }
+  
+  @NotNull
+  public static String createChainedKey(@NotNull List<String> keyComponents, int indentAddition) {
+    StringBuilder sb = new StringBuilder();
+    for (int i = 0; i < keyComponents.size(); ++i) {
+      if (i > 0) {
+        sb.append(StringUtil.repeatSymbol(' ', indentAddition + 2 * i));
+      }
+      sb.append(keyComponents.get(i)).append(":");
+      if (i + 1 < keyComponents.size()) {
+        sb.append('\n');
+      }
+    }
+    return sb.toString();
+  }
+
+  @NotNull
+  public YAMLKeyValue createYamlKeyValue(@NotNull String keyName, @NotNull String valueText) {
+    final PsiFile tempFile = createDummyYamlWithText(keyName +  ": " + valueText);
+    return PsiTreeUtil.collectElementsOfType(tempFile, YAMLKeyValue.class).iterator().next();
+  }
+
+  @NotNull
+  public YAMLFile createDummyYamlWithText(@NotNull String text) {
+    return (YAMLFile) PsiFileFactory.getInstance(myProject)
+      .createFileFromText("temp." + YAMLFileType.YML.getDefaultExtension(), YAMLFileType.YML, text, LocalTimeCounter.currentTime(), true);
+  }
+  
+  @NotNull
+  public PsiElement createEol() {
+    final YAMLFile file = createDummyYamlWithText("\n");
+    return PsiTreeUtil.getDeepestFirst(file);
+  }
+  
+  @NotNull
+  public PsiElement createSpace() {
+    final YAMLKeyValue keyValue = createYamlKeyValue("foo", "bar");
+    final ASTNode whitespaceNode = keyValue.getNode().findChildByType(TokenType.WHITE_SPACE);
+    assert whitespaceNode != null;
+    return whitespaceNode.getPsi();
+  }
+  
+  @NotNull
+  public PsiElement createIndent(int size) {
+    final YAMLFile file = createDummyYamlWithText(StringUtil.repeatSymbol(' ', size));
+    return PsiTreeUtil.getDeepestFirst(file);
+  }
+  
+  @NotNull
+  public PsiElement createColon() {
+    final YAMLFile file = createDummyYamlWithText("? foo : bar");
+    final PsiElement at = file.findElementAt("? foo ".length());
+    assert at != null && at.getNode().getElementType() == YAMLTokenTypes.COLON;
+    return at;
+  }
+  
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLElementType.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLElementType.java
new file mode 100644 (file)
index 0000000..7da5bf1
--- /dev/null
@@ -0,0 +1,13 @@
+package org.jetbrains.yaml;
+
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NonNls;
+
+/**
+ * @author oleg
+ */
+public class YAMLElementType extends IElementType {
+  public YAMLElementType(@NonNls String debugName) {
+    super(debugName, YAMLFileType.YML.getLanguage());
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLElementTypes.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLElementTypes.java
new file mode 100644 (file)
index 0000000..143cb3c
--- /dev/null
@@ -0,0 +1,35 @@
+package org.jetbrains.yaml;
+
+import com.intellij.psi.tree.IFileElementType;
+import com.intellij.psi.tree.TokenSet;
+
+/**
+ * @author oleg
+ */
+public interface YAMLElementTypes {
+  IFileElementType FILE = new IFileElementType(YAMLLanguage.INSTANCE);
+
+  YAMLElementType DOCUMENT = new YAMLElementType("Document ---");
+
+  YAMLElementType KEY_VALUE_PAIR = new YAMLElementType("Key value pair");
+  //YAMLElementType VALUE = new YAMLElementType("Value");
+  YAMLElementType HASH = new YAMLElementType("Hash");
+  YAMLElementType ARRAY = new YAMLElementType("Array");
+  YAMLElementType SEQUENCE_ITEM = new YAMLElementType("Sequence item");
+  YAMLElementType COMPOUND_VALUE = new YAMLElementType("Compound value");
+  YAMLElementType MAPPING = new YAMLElementType("Mapping");
+  YAMLElementType SEQUENCE = new YAMLElementType("Sequence");
+  YAMLElementType SCALAR_LIST_VALUE = new YAMLElementType("Scalar list value");
+  YAMLElementType SCALAR_TEXT_VALUE = new YAMLElementType("Scalar text value");
+  YAMLElementType SCALAR_PLAIN_VALUE = new YAMLElementType("Scalar plain style");
+  YAMLElementType SCALAR_QUOTED_STRING = new YAMLElementType("Scalar quoted string");
+
+  TokenSet SCALAR_VALUES = TokenSet.create(
+    YAMLTokenTypes.SCALAR_TEXT,
+    YAMLTokenTypes.SCALAR_STRING,
+    YAMLTokenTypes.SCALAR_DSTRING,
+    YAMLTokenTypes.SCALAR_LIST,
+    YAMLTokenTypes.TEXT,
+    SCALAR_LIST_VALUE
+  );
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLFileType.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLFileType.java
new file mode 100644 (file)
index 0000000..911240d
--- /dev/null
@@ -0,0 +1,41 @@
+package org.jetbrains.yaml;
+
+import com.intellij.icons.AllIcons;
+import com.intellij.openapi.fileTypes.LanguageFileType;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+
+public class YAMLFileType extends LanguageFileType {
+  public static final YAMLFileType YML = new YAMLFileType();
+  @NonNls public static final String DEFAULT_EXTENSION = "yml";
+  @NonNls private static final String NAME = "YAML";
+  @NonNls private static final String DESCRIPTION = YAMLBundle.message("filetype.description.yaml");
+
+  private YAMLFileType() {
+    super(YAMLLanguage.INSTANCE);
+  }
+
+  @NotNull
+  public String getName() {
+    return NAME;
+  }
+
+  @NotNull
+  public String getDescription() {
+    return DESCRIPTION;
+  }
+
+  @NotNull
+  public String getDefaultExtension() {
+    return DEFAULT_EXTENSION;
+  }
+
+  @Nullable
+  public Icon getIcon() {
+    return AllIcons.Nodes.DataTables;
+  }
+}
+
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLFileTypeLoader.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLFileTypeLoader.java
new file mode 100644 (file)
index 0000000..28eb209
--- /dev/null
@@ -0,0 +1,14 @@
+package org.jetbrains.yaml;
+
+import com.intellij.openapi.fileTypes.FileTypeConsumer;
+import com.intellij.openapi.fileTypes.FileTypeFactory;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author oleg
+ */
+public class YAMLFileTypeLoader extends FileTypeFactory {
+  public void createFileTypes(final @NotNull FileTypeConsumer consumer) {
+    consumer.consume(YAMLFileType.YML, YAMLFileType.DEFAULT_EXTENSION + ";yaml");
+  }
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLHighlighter.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLHighlighter.java
new file mode 100644 (file)
index 0000000..76d650c
--- /dev/null
@@ -0,0 +1,56 @@
+package org.jetbrains.yaml;
+
+import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
+import com.intellij.openapi.editor.HighlighterColors;
+import com.intellij.openapi.editor.colors.TextAttributesKey;
+import org.jetbrains.annotations.NonNls;
+
+/**
+ * @author oleg
+ */
+public class YAMLHighlighter {
+  @NonNls
+  static final String SCALAR_KEY_ID = "YAML_SCALAR_KEY";
+  @NonNls
+  static final String SCALAR_TEXT_ID = "YAML_SCALAR_VALUE";
+  @NonNls
+  static final String SCALAR_STRING_ID = "YAML_SCALAR_STRING";
+  @NonNls
+  static final String SCALAR_DSTRING_ID = "YAML_SCALAR_DSTRING";
+  @NonNls
+  static final String SCALAR_LIST_ID = "YAML_SCALAR_LIST";
+  @NonNls
+  static final String COMMENT_ID = "YAML_COMMENT";
+  @NonNls
+  static final String TEXT_ID = "YAML_TEXT";
+  @NonNls
+  static final String SIGN_ID = "YAML_SIGN";
+
+  // Text default attrs
+  public static final TextAttributesKey SCALAR_KEY_DEFAULT_ATTRS = DefaultLanguageHighlighterColors.KEYWORD;
+  public static final TextAttributesKey COMMENT_DEFAULT_ATTRS = DefaultLanguageHighlighterColors.DOC_COMMENT;
+  public static final TextAttributesKey SCALAR_TEXT_DEFAULT_ATTRS = HighlighterColors.TEXT;
+  public static final TextAttributesKey SCALAR_STRING_DEFAULT_ATTRS = DefaultLanguageHighlighterColors.STRING;
+  public static final TextAttributesKey SCALAR_DSTRING_DEFAULT_ATTRS = DefaultLanguageHighlighterColors.STRING;
+  public static final TextAttributesKey SCALAR_LIST_DEFAULT_ATTRS = HighlighterColors.TEXT;
+  public static final TextAttributesKey TEXT_DEFAULT_ATTRS = HighlighterColors.TEXT;
+  public static final TextAttributesKey SIGN_DEFAULT_ATTRS = DefaultLanguageHighlighterColors.OPERATION_SIGN;
+
+  // text attributes keys
+  public static final TextAttributesKey SCALAR_KEY = TextAttributesKey
+    .createTextAttributesKey(SCALAR_KEY_ID, SCALAR_KEY_DEFAULT_ATTRS);
+  public static final TextAttributesKey SCALAR_TEXT = TextAttributesKey
+    .createTextAttributesKey(SCALAR_TEXT_ID, SCALAR_TEXT_DEFAULT_ATTRS);
+  public static final TextAttributesKey SCALAR_STRING =
+      TextAttributesKey.createTextAttributesKey(SCALAR_STRING_ID, SCALAR_STRING_DEFAULT_ATTRS);
+  public static final TextAttributesKey SCALAR_DSTRING =
+      TextAttributesKey.createTextAttributesKey(SCALAR_DSTRING_ID, SCALAR_DSTRING_DEFAULT_ATTRS);
+  public static final TextAttributesKey SCALAR_LIST = TextAttributesKey
+    .createTextAttributesKey(SCALAR_LIST_ID, SCALAR_LIST_DEFAULT_ATTRS);
+  public static final TextAttributesKey COMMENT = TextAttributesKey.createTextAttributesKey(COMMENT_ID, COMMENT_DEFAULT_ATTRS);
+  public static final TextAttributesKey TEXT = TextAttributesKey.createTextAttributesKey(TEXT_ID, TEXT_DEFAULT_ATTRS);
+  public static final TextAttributesKey SIGN = TextAttributesKey.createTextAttributesKey(SIGN_ID, SIGN_DEFAULT_ATTRS);
+
+  private YAMLHighlighter() {
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLLanguage.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLLanguage.java
new file mode 100644 (file)
index 0000000..b8ba079
--- /dev/null
@@ -0,0 +1,21 @@
+package org.jetbrains.yaml;
+
+import com.intellij.lang.Language;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author oleg
+ */
+public class YAMLLanguage extends Language {
+  public static final YAMLLanguage INSTANCE = new YAMLLanguage();
+
+  private YAMLLanguage() {
+    super("yaml");
+  }
+
+  @NotNull
+  @Override
+  public String getDisplayName() {
+    return "YAML";
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLLanguageCodeStyleSettingsProvider.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLLanguageCodeStyleSettingsProvider.java
new file mode 100644 (file)
index 0000000..6f0361f
--- /dev/null
@@ -0,0 +1,64 @@
+package org.jetbrains.yaml;
+
+import com.intellij.application.options.IndentOptionsEditor;
+import com.intellij.lang.Language;
+import com.intellij.openapi.application.ApplicationBundle;
+import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
+import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
+import org.jetbrains.annotations.NotNull;
+
+import javax.swing.*;
+
+/**
+ * @author oleg
+ */
+public class YAMLLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider {
+  @Override
+  public CommonCodeStyleSettings getDefaultCommonSettings() {
+    CommonCodeStyleSettings defaultSettings = new CommonCodeStyleSettings(YAMLLanguage.INSTANCE);
+    CommonCodeStyleSettings.IndentOptions indentOptions = defaultSettings.initIndentOptions();
+    indentOptions.INDENT_SIZE = 2;
+    indentOptions.USE_TAB_CHARACTER = false;
+    return defaultSettings;
+  }
+
+  @Override
+  public IndentOptionsEditor getIndentOptionsEditor() {
+    return new YAMLIndentOptionsEditor();
+  }
+
+  @NotNull
+  @Override
+  public Language getLanguage() {
+    return YAMLLanguage.INSTANCE;
+  }
+
+  @Override
+  public String getCodeSample(@NotNull SettingsType settingsType) {
+    return "product: \n" + "  name: RubyMine\n" + "  version: 8\n" + "  vendor: JetBrains\n" + "  url: \"https://www.jetbrains.com/ruby\"";
+  }
+
+  private class YAMLIndentOptionsEditor extends IndentOptionsEditor {
+
+    @Override
+    protected void addComponents() {
+      addTabOptions();
+      // Tabs in YAML are not allowed
+      myCbUseTab.setEnabled(false);
+
+      myTabSizeField = createIndentTextField();
+      myTabSizeLabel = new JLabel(ApplicationBundle.message("editbox.indent.tab.size"));
+      // Do not add
+      //add(myTabSizeLabel, myTabSizeField);
+
+      myIndentField = createIndentTextField();
+      myIndentLabel = new JLabel(ApplicationBundle.message("editbox.indent.indent"));
+      add(myIndentLabel, myIndentField);
+    }
+
+    public void setEnabled(boolean enabled) {
+      // Do nothing
+    }
+  }
+
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLPairedBraceMatcher.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLPairedBraceMatcher.java
new file mode 100644 (file)
index 0000000..63810c3
--- /dev/null
@@ -0,0 +1,32 @@
+package org.jetbrains.yaml;
+
+import com.intellij.lang.BracePair;
+import com.intellij.lang.PairedBraceMatcher;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author oleg
+ */
+public class YAMLPairedBraceMatcher implements PairedBraceMatcher, YAMLTokenTypes {
+    private static final BracePair[] PAIRS = new BracePair[]{
+            new BracePair(LBRACE, RBRACE, true),
+            new BracePair(LBRACKET, RBRACKET, true),
+    };
+
+    @NotNull
+    public BracePair[] getPairs() {
+        return PAIRS;
+    }
+
+    public boolean isPairedBracesAllowedBeforeType(@NotNull IElementType iElementType, @Nullable IElementType iElementType1) {
+        return true;
+    }
+
+  public int getCodeConstructStart(final PsiFile file, final int openingBraceOffset) {
+    return openingBraceOffset;
+  }
+}
+
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLParserDefinition.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLParserDefinition.java
new file mode 100644 (file)
index 0000000..c2443d1
--- /dev/null
@@ -0,0 +1,104 @@
+package org.jetbrains.yaml;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.lang.ParserDefinition;
+import com.intellij.lang.PsiParser;
+import com.intellij.lexer.Lexer;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.FileViewProvider;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.tree.IFileElementType;
+import com.intellij.psi.tree.TokenSet;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.yaml.lexer.YAMLFlexLexer;
+import org.jetbrains.yaml.parser.YAMLParser;
+import org.jetbrains.yaml.psi.impl.*;
+
+/**
+ * @author oleg
+ */
+public class YAMLParserDefinition implements ParserDefinition, YAMLElementTypes {
+  private static final TokenSet myCommentTokens = TokenSet.create(YAMLTokenTypes.COMMENT);
+
+  @NotNull
+  public Lexer createLexer(final Project project) {
+    return new YAMLFlexLexer();
+  }
+
+  @Nullable
+  public PsiParser createParser(final Project project) {
+    return new YAMLParser();
+  }
+
+  public IFileElementType getFileNodeType() {
+    return FILE;
+  }
+
+  @NotNull
+  public TokenSet getWhitespaceTokens() {
+    return TokenSet.create(YAMLTokenTypes.WHITESPACE);
+  }
+
+  @NotNull
+  public TokenSet getCommentTokens() {
+    return myCommentTokens;
+  }
+
+  @NotNull
+  public TokenSet getStringLiteralElements() {
+    return TokenSet.create(YAMLTokenTypes.SCALAR_STRING, YAMLTokenTypes.SCALAR_DSTRING, YAMLTokenTypes.TEXT);
+  }
+
+  @NotNull
+  public PsiElement createElement(final ASTNode node) {
+    final IElementType type = node.getElementType();
+    if (type == DOCUMENT){
+      return new YAMLDocumentImpl(node);
+    }
+    if (type == KEY_VALUE_PAIR) {
+      return new YAMLKeyValueImpl(node);
+    }
+    if (type == COMPOUND_VALUE) {
+      return new YAMLCompoundValueImpl(node);
+    }
+    if (type == SEQUENCE) {
+      return new YAMLBlockSequenceImpl(node);
+    }
+    if (type == MAPPING) {
+      return new YAMLBlockMappingImpl(node);
+    }
+    if (type == SEQUENCE_ITEM) {
+      return new YAMLSequenceItemImpl(node);
+    }
+    if (type == HASH) {
+      return new YAMLHashImpl(node);
+    }
+    if (type == ARRAY) {
+      return new YAMLArrayImpl(node);
+    }
+    if (type == SCALAR_LIST_VALUE) {
+      return new YAMLScalarListImpl(node);
+    }
+    if (type == SCALAR_TEXT_VALUE) {
+      return new YAMLScalarTextImpl(node);
+    }
+    if (type == SCALAR_PLAIN_VALUE) {
+      return new YAMLPlainTextImpl(node);
+    }
+    if (type == SCALAR_QUOTED_STRING) {
+      return new YAMLQuotedTextImpl(node);
+    }
+    return new YAMLPsiElementImpl(node);
+  }
+
+  public PsiFile createFile(final FileViewProvider viewProvider) {
+    return new YAMLFileImpl(viewProvider);
+  }
+
+  public SpaceRequirements spaceExistanceTypeBetweenTokens(final ASTNode left, final ASTNode right) {
+    return SpaceRequirements.MAY;
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLSyntaxHighlighter.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLSyntaxHighlighter.java
new file mode 100644 (file)
index 0000000..eaa6574
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2000-2008 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.yaml;
+
+import com.intellij.lexer.Lexer;
+import com.intellij.openapi.editor.colors.TextAttributesKey;
+import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.lexer.YAMLFlexLexer;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author: oleg
+ * @date: Feb 11, 2008
+ */
+public class YAMLSyntaxHighlighter extends SyntaxHighlighterBase implements YAMLTokenTypes {
+
+  private static final Map<IElementType, TextAttributesKey> ATTRIBUTES = new HashMap<IElementType, TextAttributesKey>();
+
+  static {
+    ATTRIBUTES.put(SCALAR_KEY, YAMLHighlighter.SCALAR_KEY);
+    ATTRIBUTES.put(SCALAR_STRING, YAMLHighlighter.SCALAR_STRING);
+    ATTRIBUTES.put(SCALAR_DSTRING, YAMLHighlighter.SCALAR_DSTRING);
+    ATTRIBUTES.put(SCALAR_TEXT, YAMLHighlighter.SCALAR_TEXT);
+    ATTRIBUTES.put(SCALAR_LIST, YAMLHighlighter.SCALAR_LIST);
+    ATTRIBUTES.put(COMMENT, YAMLHighlighter.COMMENT);
+    ATTRIBUTES.put(TEXT, YAMLHighlighter.TEXT);
+    ATTRIBUTES.put(LBRACE, YAMLHighlighter.SIGN);
+    ATTRIBUTES.put(RBRACE, YAMLHighlighter.SIGN);
+    ATTRIBUTES.put(LBRACKET, YAMLHighlighter.SIGN);
+    ATTRIBUTES.put(RBRACKET, YAMLHighlighter.SIGN);
+    ATTRIBUTES.put(COMMA, YAMLHighlighter.SIGN);
+    ATTRIBUTES.put(QUESTION, YAMLHighlighter.SIGN);
+    ATTRIBUTES.put(COLON, YAMLHighlighter.SIGN);
+    ATTRIBUTES.put(DOCUMENT_MARKER, YAMLHighlighter.SIGN);
+    ATTRIBUTES.put(SEQUENCE_MARKER, YAMLHighlighter.SIGN);
+  }
+
+
+  @NotNull
+  public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
+    return SyntaxHighlighterBase.pack(ATTRIBUTES.get(tokenType));
+  }
+
+  @NotNull
+  public Lexer getHighlightingLexer() {
+    return new YAMLFlexLexer();
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLSyntaxHighlighterFactory.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLSyntaxHighlighterFactory.java
new file mode 100644 (file)
index 0000000..e0b13ef
--- /dev/null
@@ -0,0 +1,17 @@
+package org.jetbrains.yaml;
+
+import com.intellij.openapi.fileTypes.SyntaxHighlighter;
+import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author yole
+ */
+public class YAMLSyntaxHighlighterFactory extends SyntaxHighlighterFactory {
+  @NotNull
+  public SyntaxHighlighter getSyntaxHighlighter(final Project project, final VirtualFile virtualFile) {
+    return new YAMLSyntaxHighlighter();
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLTokenTypes.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLTokenTypes.java
new file mode 100644 (file)
index 0000000..249d5d9
--- /dev/null
@@ -0,0 +1,34 @@
+package org.jetbrains.yaml;
+
+/**
+ * @author: oleg
+ */
+public interface YAMLTokenTypes {
+  YAMLElementType COMMENT = new YAMLElementType("comment");
+  YAMLElementType WHITESPACE = new YAMLElementType("whitespace");
+  YAMLElementType INDENT = new YAMLElementType("indent");
+  YAMLElementType EOL = new YAMLElementType("Eol");
+
+  YAMLElementType LBRACE = new YAMLElementType("{");
+  YAMLElementType RBRACE = new YAMLElementType("}");
+  YAMLElementType LBRACKET = new YAMLElementType("[");
+  YAMLElementType RBRACKET = new YAMLElementType("]");
+  YAMLElementType COMMA = new YAMLElementType(",");
+  YAMLElementType COLON = new YAMLElementType(":");
+  YAMLElementType QUESTION = new YAMLElementType("?");
+
+  YAMLElementType DOCUMENT_MARKER = new YAMLElementType("---");
+  YAMLElementType DOCUMENT_END = new YAMLElementType("...");
+  YAMLElementType SEQUENCE_MARKER = new YAMLElementType("-");
+
+  YAMLElementType TAG = new YAMLElementType("tag");
+
+  YAMLElementType SCALAR_KEY = new YAMLElementType("scalar key");
+  YAMLElementType TEXT = new YAMLElementType("text");
+
+  YAMLElementType SCALAR_STRING = new YAMLElementType("scalar string");
+  YAMLElementType SCALAR_DSTRING = new YAMLElementType("scalar dstring");
+
+  YAMLElementType SCALAR_LIST = new YAMLElementType("scalar list");
+  YAMLElementType SCALAR_TEXT = new YAMLElementType("scalar text");
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLUtil.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLUtil.java
new file mode 100644 (file)
index 0000000..bac170d
--- /dev/null
@@ -0,0 +1,288 @@
+package org.jetbrains.yaml;
+
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.ObjectUtils;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.yaml.psi.*;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author oleg
+ */
+public class YAMLUtil {
+
+  @NotNull
+  public static String getFullKey(final YAMLKeyValue yamlKeyValue) {
+    final StringBuilder builder = new StringBuilder();
+    YAMLKeyValue element = yamlKeyValue;
+    PsiElement parent;
+    while (element!=null &&
+           (parent = PsiTreeUtil.getParentOfType(element, YAMLKeyValue.class, YAMLDocument.class)) instanceof YAMLKeyValue){
+      if (builder.length()>0){
+        builder.insert(0, '.');
+      }
+      builder.insert(0, element.getKeyText());
+      element = (YAMLKeyValue) parent;
+    }
+    return builder.toString();
+  }
+  
+  @NotNull
+  public static Collection<YAMLKeyValue> getTopLevelKeys(final YAMLFile file) {
+    final YAMLValue topLevelValue = file.getDocuments().get(0).getTopLevelValue();
+    if (topLevelValue instanceof YAMLMapping) {
+      return ((YAMLMapping)topLevelValue).getKeyValues();
+    }
+    else {
+      return Collections.emptyList();
+    }
+  } 
+
+  @Nullable
+  public static YAMLKeyValue getQualifiedKeyInFile(final YAMLFile file, List<String> key) {
+    return getQualifiedKeyInDocument(file.getDocuments().get(0), key);
+  }
+
+  @Nullable
+  public static YAMLKeyValue getQualifiedKeyInDocument(@NotNull YAMLDocument document, @NotNull List<String> key) {
+    assert key.size() != 0;
+
+    YAMLMapping mapping = ObjectUtils.tryCast(document.getTopLevelValue(), YAMLMapping.class);
+    for (int i = 0; i < key.size(); i++) {
+      if (mapping == null) {
+        return null;
+      }
+
+      final YAMLKeyValue keyValue = mapping.getKeyValueByKey(key.get(i));
+      if (keyValue == null || i + 1 == key.size()) {
+        return keyValue;
+      }
+      
+      mapping = ObjectUtils.tryCast(keyValue.getValue(), YAMLMapping.class);
+    }
+    throw new IllegalStateException("Should have returned from the loop");
+  }
+
+  @Nullable
+  public static YAMLKeyValue getQualifiedKeyInFile(final YAMLFile file, String... key) {
+    return getQualifiedKeyInFile(file, Arrays.asList(key));
+  }
+
+  @Nullable
+  public static YAMLKeyValue findKeyInProbablyMapping(@Nullable YAMLValue node, @NotNull String keyText) {
+    if (!(node instanceof YAMLMapping)) {
+      return null;
+    }
+    return ((YAMLMapping)node).getKeyValueByKey(keyText);
+  }
+
+  @Nullable
+  public static Pair<PsiElement, String> getValue(final YAMLFile file, String... key) {
+    final YAMLKeyValue record = getQualifiedKeyInFile(file, key);
+    if (record != null) {
+      final PsiElement psiValue = record.getValue();
+      return Pair.create(psiValue, record.getValueText());
+    }
+    return null;
+  }
+
+  //public List<String> getAllKeys(final YAMLFile file){
+  //  return getAllKeys(file, ArrayUtil.EMPTY_STRING_ARRAY);
+  //}
+  //
+  //public List<String> getAllKeys(final YAMLFile file, final String[] key){
+  //  final YAMLPsiElement record = getQualifiedKeyInFile(file, key);
+  //  if (record == null){
+  //    return Collections.emptyList();
+  //  }
+  //  PsiElement psiValue = ((YAMLKeyValue)record).getValue();
+  //
+  //  final StringBuilder builder = new StringBuilder();
+  //  for (String keyPart : key) {
+  //    if (builder.length() != 0){
+  //      builder.append(".");
+  //    }
+  //    builder.append(keyPart);
+  //  }
+  //
+  //  final ArrayList<String> list = new ArrayList<String>();
+  //
+  //  addKeysRec(builder.toString(), psiValue, list);
+  //  return list;
+  //}
+
+  //private static void addKeysRec(final String prefix, final PsiElement element, final List<String> list) {
+  //  if (element instanceof YAMLCompoundValue){
+  //    for (YAMLPsiElement child : ((YAMLCompoundValue)element).getYAMLElements()) {
+  //      addKeysRec(prefix, child, list);
+  //    }
+  //  }
+  //  if (element instanceof YAMLKeyValue){
+  //    final YAMLKeyValue yamlKeyValue = (YAMLKeyValue)element;
+  //    final PsiElement psiValue = yamlKeyValue.getValue();
+  //    String key = yamlKeyValue.getKeyText();
+  //    if (prefix.length() > 0){
+  //      key = prefix + "." + key;
+  //    }
+  //    if (YAMLUtil.isScalarOrEmptyCompoundValue(psiValue)) {
+  //      list.add(key);
+  //    } else {
+  //      addKeysRec(key, psiValue, list);
+  //    }
+  //  }
+  //}
+
+  public YAMLKeyValue createI18nRecord(final YAMLFile file, final String key, final String text) {
+    return createI18nRecord(file, key.split("\\."), text);
+  }
+
+  @Nullable
+  public static YAMLKeyValue createI18nRecord(final YAMLFile file, final String[] key, final String text) {
+    final YAMLDocument root = file.getDocuments().get(0);
+    assert root != null;
+    assert key.length > 0;
+
+    YAMLMapping rootMapping = PsiTreeUtil.findChildOfType(root, YAMLMapping.class);
+    if (rootMapping == null) {
+      final YAMLFile yamlFile = YAMLElementGenerator.getInstance(file.getProject()).createDummyYamlWithText(key[0] + ":");
+      final YAMLMapping mapping = (YAMLMapping) yamlFile.getDocuments().get(0).getTopLevelValue();
+      assert mapping != null;
+      rootMapping = ((YAMLMapping)root.add(mapping));
+    }
+
+    YAMLMapping current = rootMapping;
+    final int keyLength = key.length;
+    int i;
+    for (i = 0; i < keyLength; i++) {
+      final YAMLKeyValue existingRec = current.getKeyValueByKey(key[i]);
+      if (existingRec != null){
+        final YAMLMapping nextMapping = ObjectUtils.tryCast(existingRec.getValue(), YAMLMapping.class);
+
+        if (nextMapping != null) {
+          current = nextMapping;
+          continue;
+        }
+      }
+
+      // Calc current key indent
+
+      String indent = StringUtil.repeatSymbol(' ', getIndentInThisLine(current));
+
+      // Generate items
+      final StringBuilder builder = new StringBuilder();
+      builder.append("---");
+      for (int j = i; j < keyLength; j++) {
+        builder.append("\n").append(indent);
+        builder.append(key[j]).append(":");
+        indent += "  ";
+      }
+      builder.append(" ").append(text);
+
+      // Create dummy mapping
+      final YAMLFile fileWithKey = YAMLElementGenerator.getInstance(file.getProject()).createDummyYamlWithText(builder.toString());
+      final YAMLMapping dummyMapping = PsiTreeUtil.findChildOfType(fileWithKey.getDocuments().get(0), YAMLMapping.class);
+      assert dummyMapping != null && dummyMapping.getKeyValues().size() == 1;
+
+      // Add or replace
+      final YAMLKeyValue dummyKeyValue = dummyMapping.getKeyValues().iterator().next();
+      current.putKeyValue(dummyKeyValue);
+
+      if (!(dummyKeyValue.getValue() instanceof YAMLMapping)) {
+        return dummyKeyValue;
+      }
+      else {
+        current = ((YAMLMapping)dummyKeyValue.getValue());
+      }
+  
+    }
+
+    // Conflict with existing value
+    final StringBuilder builder = new StringBuilder();
+    final int top = Math.min(i + 1, keyLength);
+    for (int j=0;j<top;j++){
+      if (builder.length() > 0){
+        builder.append('.');
+      }
+      builder.append(key[j]);
+    }
+    throw new IncorrectOperationException(YAMLBundle.message("new.name.conflicts.with", builder.toString()));
+  }
+
+  //public static void removeI18nRecord(final YAMLFile file, final String[] key){
+  //  PsiElement element = getQualifiedKeyInFile(file, key);
+  //  while (element != null){
+  //    final PsiElement parent = element.getParent();
+  //    if (parent instanceof YAMLDocument) {
+  //      ((YAMLKeyValue)element).getValue().delete();
+  //      return;
+  //    }
+  //    if (parent instanceof YAMLCompoundValue) {
+  //      if (((YAMLCompoundValue)parent).getYAMLElements().size() > 1) {
+  //        element.delete();
+  //        return;
+  //      }
+  //    }
+  //    element = parent;
+  //  }
+  //}
+
+  public static PsiElement rename(final YAMLKeyValue element, final String newName) {
+    if (newName.contains(".")){
+      throw new IncorrectOperationException(YAMLBundle.message("rename.wrong.name"));
+    }
+    if (newName.equals(element.getName())){
+      throw new IncorrectOperationException(YAMLBundle.message("rename.same.name"));
+    }
+    final YAMLKeyValue topKeyValue = YAMLElementGenerator.getInstance(element.getProject()).createYamlKeyValue(newName, "Foo");
+
+    final PsiElement key = element.getKey();
+    if (key == null || topKeyValue.getKey() == null) {
+      throw new IllegalStateException();
+    }
+    key.replace(topKeyValue.getKey());
+    return element;
+  }
+
+  public static int getIndentInThisLine(@NotNull final PsiElement elementInLine) {
+    PsiElement currentElement = elementInLine;
+    while (currentElement != null) {
+      final IElementType type = currentElement.getNode().getElementType();
+      if (type == YAMLTokenTypes.EOL) {
+        return 0;
+      }
+      if (type == YAMLTokenTypes.INDENT) {
+        return currentElement.getTextLength();
+      }
+
+      currentElement = PsiTreeUtil.prevLeaf(currentElement);
+    }
+    return 0;
+  }
+  
+  public static int getIndentToThisElement(@NotNull final PsiElement element) {
+    int offset = element.getTextOffset();
+
+    PsiElement currentElement = element;
+    while (currentElement != null) {
+      final IElementType type = currentElement.getNode().getElementType();
+      if (type == YAMLTokenTypes.EOL) {
+        return offset - currentElement.getTextOffset() - 1;
+      }
+
+      currentElement = PsiTreeUtil.prevLeaf(currentElement);
+    }
+    return offset;
+  }
+
+  
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/completion/YamlKeyCompletionInsertHandler.java b/plugins/yaml/src/org/jetbrains/yaml/completion/YamlKeyCompletionInsertHandler.java
new file mode 100644 (file)
index 0000000..543008a
--- /dev/null
@@ -0,0 +1,116 @@
+package org.jetbrains.yaml.completion;
+
+import com.intellij.codeInsight.completion.InsertHandler;
+import com.intellij.codeInsight.completion.InsertionContext;
+import com.intellij.codeInsight.lookup.LookupElement;
+import com.intellij.openapi.command.WriteCommandAction;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.EditorModificationUtil;
+import com.intellij.psi.PsiDocumentManager;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.util.PsiTreeUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.yaml.YAMLElementGenerator;
+import org.jetbrains.yaml.YAMLTokenTypes;
+import org.jetbrains.yaml.psi.YAMLDocument;
+import org.jetbrains.yaml.psi.YAMLKeyValue;
+import org.jetbrains.yaml.psi.YAMLValue;
+
+public abstract class YamlKeyCompletionInsertHandler<T extends LookupElement> implements InsertHandler<T> {
+
+  @NotNull
+  protected abstract YAMLKeyValue createNewEntry(@NotNull YAMLDocument document, T item);
+
+  @Override
+  public void handleInsert(InsertionContext context, T item) {
+    final PsiElement currentElement = context.getFile().findElementAt(context.getStartOffset());
+    assert currentElement != null : "no element at " + context.getStartOffset();
+
+    final YAMLDocument holdingDocument = PsiTreeUtil.getParentOfType(currentElement, YAMLDocument.class);
+    assert holdingDocument != null;
+
+    final YAMLValue oldValue = deleteLookupTextAndRetrieveOldValue(context, currentElement);
+    final YAMLKeyValue created = createNewEntry(holdingDocument, item);
+
+    context.getEditor().getCaretModel().moveToOffset(created.getTextRange().getEndOffset());
+    if (oldValue != null) {
+      WriteCommandAction.runWriteCommandAction(context.getProject(), new Runnable() {
+        @Override
+        public void run() {
+          created.setValue(oldValue);
+        }
+      });
+    }
+
+    PsiDocumentManager.getInstance(context.getProject()).doPostponedOperationsAndUnblockDocument(context.getDocument());
+
+    if (!isCharAtCaret(context.getEditor(), ' ')) {
+      EditorModificationUtil.insertStringAtCaret(context.getEditor(), " ");
+    }
+    else {
+      context.getEditor().getCaretModel().moveCaretRelatively(1, 0, false, false, true);
+    }
+  }
+
+  @Nullable
+  protected YAMLValue deleteLookupTextAndRetrieveOldValue(InsertionContext context, @NotNull PsiElement elementAtCaret) {
+    final YAMLValue oldValue;
+    if (elementAtCaret.getNode().getElementType() != YAMLTokenTypes.SCALAR_KEY) {
+      deleteLookupPlain(context);
+      return null;
+    }
+
+    final YAMLKeyValue keyValue = PsiTreeUtil.getParentOfType(elementAtCaret, YAMLKeyValue.class);
+    assert keyValue != null;
+
+    context.commitDocument();
+    if (keyValue.getValue() != null) {
+      // Save old value somewhere
+      final YAMLKeyValue dummyKV = YAMLElementGenerator.getInstance(context.getProject()).createYamlKeyValue("foo", "b");
+      dummyKV.setValue(keyValue.getValue());
+      oldValue = dummyKV.getValue();
+    }
+    else {
+      oldValue = null;
+    }
+
+    context.setTailOffset(keyValue.getTextRange().getEndOffset());
+    WriteCommandAction.runWriteCommandAction(context.getProject(), new Runnable() {
+      @Override
+      public void run() {
+        keyValue.getParentMapping().deleteKeyValue(keyValue);
+      }
+    });
+    return oldValue;
+  }
+
+  private static void deleteLookupPlain(InsertionContext context) {
+    final Document document = context.getDocument();
+    final CharSequence sequence = document.getCharsSequence();
+    int offset = context.getStartOffset() - 1;
+    while (offset >= 0) {
+      final char c = sequence.charAt(offset);
+      if (c != ' ' && c != '\t') {
+        if (c == '\n') {
+          offset--;
+        }
+        else {
+          offset = context.getStartOffset() - 1;
+        }
+        break;
+      }
+      offset--;
+    }
+
+    document.deleteString(offset + 1, context.getTailOffset());
+    context.commitDocument();
+  }
+
+  public static boolean isCharAtCaret(Editor editor, char ch) {
+    final int startOffset = editor.getCaretModel().getOffset();
+    final Document document = editor.getDocument();
+    return document.getTextLength() > startOffset && document.getCharsSequence().charAt(startOffset) == ch;
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/folding/YAMLFoldingBuilder.java b/plugins/yaml/src/org/jetbrains/yaml/folding/YAMLFoldingBuilder.java
new file mode 100644 (file)
index 0000000..f61a88f
--- /dev/null
@@ -0,0 +1,75 @@
+package org.jetbrains.yaml.folding;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.lang.folding.FoldingBuilder;
+import com.intellij.lang.folding.FoldingDescriptor;
+import com.intellij.openapi.editor.Document;
+import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.tree.TokenSet;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.yaml.YAMLElementTypes;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @author oleg
+ */
+public class YAMLFoldingBuilder implements FoldingBuilder, DumbAware {
+
+  @NotNull
+  public FoldingDescriptor[] buildFoldRegions(@NotNull ASTNode astNode, @NotNull Document document) {
+    List<FoldingDescriptor> descriptors = new LinkedList<FoldingDescriptor>();
+    collectDescriptors(astNode, descriptors);
+    return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
+  }
+
+  private static void collectDescriptors(@NotNull final ASTNode node, @NotNull final List<FoldingDescriptor> descriptors) {
+    final IElementType type = node.getElementType();
+    final TextRange nodeTextRange = node.getTextRange();
+    if (!StringUtil.isEmptyOrSpaces(node.getText()) && nodeTextRange.getLength() >= 2) {
+      if (type == YAMLElementTypes.KEY_VALUE_PAIR) {
+        final ASTNode valueNode = node.findChildByType(YAMLElementTypes.COMPOUND_VALUE);
+        // We should ignore empty compound values
+        if (valueNode != null && !StringUtil.isEmpty(valueNode.getText().trim())){
+          descriptors.add(new FoldingDescriptor(node, nodeTextRange));
+        }
+      }
+      if (type == YAMLElementTypes.DOCUMENT &&
+          node.getTreeParent().getChildren(TokenSet.create(YAMLElementTypes.DOCUMENT)).length > 1){
+        descriptors.add(new FoldingDescriptor(node, nodeTextRange));
+      }
+      if (type == YAMLElementTypes.SCALAR_TEXT_VALUE
+          || type == YAMLElementTypes.SCALAR_LIST_VALUE
+          || type == YAMLElementTypes.SCALAR_PLAIN_VALUE) {
+        descriptors.add(new FoldingDescriptor(node, nodeTextRange));
+      }
+    }
+    for (ASTNode child : node.getChildren(null)) {
+      collectDescriptors(child, descriptors);
+    }
+  }
+
+  @Nullable
+  public String getPlaceholderText(@NotNull ASTNode node) {
+    final IElementType type = node.getElementType();
+    if (type == YAMLElementTypes.DOCUMENT){
+      return "---";
+    }
+    if (type == YAMLElementTypes.KEY_VALUE_PAIR){
+      return node.getFirstChildNode().getText();
+    }
+    if (type == YAMLElementTypes.SCALAR_TEXT_VALUE || type == YAMLElementTypes.SCALAR_LIST_VALUE) {
+      return node.getText().substring(0, 1);
+    }
+    return "...";
+  }
+
+  public boolean isCollapsedByDefault(@NotNull ASTNode node) {
+    return false;
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/lexer/YAMLFlexLexer.java b/plugins/yaml/src/org/jetbrains/yaml/lexer/YAMLFlexLexer.java
new file mode 100644 (file)
index 0000000..7c0cab0
--- /dev/null
@@ -0,0 +1,61 @@
+package org.jetbrains.yaml.lexer;
+
+import com.intellij.lexer.FlexAdapter;
+import com.intellij.lexer.MergingLexerAdapter;
+import com.intellij.psi.tree.TokenSet;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.YAMLTokenTypes;
+
+import java.io.Reader;
+
+/**
+ * @author oleg
+ */
+public class YAMLFlexLexer extends MergingLexerAdapter {
+  private static final TokenSet TOKENS_TO_MERGE = TokenSet.create(YAMLTokenTypes.TEXT);
+  
+  private static final int DIRTY_STATE = 239;
+
+  public YAMLFlexLexer() {
+    super(new MyFlexAdapter(new _YAMLLexer((Reader) null)), TOKENS_TO_MERGE);
+  }
+
+  private static class MyFlexAdapter extends FlexAdapter {
+
+    private boolean myStateCleanliness = false;
+
+    public MyFlexAdapter(_YAMLLexer flex) {
+      super(flex);
+    }
+
+    @Override
+    public void start(@NotNull CharSequence buffer, int startOffset, int endOffset, int initialState) {
+      if (initialState != DIRTY_STATE) {
+        ((_YAMLLexer)getFlex()).cleanMyState();
+      }
+      else {
+        // That should not occur normally, but some complex lexers (e.g. black and white lexer)
+        // require "suspending" of the lexer to pass some template language. In these cases we
+        // believe that the same instance of the lexer would be restored (with its internal state) 
+        initialState = 0;
+      }
+
+      super.start(buffer, startOffset, endOffset, initialState);
+    }
+
+    @Override
+    public int getState() {
+      final int state = super.getState();
+      if (state != 0 || myStateCleanliness) {
+        return state;
+      }
+      return DIRTY_STATE;
+    }
+
+    @Override
+    protected void locateToken() {
+      myStateCleanliness = ((_YAMLLexer)getFlex()).isCleanState();
+      super.locateToken();
+    }
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/lexer/yaml.flex b/plugins/yaml/src/org/jetbrains/yaml/lexer/yaml.flex
new file mode 100644 (file)
index 0000000..dd5e415
--- /dev/null
@@ -0,0 +1,391 @@
+package org.jetbrains.yaml.lexer;
+
+import com.intellij.lexer.FlexLexer;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.yaml.YAMLTokenTypes;
+
+/* Auto generated File */
+%%
+
+%class _YAMLLexer
+%implements FlexLexer, YAMLTokenTypes
+%unicode
+%public
+
+%function advance
+%type IElementType
+
+%eof{ return;
+%eof}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////// USER CODE //////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+%{
+  private int currentLineIndent = 0;
+  private int valueIndent = -1;
+  private int braceCount = 0;
+  private IElementType valueTokenType = null;
+  private int previousState = YYINITIAL;
+
+  public boolean isCleanState() {
+    return yystate() == YYINITIAL
+      && currentLineIndent == 0
+      && braceCount == 0;
+  }
+
+  public void cleanMyState() {
+    currentLineIndent = 0;
+    braceCount = 0;
+  }
+
+  private char previousChar() {
+    return getChar(-1);
+  }
+
+  private char getChar(final int offset) {
+    final int loc = getTokenStart()  + offset;
+    return 0 <= loc && loc < zzBuffer.length() ? zzBuffer.charAt(loc) : (char) -1;
+  }
+
+  private char getCharAfter(final int offset) {
+    final int loc = getTokenEnd()  + offset;
+    return 0 <= loc && loc < zzBuffer.length() ? zzBuffer.charAt(loc) : (char) -1;
+  }
+
+  private IElementType getWhitespaceTypeAndUpdateIndent() {
+    if (isAfterEol()) {
+      currentLineIndent = yylength();
+      return INDENT;
+    }
+    else {
+      return WHITESPACE;
+    }
+  }
+
+  private boolean isAfterEol() {
+    final char prev = previousChar();
+    return prev == (char)-1 || prev == '\n';
+  }
+
+  private boolean isAfterSpace() {
+    final char prev = previousChar();
+    return prev == (char)-1 || prev == '\t' || prev == ' ';
+  }
+
+  private void yyBegin(int newState) {
+    //System.out.println("yybegin(): " + newState);
+    yybegin(newState);
+  }
+
+  private boolean startsWith(CharSequence haystack, CharSequence needle) {
+    for (int i = Math.min(haystack.length(), needle.length()) - 1; i >= 0; i--) {
+      if (haystack.charAt(i) != needle.charAt(i)) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  private IElementType tokenOrForbidden(IElementType tokenType) {
+    if (!isAfterEol() || yylength() < 3) {
+      return tokenType;
+    }
+
+    if (startsWith(yytext(), "---")) {
+      braceCount = 0;
+      yyBegin(YYINITIAL);
+      yypushback(yylength() - 3);
+      return DOCUMENT_MARKER;
+    }
+    if (startsWith(yytext(), "...")) {
+      braceCount = 0;
+      yyBegin(YYINITIAL);
+      yypushback(yylength() - 3);
+      return DOCUMENT_END;
+    }
+    return tokenType;
+  }
+%}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////////////////////// REGEXPS DECLARATIONS //////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// NB !(!a|b) is "a - b"
+// From the spec
+ANY_CHAR = [^\n] | "\n"
+
+NS_CHAR = [^\n\t\r\ ]
+NS_INDICATOR = [-?:,\[\]\{\}#&*!|>'\"%@`]
+
+NS_PLAIN_SAFE_flow  = [^\n\r\t\ ,\[\]\{\}] // NS_CHAR - flow indicators
+NS_PLAIN_SAFE_block = {NS_CHAR}
+
+NS_PLAIN_FIRST_flow  = !(!{NS_CHAR}|{NS_INDICATOR}) | [?:-] {NS_PLAIN_SAFE_flow}
+NS_PLAIN_FIRST_block = !(!{NS_CHAR}|{NS_INDICATOR}) | [?:-] {NS_PLAIN_SAFE_block}
+
+NS_PLAIN_CHAR_flow  = {NS_CHAR} "#" | !(!{NS_PLAIN_SAFE_flow}|[:#])  | ":" {NS_PLAIN_SAFE_flow}
+NS_PLAIN_CHAR_block = {NS_CHAR} "#" | !(!{NS_PLAIN_SAFE_block}|[:#]) | ":" {NS_PLAIN_SAFE_block}
+
+NB_NS_PLAIN_IN_LINE_flow  = ({WHITE_SPACE_CHAR}* {NS_PLAIN_CHAR_flow})*
+NB_NS_PLAIN_IN_LINE_block = ({WHITE_SPACE_CHAR}* {NS_PLAIN_CHAR_block})*
+
+NS_PLAIN_ONE_LINE_flow  = {NS_PLAIN_FIRST_flow}  {NB_NS_PLAIN_IN_LINE_flow}
+NS_PLAIN_ONE_LINE_block = {NS_PLAIN_FIRST_block} {NB_NS_PLAIN_IN_LINE_block}
+
+EOL =                           "\n"
+WHITE_SPACE_CHAR =              [ \t]
+WHITE_SPACE =                   {WHITE_SPACE_CHAR}+
+
+LINE =                          .*
+COMMENT =                       "#"{LINE}
+
+ID =                            [^\n\-\ {}\[\]#][^\n{}\[\]>:#]*
+
+KEY_flow = {NS_PLAIN_ONE_LINE_flow} {WHITE_SPACE_CHAR}* ":"
+KEY_block = {NS_PLAIN_ONE_LINE_block} {WHITE_SPACE_CHAR}* ":"
+
+INJECTION =                     ("{{" {ID} "}"{0,2}) | ("%{" [^}\n]* "}"?)
+
+ESCAPE_SEQUENCE=                \\[^\n]
+DSTRING_SINGLE_LINE=            \"([^\\\"\n]|{ESCAPE_SEQUENCE})*\"
+DSTRING=                        \"([^\\\"]|{ESCAPE_SEQUENCE}|\\\n)*\"
+STRING_SINGLE_LINE=             '([^'\n]|'')*'
+STRING=                         '([^']|'')*'
+NS_HEX_DIGIT = [[:digit:]a-fA-F]
+NS_WORD_CHAR = [:digit:] | "-" | [a-zA-Z]
+NS_URI_CHAR =  "%" {NS_HEX_DIGIT} {NS_HEX_DIGIT} | {NS_WORD_CHAR} | [#;\/?:@&=+$,_.!~*'()\[\]]
+C_VERBATIM_TAG = "!" "<" {NS_URI_CHAR}+ ">"
+NS_TAG_CHAR = "%" {NS_HEX_DIGIT} {NS_HEX_DIGIT} | {NS_WORD_CHAR} | [#;\/?:@&=+$_.~*'()]
+C_TAG_HANDLE = "!" {NS_WORD_CHAR}+ "!" | "!" "!" | "!"
+C_NS_SHORTHAND_TAG = {C_TAG_HANDLE} {NS_TAG_CHAR}+
+C_NON_SPECIFIC_TAG = "!"
+C_NS_TAG_PROPERTY = {C_VERBATIM_TAG} | {C_NS_SHORTHAND_TAG} | {C_NON_SPECIFIC_TAG}
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////// STATES DECLARATIONS //////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+%xstate BRACES, VALUE, VALUE_OR_KEY, VALUE_BRACE, INDENT_VALUE
+
+%%
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//////// RULES declarations ////////////////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+<YYINITIAL, BRACES, VALUE, VALUE_BRACE, VALUE_OR_KEY> {
+
+{COMMENT}                       {
+                                  // YAML spec: when a comment follows another syntax element,
+                                  //  it must be separated from it by space characters.
+                                  return (isAfterEol() || isAfterSpace()) ? COMMENT : TEXT;
+                                }
+
+{EOL}                           {   if (braceCount == 0) {
+                                      yyBegin(YYINITIAL);
+                                    }
+                                    currentLineIndent = 0;
+                                    return EOL;
+                                }
+"["                             {   braceCount++;
+                                    if (braceCount != 0 && yystate() != BRACES) {
+                                      previousState = yystate();
+                                    }
+                                    yyBegin(braceCount == 0 ? previousState: BRACES);
+                                    return LBRACKET;
+                                }
+"]"                             {   if (braceCount == 0) {
+                                      yyBegin(VALUE);
+                                      return TEXT;
+                                    }
+                                    braceCount--;
+                                    if (yystate() == BRACES && braceCount == 0){
+                                      yyBegin(previousState);
+                                    }
+                                    return RBRACKET;
+                                }
+
+","                             {   if (braceCount > 0) {
+                                      yyBegin(BRACES);
+                                      return COMMA;
+                                    }
+                                    yyBegin(VALUE);
+                                    return TEXT;
+                                }
+":" / ({WHITE_SPACE} | {EOL})   {   return COLON; }
+"?"                             {   return QUESTION; }
+
+{C_NS_TAG_PROPERTY} / ({WHITE_SPACE} | {EOL}) {
+  return TAG;
+}
+
+}
+
+<YYINITIAL, BRACES, VALUE_OR_KEY> {
+
+
+{STRING_SINGLE_LINE} ":" {
+  return SCALAR_KEY;
+}
+
+{DSTRING_SINGLE_LINE} ":" {
+  return SCALAR_KEY;
+}
+
+
+}
+
+<BRACES> {
+{KEY_flow} / !(!{ANY_CHAR}|{NS_PLAIN_SAFE_flow}) {
+  yyBegin(VALUE_BRACE);
+  return SCALAR_KEY;
+}
+
+}
+
+<YYINITIAL, VALUE_OR_KEY> {
+{KEY_block} / !(!{ANY_CHAR}|{NS_PLAIN_SAFE_block}) {
+  yyBegin(VALUE);
+  return SCALAR_KEY;
+}
+}
+
+<YYINITIAL, BRACES, VALUE, VALUE_BRACE, VALUE_OR_KEY> {
+
+{WHITE_SPACE}                   { return getWhitespaceTypeAndUpdateIndent(); }
+
+}
+
+<YYINITIAL, BRACES>{
+
+"---" |
+"..." {
+   return tokenOrForbidden(TEXT);
+}
+
+"-" / ({WHITE_SPACE} | {EOL})   {   yyBegin(VALUE_OR_KEY);
+                                    return SEQUENCE_MARKER; }
+
+}
+
+
+<YYINITIAL, BRACES, VALUE, VALUE_BRACE, VALUE_OR_KEY>{
+
+{STRING} {
+ return SCALAR_STRING;
+}
+
+{DSTRING} {
+ return SCALAR_DSTRING;
+}
+
+}
+
+<YYINITIAL, VALUE, VALUE_BRACE, VALUE_OR_KEY>{
+
+">"("-"|"+")? / ({WHITE_SPACE} | {EOL})      {
+                                    yyBegin(INDENT_VALUE);
+                                    valueIndent = currentLineIndent;
+                                    valueTokenType = SCALAR_TEXT;
+                                    return valueTokenType;
+                                }
+
+"|"("-"|"+")? / ({WHITE_SPACE} | {EOL})
+                                {   yyBegin(INDENT_VALUE);
+                                    valueIndent = currentLineIndent;
+                                    valueTokenType = SCALAR_LIST;
+                                    return valueTokenType;
+                                }
+
+}
+
+<YYINITIAL, VALUE, VALUE_OR_KEY> {
+  {INJECTION}? {NS_PLAIN_ONE_LINE_block} {
+    return tokenOrForbidden(TEXT);
+  }
+}
+
+<BRACES, VALUE_BRACE> {
+  {INJECTION}? {NS_PLAIN_ONE_LINE_flow} {
+    return tokenOrForbidden(TEXT);
+  }
+}
+
+<YYINITIAL, BRACES, VALUE, VALUE_BRACE, VALUE_OR_KEY> {
+"{"                             {   braceCount++;
+                                    if (braceCount != 0 && yystate() != BRACES) {
+                                      previousState = yystate();
+                                    }
+                                    yyBegin(braceCount == 0 ? previousState: BRACES);
+                                    return LBRACE;
+                                }
+"}"                             {   if (braceCount == 0) {
+                                      yyBegin(VALUE);
+                                      return TEXT;
+                                    }
+                                    braceCount--;
+                                    if (yystate() == BRACES && braceCount == 0){
+                                      yyBegin(previousState);
+                                    }
+                                    return RBRACE;
+                                }
+}
+
+<VALUE, VALUE_BRACE, VALUE_OR_KEY>{
+.                               {   return TEXT; }
+}
+
+<YYINITIAL, BRACES> {
+. {
+  return TEXT;
+}
+}
+
+<INDENT_VALUE> {
+
+{EOL} {
+          currentLineIndent = 0;
+          return EOL;
+      }
+
+{WHITE_SPACE} / {EOL}                    {
+                                            return getWhitespaceTypeAndUpdateIndent();
+                                        }
+{WHITE_SPACE}                           {   IElementType type = getWhitespaceTypeAndUpdateIndent();
+                                            if (currentLineIndent <= valueIndent) {
+                                              yyBegin(YYINITIAL);
+                                            }
+                                            return type;
+                                        }
+[^ \n\t] {LINE}?                        {   if (currentLineIndent <= valueIndent) {
+                                                yypushback(yylength());
+                                                yyBegin(YYINITIAL);
+                                                break;
+                                            } else {
+                                                return valueTokenType;
+                                            }
+                                        }
+}
+
+// Rules for matching EOLs
+<BRACES> {
+
+{KEY_flow} {
+  if (zzMarkedPos == zzEndRead){
+    return SCALAR_KEY;
+  }
+  yyBegin(VALUE);
+  return tokenOrForbidden(TEXT);
+}
+
+}
+
+<YYINITIAL, VALUE_OR_KEY> {
+{KEY_block} {
+  if (zzMarkedPos == zzEndRead){
+    return SCALAR_KEY;
+  }
+  yyBegin(VALUE);
+  return tokenOrForbidden(TEXT);
+}
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/parser/YAMLParser.java b/plugins/yaml/src/org/jetbrains/yaml/parser/YAMLParser.java
new file mode 100644 (file)
index 0000000..9138502
--- /dev/null
@@ -0,0 +1,442 @@
+package org.jetbrains.yaml.parser;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.lang.PsiBuilder;
+import com.intellij.lang.PsiParser;
+import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.tree.TokenSet;
+import com.intellij.util.containers.Stack;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.yaml.YAMLElementTypes;
+import org.jetbrains.yaml.YAMLTokenTypes;
+
+/**
+ * @author oleg
+ */
+public class YAMLParser implements PsiParser, YAMLTokenTypes {
+  public static final TokenSet HASH_STOP_TOKENS = TokenSet.create(RBRACE, COMMA);
+  public static final TokenSet ARRAY_STOP_TOKENS = TokenSet.create(RBRACKET, COMMA);
+  private PsiBuilder myBuilder;
+  private boolean eolSeen = false;
+  private int myIndent;
+  private PsiBuilder.Marker myAfterLastEolMarker;
+
+  private final Stack<TokenSet> myStopTokensStack = new Stack<TokenSet>();
+
+  @NotNull
+  public ASTNode parse(@NotNull final IElementType root, @NotNull final PsiBuilder builder) {
+    myBuilder = builder;
+    myStopTokensStack.clear();
+    final PsiBuilder.Marker fileMarker = mark();
+    parseFile();
+    assert myBuilder.eof() : "Not all tokens were passed.";
+    fileMarker.done(root);
+    return builder.getTreeBuilt();
+  }
+
+  private void parseFile() {
+    passJunk();
+    parseDocument();
+    passJunk();
+    while (!myBuilder.eof()) {
+      parseDocument();
+      passJunk();
+    }
+    dropEolMarker();
+  }
+
+  private void parseDocument() {
+    final PsiBuilder.Marker marker = mark();
+    if (myBuilder.getTokenType() == DOCUMENT_MARKER) {
+      advanceLexer();
+    }
+    parseBlockNode(0, false);
+    dropEolMarker();
+    marker.done(YAMLElementTypes.DOCUMENT);
+  }
+
+  private void parseBlockNode(int indent, boolean insideSequence) {
+    passJunk();
+
+    final PsiBuilder.Marker marker = mark();
+    PsiBuilder.Marker endOfNodeMarker = null;
+    IElementType nodeType = null;
+    
+    
+    // It looks like tag for a block node should be located on a separate line 
+    if (getTokenType() == YAMLTokenTypes.TAG && myBuilder.lookAhead(1) == YAMLTokenTypes.EOL) {
+      advanceLexer();
+    }
+
+    int numberOfItems = 0;
+    while (!eof() && (isJunk() || !eolSeen || myIndent + getIndentBonus(insideSequence) >= indent)) {
+      if (isJunk()) {
+        advanceLexer();
+        continue;
+      }
+
+      if (!myStopTokensStack.isEmpty() && myStopTokensStack.peek().contains(getTokenType())) {
+        rollBackToEol();
+        break;
+      }
+
+      numberOfItems++;
+      final IElementType parsedTokenType = parseSingleStatement(eolSeen ? myIndent : indent);
+      if (nodeType == null) {
+        if (parsedTokenType == YAMLElementTypes.SEQUENCE_ITEM) {
+          nodeType = YAMLElementTypes.SEQUENCE;
+        }
+        else if (parsedTokenType == YAMLElementTypes.KEY_VALUE_PAIR) {
+          nodeType = YAMLElementTypes.MAPPING;
+        }
+        else if (numberOfItems > 1) {
+          nodeType = YAMLElementTypes.COMPOUND_VALUE;
+        }
+      }
+      if (endOfNodeMarker != null) {
+        endOfNodeMarker.drop();
+      }
+      endOfNodeMarker = mark();
+      
+    }
+
+    if (endOfNodeMarker != null) {
+      dropEolMarker();
+      endOfNodeMarker.rollbackTo();
+    }
+    else {
+      rollBackToEol();
+    }
+    if (nodeType != null) {
+      marker.done(nodeType);
+    }
+    else {
+      marker.drop();
+    }
+  }
+
+  /**
+   * @link {http://www.yaml.org/spec/1.2/spec.html#id2777534}
+   */
+  private int getIndentBonus(final boolean insideSequence) {
+    if (!insideSequence && getTokenType() == SEQUENCE_MARKER) {
+      return 1;
+    }
+    else {
+      return 0;
+    }
+  }
+
+  private int getShorthandIndentAddition() {
+    final int offset = myBuilder.getCurrentOffset();
+    final IElementType nextToken = myBuilder.lookAhead(1);
+    if (nextToken != SEQUENCE_MARKER && nextToken != SCALAR_KEY) {
+      return 1;
+    }
+    if (myBuilder.rawLookup(1) == WHITESPACE) {
+      return myBuilder.rawTokenTypeStart(2) - offset;
+    }
+    else {
+      return 1;
+    }
+  }
+
+  @Nullable
+  private IElementType parseSingleStatement(int indent) {
+    if (eof()) {
+      return null;
+    }
+    
+    final PsiBuilder.Marker marker = mark();
+    if (getTokenType() == YAMLTokenTypes.TAG) {
+      advanceLexer();
+    }
+
+    final IElementType tokenType = getTokenType();
+    final IElementType nodeType;
+    if (tokenType == LBRACE) {
+      nodeType = parseHash();
+    }
+    else if (tokenType == LBRACKET) {
+      nodeType = parseArray();
+    }
+    else if (tokenType == SEQUENCE_MARKER) {
+      nodeType = parseSequenceItem(indent);
+    }
+    else if (tokenType == QUESTION) {
+      nodeType = parseExplicitKeyValue(indent);
+    }
+    else if (tokenType == SCALAR_KEY) {
+      nodeType = parseScalarKeyValue(indent);
+    }
+    else if (YAMLElementTypes.SCALAR_VALUES.contains(getTokenType())) {
+      nodeType = parseScalarValue(indent);
+    }
+    else {
+      advanceLexer();
+      nodeType = null;
+    }
+    
+    if (nodeType != null) {
+      marker.done(nodeType);
+    }
+    else {
+      marker.drop();
+    }
+    return nodeType;
+  }
+
+  @Nullable
+  private IElementType parseScalarValue(int indent) {
+    final IElementType tokenType = getTokenType();
+    assert YAMLElementTypes.SCALAR_VALUES.contains(tokenType) : "Scalar value expected!";
+    if (tokenType == SCALAR_LIST || tokenType == SCALAR_TEXT) {
+      return parseMultiLineScalar(tokenType);
+    }
+    else if (tokenType == TEXT) {
+      return parseMultiLinePlainScalar(indent);
+    }
+    else if (tokenType == SCALAR_DSTRING || tokenType == SCALAR_STRING) {
+      return parseQuotedString();
+    }
+    else {
+      advanceLexer();
+      return null;
+    }
+  }
+
+  @NotNull
+  private IElementType parseQuotedString() {
+    advanceLexer();
+    return YAMLElementTypes.SCALAR_QUOTED_STRING;
+  }
+
+  @NotNull
+  private IElementType parseMultiLineScalar(final IElementType tokenType) {
+    IElementType type = getTokenType();
+    while (type == tokenType || type == INDENT || type == EOL) {
+      advanceLexer();
+      type = getTokenType();
+    }
+    rollBackToEol();
+    return tokenType == SCALAR_LIST ? YAMLElementTypes.SCALAR_LIST_VALUE : YAMLElementTypes.SCALAR_TEXT_VALUE;
+  }
+
+  @NotNull
+  private IElementType parseMultiLinePlainScalar(final int indent) {
+    PsiBuilder.Marker lastTextEnd = null;
+
+    IElementType type = getTokenType();
+    while (type == TEXT || type == INDENT || type == EOL) {
+      advanceLexer();
+
+      if (type == TEXT) {
+        if (lastTextEnd != null && myIndent < indent) {
+          break;
+        }
+        if (lastTextEnd != null) {
+          lastTextEnd.drop();
+        }
+        lastTextEnd = mark();
+      }
+      type = getTokenType();
+    }
+
+    rollBackToEol();
+    assert lastTextEnd != null;
+    lastTextEnd.rollbackTo();
+    return YAMLElementTypes.SCALAR_PLAIN_VALUE;
+  }
+
+  @NotNull
+  private IElementType parseExplicitKeyValue(int indent) {
+    assert getTokenType() == QUESTION;
+
+    int indentAddition = getShorthandIndentAddition();
+    advanceLexer();
+
+    if (!myStopTokensStack.isEmpty() && myStopTokensStack.peek() == HASH_STOP_TOKENS // This means we're inside some hash
+        && getTokenType() == SCALAR_KEY) {
+      parseScalarKeyValue(indent);
+    }
+    else {
+      myStopTokensStack.add(TokenSet.create(COLON));
+      eolSeen = false;
+
+      passJunk();
+
+      parseBlockNode(indent + indentAddition, false);
+
+      myStopTokensStack.pop();
+
+      passJunk();
+      if (getTokenType() == COLON) {
+        indentAddition = getShorthandIndentAddition();
+        advanceLexer();
+
+        eolSeen = false;
+        parseBlockNode(indent + indentAddition, false);
+      }
+    }
+
+    return YAMLElementTypes.KEY_VALUE_PAIR;
+  }
+
+
+  @NotNull
+  private IElementType parseScalarKeyValue(int indent) {
+    assert getTokenType() == SCALAR_KEY : "Expected scalar key";
+    eolSeen = false;
+
+    int indentAddition = getShorthandIndentAddition();
+    advanceLexer();
+
+    final PsiBuilder.Marker rollbackMarker = mark();
+    
+    passJunk();
+    if (eolSeen && (eof() || myIndent + getIndentBonus(false) < indent + indentAddition)) {
+      dropEolMarker();
+      rollbackMarker.rollbackTo();
+    }
+    else {
+      rollbackMarker.drop();
+      parseBlockNode(indent + indentAddition, false);
+    }
+
+    return YAMLElementTypes.KEY_VALUE_PAIR;
+  }
+
+  @NotNull
+  private IElementType parseSequenceItem(int indent) {
+    assert getTokenType() == SEQUENCE_MARKER;
+
+    int indentAddition = getShorthandIndentAddition();
+    advanceLexer();
+    eolSeen = false;
+    passJunk();
+
+    parseBlockNode(indent + indentAddition, true);
+    rollBackToEol();
+    return YAMLElementTypes.SEQUENCE_ITEM;
+  }
+
+  @NotNull
+  private IElementType parseHash() {
+    assert getTokenType() == LBRACE;
+    advanceLexer();
+    myStopTokensStack.add(HASH_STOP_TOKENS);
+
+    while (!eof()) {
+      if (getTokenType() == RBRACE) {
+        advanceLexer();
+        break;
+      }
+      parseSingleStatement(0);
+    }
+
+    myStopTokensStack.pop();
+    dropEolMarker();
+    return YAMLElementTypes.HASH;
+  }
+
+  @NotNull
+  private IElementType parseArray() {
+    assert getTokenType() == LBRACKET;
+    advanceLexer();
+    myStopTokensStack.add(ARRAY_STOP_TOKENS);
+
+    while (!eof()) {
+      if (getTokenType() == RBRACKET) {
+        advanceLexer();
+        break;
+      }
+      if (isJunk()) {
+        advanceLexer();
+        continue;
+      }
+      
+      final PsiBuilder.Marker marker = mark();
+      final IElementType parsedElement = parseSingleStatement(0);
+      if (parsedElement != null) {
+        marker.done(YAMLElementTypes.SEQUENCE_ITEM);
+      }
+      else {
+        marker.error("Sequence item expected");
+      }
+      
+      if (getTokenType() == YAMLTokenTypes.COMMA) {
+        advanceLexer();
+      }
+    }
+
+    myStopTokensStack.pop();
+    dropEolMarker();
+    return YAMLElementTypes.ARRAY;
+  }
+
+  private boolean eof() {
+    return myBuilder.eof() || myBuilder.getTokenType() == DOCUMENT_MARKER;
+  }
+
+  @Nullable
+  private IElementType getTokenType() {
+    return eof() ? null : myBuilder.getTokenType();
+  }
+
+  private void dropEolMarker() {
+    if (myAfterLastEolMarker != null) {
+      myAfterLastEolMarker.drop();
+      myAfterLastEolMarker = null;
+    }
+  }
+
+  private void rollBackToEol() {
+    if (eolSeen && myAfterLastEolMarker != null) {
+      eolSeen = false;
+      myAfterLastEolMarker.rollbackTo();
+      myAfterLastEolMarker = null;
+    }
+  }
+
+  private PsiBuilder.Marker mark() {
+    dropEolMarker();
+    return myBuilder.mark();
+  }
+
+  private void advanceLexer() {
+    if (myBuilder.eof()) {
+      return;
+    }
+    final IElementType type = myBuilder.getTokenType();
+    eolSeen = eolSeen || type == EOL;
+    if (type == EOL) {
+      // Drop and create new eolMarker
+      myAfterLastEolMarker = mark();
+      myIndent = 0;
+    }
+    else if (type == INDENT) {
+      myIndent = getCurrentTokenLength();
+    }
+    else {
+      // Drop Eol Marker if other token seen
+      dropEolMarker();
+    }
+    myBuilder.advanceLexer();
+  }
+
+  private int getCurrentTokenLength() {
+    return myBuilder.rawTokenTypeStart(1) - myBuilder.getCurrentOffset();
+  }
+
+  private void passJunk() {
+    while (!eof() && isJunk()) {
+      advanceLexer();
+    }
+  }
+
+  private boolean isJunk() {
+    final IElementType type = getTokenType();
+    return type == INDENT || type == EOL;
+  }
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLCompoundValue.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLCompoundValue.java
new file mode 100644 (file)
index 0000000..f8583e3
--- /dev/null
@@ -0,0 +1,11 @@
+package org.jetbrains.yaml.psi;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author oleg
+ */
+public interface YAMLCompoundValue extends YAMLValue {
+  @NotNull
+  String getTextValue();
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLDocument.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLDocument.java
new file mode 100644 (file)
index 0000000..9d055cb
--- /dev/null
@@ -0,0 +1,11 @@
+package org.jetbrains.yaml.psi;
+
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author oleg
+ */
+public interface YAMLDocument extends YAMLPsiElement {
+  @Nullable
+  YAMLValue getTopLevelValue();
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLFile.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLFile.java
new file mode 100644 (file)
index 0000000..3b42860
--- /dev/null
@@ -0,0 +1,12 @@
+package org.jetbrains.yaml.psi;
+
+import com.intellij.psi.PsiFile;
+
+import java.util.List;
+
+/**
+ * @author oleg
+ */
+public interface YAMLFile extends PsiFile, YAMLPsiElement {
+  List<YAMLDocument> getDocuments();
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLKeyValue.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLKeyValue.java
new file mode 100644 (file)
index 0000000..967b74a
--- /dev/null
@@ -0,0 +1,33 @@
+package org.jetbrains.yaml.psi;
+
+import com.intellij.pom.PomTarget;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiNamedElement;
+import org.jetbrains.annotations.Contract;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author oleg
+ */
+public interface YAMLKeyValue extends YAMLPsiElement, PsiNamedElement, PomTarget {
+  @Contract(pure = true)
+  @Nullable
+  PsiElement getKey();
+
+  @Contract(pure = true)
+  @NotNull
+  String getKeyText();
+
+  @Contract(pure = true)
+  @Nullable
+  YAMLValue getValue();
+
+  @Contract(pure = true)
+  @NotNull
+  String getValueText();
+  
+  YAMLMapping getParentMapping();
+
+  void setValue(@NotNull YAMLValue value);
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLMapping.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLMapping.java
new file mode 100644 (file)
index 0000000..1f71805
--- /dev/null
@@ -0,0 +1,24 @@
+package org.jetbrains.yaml.psi;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
+/**
+ * A collection representing a set of key-value pairs
+ */
+public interface YAMLMapping extends YAMLCompoundValue {
+  @NotNull
+  Collection<YAMLKeyValue> getKeyValues();
+
+  @Nullable
+  YAMLKeyValue getKeyValueByKey(@NotNull String keyText);
+
+  void putKeyValue(@NotNull YAMLKeyValue keyValueToAdd);
+
+  /**
+   * This one's different from plain deletion in a way that excess newlines/commas are also deleted
+   */
+  void deleteKeyValue(@NotNull YAMLKeyValue keyValueToDelete);
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLPsiElement.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLPsiElement.java
new file mode 100644 (file)
index 0000000..d1118d4
--- /dev/null
@@ -0,0 +1,12 @@
+package org.jetbrains.yaml.psi;
+
+import com.intellij.psi.NavigatablePsiElement;
+
+import java.util.List;
+
+/**
+ * @author oleg
+ */
+public interface YAMLPsiElement extends NavigatablePsiElement {
+  List<YAMLPsiElement> getYAMLElements();
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLPsiManager.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLPsiManager.java
new file mode 100644 (file)
index 0000000..af27e00
--- /dev/null
@@ -0,0 +1,53 @@
+package org.jetbrains.yaml.psi;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiDirectory;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiFileSystemItem;
+import com.intellij.psi.impl.PsiTreeChangeEventImpl;
+import com.intellij.psi.impl.PsiTreeChangePreprocessorBase;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * @author oleg
+ */
+final class YAMLPsiManager extends PsiTreeChangePreprocessorBase {
+  public YAMLPsiManager(@NotNull Project project) {
+    super(project);
+  }
+
+  @Override
+  protected boolean isInsideCodeBlock(PsiElement element) {
+    if (element instanceof PsiFileSystemItem) {
+      return false;
+    }
+
+    if (element == null || element.getParent() == null) {
+      return true;
+    }
+
+    while (true) {
+      if (element instanceof YAMLFile) {
+        return false;
+      }
+      if (element instanceof PsiFile || element instanceof PsiDirectory) {
+        return true;
+      }
+      PsiElement parent = element.getParent();
+      if (!(parent instanceof YAMLFile ||
+            parent instanceof YAMLKeyValue ||
+            parent instanceof YAMLCompoundValue ||
+            parent instanceof YAMLDocument)) {
+        return true;
+      }
+      element = parent;
+    }
+  }
+
+  @Override
+  public void treeChanged(@NotNull PsiTreeChangeEventImpl event) {
+    if (!(event.getFile() instanceof YAMLFile)) return;
+    super.treeChanged(event);
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLQuotedText.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLQuotedText.java
new file mode 100644 (file)
index 0000000..f9e4eca
--- /dev/null
@@ -0,0 +1,5 @@
+package org.jetbrains.yaml.psi;
+
+public interface YAMLQuotedText extends YAMLScalar {
+  boolean isSingleQuote();
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLScalar.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLScalar.java
new file mode 100644 (file)
index 0000000..32e431e
--- /dev/null
@@ -0,0 +1,10 @@
+package org.jetbrains.yaml.psi;
+
+import org.jetbrains.annotations.NotNull;
+
+public interface YAMLScalar extends YAMLValue {
+  @NotNull
+  String getTextValue();
+
+  boolean isMultiline();
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLScalarList.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLScalarList.java
new file mode 100644 (file)
index 0000000..7b87d8e
--- /dev/null
@@ -0,0 +1,7 @@
+package org.jetbrains.yaml.psi;
+
+/**
+ * @author oleg
+ */
+public interface YAMLScalarList extends YAMLScalar {
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLScalarText.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLScalarText.java
new file mode 100644 (file)
index 0000000..920467b
--- /dev/null
@@ -0,0 +1,7 @@
+package org.jetbrains.yaml.psi;
+
+/**
+ * @author oleg
+ */
+public interface YAMLScalarText extends YAMLScalar {
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLSequence.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLSequence.java
new file mode 100644 (file)
index 0000000..d7434f8
--- /dev/null
@@ -0,0 +1,13 @@
+package org.jetbrains.yaml.psi;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+/**
+ * A collection representing a sequence of items
+ */
+public interface YAMLSequence extends YAMLCompoundValue {
+  @NotNull
+  List<YAMLSequenceItem> getItems();
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLSequenceItem.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLSequenceItem.java
new file mode 100644 (file)
index 0000000..6f37dd1
--- /dev/null
@@ -0,0 +1,16 @@
+package org.jetbrains.yaml.psi;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
+/**
+ * @author oleg
+ */
+public interface YAMLSequenceItem extends YAMLPsiElement {
+  @Nullable
+  YAMLValue getValue();
+  @NotNull
+  Collection<YAMLKeyValue> getKeysValues();
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLValue.java b/plugins/yaml/src/org/jetbrains/yaml/psi/YAMLValue.java
new file mode 100644 (file)
index 0000000..140d06e
--- /dev/null
@@ -0,0 +1,9 @@
+package org.jetbrains.yaml.psi;
+
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.Nullable;
+
+public interface YAMLValue extends YAMLPsiElement {
+  @Nullable
+  PsiElement getTag();
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLArrayImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLArrayImpl.java
new file mode 100644 (file)
index 0000000..2a8617a
--- /dev/null
@@ -0,0 +1,19 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.psi.YAMLSequence;
+
+/**
+ * @author oleg
+ */
+public class YAMLArrayImpl extends YAMLSequenceImpl implements YAMLSequence {
+  public YAMLArrayImpl(@NotNull final ASTNode node) {
+    super(node);
+  }
+
+  @Override
+  public String toString() {
+    return "YAML array";
+  }
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockMappingImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockMappingImpl.java
new file mode 100644 (file)
index 0000000..1a63a91
--- /dev/null
@@ -0,0 +1,25 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.YAMLElementGenerator;
+import org.jetbrains.yaml.YAMLUtil;
+import org.jetbrains.yaml.psi.YAMLKeyValue;
+
+public class YAMLBlockMappingImpl extends YAMLMappingImpl {
+  public YAMLBlockMappingImpl(@NotNull ASTNode node) {
+    super(node);
+  }
+
+  @Override
+  protected void addNewKey(@NotNull YAMLKeyValue key) {
+    final int indent = YAMLUtil.getIndentToThisElement(this);
+
+    final YAMLElementGenerator generator = YAMLElementGenerator.getInstance(getProject());
+    add(generator.createEol());
+    if (indent > 0) {
+      add(generator.createIndent(indent));
+    }
+    add(key);
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockScalarImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockScalarImpl.java
new file mode 100644 (file)
index 0000000..7056ba3
--- /dev/null
@@ -0,0 +1,78 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.YAMLTokenTypes;
+import org.jetbrains.yaml.YAMLUtil;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public abstract class YAMLBlockScalarImpl extends YAMLScalarImpl {
+  public YAMLBlockScalarImpl(@NotNull ASTNode node) {
+    super(node);
+  }
+
+  @NotNull
+  protected abstract IElementType getContentType();
+
+  @Override
+  public boolean isMultiline() {
+    return true;
+  }
+
+  @NotNull
+  @Override
+  public List<TextRange> getContentRanges() {
+    final int myStart = getTextOffset();
+    final ASTNode node = getNode();
+    final List<TextRange> result = new ArrayList<TextRange>();
+
+    final int indent = locateIndent();
+
+    final ASTNode firstEol = node.findChildByType(YAMLTokenTypes.EOL);
+    if (firstEol == null) {
+      return Collections.emptyList();
+    }
+
+    int thisLineStart = firstEol.getStartOffset() + 1;
+    for (ASTNode child = firstEol.getTreeNext(); child != null; child = child.getTreeNext()) {
+      if (child.getElementType() == getContentType()) {
+        assert thisLineStart != -1;
+        result.add(TextRange.create(thisLineStart, child.getTextRange().getEndOffset()).shiftRight(-myStart));
+        thisLineStart = -1;
+
+        if (node.findChildByType(getContentType(), child.getTreeNext()) == null) {
+          break;
+        }
+      }
+      else if (child.getElementType() == YAMLTokenTypes.INDENT) {
+        thisLineStart = child.getStartOffset() + Math.min(indent, child.getTextLength());
+      }
+      if (child.getElementType() == YAMLTokenTypes.EOL) {
+        if (thisLineStart != -1) {
+          result.add(TextRange.create(thisLineStart, child.getStartOffset()).shiftRight(-myStart));
+        }
+        thisLineStart = child.getStartOffset() + 1;
+      }
+    }
+
+    return result;
+  }
+
+  private int locateIndent() {
+    int number = 0;
+    for (ASTNode child = getNode().getFirstChildNode(); child != null; child = child.getTreeNext()) {
+      if (child.getElementType() == getContentType()) {
+        number++;
+        if (number == 2) {
+          return YAMLUtil.getIndentInThisLine(child.getPsi());
+        }
+      }
+    }
+    return 0;
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockSequenceImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLBlockSequenceImpl.java
new file mode 100644 (file)
index 0000000..3eaabf7
--- /dev/null
@@ -0,0 +1,10 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import org.jetbrains.annotations.NotNull;
+
+public class YAMLBlockSequenceImpl extends YAMLSequenceImpl {
+  public YAMLBlockSequenceImpl(@NotNull ASTNode node) {
+    super(node);
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLCompoundValueImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLCompoundValueImpl.java
new file mode 100644 (file)
index 0000000..0377c6e
--- /dev/null
@@ -0,0 +1,38 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.psi.YAMLCompoundValue;
+import org.jetbrains.yaml.psi.YAMLScalar;
+
+/**
+ * @author oleg
+ */
+public class YAMLCompoundValueImpl extends YAMLValueImpl implements YAMLCompoundValue {
+  public YAMLCompoundValueImpl(@NotNull final ASTNode node) {
+    super(node);
+  }
+
+  @Override
+  public String toString() {
+    return "YAML compound value";
+  }
+
+  @NotNull
+  @Override
+  public String getTextValue() {
+    PsiElement element = getTag() != null ? getTag().getNextSibling() : getFirstChild();
+
+    while (element != null && !(element instanceof YAMLScalar)) {
+      element = element.getNextSibling();
+    }
+
+    if (element != null) {
+      return ((YAMLScalar)element).getTextValue();
+    }
+    else {
+      return "<compoundValue:" + Integer.toHexString(getText().hashCode()) + ">";
+    }
+  }
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLDocumentImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLDocumentImpl.java
new file mode 100644 (file)
index 0000000..bcefe3e
--- /dev/null
@@ -0,0 +1,28 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.util.PsiTreeUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.yaml.psi.YAMLDocument;
+import org.jetbrains.yaml.psi.YAMLValue;
+
+/**
+ * @author oleg
+ */
+public class YAMLDocumentImpl extends YAMLPsiElementImpl implements YAMLDocument {
+  public YAMLDocumentImpl(@NotNull final ASTNode node) {
+    super(node);
+  }
+
+  @Override
+  public String toString() {
+    return "YAML document";
+  }
+
+  @Nullable
+  @Override
+  public YAMLValue getTopLevelValue() {
+    return PsiTreeUtil.findChildOfType(this, YAMLValue.class);
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLFileImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLFileImpl.java
new file mode 100644 (file)
index 0000000..1567d6c
--- /dev/null
@@ -0,0 +1,56 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.extapi.psi.PsiFileBase;
+import com.intellij.lang.ASTNode;
+import com.intellij.openapi.fileTypes.FileType;
+import com.intellij.psi.FileViewProvider;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.tree.TokenSet;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.YAMLElementTypes;
+import org.jetbrains.yaml.YAMLFileType;
+import org.jetbrains.yaml.YAMLLanguage;
+import org.jetbrains.yaml.psi.YAMLDocument;
+import org.jetbrains.yaml.psi.YAMLFile;
+import org.jetbrains.yaml.psi.YAMLPsiElement;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author oleg
+ */
+public class YAMLFileImpl extends PsiFileBase implements YAMLFile {
+  public YAMLFileImpl(FileViewProvider viewProvider) {
+    super(viewProvider, YAMLLanguage.INSTANCE);
+  }
+
+  @NotNull
+  public FileType getFileType() {
+    return YAMLFileType.YML;
+  }
+
+  @Override
+  public String toString() {
+    return "YAML file";
+  }
+
+  public List<YAMLDocument> getDocuments() {
+    final ArrayList<YAMLDocument> result = new ArrayList<YAMLDocument>();
+    for (ASTNode node : getNode().getChildren(TokenSet.create(YAMLElementTypes.DOCUMENT))) {
+     result.add((YAMLDocument) node.getPsi());
+    }
+    return result;
+  }
+
+  public List<YAMLPsiElement> getYAMLElements() {
+    final ArrayList<YAMLPsiElement> result = new ArrayList<YAMLPsiElement>();
+    for (ASTNode node : getNode().getChildren(null)) {
+      final PsiElement psi = node.getPsi();
+      if (psi instanceof YAMLPsiElement){
+        result.add((YAMLPsiElement) psi);
+      }
+    }
+    return result;
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLHashImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLHashImpl.java
new file mode 100644 (file)
index 0000000..e7784bf
--- /dev/null
@@ -0,0 +1,44 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.YAMLElementGenerator;
+import org.jetbrains.yaml.YAMLTokenTypes;
+import org.jetbrains.yaml.psi.YAMLFile;
+import org.jetbrains.yaml.psi.YAMLKeyValue;
+import org.jetbrains.yaml.psi.YAMLMapping;
+
+/**
+ * @author oleg
+ */
+public class YAMLHashImpl extends YAMLMappingImpl implements YAMLMapping {
+  public YAMLHashImpl(@NotNull final ASTNode node) {
+    super(node);
+  }
+
+  @Override
+  protected void addNewKey(@NotNull YAMLKeyValue key) {
+    PsiElement anchor = null;
+    for (PsiElement child = getLastChild(); child != null; child = child.getPrevSibling()) {
+      final IElementType type = child.getNode().getElementType();
+      if (type == YAMLTokenTypes.COMMA || type == YAMLTokenTypes.LBRACE) {
+        anchor = child;
+      }
+    }
+    
+    addAfter(key, anchor);
+
+    final YAMLFile dummyFile = YAMLElementGenerator.getInstance(getProject()).createDummyYamlWithText("{,}");
+    final PsiElement comma = dummyFile.findElementAt(1);
+    assert comma != null && comma.getNode().getElementType() == YAMLTokenTypes.COMMA;
+    
+    addAfter(comma, key);
+  }
+
+  @Override
+  public String toString() {
+    return "YAML hash";
+  }
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLKeyValueImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLKeyValueImpl.java
new file mode 100644 (file)
index 0000000..6c1e073
--- /dev/null
@@ -0,0 +1,180 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.navigation.ItemPresentation;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiReference;
+import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
+import com.intellij.util.IncorrectOperationException;
+import com.intellij.util.ObjectUtils;
+import com.intellij.util.PlatformIcons;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.yaml.YAMLElementGenerator;
+import org.jetbrains.yaml.YAMLTokenTypes;
+import org.jetbrains.yaml.YAMLUtil;
+import org.jetbrains.yaml.psi.*;
+
+import javax.swing.*;
+
+/**
+ * @author oleg
+ */
+public class YAMLKeyValueImpl extends YAMLPsiElementImpl implements YAMLKeyValue {
+  public YAMLKeyValueImpl(@NotNull final ASTNode node) {
+    super(node);
+  }
+
+  @Override
+  public String toString() {
+    return "YAML key value";
+  }
+
+  @Nullable
+  public PsiElement getKey() {
+    final PsiElement result = findChildByType(YAMLTokenTypes.SCALAR_KEY);
+    if (result != null) {
+      return result;
+    }
+    if (isExplicit()) {
+      return findChildByClass(YAMLCompoundValue.class);
+    }
+    return null;
+  }
+
+  @Nullable
+  @Override
+  public YAMLMapping getParentMapping() {
+    return ObjectUtils.tryCast(super.getParent(), YAMLMapping.class);
+  }
+
+  @Nullable
+  @Override
+  public String getName() {
+    return getKeyText();
+  }
+
+  @NotNull
+  public String getKeyText() {
+    final PsiElement keyElement = getKey();
+    if (keyElement == null) {
+      return "";
+    }
+
+    if (keyElement instanceof YAMLCompoundValue) {
+      return ((YAMLCompoundValue)keyElement).getTextValue();
+    }
+
+    final String text = keyElement.getText();
+    return StringUtil.unquoteString(text.substring(0, text.length() - 1));
+  }
+
+  @Nullable
+  public YAMLValue getValue() {
+    for (PsiElement child = getLastChild(); child != null; child = child.getPrevSibling()) {
+      if (child instanceof YAMLValue) {
+        return ((YAMLValue)child);
+      }
+    }
+    return null;
+  }
+
+  @NotNull
+  public String getValueText() {
+    final YAMLValue value = getValue();
+    if (value instanceof YAMLScalar){
+      return ((YAMLScalar)value).getTextValue();
+    }
+    else if (value instanceof YAMLCompoundValue) {
+      return ((YAMLCompoundValue)value).getTextValue();
+    }
+    return "";
+  }
+
+
+  @Override
+  public void setValue(@NotNull YAMLValue value) {
+    adjustWhitespaceToContentType(value instanceof YAMLScalar);
+    
+    if (getValue() != null) {
+      getValue().replace(value);
+      return;
+    }
+
+    final YAMLElementGenerator generator = YAMLElementGenerator.getInstance(getProject());
+    if (isExplicit()) {
+      if (findChildByType(YAMLTokenTypes.COLON) == null) {
+        add(generator.createColon());
+        add(generator.createSpace());
+        add(value);
+      }
+    }
+    else {
+      add(value);
+    }
+  }
+  
+  private void adjustWhitespaceToContentType(boolean isScalar) {
+    assert getKey() != null;
+    PsiElement key = getKey();
+    
+    if (key.getNextSibling() != null && key.getNextSibling().getNode().getElementType() == YAMLTokenTypes.COLON) {
+      key = key.getNextSibling();
+    }
+    
+    while (key.getNextSibling() != null && !(key.getNextSibling() instanceof YAMLValue)) {
+      key.getNextSibling().delete();
+    }
+    final YAMLElementGenerator generator = YAMLElementGenerator.getInstance(getProject());
+    if (isScalar) {
+      addAfter(generator.createSpace(), key);
+    }
+    else {
+      final int indent = YAMLUtil.getIndentToThisElement(this);
+      addAfter(generator.createIndent(indent + 2), key);
+      addAfter(generator.createEol(), key);
+    }
+  }
+
+  @Override
+  public ItemPresentation getPresentation() {
+    final YAMLFile yamlFile = (YAMLFile)getContainingFile();
+    final PsiElement value = getValue();
+    return new ItemPresentation() {
+      public String getPresentableText() {
+        if (value instanceof YAMLScalar){
+          return getValueText();
+        }
+        return getName();
+      }
+
+      public String getLocationString() {
+        return "[" + yamlFile.getName() + "]";
+      }
+
+      public Icon getIcon(boolean open) {
+        return PlatformIcons.PROPERTY_ICON;
+      }
+    };
+  }
+
+  public PsiElement setName(@NonNls @NotNull String newName) throws IncorrectOperationException {
+    return YAMLUtil.rename(this, newName);
+  }
+
+  /**
+   * Provide reference contributor with given method registerReferenceProviders implementation:
+   * registrar.registerReferenceProvider(PlatformPatterns.psiElement(YAMLKeyValue.class), ReferenceProvider);
+   */
+  @NotNull
+  public PsiReference[] getReferences() {
+    return ReferenceProvidersRegistry.getReferencesFromProviders(this);
+  }
+
+  private boolean isExplicit() {
+    final ASTNode child = getNode().getFirstChildNode();
+    return child != null && child.getElementType() == YAMLTokenTypes.QUESTION;
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLMappingImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLMappingImpl.java
new file mode 100644 (file)
index 0000000..287a1d3
--- /dev/null
@@ -0,0 +1,76 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.util.PsiTreeUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.yaml.psi.YAMLKeyValue;
+import org.jetbrains.yaml.psi.YAMLMapping;
+
+import java.util.Collection;
+
+public abstract class YAMLMappingImpl extends YAMLCompoundValueImpl implements YAMLMapping {
+  public YAMLMappingImpl(@NotNull ASTNode node) {
+    super(node);
+  }
+
+  @NotNull
+  @Override
+  public Collection<YAMLKeyValue> getKeyValues() {
+    return PsiTreeUtil.getChildrenOfTypeAsList(this, YAMLKeyValue.class);
+  }
+
+  @Nullable
+  @Override
+  public YAMLKeyValue getKeyValueByKey(@NotNull String keyText) {
+    for (YAMLKeyValue keyValue : getKeyValues()) {
+      if (keyText.equals(keyValue.getKeyText())) {
+        return keyValue;
+      }
+    }
+    return null;
+  }
+
+  @Override
+  public void putKeyValue(@NotNull YAMLKeyValue keyValueToAdd) {
+    final YAMLKeyValue existingKey = getKeyValueByKey(keyValueToAdd.getKeyText());
+    if (existingKey == null) {
+      addNewKey(keyValueToAdd);
+    }
+    else {
+      existingKey.replace(keyValueToAdd);
+    }
+  }
+
+  @Override
+  public void deleteKeyValue(@NotNull YAMLKeyValue keyValueToDelete) {
+    if (keyValueToDelete.getParent() != this) {
+      throw new IllegalArgumentException("KeyValue should be the child of this");
+    }
+
+    if (keyValueToDelete.getPrevSibling() != null) {
+      while (keyValueToDelete.getPrevSibling() != null && !(keyValueToDelete.getPrevSibling() instanceof YAMLKeyValue)) {
+        keyValueToDelete.getPrevSibling().delete();
+      }
+    }
+    else {
+      while (keyValueToDelete.getNextSibling() != null && !(keyValueToDelete.getNextSibling() instanceof YAMLKeyValue)) {
+        keyValueToDelete.getNextSibling().delete();
+      }
+    }
+    keyValueToDelete.delete();
+  }
+
+  protected abstract void addNewKey(@NotNull YAMLKeyValue key);
+
+  @Override
+  public String toString() {
+    return "YAML mapping";
+  }
+
+  @NotNull
+  @Override
+  public String getTextValue() {
+    return "<mapping:" + Integer.toHexString(getText().hashCode()) + ">";
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLPlainTextImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLPlainTextImpl.java
new file mode 100644 (file)
index 0000000..9be2ed8
--- /dev/null
@@ -0,0 +1,62 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.TextRange;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.YAMLTokenTypes;
+import org.jetbrains.yaml.psi.YAMLScalar;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class YAMLPlainTextImpl extends YAMLScalarImpl implements YAMLScalar {
+  public YAMLPlainTextImpl(@NotNull ASTNode node) {
+    super(node);
+  }
+
+  @NotNull
+  @Override
+  public List<TextRange> getContentRanges() {
+    final int myStart = getTextOffset();
+    final ASTNode node = getNode();
+    final List<TextRange> result = new ArrayList<TextRange>();
+
+    boolean seenText = false;
+    for (ASTNode child = node.getFirstChildNode(); child != null; child = child.getTreeNext()) {
+      if (child.getElementType() == YAMLTokenTypes.TEXT) {
+        seenText = true;
+        result.add(child.getTextRange().shiftRight(-myStart));
+      }
+      else if (child.getElementType() == YAMLTokenTypes.EOL) {
+        if (!seenText) {
+          result.add(child.getTextRange().shiftRight(-myStart));
+        }
+        seenText = false;
+      }
+    }
+
+    return result;
+  }
+
+  @NotNull
+  @Override
+  protected String getRangesJoiner(@NotNull CharSequence leftString, @NotNull CharSequence rightString) {
+    if (leftString.equals("\n") || rightString.equals("\n")) {
+      return "";
+    }
+    else {
+      return " ";
+    }
+  }
+
+  @Override
+  public String toString() {
+    return "YAML plain scalar text";
+  }
+
+
+  @Override
+  public boolean isMultiline() {
+    return getNode().findChildByType(YAMLTokenTypes.EOL) != null;
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLPsiElementImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLPsiElementImpl.java
new file mode 100644 (file)
index 0000000..918156a
--- /dev/null
@@ -0,0 +1,35 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.extapi.psi.ASTWrapperPsiElement;
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.psi.YAMLPsiElement;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author oleg
+ */
+public class YAMLPsiElementImpl extends ASTWrapperPsiElement implements YAMLPsiElement {
+  public YAMLPsiElementImpl(@NotNull final ASTNode node) {
+    super(node);
+  }
+
+  @Override
+  public String toString() {
+    return "YAML element";
+  }
+
+  public List<YAMLPsiElement> getYAMLElements() {
+    final ArrayList<YAMLPsiElement> result = new ArrayList<YAMLPsiElement>();
+    for (ASTNode node : getNode().getChildren(null)) {
+      final PsiElement psi = node.getPsi();
+      if (psi instanceof YAMLPsiElement){
+        result.add((YAMLPsiElement) psi);
+      }
+    }
+    return result;
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLQuotedTextImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLQuotedTextImpl.java
new file mode 100644 (file)
index 0000000..777b7e1
--- /dev/null
@@ -0,0 +1,99 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.openapi.util.text.StringUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.YAMLTokenTypes;
+import org.jetbrains.yaml.psi.YAMLQuotedText;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class YAMLQuotedTextImpl extends YAMLScalarImpl implements YAMLQuotedText {
+  private final boolean myIsSingleQuoted;
+
+  public YAMLQuotedTextImpl(@NotNull ASTNode node) {
+    super(node);
+    myIsSingleQuoted = getNode().getFirstChildNode().getElementType() == YAMLTokenTypes.SCALAR_STRING;
+  }
+
+  @NotNull
+  @Override
+  public List<TextRange> getContentRanges() {
+    List<TextRange> result = new ArrayList<TextRange>();
+
+    final List<String> lines = StringUtil.split(getText(), "\n", true, false);
+    // First line has opening quote
+    int cumulativeOffset = 0;
+    for (int i = 0; i < lines.size(); ++i) {
+      final String line = lines.get(i);
+
+      int lineStart = 0;
+      int lineEnd = line.length();
+      if (i == 0) {
+        lineStart++;
+      }
+      else {
+        while (lineStart < line.length() && Character.isWhitespace(line.charAt(lineStart))) {
+          lineStart++;
+        }
+      }
+      if (i == lines.size() - 1) {
+        // Last line has closing quote
+        lineEnd--;
+      }
+      else {
+        while (lineEnd > lineStart && Character.isWhitespace(line.charAt(lineEnd - 1))) {
+          lineEnd--;
+        }
+      }
+
+      result.add(TextRange.create(lineStart, lineEnd).shiftRight(cumulativeOffset));
+      cumulativeOffset += line.length() + 1;
+    }
+
+    return result;
+  }
+
+  @NotNull
+  @Override
+  protected String getRangesJoiner(@NotNull CharSequence leftString, @NotNull CharSequence rightString) {
+    if (leftString.length() == 0 || !isSingleQuote() && leftString.charAt(leftString.length() - 1) == '\\') {
+      return "\n";
+    }
+    else if (rightString.length() == 0) {
+      return "";
+    }
+    else {
+      return " ";
+    }
+  }
+
+  @NotNull
+  @Override
+  public String getTextValue() {
+    final String gluedText = super.getTextValue();
+    if (isSingleQuote()) {
+      return StringUtil.replace(gluedText, "''", "'");
+    }
+    else {
+      final String trimmedEndEscapes = StringUtil.replace(gluedText, new String[]{"\\\n", "\\ "}, new String[]{"", " "});
+      return StringUtil.replaceUnicodeEscapeSequences(trimmedEndEscapes);
+    }
+  }
+
+  @Override
+  public boolean isMultiline() {
+    return getText().contains("\n");
+  }
+
+  public boolean isSingleQuote() {
+    return myIsSingleQuoted;
+  }
+
+  @Override
+  public String toString() {
+    return "YAML quoted text";
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarElementManipulator.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarElementManipulator.java
new file mode 100644 (file)
index 0000000..54051a0
--- /dev/null
@@ -0,0 +1,25 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.AbstractElementManipulator;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.psi.YAMLScalar;
+
+public class YAMLScalarElementManipulator extends AbstractElementManipulator<YAMLScalar> {
+
+  @NotNull
+  @Override
+  public TextRange getRangeInElement(@NotNull YAMLScalar element) {
+    final String content = element.getText();
+    final int startOffset = content.startsWith("'") || content.startsWith("\"") ? 1 : 0;
+    final int endOffset = content.length() > 1 && (content.endsWith("'") || content.endsWith("\"")) ? -1 : 0;
+    return new TextRange(startOffset, content.length() + endOffset);
+  }
+
+  @Override
+  public YAMLScalar handleContentChange(@NotNull YAMLScalar element, @NotNull TextRange range, String newContent)
+    throws IncorrectOperationException {
+    return element;
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarImpl.java
new file mode 100644 (file)
index 0000000..b81742d
--- /dev/null
@@ -0,0 +1,58 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.PsiReference;
+import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.psi.YAMLScalar;
+
+import java.util.List;
+
+public abstract class YAMLScalarImpl extends YAMLValueImpl implements YAMLScalar {
+  public YAMLScalarImpl(@NotNull ASTNode node) {
+    super(node);
+  }
+
+  @NotNull
+  public abstract List<TextRange> getContentRanges();
+
+  @NotNull
+  protected abstract String getRangesJoiner(@NotNull CharSequence leftString, @NotNull CharSequence rightString);
+
+  @NotNull
+  @Override
+  public String getTextValue() {
+    final String text = getText();
+
+
+    final StringBuilder builder = new StringBuilder();
+    CharSequence prevString = null;
+    boolean isFirst = true;
+    for (TextRange range : getContentRanges()) {
+      final CharSequence curString = range.subSequence(text);
+
+      if (!isFirst) {
+        builder.append(getRangesJoiner(prevString, curString));
+      }
+      else {
+        isFirst = false;
+      }
+      builder.append(curString);
+      prevString = curString;
+    }
+    return builder.toString();
+  }
+
+
+  @Override
+  public PsiReference getReference() {
+    final PsiReference[] references = getReferences();
+    return references.length == 1 ? references[0] : null;
+  }
+
+  @NotNull
+  public PsiReference[] getReferences() {
+    return ReferenceProvidersRegistry.getReferencesFromProviders(this);
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarListImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarListImpl.java
new file mode 100644 (file)
index 0000000..a54eb58
--- /dev/null
@@ -0,0 +1,40 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.YAMLTokenTypes;
+import org.jetbrains.yaml.psi.YAMLScalarList;
+
+/**
+ * @author oleg
+ * @see <http://www.yaml.org/spec/1.2/spec.html#id2795688>
+ */
+public class YAMLScalarListImpl extends YAMLBlockScalarImpl implements YAMLScalarList {
+  public YAMLScalarListImpl(@NotNull final ASTNode node) {
+    super(node);
+  }
+
+  @NotNull
+  @Override
+  protected IElementType getContentType() {
+    return YAMLTokenTypes.SCALAR_LIST;
+  }
+
+  @NotNull
+  @Override
+  public String getTextValue() {
+    return super.getTextValue() + "\n";
+  }
+
+  @NotNull
+  @Override
+  protected String getRangesJoiner(@NotNull CharSequence leftString, @NotNull CharSequence rightString) {
+    return "\n";
+  }
+
+  @Override
+  public String toString() {
+    return "YAML scalar list";
+  }
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarTextImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLScalarTextImpl.java
new file mode 100644 (file)
index 0000000..6aaf7e5
--- /dev/null
@@ -0,0 +1,51 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.tree.IElementType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.YAMLTokenTypes;
+import org.jetbrains.yaml.psi.YAMLScalarText;
+
+/**
+ * @author oleg
+ */
+public class YAMLScalarTextImpl extends YAMLBlockScalarImpl implements YAMLScalarText {
+  public YAMLScalarTextImpl(@NotNull final ASTNode node) {
+    super(node);
+  }
+
+  @NotNull
+  @Override
+  protected IElementType getContentType() {
+    return YAMLTokenTypes.SCALAR_TEXT;
+  }
+
+  @NotNull
+  @Override
+  protected String getRangesJoiner(@NotNull CharSequence leftString, @NotNull CharSequence rightString) {
+    if (StringUtil.isEmptyOrSpaces(leftString)) {
+      return "\n";
+    }
+    if (StringUtil.startsWithChar(leftString, ' ') || StringUtil.startsWithChar(leftString, '\t')
+      || StringUtil.startsWithChar(rightString, ' ') || StringUtil.startsWithChar(rightString, '\t')) {
+      return "\n";
+    }
+    if (StringUtil.isEmptyOrSpaces(rightString)) {
+      return "";
+    }
+    return " ";
+  }
+
+  @NotNull
+  @Override
+  public String getTextValue() {
+    return super.getTextValue() + "\n";
+  }
+
+  @Override
+  public String toString() {
+    return "YAML scalar text";
+  }
+
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLSequenceImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLSequenceImpl.java
new file mode 100644 (file)
index 0000000..4270448
--- /dev/null
@@ -0,0 +1,32 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.util.PsiTreeUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.yaml.psi.YAMLSequence;
+import org.jetbrains.yaml.psi.YAMLSequenceItem;
+
+import java.util.List;
+
+public abstract class YAMLSequenceImpl extends YAMLCompoundValueImpl implements YAMLSequence {
+  public YAMLSequenceImpl(@NotNull ASTNode node) {
+    super(node);
+  }
+
+  @NotNull
+  @Override
+  public List<YAMLSequenceItem> getItems() {
+    return PsiTreeUtil.getChildrenOfTypeAsList(this, YAMLSequenceItem.class);
+  }
+
+  @NotNull
+  @Override
+  public String getTextValue() {
+    return "<sequence:" + Integer.toHexString(getText().hashCode()) + ">";
+  }
+
+  @Override
+  public String toString() {
+    return "YAML sequence";
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLSequenceItemImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLSequenceItemImpl.java
new file mode 100644 (file)
index 0000000..f4ccc5f
--- /dev/null
@@ -0,0 +1,44 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.util.PsiTreeUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.yaml.psi.YAMLKeyValue;
+import org.jetbrains.yaml.psi.YAMLMapping;
+import org.jetbrains.yaml.psi.YAMLSequenceItem;
+import org.jetbrains.yaml.psi.YAMLValue;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @author oleg
+ */
+public class YAMLSequenceItemImpl extends YAMLPsiElementImpl implements YAMLSequenceItem {
+  public YAMLSequenceItemImpl(@NotNull final ASTNode node) {
+    super(node);
+  }
+
+  @Nullable
+  @Override
+  public YAMLValue getValue() {
+    return PsiTreeUtil.findChildOfType(this, YAMLValue.class);
+  }
+
+  @NotNull
+  public Collection<YAMLKeyValue> getKeysValues() {
+    final YAMLMapping mapping = PsiTreeUtil.findChildOfType(this, YAMLMapping.class);
+    if (mapping == null) {
+      return Collections.emptyList();
+    }
+    else {
+      return mapping.getKeyValues();
+    }
+  }
+
+  @Override
+  public String toString() {
+    return "YAML sequence item";
+  }
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLValueImpl.java b/plugins/yaml/src/org/jetbrains/yaml/psi/impl/YAMLValueImpl.java
new file mode 100644 (file)
index 0000000..030b85b
--- /dev/null
@@ -0,0 +1,31 @@
+package org.jetbrains.yaml.psi.impl;
+
+import com.intellij.lang.ASTNode;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.yaml.YAMLTokenTypes;
+import org.jetbrains.yaml.psi.YAMLValue;
+
+abstract class YAMLValueImpl extends YAMLPsiElementImpl implements YAMLValue {
+  public YAMLValueImpl(@NotNull ASTNode node) {
+    super(node);
+  }
+
+  @Nullable
+  @Override
+  public PsiElement getTag() {
+    final PsiElement firstChild = getFirstChild();
+    if (firstChild.getNode().getElementType() == YAMLTokenTypes.TAG) {
+      return firstChild;
+    }
+    else {
+      return null;
+    }
+  }
+
+  @Override
+  public String toString() {
+    return "YAML value";
+  }
+}
diff --git a/plugins/yaml/src/org/jetbrains/yaml/structureView/YAMLStructureViewBuilder.java b/plugins/yaml/src/org/jetbrains/yaml/structureView/YAMLStructureViewBuilder.java
new file mode 100644 (file)
index 0000000..0373ae1
--- /dev/null
@@ -0,0 +1,31 @@
+package org.jetbrains.yaml.structureView;
+
+import com.intellij.ide.structureView.StructureViewModel;
+import com.intellij.ide.structureView.StructureViewModelBase;
+import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
+import com.intellij.ide.util.treeView.smartTree.Sorter;
+import com.intellij.openapi.editor.Editor;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.yaml.psi.YAMLDocument;
+import org.jetbrains.yaml.psi.YAMLFile;
+import org.jetbrains.yaml.psi.YAMLKeyValue;
+
+/**
+ * @author oleg
+ */
+public class YAMLStructureViewBuilder extends TreeBasedStructureViewBuilder {
+  private final YAMLFile myPsiFile;
+
+  public YAMLStructureViewBuilder(@NotNull final YAMLFile psiFile) {
+    myPsiFile = psiFile;
+  }
+
+  @Override
+  @NotNull
+  public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+    return new StructureViewModelBase(myPsiFile, editor, new YAMLStructureViewElement(myPsiFile))
+      .withSorters(Sorter.ALPHA_SORTER)
+      .withSuitableClasses(YAMLFile.class, YAMLDocument.class, YAMLKeyValue.class);
+  }
+}
\ No newline at end of file
diff --git a/plugins/yaml/src/org/jetbrains/yaml/structureView/YAMLStructureViewElement.java b/plugins/yaml/src/org/jetbrains/yaml/structureView/YAMLStructureViewElement.java
new file mode 100644 (file)
index 0000000..ee690a5
--- /dev/null
@@ -0,0 +1,151 @@
+package org.jetbrains.yaml.structureView;
+
+import com.intellij.ide.structureView.StructureViewTreeElement;
+import com.intellij.navigation.ItemPresentation;
+import com.intellij.psi.PsiElement;
+import com.intellij.util.PlatformIcons;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.yaml.psi.*;
+
+import javax.swing.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author oleg
+ */
+public class YAMLStructureViewElement implements StructureViewTreeElement {
+  private final YAMLPsiElement myElement;
+
+  public YAMLStructureViewElement(final YAMLPsiElement element) {
+    myElement = element;
+  }
+
+  @NotNull
+  public StructureViewTreeElement[] getChildren() {
+    final Collection<? extends YAMLPsiElement> children;
+    if (myElement instanceof YAMLFile) {
+      children = ((YAMLFile)myElement).getDocuments();
+    }
+    else if (myElement instanceof YAMLDocument) {
+      children = getChildrenForValue(((YAMLDocument)myElement).getTopLevelValue());
+    }
+    else if (myElement instanceof YAMLSequenceItem) {
+      children = getChildrenForValue(((YAMLSequenceItem)myElement).getValue());
+    }
+    else if (myElement instanceof YAMLKeyValue) {
+      children = getChildrenForValue(((YAMLKeyValue)myElement).getValue());
+    }
+    else {
+      children = Collections.emptyList();
+    }
+    
+    final List<StructureViewTreeElement> structureElements = new ArrayList<StructureViewTreeElement>();
+    for (YAMLPsiElement child : children) {
+      structureElements.add(new YAMLStructureViewElement(child));
+    }
+    return structureElements.toArray(new StructureViewTreeElement[structureElements.size()]);
+  }
+  
+  @NotNull
+  private static Collection<? extends YAMLPsiElement> getChildrenForValue(@Nullable YAMLPsiElement element) {
+    if (element instanceof YAMLMapping) {
+      return ((YAMLMapping)element).getKeyValues();
+    }
+    if (element instanceof YAMLSequence) {
+      return ((YAMLSequence)element).getItems();
+    }
+    return Collections.emptyList();
+  }
+  
+
+
+  @NotNull
+  public ItemPresentation getPresentation() {
+    if (myElement instanceof YAMLKeyValue){
+      final YAMLKeyValue kv = (YAMLKeyValue)myElement;
+      return new ItemPresentation() {
+        public String getPresentableText() {
+          return kv.getKeyText();
+        }
+
+        public String getLocationString() {
+          if (kv.getValue() instanceof YAMLScalar) {
+            return kv.getValueText();
+          }
+          else {
+            return null;
+          }
+        }
+
+        public Icon getIcon(boolean open) {
+          final PsiElement value = kv.getValue();
+          return value instanceof YAMLScalar ? PlatformIcons.PROPERTY_ICON : PlatformIcons.XML_TAG_ICON;
+        }
+      };
+    }
+    if (myElement instanceof YAMLDocument){
+      return new ItemPresentation() {
+        public String getPresentableText() {
+          return "YAML document";
+        }
+
+        public String getLocationString() {
+          return null;
+        }
+
+        public Icon getIcon(boolean open) {
+          return PlatformIcons.XML_TAG_ICON;
+        }
+      };
+    }
+    if (myElement instanceof YAMLSequenceItem) {
+      final YAMLSequenceItem item = ((YAMLSequenceItem)myElement);
+      return new ItemPresentation() {
+        @Nullable
+        @Override
+        public String getPresentableText() {
+          if (item.getValue() instanceof YAMLScalar) {
+            return ((YAMLScalar)item.getValue()).getTextValue();
+          }
+          else {
+            return "Sequence Item";
+          }
+        }
+
+        @Nullable
+        @Override
+        public String getLocationString() {
+          return null;
+        }
+
+        @Nullable
+        @Override
+        public Icon getIcon(boolean unused) {
+          return item.getValue() instanceof YAMLScalar ? PlatformIcons.PROPERTY_ICON : PlatformIcons.XML_TAG_ICON;
+        }
+      };
+    }
+    return myElement.getPresentation();
+  }
+
+  public YAMLPsiElement getValue() {
+    return myElement;
+  }
+
+  public void navigate(boolean requestFocus) {
+    myElement.navigate(requestFocus);
+  }
+
+  public boolean canNavigate() {
+    return myElement.canNavigate();
+  }
+
+  public boolean canNavigateToSource() {
+    return myElement.canNavigateToSource();
+  }
+}
+
diff --git a/plugins/yaml/src/org/jetbrains/yaml/structureView/YAMLStructureViewFactory.java b/plugins/yaml/src/org/jetbrains/yaml/structureView/YAMLStructureViewFactory.java
new file mode 100644 (file)
index 0000000..776ce0f
--- /dev/null
@@ -0,0 +1,15 @@
+package org.jetbrains.yaml.structureView;
+
+import com.intellij.ide.structureView.StructureViewBuilder;
+import com.intellij.lang.PsiStructureViewFactory;
+import com.intellij.psi.PsiFile;
+import org.jetbrains.yaml.psi.YAMLFile;
+
+/**
+ * @author oleg
+ */
+public class YAMLStructureViewFactory implements PsiStructureViewFactory {
+  public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
+    return new YAMLStructureViewBuilder((YAMLFile) psiFile);
+  }
+}
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/YAMLLexerTest.java b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/YAMLLexerTest.java
new file mode 100644 (file)
index 0000000..42f720c
--- /dev/null
@@ -0,0 +1,208 @@
+package org.jetbrains.yaml.lexer;
+
+import com.intellij.lexer.Lexer;
+import com.intellij.testFramework.LexerTestCase;
+
+public class YAMLLexerTest extends LexerTestCase {
+  @Override
+  protected Lexer createLexer() {
+    return new YAMLFlexLexer();
+  }
+
+  @Override
+  protected String getDirPath() {
+    return "plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data";
+  }
+
+  public void test2docs() {
+    doTest();
+  }
+
+  public void testColorspage(){
+    doTest();
+  }
+
+  public void testDocuments(){
+    doTest();
+  }
+
+  public void testIndentation(){
+    doTest();
+  }
+
+  public void testMap_between_seq(){
+    doTest();
+  }
+
+  public void testMap_map(){
+    doTest();
+  }
+
+  public void testQuoted_scalars(){
+    doTest();
+  }
+
+  public void testSample_log(){
+    doTest();
+  }
+
+  public void testSeq_seq(){
+    doTest();
+  }
+
+  public void testSequence_mappings(){
+    doTest();
+  }
+
+  public void testWrong_string_highlighting(){
+    doTest();
+  }
+
+  public void testValue_injection(){
+    doTest();
+  }
+
+  public void testValue_injection_2(){
+    doTest();
+  }
+
+  public void testComma(){
+    doTest();
+  }
+
+  public void testIndex(){
+    doTest();
+  }
+
+  public void testKeydots(){
+    doTest();
+  }
+
+  public void testColons74100(){
+    doTest();
+  }
+
+  public void testOnlyyamlkey(){
+    doTest();
+  }
+
+  public void testKey_parens(){
+    doTest();
+  }
+
+  public void testKey_trailing_space(){
+    doTest();
+  }
+
+  public void testComments(){
+    doTest();
+  }
+
+  public void testNon_comment() {
+    doTest();
+  }
+
+  public void testNon_comment2() {
+    doTest();
+  }
+
+  public void testKey_with_brackets() {
+    doTest();
+  }
+
+  public void testStrings() {
+    doTest();
+  }
+
+  public void testStringWithTag() {
+    doTest();
+  }
+
+  public void testNested_seqs() {
+    doTest();
+  }
+
+  public void testMultiline_seq() {
+    doTest();
+  }
+
+  public void testClosing_braces_in_value() {
+    doTest();
+  }
+
+  public void testQuoted_keys() {
+    doTest();
+  }
+
+  public void testTyped_scalar_list() {
+    doTest();
+  }
+
+  public void testMultiline_ruby_16796() {
+    doTest();
+  }
+
+  public void testRuby14738() {
+    doTest();
+  }
+
+  public void testRuby14864() throws Throwable {
+    doTest();
+  }
+
+  public void testRuby15402() throws Throwable {
+    doTest();
+  }
+
+  public void testRuby17389() throws Throwable {
+    doTest();
+  }
+
+  public void testEmptyMultiline() throws Throwable {
+    doTest();
+  }
+
+  public void testMultilineDoubleQuotedKey() {
+    doTest();
+  }
+
+  public void testMultilineSingleQuotedKey() {
+    doTest();
+  }
+
+  public void testMultilineDqLiteralWithEscapedNewlines() {
+    doTest();
+  }
+
+  public void testSmallExplicitDocument() {
+    doTest();
+  }
+
+  public void testSmallStream() {
+    doTest();
+  }
+
+  public void testVerbatimTags() {
+    doTest();
+  }
+
+  public void testTagShorthands() {
+    doTest();
+  }
+
+  public void testOnlyScalars() {
+    doTest();
+  }
+
+  public void testOnlyScalarNoDocument() {
+    doTest();
+  }
+
+  public void testSingleQuotedEscapes() {
+    doTest();
+  }
+
+  private void doTest() {
+    doFileTest("yml");
+  }
+}
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/2docs.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/2docs.txt
new file mode 100644 (file)
index 0000000..f10a5af
--- /dev/null
@@ -0,0 +1,28 @@
+comment ('# Ranking of 1998 home runs')
+Eol ('\n')
+--- ('---')
+Eol ('\n')
+- ('-')
+whitespace (' ')
+text ('Mark McGwire')
+Eol ('\n')
+- ('-')
+whitespace (' ')
+text ('Sammy Sosa')
+Eol ('\n')
+- ('-')
+whitespace (' ')
+text ('Ken Griffey')
+Eol ('\n')
+Eol ('\n')
+comment ('# Team ranking')
+Eol ('\n')
+--- ('---')
+Eol ('\n')
+- ('-')
+whitespace (' ')
+text ('Chicago Cubs')
+Eol ('\n')
+- ('-')
+whitespace (' ')
+text ('St Louis Cardinals')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/2docs.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/2docs.yml
new file mode 100644 (file)
index 0000000..bc711d5
--- /dev/null
@@ -0,0 +1,10 @@
+# Ranking of 1998 home runs
+---
+- Mark McGwire
+- Sammy Sosa
+- Ken Griffey
+
+# Team ranking
+---
+- Chicago Cubs
+- St Louis Cardinals
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/closing_braces_in_value.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/closing_braces_in_value.txt
new file mode 100644 (file)
index 0000000..e0fa9cc
--- /dev/null
@@ -0,0 +1,7 @@
+scalar key ('pattern:')
+whitespace ('  ')
+text ('/boo/{id}')
+Eol ('\n')
+scalar key ('pattern:')
+whitespace ('  ')
+text ('/boo/[id]')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/closing_braces_in_value.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/closing_braces_in_value.yml
new file mode 100644 (file)
index 0000000..e115f0b
--- /dev/null
@@ -0,0 +1,2 @@
+pattern:  /boo/{id}
+pattern:  /boo/[id]
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/colons74100.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/colons74100.txt
new file mode 100644 (file)
index 0000000..c4c2369
--- /dev/null
@@ -0,0 +1,12 @@
+scalar key ('server1:')
+whitespace (' ')
+text ('http://localhost:9876')
+Eol ('\n')
+scalar key ('server2:')
+Eol ('\n')
+indent ('  ')
+text ('http://localhost:8765')
+Eol ('\n')
+scalar key ('server3:')
+whitespace (' ')
+text ('test')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/colons74100.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/colons74100.yml
new file mode 100644 (file)
index 0000000..86604f0
--- /dev/null
@@ -0,0 +1,4 @@
+server1: http://localhost:9876
+server2:
+  http://localhost:8765
+server3: test
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/colorspage.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/colorspage.txt
new file mode 100644 (file)
index 0000000..ee0f927
--- /dev/null
@@ -0,0 +1,49 @@
+comment ('# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html')
+Eol ('\n')
+scalar key ('static_sidebar:')
+Eol ('\n')
+indent ('  ')
+scalar key ('id:')
+whitespace (' ')
+scalar dstring ('"foo"')
+Eol ('\n')
+indent ('  ')
+scalar key ('name:')
+whitespace (' ')
+scalar string (''side_bar'')
+Eol ('\n')
+indent ('  ')
+scalar key ('staged_position:')
+whitespace (' ')
+text ('1')
+Eol ('\n')
+indent ('  ')
+scalar key ('blog_id:')
+whitespace (' ')
+text ('1')
+Eol ('\n')
+indent ('  ')
+scalar key ('config:')
+whitespace (' ')
+scalar list ('|+')
+Eol ('\n')
+indent ('    ')
+scalar list ('--- !map:HashWithIndifferentAccess')
+Eol ('\n')
+indent ('      ')
+scalar list ('title: Static Sidebar')
+Eol ('\n')
+indent ('      ')
+scalar list ('body: The body of a static sidebar')
+Eol ('\n')
+indent ('  ')
+scalar key ('type:')
+whitespace (' ')
+text ('StaticSidebar')
+Eol ('\n')
+indent ('  ')
+scalar key ('type:')
+whitespace (' ')
+scalar text ('>')
+whitespace (' ')
+text ('some_type_here')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/colorspage.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/colorspage.yml
new file mode 100644 (file)
index 0000000..0ebd0fa
--- /dev/null
@@ -0,0 +1,12 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+static_sidebar:
+  id: "foo"
+  name: 'side_bar'
+  staged_position: 1
+  blog_id: 1
+  config: |+
+    --- !map:HashWithIndifferentAccess
+      title: Static Sidebar
+      body: The body of a static sidebar
+  type: StaticSidebar
+  type: > some_type_here
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/comma.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/comma.txt
new file mode 100644 (file)
index 0000000..ccfec8b
--- /dev/null
@@ -0,0 +1,3 @@
+scalar key ('key:')
+whitespace (' ')
+text ('Hello, how are you?')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/comma.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/comma.yml
new file mode 100644 (file)
index 0000000..8a28c1d
--- /dev/null
@@ -0,0 +1 @@
+key: Hello, how are you?
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/comments.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/comments.txt
new file mode 100644 (file)
index 0000000..d5a533c
--- /dev/null
@@ -0,0 +1,24 @@
+scalar key ('en:')
+Eol ('\n')
+indent ('  ')
+scalar key ('aaa:')
+whitespace (' ')
+scalar dstring ('"AAA"')
+Eol ('\n')
+comment ('#  bbb:')
+Eol ('\n')
+comment ('#    ccc: "CCC"')
+Eol ('\n')
+scalar key ('installation:')
+Eol ('\n')
+indent ('  ')
+scalar key ('name:')
+whitespace (' ')
+[ ('[')
+] (']')
+whitespace (' ')
+comment ('# todo: "Not specified"')
+Eol ('\n')
+text ('en')
+whitespace (' ')
+comment ('#comment: TODO')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/comments.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/comments.yml
new file mode 100644 (file)
index 0000000..dfd728b
--- /dev/null
@@ -0,0 +1,7 @@
+en:
+  aaa: "AAA"
+#  bbb:
+#    ccc: "CCC"
+installation:
+  name: [] # todo: "Not specified"
+en #comment: TODO
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/documents.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/documents.txt
new file mode 100644 (file)
index 0000000..e85045f
--- /dev/null
@@ -0,0 +1,52 @@
+--- ('---')
+Eol ('\n')
+scalar key ('RubyMine Develoers:')
+Eol ('\n')
+indent ('    ')
+scalar key ('name:')
+whitespace (' ')
+text ('yole')
+Eol ('\n')
+indent ('    ')
+scalar key ('name:')
+whitespace (' ')
+text ('romeo')
+Eol ('\n')
+indent ('    ')
+scalar key ('name:')
+whitespace (' ')
+text ('den')
+Eol ('\n')
+indent ('    ')
+scalar key ('name:')
+whitespace (' ')
+text ('oleg')
+Eol ('\n')
+--- ('---')
+Eol ('\n')
+scalar key ('RubyMine Versions:')
+Eol ('\n')
+indent ('    ')
+- ('-')
+whitespace (' ')
+text ('1.0')
+Eol ('\n')
+indent ('    ')
+- ('-')
+whitespace (' ')
+text ('1.1')
+Eol ('\n')
+indent ('    ')
+- ('-')
+whitespace (' ')
+text ('1.1.1')
+Eol ('\n')
+indent ('    ')
+- ('-')
+whitespace (' ')
+text ('1.5 EAP')
+Eol ('\n')
+indent ('    ')
+- ('-')
+whitespace (' ')
+text ('1.5')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/documents.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/documents.yml
new file mode 100644 (file)
index 0000000..f88e3b1
--- /dev/null
@@ -0,0 +1,13 @@
+---
+RubyMine Develoers:
+    name: yole
+    name: romeo
+    name: den
+    name: oleg
+---
+RubyMine Versions:
+    - 1.0
+    - 1.1
+    - 1.1.1
+    - 1.5 EAP
+    - 1.5
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/emptyMultiline.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/emptyMultiline.txt
new file mode 100644 (file)
index 0000000..e2d06aa
--- /dev/null
@@ -0,0 +1,26 @@
+--- ('---')
+Eol ('\n')
+scalar key ('foo:')
+whitespace (' ')
+scalar text ('>')
+Eol ('\n')
+scalar key ('bar:')
+Eol ('\n')
+indent ('  ')
+scalar key ('abc:')
+whitespace (' ')
+text ('def')
+Eol ('\n')
+indent ('  ')
+scalar key ('ghi:')
+whitespace (' ')
+scalar text ('>')
+Eol ('\n')
+indent ('  ')
+scalar key ('jkl:')
+whitespace (' ')
+text ('mno')
+Eol ('\n')
+scalar key ('baz:')
+whitespace (' ')
+text ('qwe')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/emptyMultiline.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/emptyMultiline.yml
new file mode 100644 (file)
index 0000000..3c69f02
--- /dev/null
@@ -0,0 +1,7 @@
+---
+foo: >
+bar:
+  abc: def
+  ghi: >
+  jkl: mno
+baz: qwe
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/indentation.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/indentation.txt
new file mode 100644 (file)
index 0000000..a6ca77e
--- /dev/null
@@ -0,0 +1,23 @@
+scalar key ('name:')
+whitespace (' ')
+text ('Mark McGwire')
+Eol ('\n')
+scalar key ('accomplishment:')
+whitespace (' ')
+scalar text ('>')
+Eol ('\n')
+indent ('  ')
+scalar text ('Mark set a major league')
+Eol ('\n')
+indent ('  ')
+scalar text ('home run record in 1998.')
+Eol ('\n')
+scalar key ('stats:')
+whitespace (' ')
+scalar list ('|')
+Eol ('\n')
+indent ('  ')
+scalar list ('65 Home Runs')
+Eol ('\n')
+indent ('  ')
+scalar list ('0.278 Batting Average')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/indentation.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/indentation.yml
new file mode 100644 (file)
index 0000000..9f66d88
--- /dev/null
@@ -0,0 +1,7 @@
+name: Mark McGwire
+accomplishment: >
+  Mark set a major league
+  home run record in 1998.
+stats: |
+  65 Home Runs
+  0.278 Batting Average
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/index.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/index.txt
new file mode 100644 (file)
index 0000000..0f17932
--- /dev/null
@@ -0,0 +1,30 @@
+scalar key ('indexes:')
+Eol ('\n')
+Eol ('\n')
+- ('-')
+whitespace (' ')
+scalar key ('kind:')
+whitespace (' ')
+text ('MessageIndex')
+Eol ('\n')
+indent ('  ')
+scalar key ('properties:')
+Eol ('\n')
+indent ('  ')
+- ('-')
+whitespace (' ')
+scalar key ('name:')
+whitespace (' ')
+text ('group_name')
+Eol ('\n')
+indent ('  ')
+- ('-')
+whitespace (' ')
+scalar key ('name:')
+whitespace (' ')
+text ('created_at')
+Eol ('\n')
+indent ('    ')
+scalar key ('direction:')
+whitespace (' ')
+text ('desc')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/index.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/index.yml
new file mode 100644 (file)
index 0000000..b4e02e1
--- /dev/null
@@ -0,0 +1,7 @@
+indexes:
+
+- kind: MessageIndex
+  properties:
+  - name: group_name
+  - name: created_at
+    direction: desc
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_parens.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_parens.txt
new file mode 100644 (file)
index 0000000..4ec3f3b
--- /dev/null
@@ -0,0 +1 @@
+scalar key ('comment(c):')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_parens.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_parens.yml
new file mode 100644 (file)
index 0000000..40c2881
--- /dev/null
@@ -0,0 +1 @@
+comment(c):
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_trailing_space.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_trailing_space.txt
new file mode 100644 (file)
index 0000000..e1d4163
--- /dev/null
@@ -0,0 +1 @@
+scalar key ('foo   :')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_trailing_space.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_trailing_space.yml
new file mode 100644 (file)
index 0000000..88e1321
--- /dev/null
@@ -0,0 +1 @@
+foo   :
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_with_brackets.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_with_brackets.txt
new file mode 100644 (file)
index 0000000..f17065f
--- /dev/null
@@ -0,0 +1,3 @@
+scalar key ('foo[in_brackets]:')
+whitespace (' ')
+text ('text')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_with_brackets.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/key_with_brackets.yml
new file mode 100644 (file)
index 0000000..d273b27
--- /dev/null
@@ -0,0 +1 @@
+foo[in_brackets]: text
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/keydots.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/keydots.txt
new file mode 100644 (file)
index 0000000..05d152b
--- /dev/null
@@ -0,0 +1,6 @@
+scalar key ('my.testevent.pre:')
+Eol ('\n')
+indent ('  ')
+scalar key ('type:')
+whitespace ('     ')
+text ('sfEvent')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/keydots.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/keydots.yml
new file mode 100644 (file)
index 0000000..fc7d608
--- /dev/null
@@ -0,0 +1,3 @@
+my.testevent.pre:
+  type:     sfEvent
+
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/map_between_seq.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/map_between_seq.txt
new file mode 100644 (file)
index 0000000..cb9fb71
--- /dev/null
@@ -0,0 +1,45 @@
+? ('?')
+whitespace (' ')
+- ('-')
+whitespace (' ')
+text ('Detroit Tigers')
+Eol ('\n')
+indent ('  ')
+- ('-')
+whitespace (' ')
+text ('Chicago cubs')
+Eol ('\n')
+: (':')
+Eol ('\n')
+indent ('  ')
+- ('-')
+whitespace (' ')
+text ('2001-07-23')
+Eol ('\n')
+Eol ('\n')
+? ('?')
+whitespace (' ')
+[ ('[')
+whitespace (' ')
+text ('New York Yankees')
+, (',')
+Eol ('\n')
+indent ('    ')
+text ('Atlanta Braves')
+whitespace (' ')
+] (']')
+Eol ('\n')
+: (':')
+whitespace (' ')
+[ ('[')
+whitespace (' ')
+text ('2001-07-02')
+, (',')
+whitespace (' ')
+text ('2001-08-12')
+, (',')
+Eol ('\n')
+indent ('    ')
+text ('2001-08-14')
+whitespace (' ')
+] (']')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/map_between_seq.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/map_between_seq.yml
new file mode 100644 (file)
index 0000000..9123ce2
--- /dev/null
@@ -0,0 +1,9 @@
+? - Detroit Tigers
+  - Chicago cubs
+:
+  - 2001-07-23
+
+? [ New York Yankees,
+    Atlanta Braves ]
+: [ 2001-07-02, 2001-08-12,
+    2001-08-14 ]
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/map_map.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/map_map.txt
new file mode 100644 (file)
index 0000000..506fc88
--- /dev/null
@@ -0,0 +1,30 @@
+scalar key ('Mark McGwire:')
+whitespace (' ')
+{ ('{')
+scalar key ('hr:')
+whitespace (' ')
+text ('65')
+, (',')
+whitespace (' ')
+scalar key ('avg:')
+whitespace (' ')
+text ('0.278')
+} ('}')
+Eol ('\n')
+scalar key ('Sammy Sosa:')
+whitespace (' ')
+{ ('{')
+Eol ('\n')
+indent ('    ')
+scalar key ('hr:')
+whitespace (' ')
+text ('63')
+, (',')
+Eol ('\n')
+indent ('    ')
+scalar key ('avg:')
+whitespace (' ')
+text ('0.288')
+Eol ('\n')
+indent ('  ')
+} ('}')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/map_map.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/map_map.yml
new file mode 100644 (file)
index 0000000..7a957b2
--- /dev/null
@@ -0,0 +1,5 @@
+Mark McGwire: {hr: 65, avg: 0.278}
+Sammy Sosa: {
+    hr: 63,
+    avg: 0.288
+  }
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineDoubleQuotedKey.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineDoubleQuotedKey.txt
new file mode 100644 (file)
index 0000000..3453657
--- /dev/null
@@ -0,0 +1,14 @@
+--- ('---')
+Eol ('\n')
+scalar key ('foo:')
+whitespace (' ')
+text ('bar')
+Eol ('\n')
+scalar key ('"baz":')
+whitespace (' ')
+text ('babaz')
+Eol ('\n')
+scalar dstring ('"tra\ntata"')
+: (':')
+whitespace (' ')
+text ('is restricted')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineDoubleQuotedKey.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineDoubleQuotedKey.yml
new file mode 100644 (file)
index 0000000..6f37f40
--- /dev/null
@@ -0,0 +1,5 @@
+---
+foo: bar
+"baz": babaz
+"tra
+tata": is restricted
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineDqLiteralWithEscapedNewlines.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineDqLiteralWithEscapedNewlines.txt
new file mode 100644 (file)
index 0000000..7066a86
--- /dev/null
@@ -0,0 +1,3 @@
+scalar key ('somevalue:')
+whitespace (' ')
+scalar dstring ('"text text skjdfhjksd fjs djfksjdkfksdfkds jf\\n  sdkjfhsjkdfhjkshdfjhsdjkfhskjdf"')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineDqLiteralWithEscapedNewlines.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineDqLiteralWithEscapedNewlines.yml
new file mode 100644 (file)
index 0000000..a05961b
--- /dev/null
@@ -0,0 +1,2 @@
+somevalue: "text text skjdfhjksd fjs djfksjdkfksdfkds jf\
+  sdkjfhsjkdfhjkshdfjhsdjkfhskjdf"
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineSingleQuotedKey.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineSingleQuotedKey.txt
new file mode 100644 (file)
index 0000000..821fa13
--- /dev/null
@@ -0,0 +1,14 @@
+--- ('---')
+Eol ('\n')
+scalar key ('foo:')
+whitespace (' ')
+text ('bar')
+Eol ('\n')
+scalar key (''asd':')
+whitespace (' ')
+text ('def')
+Eol ('\n')
+scalar string (''dsad\nasd'')
+: (':')
+whitespace (' ')
+text ('restricted')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineSingleQuotedKey.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multilineSingleQuotedKey.yml
new file mode 100644 (file)
index 0000000..96dc6f9
--- /dev/null
@@ -0,0 +1,5 @@
+---
+foo: bar
+'asd': def
+'dsad
+asd': restricted
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multiline_ruby_16796.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multiline_ruby_16796.txt
new file mode 100644 (file)
index 0000000..1b84809
--- /dev/null
@@ -0,0 +1,23 @@
+scalar key ('copy:')
+Eol ('\n')
+indent ('  ')
+text ('src="keys/{{ item }}"')
+Eol ('\n')
+indent ('  ')
+text ('dest="{{ deploy_home }}/.ssh/"')
+Eol ('\n')
+indent ('  ')
+text ('owner="{{ deploy_user }}"')
+Eol ('\n')
+indent ('  ')
+text ('group="{{ deploy_group }}"')
+Eol ('\n')
+indent ('  ')
+text ('mode=0600')
+Eol ('\n')
+scalar key ('with_items:')
+Eol ('\n')
+indent ('  ')
+- ('-')
+whitespace (' ')
+scalar dstring ('"id_rsa"')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multiline_ruby_16796.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multiline_ruby_16796.yml
new file mode 100644 (file)
index 0000000..7abbe02
--- /dev/null
@@ -0,0 +1,8 @@
+copy:
+  src="keys/{{ item }}"
+  dest="{{ deploy_home }}/.ssh/"
+  owner="{{ deploy_user }}"
+  group="{{ deploy_group }}"
+  mode=0600
+with_items:
+  - "id_rsa"
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multiline_seq.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multiline_seq.txt
new file mode 100644 (file)
index 0000000..c46fe23
--- /dev/null
@@ -0,0 +1,27 @@
+scalar key ('item:')
+Eol ('\n')
+- ('-')
+Eol ('\n')
+indent ('  ')
+scalar key ('property:')
+whitespace (' ')
+[ ('[')
+Eol ('\n')
+indent ('   ')
+scalar string (''value[]'')
+Eol ('\n')
+indent ('  ')
+] (']')
+Eol ('\n')
+- ('-')
+Eol ('\n')
+indent ('  ')
+scalar key ('property:')
+whitespace (' ')
+[ ('[')
+Eol ('\n')
+indent ('   ')
+scalar string (''value'')
+Eol ('\n')
+indent ('  ')
+] (']')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multiline_seq.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/multiline_seq.yml
new file mode 100644 (file)
index 0000000..2378de0
--- /dev/null
@@ -0,0 +1,9 @@
+item:
+-
+  property: [
+   'value[]'
+  ]
+-
+  property: [
+   'value'
+  ]
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/nested_seqs.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/nested_seqs.txt
new file mode 100644 (file)
index 0000000..1a9df5a
--- /dev/null
@@ -0,0 +1,16 @@
+- ('-')
+whitespace (' ')
+[ ('[')
+whitespace (' ')
+text ('setEntityClass')
+, (',')
+whitespace (' ')
+[ ('[')
+text ('MyprojectMyBundle:MyEntity')
+] (']')
+whitespace (' ')
+] (']')
+Eol ('\n')
+- ('-')
+whitespace (' ')
+text ('something, with comma')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/nested_seqs.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/nested_seqs.yml
new file mode 100644 (file)
index 0000000..bf16cdb
--- /dev/null
@@ -0,0 +1,2 @@
+- [ setEntityClass, [MyprojectMyBundle:MyEntity] ]
+- something, with comma
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/non_comment.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/non_comment.txt
new file mode 100644 (file)
index 0000000..f0c8340
--- /dev/null
@@ -0,0 +1,3 @@
+scalar key ('hello:')
+whitespace (' ')
+text ('hello#my_non_comment')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/non_comment.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/non_comment.yml
new file mode 100644 (file)
index 0000000..d70f000
--- /dev/null
@@ -0,0 +1 @@
+hello: hello#my_non_comment
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/non_comment2.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/non_comment2.txt
new file mode 100644 (file)
index 0000000..32de8b5
--- /dev/null
@@ -0,0 +1,3 @@
+scalar key ('foo#non_comment:')
+whitespace (' ')
+text ('text')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/non_comment2.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/non_comment2.yml
new file mode 100644 (file)
index 0000000..c53dbc2
--- /dev/null
@@ -0,0 +1 @@
+foo#non_comment: text
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyScalarNoDocument.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyScalarNoDocument.txt
new file mode 100644 (file)
index 0000000..5500c75
--- /dev/null
@@ -0,0 +1,10 @@
+scalar list ('|')
+Eol ('\n')
+indent ('  ')
+Eol ('\n')
+Eol ('\n')
+indent (' ')
+scalar list ('foo')
+Eol ('\n')
+indent (' ')
+scalar list ('bar')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyScalarNoDocument.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyScalarNoDocument.yml
new file mode 100644 (file)
index 0000000..b709b46
--- /dev/null
@@ -0,0 +1,5 @@
+|
+  
+
+ foo
+ bar
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyScalars.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyScalars.txt
new file mode 100644 (file)
index 0000000..3ca18d1
--- /dev/null
@@ -0,0 +1,20 @@
+--- ('---')
+whitespace (' ')
+scalar list ('|')
+Eol ('\n')
+indent (' ')
+scalar list ('literal')
+Eol ('\n')
+indent (' ')
+scalar list ('text')
+Eol ('\n')
+Eol ('\n')
+--- ('---')
+whitespace (' ')
+scalar text ('>')
+Eol ('\n')
+indent (' ')
+scalar text ('literal')
+Eol ('\n')
+indent (' ')
+scalar text ('text')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyScalars.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyScalars.yml
new file mode 100644 (file)
index 0000000..8f56ae4
--- /dev/null
@@ -0,0 +1,7 @@
+--- |
+ literal
+ text
+
+--- >
+ literal
+ text
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyyamlkey.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyyamlkey.txt
new file mode 100644 (file)
index 0000000..4695702
--- /dev/null
@@ -0,0 +1 @@
+scalar key ('foo:')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyyamlkey.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/onlyyamlkey.yml
new file mode 100644 (file)
index 0000000..0152a79
--- /dev/null
@@ -0,0 +1 @@
+foo:
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/quoted_keys.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/quoted_keys.txt
new file mode 100644 (file)
index 0000000..1a1a07d
--- /dev/null
@@ -0,0 +1,26 @@
+scalar key ('"quoted key 1":')
+whitespace (' ')
+[ ('[')
+scalar dstring ('"loginGuard"')
+, (',')
+whitespace (' ')
+scalar dstring ('"arrangementPage"')
+] (']')
+Eol ('\n')
+scalar key ('"quoted key 2":')
+whitespace (' ')
+[ ('[')
+scalar dstring ('"loginGuard"')
+, (',')
+whitespace (' ')
+scalar dstring ('"repositoryPage"')
+] (']')
+Eol ('\n')
+scalar key ('key:')
+whitespace (' ')
+[ ('[')
+whitespace (' ')
+scalar key ('"quoted key 3":')
+whitespace (' ')
+scalar dstring ('"loginGuard"')
+] (']')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/quoted_keys.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/quoted_keys.yml
new file mode 100644 (file)
index 0000000..3919af1
--- /dev/null
@@ -0,0 +1,3 @@
+"quoted key 1": ["loginGuard", "arrangementPage"]
+"quoted key 2": ["loginGuard", "repositoryPage"]
+key: [ "quoted key 3": "loginGuard"]
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/quoted_scalars.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/quoted_scalars.txt
new file mode 100644 (file)
index 0000000..4161597
--- /dev/null
@@ -0,0 +1,41 @@
+scalar key ('unicode:')
+whitespace (' ')
+scalar dstring ('"Sosa did fine.\u263A"')
+Eol ('\n')
+scalar key ('control:')
+whitespace (' ')
+scalar dstring ('"\b1998\t1999\t2000\n"')
+Eol ('\n')
+scalar key ('hex esc:')
+whitespace (' ')
+scalar dstring ('"\x0d\x0a is \r\n"')
+Eol ('\n')
+Eol ('\n')
+scalar key ('single:')
+whitespace (' ')
+scalar string (''"Howdy!" he cried.'')
+Eol ('\n')
+scalar key ('quoted:')
+whitespace (' ')
+scalar string ('' # not a ''comment''.'')
+Eol ('\n')
+scalar key ('tie-fighter:')
+whitespace (' ')
+scalar string (''|\-*-/|'')
+Eol ('\n')
+scalar key ('foo:')
+whitespace (' ')
+[ ('[')
+scalar string (''a'')
+, (',')
+whitespace (' ')
+scalar string (''b'')
+] (']')
+Eol ('\n')
+scalar key ('key:')
+whitespace (' ')
+scalar string (''value\'')
+Eol ('\n')
+scalar key ('key2:')
+whitespace (' ')
+scalar string (''value'')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/quoted_scalars.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/quoted_scalars.yml
new file mode 100644 (file)
index 0000000..6f1e8aa
--- /dev/null
@@ -0,0 +1,10 @@
+unicode: "Sosa did fine.\u263A"
+control: "\b1998\t1999\t2000\n"
+hex esc: "\x0d\x0a is \r\n"
+
+single: '"Howdy!" he cried.'
+quoted: ' # not a ''comment''.'
+tie-fighter: '|\-*-/|'
+foo: ['a', 'b']
+key: 'value\'
+key2: 'value'
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby14738.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby14738.txt
new file mode 100644 (file)
index 0000000..c8aadae
--- /dev/null
@@ -0,0 +1,16 @@
+scalar key ('my_service:')
+Eol ('\n')
+indent ('  ')
+scalar key ('class:')
+whitespace (' ')
+text ('My\Service')
+Eol ('\n')
+indent ('  ')
+scalar key ('arguments:')
+whitespace (' ')
+[ ('[')
+text ('@doctrine.orm.entity_manager')
+, (',')
+whitespace (' ')
+text ('@?logger')
+] (']')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby14738.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby14738.yml
new file mode 100644 (file)
index 0000000..920fbf3
--- /dev/null
@@ -0,0 +1,3 @@
+my_service:
+  class: My\Service
+  arguments: [@doctrine.orm.entity_manager, @?logger]
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby14864.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby14864.txt
new file mode 100644 (file)
index 0000000..cac55a4
--- /dev/null
@@ -0,0 +1,10 @@
+scalar key ('a:')
+whitespace (' ')
+scalar text ('>-')
+Eol ('\n')
+indent ('  ')
+scalar text ('aaaaa'sdasdasd')
+Eol ('\n')
+scalar key ('b:')
+whitespace (' ')
+text ('1')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby14864.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby14864.yml
new file mode 100644 (file)
index 0000000..70f28f0
--- /dev/null
@@ -0,0 +1,3 @@
+a: >-
+  aaaaa'sdasdasd
+b: 1
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby15402.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby15402.txt
new file mode 100644 (file)
index 0000000..17e7fc5
--- /dev/null
@@ -0,0 +1,22 @@
+scalar key ('MetalProductsBundle:Products:searchSuggest:')
+Eol ('\n')
+indent ('    ')
+scalar key ('path:')
+whitespace ('      ')
+text ('/search-suggest/')
+Eol ('\n')
+indent ('    ')
+scalar key ('host:')
+whitespace ('      ')
+scalar dstring ('"{subdomain}.%base_host%"')
+Eol ('\n')
+indent ('    ')
+scalar key ('defaults:')
+whitespace ('  ')
+{ ('{')
+whitespace (' ')
+scalar key ('_controller:')
+whitespace (' ')
+text ('MetalProductsBundle:Products:searchSuggest')
+whitespace (' ')
+} ('}')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby15402.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby15402.yml
new file mode 100644 (file)
index 0000000..95d2fb8
--- /dev/null
@@ -0,0 +1,4 @@
+MetalProductsBundle:Products:searchSuggest:
+    path:      /search-suggest/
+    host:      "{subdomain}.%base_host%"
+    defaults:  { _controller: MetalProductsBundle:Products:searchSuggest }
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby17389.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby17389.txt
new file mode 100644 (file)
index 0000000..57b880f
--- /dev/null
@@ -0,0 +1,10 @@
+--- ('---')
+Eol ('\n')
+scalar key ('foo:')
+whitespace (' ')
+{ ('{')
+} ('}')
+Eol ('\n')
+scalar key ('bar:')
+whitespace (' ')
+scalar dstring ('"baz"')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby17389.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/ruby17389.yml
new file mode 100644 (file)
index 0000000..588395f
--- /dev/null
@@ -0,0 +1,3 @@
+---
+foo: {}
+bar: "baz"
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/sample_log.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/sample_log.txt
new file mode 100644 (file)
index 0000000..a845585
--- /dev/null
@@ -0,0 +1,45 @@
+scalar key ('Date:')
+whitespace (' ')
+text ('2001-11-23')
+Eol ('\n')
+scalar key ('Stack:')
+Eol ('\n')
+indent ('  ')
+- ('-')
+whitespace (' ')
+scalar key ('file:')
+whitespace (' ')
+text ('TopClass.py')
+Eol ('\n')
+indent ('    ')
+scalar key ('line:')
+whitespace (' ')
+text ('23')
+Eol ('\n')
+indent ('    ')
+scalar key ('code:')
+whitespace (' ')
+scalar list ('|')
+Eol ('\n')
+indent ('      ')
+scalar list ('x = MoreObject("345\n")')
+Eol ('\n')
+indent ('  ')
+- ('-')
+whitespace (' ')
+scalar key ('file:')
+whitespace (' ')
+text ('MoreClass.py')
+Eol ('\n')
+indent ('    ')
+scalar key ('line:')
+whitespace (' ')
+text ('58')
+Eol ('\n')
+indent ('    ')
+scalar key ('code:')
+whitespace (' ')
+scalar list ('|-')
+Eol ('\n')
+indent ('      ')
+scalar list ('foo = bar')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/sample_log.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/sample_log.yml
new file mode 100644 (file)
index 0000000..0eabd44
--- /dev/null
@@ -0,0 +1,10 @@
+Date: 2001-11-23
+Stack:
+  - file: TopClass.py
+    line: 23
+    code: |
+      x = MoreObject("345\n")
+  - file: MoreClass.py
+    line: 58
+    code: |-
+      foo = bar
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/seq_seq.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/seq_seq.txt
new file mode 100644 (file)
index 0000000..d0363d1
--- /dev/null
@@ -0,0 +1,38 @@
+- ('-')
+whitespace (' ')
+[ ('[')
+text ('name')
+whitespace ('        ')
+, (',')
+whitespace (' ')
+text ('hr')
+, (',')
+whitespace (' ')
+text ('avg')
+whitespace ('  ')
+] (']')
+Eol ('\n')
+- ('-')
+whitespace (' ')
+[ ('[')
+text ('Mark McGwire')
+, (',')
+whitespace (' ')
+text ('65')
+, (',')
+whitespace (' ')
+text ('0.278')
+] (']')
+Eol ('\n')
+- ('-')
+whitespace (' ')
+[ ('[')
+text ('Sammy Sosa')
+whitespace ('  ')
+, (',')
+whitespace (' ')
+text ('63')
+, (',')
+whitespace (' ')
+text ('0.288')
+] (']')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/seq_seq.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/seq_seq.yml
new file mode 100644 (file)
index 0000000..cdd7770
--- /dev/null
@@ -0,0 +1,3 @@
+- [name        , hr, avg  ]
+- [Mark McGwire, 65, 0.278]
+- [Sammy Sosa  , 63, 0.288]
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/sequence_mappings.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/sequence_mappings.txt
new file mode 100644 (file)
index 0000000..dccd579
--- /dev/null
@@ -0,0 +1,33 @@
+- ('-')
+Eol ('\n')
+indent ('  ')
+scalar key ('name:')
+whitespace (' ')
+text ('Mark McGwire')
+Eol ('\n')
+indent ('  ')
+scalar key ('hr:')
+whitespace ('   ')
+text ('65')
+Eol ('\n')
+indent ('  ')
+scalar key ('avg:')
+whitespace ('  ')
+text ('0.278')
+Eol ('\n')
+- ('-')
+Eol ('\n')
+indent ('  ')
+scalar key ('name:')
+whitespace (' ')
+text ('Sammy Sosa')
+Eol ('\n')
+indent ('  ')
+scalar key ('hr:')
+whitespace ('   ')
+text ('63')
+Eol ('\n')
+indent ('  ')
+scalar key ('avg:')
+whitespace ('  ')
+text ('0.288')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/sequence_mappings.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/sequence_mappings.yml
new file mode 100644 (file)
index 0000000..430f6b3
--- /dev/null
@@ -0,0 +1,8 @@
+-
+  name: Mark McGwire
+  hr:   65
+  avg:  0.278
+-
+  name: Sammy Sosa
+  hr:   63
+  avg:  0.288
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/singleQuotedEscapes.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/singleQuotedEscapes.txt
new file mode 100644 (file)
index 0000000..e03749b
--- /dev/null
@@ -0,0 +1 @@
+scalar string (''here''s to "quotes"'')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/singleQuotedEscapes.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/singleQuotedEscapes.yml
new file mode 100644 (file)
index 0000000..c4b4ca9
--- /dev/null
@@ -0,0 +1 @@
+'here''s to "quotes"'
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/smallExplicitDocument.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/smallExplicitDocument.txt
new file mode 100644 (file)
index 0000000..1cce2ed
--- /dev/null
@@ -0,0 +1,9 @@
+text ('%YAML 1.2')
+Eol ('\n')
+--- ('---')
+Eol ('\n')
+text ('Document')
+Eol ('\n')
+... ('...')
+whitespace (' ')
+comment ('# Suffix')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/smallExplicitDocument.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/smallExplicitDocument.yml
new file mode 100644 (file)
index 0000000..bbbc37b
--- /dev/null
@@ -0,0 +1,4 @@
+%YAML 1.2
+---
+Document
+... # Suffix
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/smallStream.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/smallStream.txt
new file mode 100644 (file)
index 0000000..83f364e
--- /dev/null
@@ -0,0 +1,15 @@
+text ('Document')
+Eol ('\n')
+--- ('---')
+Eol ('\n')
+comment ('# Empty')
+Eol ('\n')
+... ('...')
+Eol ('\n')
+text ('%YAML 1.2')
+Eol ('\n')
+--- ('---')
+Eol ('\n')
+scalar key ('matches %:')
+whitespace (' ')
+text ('20')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/smallStream.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/smallStream.yml
new file mode 100644 (file)
index 0000000..4c004fd
--- /dev/null
@@ -0,0 +1,7 @@
+Document
+---
+# Empty
+...
+%YAML 1.2
+---
+matches %: 20
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/stringWithTag.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/stringWithTag.txt
new file mode 100644 (file)
index 0000000..ab03026
--- /dev/null
@@ -0,0 +1,5 @@
+scalar key ('foo:')
+whitespace (' ')
+tag ('!')
+whitespace (' ')
+scalar dstring ('"tratata"')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/stringWithTag.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/stringWithTag.yml
new file mode 100644 (file)
index 0000000..5104510
--- /dev/null
@@ -0,0 +1 @@
+foo: ! "tratata"
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/strings.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/strings.txt
new file mode 100644 (file)
index 0000000..d3585ab
--- /dev/null
@@ -0,0 +1,125 @@
+scalar key ('foo1:')
+whitespace (' ')
+[ ('[')
+scalar dstring ('"day"')
+, (',')
+whitespace (' ')
+scalar dstring ('"month"')
+, (',')
+whitespace (' ')
+scalar dstring ('"year"')
+] (']')
+Eol ('\n')
+scalar key ('foo2:')
+whitespace (' ')
+[ ('[')
+scalar string (''day'')
+, (',')
+whitespace (' ')
+scalar string (''month'')
+, (',')
+whitespace (' ')
+scalar string (''year'')
+] (']')
+Eol ('\n')
+scalar key ('foo3:')
+whitespace (' ')
+[ ('[')
+scalar dstring ('"day[1]"')
+, (',')
+whitespace (' ')
+scalar dstring ('"month[1]"')
+, (',')
+whitespace (' ')
+scalar dstring ('"year[1]"')
+] (']')
+Eol ('\n')
+scalar key ('foo4:')
+whitespace (' ')
+[ ('[')
+scalar string (''day[1]'')
+, (',')
+whitespace (' ')
+scalar string (''month[1]'')
+, (',')
+whitespace (' ')
+scalar string (''year[1]'')
+] (']')
+Eol ('\n')
+scalar key ('foo5:')
+whitespace (' ')
+[ ('[')
+scalar dstring ('"?day"')
+, (',')
+whitespace (' ')
+scalar dstring ('"?month"')
+, (',')
+whitespace (' ')
+scalar dstring ('"?year"')
+] (']')
+Eol ('\n')
+scalar key ('foo6:')
+whitespace (' ')
+[ ('[')
+scalar string (''?day'')
+, (',')
+whitespace (' ')
+scalar string (''?month'')
+, (',')
+whitespace (' ')
+scalar string (''?year'')
+] (']')
+Eol ('\n')
+scalar key ('foo7:')
+whitespace (' ')
+[ ('[')
+scalar dstring ('"-day"')
+, (',')
+whitespace (' ')
+scalar dstring ('"-month"')
+, (',')
+whitespace (' ')
+scalar dstring ('"-year"')
+] (']')
+Eol ('\n')
+scalar key ('foo8:')
+whitespace (' ')
+[ ('[')
+scalar string (''-day'')
+, (',')
+whitespace (' ')
+scalar string (''-month'')
+, (',')
+whitespace (' ')
+scalar string (''-year'')
+] (']')
+Eol ('\n')
+scalar key ('foo9:')
+whitespace (' ')
+[ ('[')
+scalar dstring ('":day"')
+, (',')
+whitespace (' ')
+scalar dstring ('":month"')
+, (',')
+whitespace (' ')
+scalar dstring ('":year"')
+] (']')
+Eol ('\n')
+scalar key ('foo10:')
+whitespace (' ')
+[ ('[')
+scalar string ('':day'')
+, (',')
+whitespace (' ')
+scalar string ('':month'')
+, (',')
+whitespace (' ')
+scalar string ('':year'')
+] (']')
+Eol ('\n')
+scalar key ('foo11:')
+whitespace (' ')
+tag ('!')
+whitespace (' ')
+scalar dstring ('"multi\n  line\"\n  string"')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/strings.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/strings.yml
new file mode 100644 (file)
index 0000000..0f21caa
--- /dev/null
@@ -0,0 +1,13 @@
+foo1: ["day", "month", "year"]
+foo2: ['day', 'month', 'year']
+foo3: ["day[1]", "month[1]", "year[1]"]
+foo4: ['day[1]', 'month[1]', 'year[1]']
+foo5: ["?day", "?month", "?year"]
+foo6: ['?day', '?month', '?year']
+foo7: ["-day", "-month", "-year"]
+foo8: ['-day', '-month', '-year']
+foo9: [":day", ":month", ":year"]
+foo10: [':day', ':month', ':year']
+foo11: ! "multi
+  line\"
+  string"
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/tagShorthands.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/tagShorthands.txt
new file mode 100644 (file)
index 0000000..d73400c
--- /dev/null
@@ -0,0 +1,21 @@
+text ('%TAG !e! tag:example.com,2000:app/')
+Eol ('\n')
+--- ('---')
+Eol ('\n')
+- ('-')
+whitespace (' ')
+tag ('!local')
+whitespace (' ')
+text ('foo')
+Eol ('\n')
+- ('-')
+whitespace (' ')
+tag ('!!str')
+whitespace (' ')
+text ('bar')
+Eol ('\n')
+- ('-')
+whitespace (' ')
+tag ('!e!tag%21')
+whitespace (' ')
+text ('baz')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/tagShorthands.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/tagShorthands.yml
new file mode 100644 (file)
index 0000000..5f4ef93
--- /dev/null
@@ -0,0 +1,5 @@
+%TAG !e! tag:example.com,2000:app/
+---
+- !local foo
+- !!str bar
+- !e!tag%21 baz
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/typed_scalar_list.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/typed_scalar_list.txt
new file mode 100644 (file)
index 0000000..032cba5
--- /dev/null
@@ -0,0 +1,17 @@
+scalar key ('body:')
+whitespace (' ')
+tag ('!!str')
+whitespace (' ')
+scalar list ('|-')
+Eol ('\n')
+indent ('  ')
+scalar list ('JVBER')
+Eol ('\n')
+scalar key ('body:')
+whitespace (' ')
+tag ('!!binary')
+whitespace (' ')
+scalar list ('|-')
+Eol ('\n')
+indent ('  ')
+scalar list ('JVBERi0xLjY')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/typed_scalar_list.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/typed_scalar_list.yml
new file mode 100644 (file)
index 0000000..25450e6
--- /dev/null
@@ -0,0 +1,4 @@
+body: !!str |-
+  JVBER
+body: !!binary |-
+  JVBERi0xLjY
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/value_injection.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/value_injection.txt
new file mode 100644 (file)
index 0000000..edb56e1
--- /dev/null
@@ -0,0 +1,11 @@
+scalar key ('key:')
+Eol ('\n')
+indent ('    ')
+scalar key ('one:')
+whitespace (' ')
+text ('1 text')
+Eol ('\n')
+indent ('    ')
+scalar key ('other:')
+whitespace (' ')
+text ('{{count}} text')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/value_injection.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/value_injection.yml
new file mode 100644 (file)
index 0000000..f97768b
--- /dev/null
@@ -0,0 +1,3 @@
+key:
+    one: 1 text
+    other: {{count}} text
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/value_injection_2.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/value_injection_2.txt
new file mode 100644 (file)
index 0000000..b8c1ab6
--- /dev/null
@@ -0,0 +1,11 @@
+scalar key ('key:')
+Eol ('\n')
+indent ('    ')
+scalar key ('one:')
+whitespace (' ')
+text ('1 text')
+Eol ('\n')
+indent ('    ')
+scalar key ('other:')
+whitespace (' ')
+text ('some {{count}} text')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/value_injection_2.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/value_injection_2.yml
new file mode 100644 (file)
index 0000000..ab6f9f7
--- /dev/null
@@ -0,0 +1,3 @@
+key:
+    one: 1 text
+    other: some {{count}} text
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/verbatimTags.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/verbatimTags.txt
new file mode 100644 (file)
index 0000000..b186b6c
--- /dev/null
@@ -0,0 +1,8 @@
+tag ('!<tag:yaml.org,2002:str>')
+whitespace (' ')
+scalar key ('foo :')
+Eol ('\n')
+indent ('  ')
+tag ('!<!bar>')
+whitespace (' ')
+text ('baz')
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/verbatimTags.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/verbatimTags.yml
new file mode 100644 (file)
index 0000000..9e2afa4
--- /dev/null
@@ -0,0 +1,2 @@
+!<tag:yaml.org,2002:str> foo :
+  !<!bar> baz
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/wrong_string_highlighting.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/wrong_string_highlighting.txt
new file mode 100644 (file)
index 0000000..1170149
--- /dev/null
@@ -0,0 +1,22 @@
+scalar key ('status:')
+Eol ('\n')
+indent ('    ')
+scalar key ('draft:')
+whitespace (' ')
+scalar dstring ('"Brouillon"')
+whitespace ('  ')
+Eol ('\n')
+indent ('    ')
+scalar key ('reviewed:')
+whitespace (' ')
+scalar dstring ('"Revise"')
+Eol ('\n')
+indent ('    ')
+scalar key ('hidden:')
+whitespace (' ')
+scalar dstring ('"Cache"')
+Eol ('\n')
+indent ('    ')
+scalar key ('published:')
+whitespace (' ')
+scalar dstring ('"Public"')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/wrong_string_highlighting.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/lexer/data/wrong_string_highlighting.yml
new file mode 100644 (file)
index 0000000..7a0a5d3
--- /dev/null
@@ -0,0 +1,5 @@
+status:
+    draft: "Brouillon"  
+    reviewed: "Revise"
+    hidden: "Cache"
+    published: "Public"
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/parser/YAMLParserTest.java b/plugins/yaml/testSrc/org/jetbrains/yaml/parser/YAMLParserTest.java
new file mode 100644 (file)
index 0000000..bad4632
--- /dev/null
@@ -0,0 +1,220 @@
+package org.jetbrains.yaml.parser;
+
+import com.intellij.openapi.application.PathManager;
+import com.intellij.testFramework.ParsingTestCase;
+import org.jetbrains.yaml.YAMLParserDefinition;
+
+import java.io.IOException;
+
+/**
+ * @author oleg
+ */
+public class YAMLParserTest extends ParsingTestCase {
+
+  public YAMLParserTest() {
+    super("", "yml", new YAMLParserDefinition());
+  }
+
+  protected String getTestDataPath() {
+    return PathManager.getHomePath() + "/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/";
+  }
+
+  public void test2docs() throws Throwable {
+    doCodeTest("# Ranking of 1998 home runs\n" +
+           "---\n" +
+           "- Mark McGwire\n" +
+           "- Sammy Sosa\n" +
+           "- Ken Griffey\n" +
+           "\n" +
+           "# Team ranking\n" +
+           "---\n" +
+           "- Chicago Cubs\n" +
+           "- St Louis Cardinals");
+  }
+
+  public void testIndentation() throws Throwable {
+    doCodeTest("name: Mark McGwire\n" +
+           "accomplishment: >\n" +
+           "  Mark set a major league\n" +
+           "  home run record in 1998.\n" +
+           "stats: |\n" +
+           "  65 Home Runs\n" +
+           "  0.278 Batting Average");
+  }
+
+  public void testMap_between_seq() throws Throwable {
+    doCodeTest("?\n" +
+           "  - Detroit Tigers\n" +
+           "  - Chicago cubs\n" +
+           ":\n" +
+           "  - 2001-07-23\n" +
+           "\n" +
+           "? [ New York Yankees,\n" +
+           "    Atlanta Braves ]\n" +
+           ": [ 2001-07-02, 2001-08-12,\n" +
+           "    2001-08-14 ]");
+  }
+
+  public void testMap_map() throws Throwable {
+    doCodeTest("Mark McGwire: {hr: 65, avg: 0.278}\n" +
+           "Sammy Sosa: {\n" +
+           "    hr: 63,\n" +
+           "    avg: 0.288\n" +
+           "  }");
+  }
+
+  public void testSample_log() throws Throwable {
+    doCodeTest("Stack:\n" +
+           "  - file: TopClass.py\n" +
+           "    line: 23\n" +
+           "    code: |\n" +
+           "      x = MoreObject(\"345\\n\")\n" +
+           "  - file: MoreClass.py\n" +
+           "    line: 58\n" +
+           "    code: |-\n" +
+           "      foo = bar");
+  }
+
+  public void testSeq_seq() throws Throwable {
+    doCodeTest("- [name        , hr, avg  ]\n" +
+           "- [Mark McGwire, 65, 0.278]\n" +
+           "- [Sammy Sosa  , 63, 0.288]");
+  }
+
+  public void testSequence_mappings() throws Throwable {
+    doCodeTest("-\n" +
+           "  name: Mark McGwire\n" +
+           "  hr:   65\n" +
+           "  avg:  0.278\n" +
+           "-\n" +
+           "  name: Sammy Sosa\n" +
+           "  hr:   63\n" +
+           "  avg:  0.288");
+  }
+
+  public void testBalance() throws Throwable {
+    doCodeTest("runningTime: 150000\n" +
+           "scenarios:\n" +
+           "    voice_bundle_change: {\n" +
+           "        dataCycling: true\n" +
+           "    }\n" +
+           "    smart_overview: {\n" +
+           "        dataCycling: true\n" +
+           "    }");
+  }
+
+  public void testInterpolation() throws Throwable {
+    doCodeTest("en:\n  foo: bar %{baz}");
+  }
+
+  public void testValue_injection() throws Throwable {
+    doCodeTest("key:\n" + "    one: 1 text\n" + "    other: some {{count}} text");
+  }
+
+  public void testSequence_idea76804() throws Throwable {
+    doCodeTest("server:\n" +
+           "- a\n" +
+           "- b\n" +
+           "\n" +
+           "server:\n" +
+           "  - a\n" +
+           "  - b");
+  }
+
+  public void testMultiline_ruby16796() throws Throwable {
+    doCodeTest("code:\n" +
+               "  src=\"keys/{{item}}\"\n" +
+               "  mode=0600\n" +
+               "with_items:\n" +
+               "  - \"id_rsa.pub\"\n");
+  }
+
+  public void testRuby17389() throws Throwable {
+    doCodeTest("---\n" +
+               "foo: {}\n" +
+               "bar: \"baz\"");
+  }
+
+  public void testRuby15345() throws IOException {
+    doCodeTest("- !qualified.class.name\n" +
+               "    propertyOne: bla bla\n" +
+               "    propertyWithOneSequence:\n" +
+               "        - first value\n" +
+               "    nextPropertyWithOneSequence:\n" +
+               "        - first value of another sequence");
+  }
+
+  public void testHonestMultiline() throws Throwable {
+    doCodeTest("---\n" +
+               "foo: >\n" +
+               "  first text line\n" +
+               "  second text line\n" +
+               "\n" +
+               "  baz: clazz\n" +
+               "  - this is text\n" +
+               "  - but looks like a list\n" +
+               "  - indent tells.\n" +
+               "bar: zoo");
+  }
+
+  public void testEmptyMultiline() throws Throwable {
+    doCodeTest("---\n" +
+               "foo: >\n" +
+               "bar:\n" +
+               "  abc: def\n" +
+               "  ghi: >\n" +
+               "  jkl: mno\n" +
+               "baz: qwe");
+  }
+
+  public void testIncompleteKey() throws Throwable {
+    doCodeTest("logging:\n" +
+               "  config: bla\n" +
+               "  index");
+  }
+
+  public void testStringWithTag() throws IOException {
+    doCodeTest("foo: ! \"tratata\"");
+  }
+  
+  public void testIncompleteKeyWithWhitespace() throws IOException {
+    doCodeTest("logging:\n" +
+               "  config:\n" +
+               "  \n" +
+               "  \n" +
+               "  \n" +
+               "  \n");
+  }
+
+  public void testExplicitMaps() {
+    doTest(true);
+  }
+
+  public void testSpec2_27() {
+    doTest(true);
+  }
+
+  public void testAnsibleRoleElkInit() {
+    doTest(true);
+  }
+
+  public void testAnsibleRoleElkMain() {
+    doTest(true);
+  }
+  
+  public void testBlockMapping() {
+    doTest(true);
+  }
+  
+  public void testIncompleteKeyInHierarchy() {
+    doTest(true);
+  }
+  
+  public void testKeyValueWithEmptyLineAhead() {
+    doTest(true);
+  }
+  
+  public void testMultipleDocsWithMappings() {
+    doTest(true);
+  }
+}
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/2docs.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/2docs.txt
new file mode 100644 (file)
index 0000000..d429d9a
--- /dev/null
@@ -0,0 +1,43 @@
+YAML file
+  PsiComment(comment)('# Ranking of 1998 home runs')
+  PsiElement(Eol)('\n')
+  YAML document
+    PsiElement(---)('---')
+    PsiElement(Eol)('\n')
+    YAML sequence
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML plain scalar text
+          PsiElement(text)('Mark McGwire')
+      PsiElement(Eol)('\n')
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML plain scalar text
+          PsiElement(text)('Sammy Sosa')
+      PsiElement(Eol)('\n')
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML plain scalar text
+          PsiElement(text)('Ken Griffey')
+  PsiElement(Eol)('\n')
+  PsiElement(Eol)('\n')
+  PsiComment(comment)('# Team ranking')
+  PsiElement(Eol)('\n')
+  YAML document
+    PsiElement(---)('---')
+    PsiElement(Eol)('\n')
+    YAML sequence
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML plain scalar text
+          PsiElement(text)('Chicago Cubs')
+      PsiElement(Eol)('\n')
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML plain scalar text
+          PsiElement(text)('St Louis Cardinals')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/AnsibleRoleElkInit.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/AnsibleRoleElkInit.txt
new file mode 100644 (file)
index 0000000..d64d8ba
--- /dev/null
@@ -0,0 +1,82 @@
+YAML file
+  YAML document
+    PsiElement(---)('---')
+    PsiElement(Eol)('\n')
+    YAML sequence
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML mapping
+          YAML key value
+            PsiElement(scalar key)('name:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('Validate logstash_configs variable')
+          PsiElement(Eol)('\n')
+          PsiElement(indent)('  ')
+          YAML key value
+            PsiElement(scalar key)('assert:')
+            PsiElement(Eol)('\n')
+            PsiElement(indent)('    ')
+            YAML mapping
+              YAML key value
+                PsiElement(scalar key)('that:')
+                PsiElement(Eol)('\n')
+                PsiElement(indent)('    ')
+                YAML sequence
+                  YAML sequence item
+                    PsiElement(-)('-')
+                    PsiWhiteSpace(' ')
+                    YAML plain scalar text
+                      PsiElement(text)('logstash_configs != ''')
+      PsiElement(Eol)('\n')
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML mapping
+          YAML key value
+            PsiElement(scalar key)('stat:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('path={{ logstash_configs }}/config')
+          PsiElement(Eol)('\n')
+          PsiElement(indent)('  ')
+          YAML key value
+            PsiElement(scalar key)('delegate_to:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('127.0.0.1')
+          PsiElement(Eol)('\n')
+          PsiElement(indent)('  ')
+          YAML key value
+            PsiElement(scalar key)('register:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('p')
+      PsiElement(Eol)('\n')
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML mapping
+          YAML key value
+            PsiElement(scalar key)('name:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('Validate config subdirectory')
+          PsiElement(Eol)('\n')
+          PsiElement(indent)('  ')
+          YAML key value
+            PsiElement(scalar key)('assert:')
+            PsiElement(Eol)('\n')
+            PsiElement(indent)('    ')
+            YAML mapping
+              YAML key value
+                PsiElement(scalar key)('that:')
+                PsiElement(Eol)('\n')
+                PsiElement(indent)('    ')
+                YAML sequence
+                  YAML sequence item
+                    PsiElement(-)('-')
+                    PsiWhiteSpace(' ')
+                    YAML plain scalar text
+                      PsiElement(text)('p.stat.isdir is defined and p.stat.isdir')
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/AnsibleRoleElkInit.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/AnsibleRoleElkInit.yml
new file mode 100644 (file)
index 0000000..304ace1
--- /dev/null
@@ -0,0 +1,12 @@
+---
+- name: Validate logstash_configs variable
+  assert:
+    that:
+    - logstash_configs != ''
+- stat: path={{ logstash_configs }}/config
+  delegate_to: 127.0.0.1
+  register: p
+- name: Validate config subdirectory
+  assert:
+    that:
+    - p.stat.isdir is defined and p.stat.isdir
\ No newline at end of file
diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/AnsibleRoleElkMain.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/parser/data/AnsibleRoleElkMain.txt
new file mode 100644 (file)
index 0000000..881dfd7
--- /dev/null
@@ -0,0 +1,388 @@
+YAML file
+  YAML document
+    PsiElement(---)('---')
+    PsiElement(Eol)('\n')
+    YAML sequence
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML mapping
+          YAML key value
+            PsiElement(scalar key)('include:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('init.yml')
+      PsiElement(Eol)('\n')
+      PsiElement(Eol)('\n')
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML mapping
+          YAML key value
+            PsiElement(scalar key)('name:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('Create directory')
+          PsiElement(Eol)('\n')
+          PsiElement(indent)('  ')
+          YAML key value
+            PsiElement(scalar key)('file:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('path={{ directory }} state=directory')
+      PsiElement(Eol)('\n')
+      PsiElement(Eol)('\n')
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML mapping
+          YAML key value
+            PsiElement(scalar key)('name:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('Copy Elasticsearch configuration')
+          PsiElement(Eol)('\n')
+          PsiElement(indent)('  ')
+          YAML key value
+            PsiElement(scalar key)('file:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('path={{ directory }}/config/elasticsearch/ state=directory')
+      PsiElement(Eol)('\n')
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML mapping
+          YAML key value
+            PsiElement(scalar key)('template:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('src=elasticsearch.yml dest={{ directory }}/config/elasticsearch/')
+          PsiElement(Eol)('\n')
+          PsiElement(indent)('  ')
+          YAML key value
+            PsiElement(scalar key)('notify:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('Restart Elasticsearch')
+      PsiElement(Eol)('\n')
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML mapping
+          YAML key value
+            PsiElement(scalar key)('copy:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('src=logging.yml dest={{ directory }}/config/elasticsearch/')
+          PsiElement(Eol)('\n')
+          PsiElement(indent)('  ')
+          YAML key value
+            PsiElement(scalar key)('notify:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('Restart Elasticsearch')
+      PsiElement(Eol)('\n')
+      YAML sequence item
+        PsiElement(-)('-')
+        PsiWhiteSpace(' ')
+        YAML mapping
+          YAML key value
+            PsiElement(scalar key)('name:')
+            PsiWhiteSpace(' ')
+            YAML plain scalar text
+              PsiElement(text)('Start Elasticsearch docker container')
+          PsiElement(Eol)('\n')
+          PsiElement(indent)('  ')
+          YAML key value
+            PsiElement(scalar key)('docker:')
+            PsiElement(Eol)('\n')
+            PsiElement(indent)('    ')
+            YAML mapping
+              YAML key value
+                PsiElement(scalar key)('name:')
+                PsiWhiteSpace(' ')
+                YAML plain scalar text
+                  PsiElement(text)('elasticsearch')
+              PsiElement(Eol)('\n')
+              PsiElement(indent)('    ')
+              YAML key value
+                PsiElement(scalar key)('image:')
+                PsiWhiteSpace(' ')
+                YAML plain scalar text
+                  PsiElement(text)('elasticsearch:{{ elasticsearch_version }}')
+              PsiElement(Eol)('\n')
+              PsiElement(indent)('    ')
+              YAML key value
+                PsiElement(scalar key)('volumes:')
+                PsiElement(Eol)('\n')
+                PsiElement(indent)('      ')
+                YAML sequence
+                  YAML sequence item
+                    PsiElement(-)('-')
+                    PsiWhiteSpace(' ')
+                    YAML quoted text
+                      PsiElement(scalar dstring)('"{{ directory }}/config/elasticsearch/:/usr/share/elasticsearch/config/:ro"')
+                  PsiElement(Eol)('\n')
+                  PsiElement(indent)('      ')
+                  YAML sequence item
+                    PsiElement(-)('-')
+                    PsiWhiteSpace(' ')
+                    YAML quoted text
+                      PsiElement(scalar dstring)('"{{ directory }}/data/:/usr/share/elasticsearch/data/"')
+              PsiElement(Eol)('\n')
+              PsiElement(indent)('    ')
+              YAML key value
+                PsiElement(scalar key)('ports:')
+                PsiElement(Eol)('\n')
+                PsiElement(indent)('      ')
+                YAML sequence
+                  YAML sequence item
+                    PsiElement(-)('-')
+                    PsiWhiteSpace(' ')
+                    YAML quoted text
+                      PsiElement(scalar dstring)('"{{ elasticsearch_port }}:9200"')
+              PsiElement(Eol)('\n')
+              PsiElement(indent)('    ')
+              YAML key value
+                PsiElement(scalar key)('state:')
+                PsiWhiteSpace(' ')
+                YAML plain scalar text
+                  PsiElement(text)('started')
+ &n