This commit is contained in:
cheptsov 2013-02-28 16:45:13 +04:00
parent d1376cd78e
commit 08ed7e5cfa
19 changed files with 318 additions and 3 deletions

7
.idea/ant.xml generated Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AntConfiguration">
<defaultAnt bundledAnt="true" />
</component>
</project>

10
.idea/misc.xml generated
View File

@ -6,7 +6,15 @@
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA IC-123.94" project-jdk-type="IDEA JDK">
<component name="IvyIDEA.ProjectSettings">
<option name="artifactTypeSettings">
<ArtifactTypeSettings />
</option>
<option name="propertiesSettings">
<PropertiesSettings />
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA IC-123.155" project-jdk-type="IDEA JDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

17
.idea/runConfigurations/Plugin.xml generated Normal file
View File

@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Plugin" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" factoryName="Plugin" singleton="true">
<module name="SimplePlugin" />
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -Didea.is.internal=true" />
<option name="PROGRAM_PARAMETERS" value="" />
<log_file path="$USER_HOME$/Library/Caches/IntelliJIdea12/plugins-sandbox/system/log/idea.log" checked="false" skipped="true" show_all="false" alias="IDEA LOG" />
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="" />
<option name="TRANSPORT" value="0" />
<option name="LOCAL" value="true" />
</RunnerSettings>
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Debug" />
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>
</component>

View File

@ -0,0 +1,36 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="SimpleCodeInsightTest" type="JUnit" factoryName="JUnit" singleton="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="com.simpleplugin.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<module name="SimplePlugin" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="PACKAGE_NAME" value="com.simpleplugin" />
<option name="MAIN_CLASS_NAME" value="com.simpleplugin.SimpleCodeInsightTest" />
<option name="METHOD_NAME" value="testFolding" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea -Xbootclasspath/p:../out/classes/production/boot -XX:+HeapDumpOnOutOfMemoryError -Xmx512m -XX:MaxPermSize=320m -Didea.system.path=../test-system -Didea.home.path=../ -Didea.config.path=../test-config -Didea.test.group=ALL_EXCLUDE_DEFINED" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$USER_HOME$/ultimate/community" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<envs />
<patterns />
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="" />
<option name="TRANSPORT" value="0" />
<option name="LOCAL" value="true" />
</RunnerSettings>
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Debug" />
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>
</component>

View File

@ -0,0 +1,30 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="SimpleParsingTest" type="JUnit" factoryName="JUnit">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea">
<pattern>
<option name="PATTERN" value="com.simpleplugin.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<module name="SimplePlugin" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
<option name="ALTERNATIVE_JRE_PATH" value="" />
<option name="PACKAGE_NAME" value="com.simpleplugin" />
<option name="MAIN_CLASS_NAME" value="com.simpleplugin.SimpleParsingTest" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="class" />
<option name="VM_PARAMETERS" value="-ea" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />
<option name="PASS_PARENT_ENVS" value="true" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="moduleWithDependencies" />
</option>
<envs />
<patterns />
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Run" />
<method />
</configuration>
</component>

View File

@ -6,6 +6,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />

View File

@ -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
* <a href="http://www.jflex.de/">JFlex</a> 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
* <tt>/Users/jetbrains/SimplePlugin/src/com/simpleplugin/Simple.flex</tt>
*/
class SimpleLexer implements FlexLexer {

View File

@ -0,0 +1,6 @@
public class Test {
public static void main(String[] args) {
System.out.println("simple:website");
System.out.println("simple:<error descr="Unresolved property">websit"</error>);
}
}

View File

@ -0,0 +1,5 @@
public class Test {
public static void main(String[] args) {
System.out.println("simple:<caret>");
}
}

13
testData/Example.simple Normal file
View File

@ -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

48
testData/Example.txt Normal file
View File

@ -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')

View File

@ -0,0 +1,5 @@
public class Test {
public static void main(String[] args) <fold text='{...}'>{
System.out.println("<fold text='http://en.wikipedia.org/'>simple:website</fold>");
}</fold>
}

View File

@ -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

View File

@ -0,0 +1,5 @@
public class Test {
public static void main(String[] args) {
System.out.println("simple:website<caret>");
}
}

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,5 @@
public class Test {
public static void main(String[] args) {
System.out.println("simple:website<caret>");
}
}

View File

@ -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);
}
}

View File

@ -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")
);
}
}
}