diff --git a/.idea/ant.xml b/.idea/ant.xml
new file mode 100644
index 000000000..2581ca3fe
--- /dev/null
+++ b/.idea/ant.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 7e1512672..7e6d5e6a9 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -6,7 +6,15 @@
-
+
+
+
+
+
diff --git a/.idea/runConfigurations/Plugin.xml b/.idea/runConfigurations/Plugin.xml
new file mode 100644
index 000000000..294c0ddc6
--- /dev/null
+++ b/.idea/runConfigurations/Plugin.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/SimpleCodeInsightTest.xml b/.idea/runConfigurations/SimpleCodeInsightTest.xml
new file mode 100644
index 000000000..18fea3282
--- /dev/null
+++ b/.idea/runConfigurations/SimpleCodeInsightTest.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/SimpleParsingTest.xml b/.idea/runConfigurations/SimpleParsingTest.xml
new file mode 100644
index 000000000..dc980e077
--- /dev/null
+++ b/.idea/runConfigurations/SimpleParsingTest.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SimplePlugin.iml b/SimplePlugin.iml
index f66860322..fcc9eef60 100644
--- a/SimplePlugin.iml
+++ b/SimplePlugin.iml
@@ -6,6 +6,7 @@
+
diff --git a/src/com/simpleplugin/SimpleLexer.java b/src/com/simpleplugin/SimpleLexer.java
index ac288dcf8..61884cfe2 100644
--- a/src/com/simpleplugin/SimpleLexer.java
+++ b/src/com/simpleplugin/SimpleLexer.java
@@ -1,4 +1,4 @@
-/* The following code was generated by JFlex 1.4.3 on 1/10/13 12:27 PM */
+/* The following code was generated by JFlex 1.4.3 on 2/19/13 7:59 PM */
package com.simpleplugin;
@@ -11,7 +11,7 @@ import com.intellij.psi.TokenType;
/**
* This class is a scanner generated by
* JFlex 1.4.3
- * on 1/10/13 12:27 PM from the specification file
+ * on 2/19/13 7:59 PM from the specification file
* /Users/jetbrains/SimplePlugin/src/com/simpleplugin/Simple.flex
*/
class SimpleLexer implements FlexLexer {
diff --git a/testData/AnnotationTest.java b/testData/AnnotationTest.java
new file mode 100644
index 000000000..30dce0c22
--- /dev/null
+++ b/testData/AnnotationTest.java
@@ -0,0 +1,6 @@
+public class Test {
+ public static void main(String[] args) {
+ System.out.println("simple:website");
+ System.out.println("simple:websit");
+ }
+}
diff --git a/testData/CompleteTestData.java b/testData/CompleteTestData.java
new file mode 100644
index 000000000..4a883daec
--- /dev/null
+++ b/testData/CompleteTestData.java
@@ -0,0 +1,5 @@
+public class Test {
+ public static void main(String[] args) {
+ System.out.println("simple:");
+ }
+}
diff --git a/testData/Example.simple b/testData/Example.simple
new file mode 100644
index 000000000..31492ca75
--- /dev/null
+++ b/testData/Example.simple
@@ -0,0 +1,13 @@
+# You are reading the ".properties" entry.
+! The exclamation mark can also mark text as comments.
+website = http://en.wikipedia.org/
+
+language = English
+# The backslash below tells the application to continue reading
+# the value onto the next line.
+message = Welcome to \
+ Wikipedia!
+# Add spaces to the key
+key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".
+# Unicode
+tab : \u0009
\ No newline at end of file
diff --git a/testData/Example.txt b/testData/Example.txt
new file mode 100644
index 000000000..91359302e
--- /dev/null
+++ b/testData/Example.txt
@@ -0,0 +1,48 @@
+Simple File
+ PsiComment(SimpleTokenType.COMMENT)('# You are reading the ".properties" entry.')
+ PsiElement(SimpleTokenType.CRLF)('\n')
+ PsiComment(SimpleTokenType.COMMENT)('! The exclamation mark can also mark text as comments.')
+ PsiElement(SimpleTokenType.CRLF)('\n')
+ SimplePropertyImpl(PROPERTY)
+ PsiElement(SimpleTokenType.KEY)('website')
+ PsiWhiteSpace(' ')
+ PsiElement(SimpleTokenType.SEPARATOR)('=')
+ PsiWhiteSpace(' ')
+ PsiElement(SimpleTokenType.VALUE)('http://en.wikipedia.org/')
+ PsiElement(SimpleTokenType.CRLF)('\n')
+ PsiElement(SimpleTokenType.CRLF)('\n')
+ SimplePropertyImpl(PROPERTY)
+ PsiElement(SimpleTokenType.KEY)('language')
+ PsiWhiteSpace(' ')
+ PsiElement(SimpleTokenType.SEPARATOR)('=')
+ PsiWhiteSpace(' ')
+ PsiElement(SimpleTokenType.VALUE)('English')
+ PsiElement(SimpleTokenType.CRLF)('\n')
+ PsiComment(SimpleTokenType.COMMENT)('# The backslash below tells the application to continue reading')
+ PsiElement(SimpleTokenType.CRLF)('\n')
+ PsiComment(SimpleTokenType.COMMENT)('# the value onto the next line.')
+ PsiElement(SimpleTokenType.CRLF)('\n')
+ SimplePropertyImpl(PROPERTY)
+ PsiElement(SimpleTokenType.KEY)('message')
+ PsiWhiteSpace(' ')
+ PsiElement(SimpleTokenType.SEPARATOR)('=')
+ PsiWhiteSpace(' ')
+ PsiElement(SimpleTokenType.VALUE)('Welcome to \\n Wikipedia!')
+ PsiElement(SimpleTokenType.CRLF)('\n')
+ PsiComment(SimpleTokenType.COMMENT)('# Add spaces to the key')
+ PsiElement(SimpleTokenType.CRLF)('\n')
+ SimplePropertyImpl(PROPERTY)
+ PsiElement(SimpleTokenType.KEY)('key\ with\ spaces')
+ PsiWhiteSpace(' ')
+ PsiElement(SimpleTokenType.SEPARATOR)('=')
+ PsiWhiteSpace(' ')
+ PsiElement(SimpleTokenType.VALUE)('This is the value that could be looked up with the key "key with spaces".')
+ PsiElement(SimpleTokenType.CRLF)('\n')
+ PsiComment(SimpleTokenType.COMMENT)('# Unicode')
+ PsiElement(SimpleTokenType.CRLF)('\n')
+ SimplePropertyImpl(PROPERTY)
+ PsiElement(SimpleTokenType.KEY)('tab')
+ PsiWhiteSpace(' ')
+ PsiElement(SimpleTokenType.SEPARATOR)(':')
+ PsiWhiteSpace(' ')
+ PsiElement(SimpleTokenType.VALUE)('\u0009')
\ No newline at end of file
diff --git a/testData/FoldingTestData.java b/testData/FoldingTestData.java
new file mode 100644
index 000000000..57b8c8401
--- /dev/null
+++ b/testData/FoldingTestData.java
@@ -0,0 +1,5 @@
+public class Test {
+ public static void main(String[] args) {
+ System.out.println("simple:website");
+ }
+}
diff --git a/testData/FormattingTestData.simple b/testData/FormattingTestData.simple
new file mode 100644
index 000000000..2204c5af9
--- /dev/null
+++ b/testData/FormattingTestData.simple
@@ -0,0 +1,13 @@
+# You are reading the ".properties" entry.
+! The exclamation mark can also mark text as comments.
+website=http://en.wikipedia.org/
+
+language= English
+# The backslash below tells the application to continue reading
+# the value onto the next line.
+message = Welcome to \
+ Wikipedia!
+# Add spaces to the key
+key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".
+# Unicode
+tab :\u0009
\ No newline at end of file
diff --git a/testData/RenameTestData.java b/testData/RenameTestData.java
new file mode 100644
index 000000000..384347eda
--- /dev/null
+++ b/testData/RenameTestData.java
@@ -0,0 +1,5 @@
+public class Test {
+ public static void main(String[] args) {
+ System.out.println("simple:website");
+ }
+}
diff --git a/testData/RenameTestData.simple b/testData/RenameTestData.simple
new file mode 100644
index 000000000..31492ca75
--- /dev/null
+++ b/testData/RenameTestData.simple
@@ -0,0 +1,13 @@
+# You are reading the ".properties" entry.
+! The exclamation mark can also mark text as comments.
+website = http://en.wikipedia.org/
+
+language = English
+# The backslash below tells the application to continue reading
+# the value onto the next line.
+message = Welcome to \
+ Wikipedia!
+# Add spaces to the key
+key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".
+# Unicode
+tab : \u0009
\ No newline at end of file
diff --git a/testData/RenameTestDataAfter.simple b/testData/RenameTestDataAfter.simple
new file mode 100644
index 000000000..71bf7bf73
--- /dev/null
+++ b/testData/RenameTestDataAfter.simple
@@ -0,0 +1,13 @@
+# You are reading the ".properties" entry.
+! The exclamation mark can also mark text as comments.
+websiteUrl = http://en.wikipedia.org/
+
+language = English
+# The backslash below tells the application to continue reading
+# the value onto the next line.
+message = Welcome to \
+ Wikipedia!
+# Add spaces to the key
+key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".
+# Unicode
+tab : \u0009
\ No newline at end of file
diff --git a/testData/ResolveTestData.java b/testData/ResolveTestData.java
new file mode 100644
index 000000000..384347eda
--- /dev/null
+++ b/testData/ResolveTestData.java
@@ -0,0 +1,5 @@
+public class Test {
+ public static void main(String[] args) {
+ System.out.println("simple:website");
+ }
+}
diff --git a/tests/com/simpleplugin/SimpleCodeInsightTest.java b/tests/com/simpleplugin/SimpleCodeInsightTest.java
new file mode 100644
index 000000000..e820558e1
--- /dev/null
+++ b/tests/com/simpleplugin/SimpleCodeInsightTest.java
@@ -0,0 +1,57 @@
+package com.simpleplugin;
+
+import com.intellij.codeInsight.completion.CompletionType;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.codeStyle.CodeStyleManager;
+import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
+import com.simpleplugin.psi.SimpleProperty;
+
+public class SimpleCodeInsightTest extends LightCodeInsightFixtureTestCase {
+ @Override
+ protected String getTestDataPath() {
+ return "../../SimplePlugin/testData";
+ }
+
+ public void testResolve() {
+ myFixture.configureByFiles("ResolveTestData.java", "Example.simple");
+ PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent();
+ assertEquals("http://en.wikipedia.org/", ((SimpleProperty)element.getReferences()[0].resolve()).getValue());
+ }
+
+ public void testCompletion() {
+ myFixture.configureByFiles("CompleteTestData.java", "Example.simple");
+ myFixture.complete(CompletionType.BASIC, 1);
+ System.out.println(myFixture.getLookupElementStrings());
+ }
+
+ public void testAnnotations() {
+ myFixture.configureByFiles("AnnotationTest.java", "Example.simple");
+ System.out.println(getProjectDescriptor().getSdk());
+ myFixture.checkHighlighting(false, false, true);
+ }
+
+ public void testFolding() {
+ myFixture.configureByFiles("Example.simple");
+ myFixture.testFolding(getTestDataPath() + "/FoldingTestData.java");
+ }
+
+ public void testFormatting() {
+ myFixture.configureByFiles("FormattingTestData.simple");
+ CodeStyleSettingsManager.getSettings(getProject()).SPACE_AROUND_ASSIGNMENT_OPERATORS = true;
+ ApplicationManager.getApplication().runWriteAction(new Runnable() {
+ @Override
+ public void run() {
+ CodeStyleManager.getInstance(getProject()).reformat(myFixture.getFile());
+ }
+ });
+ myFixture.checkResultByFile("Example.simple");
+ }
+
+ public void testRename() {
+ myFixture.configureByFiles("RenameTestData.java", "RenameTestData.simple");
+ myFixture.renameElementAtCaret("websiteUrl");
+ myFixture.checkResultByFile("RenameTestData.simple", "RenameTestDataAfter.simple", false);
+ }
+}
\ No newline at end of file
diff --git a/tests/com/simpleplugin/SimpleParsingTest.java b/tests/com/simpleplugin/SimpleParsingTest.java
new file mode 100644
index 000000000..c5b394dd4
--- /dev/null
+++ b/tests/com/simpleplugin/SimpleParsingTest.java
@@ -0,0 +1,33 @@
+package com.simpleplugin;
+
+import com.intellij.testFramework.ParsingTestCase;
+
+public class SimpleParsingTest extends ParsingTestCase {
+ public SimpleParsingTest() {
+ super("", "simple", new SimpleParserDefinition());
+ }
+
+ public void testExample() {
+ doTest(true, false);
+ }
+
+ @Override
+ protected String getTestDataPath() {
+ return "testData";
+ }
+
+ @Override
+ protected boolean skipSpaces() {
+ return false;
+ }
+
+ protected void doTest(boolean checkResult, boolean suppressErrors) {
+ super.doTest(checkResult);
+ if (!suppressErrors) {
+ assertFalse(
+ "PsiFile contains error elements",
+ toParseTreeText(myFile, skipSpaces(), includeRanges()).contains("PsiErrorElement")
+ );
+ }
+ }
+}