mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-27 16:57:49 +08:00
Delete DevKit, add Gradle simple_language_plugin
This commit is contained in:
parent
0dd8eca961
commit
f4fb5b1b31
@ -1,2 +0,0 @@
|
||||
rootProject.name = 'language'
|
||||
|
6
simple_language_plugin/.idea/misc.xml
generated
6
simple_language_plugin/.idea/misc.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="IntelliJ IDEA IU-171.4073.35" project-jdk-type="IDEA JDK">
|
||||
<output url="file://build" />
|
||||
</component>
|
||||
</project>
|
8
simple_language_plugin/.idea/modules.xml
generated
8
simple_language_plugin/.idea/modules.xml
generated
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/simple_language_plugin.iml" filepath="$PROJECT_DIR$/.idea/simple_language_plugin.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
495
simple_language_plugin/.idea/workspace.xml
generated
495
simple_language_plugin/.idea/workspace.xml
generated
@ -1,495 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="cfe387cf-a053-48a5-8f86-a28a9b3c09ce" name="Default" comment="" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="TRACKING_ENABLED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf>
|
||||
<file leaf-file-name="Simple.bnf" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/com/simpleplugin/Simple.bnf">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="170">
|
||||
<caret line="10" column="49" lean-forward="false" selection-start-line="10" selection-start-column="49" selection-end-line="10" selection-end-column="49" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="SimpleProperty.java" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/gen/com/simpleplugin/psi/SimpleProperty.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="85">
|
||||
<caret line="8" column="17" lean-forward="false" selection-start-line="8" selection-start-column="17" selection-end-line="8" selection-end-column="17" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="SimpleUtil.java" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/src/com/simpleplugin/SimpleUtil.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="510">
|
||||
<caret line="38" column="30" lean-forward="false" selection-start-line="38" selection-start-column="30" selection-end-line="38" selection-end-column="30" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="SimplePsiImplUtil.java" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/com/simpleplugin/psi/impl/SimplePsiImplUtil.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="381">
|
||||
<caret line="36" column="15" lean-forward="false" selection-start-line="36" selection-start-column="15" selection-end-line="36" selection-end-column="15" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
</component>
|
||||
<component name="GradleLocalSettings">
|
||||
<option name="modificationStamps">
|
||||
<map>
|
||||
<entry key="$USER_HOME$/Foo/kotlin-koans" value="1484925462000" />
|
||||
<entry key="$USER_HOME$/IdeaProjects/gradle-intellij-plugin" value="2978286332000" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="externalProjectsViewState">
|
||||
<projects_view />
|
||||
</option>
|
||||
</component>
|
||||
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
|
||||
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
|
||||
<component name="JsGulpfileManager">
|
||||
<detection-done>true</detection-done>
|
||||
<sorting>DEFINITION_ORDER</sorting>
|
||||
</component>
|
||||
<component name="ProjectFrameBounds">
|
||||
<option name="x" value="83" />
|
||||
<option name="y" value="73" />
|
||||
<option name="width" value="1144" />
|
||||
<option name="height" value="842" />
|
||||
</component>
|
||||
<component name="ProjectView">
|
||||
<navigator currentView="ProjectPane" proportions="" version="1">
|
||||
<flattenPackages />
|
||||
<showMembers />
|
||||
<showModules />
|
||||
<showLibraryContents />
|
||||
<hideEmptyPackages />
|
||||
<abbreviatePackageNames />
|
||||
<autoscrollToSource />
|
||||
<autoscrollFromSource />
|
||||
<sortByType />
|
||||
<manualOrder />
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<expand>
|
||||
<path>
|
||||
<item name="simple_language_plugin" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="simple_language_plugin" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="simple_language_plugin" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="simple_language_plugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="gen" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="simple_language_plugin" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="simple_language_plugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="gen" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="simpleplugin" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="simple_language_plugin" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="simple_language_plugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="gen" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="simpleplugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="parser" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="simple_language_plugin" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="simple_language_plugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="gen" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="simpleplugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="psi" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="simple_language_plugin" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="simple_language_plugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="gen" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="simpleplugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="psi" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="impl" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="simple_language_plugin" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="simple_language_plugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="simple_language_plugin" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="simple_language_plugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="simpleplugin" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="simple_language_plugin" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="simple_language_plugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="simpleplugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="psi" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="simple_language_plugin" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="simple_language_plugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="src" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="simpleplugin" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="psi" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="impl" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
</expand>
|
||||
<select />
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="Scope" />
|
||||
<pane id="Scratches" />
|
||||
<pane id="AndroidView" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
|
||||
<property name="nodejs_interpreter_path" value="/usr/local/bin/node" />
|
||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||
<property name="aspect.path.notification.shown" value="true" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="project.structure.last.edited" value="Project" />
|
||||
<property name="project.structure.proportion" value="0.17125" />
|
||||
<property name="project.structure.side.proportion" value="0.0" />
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration default="true" type="Applet" factoryName="Applet">
|
||||
<option name="WIDTH" value="400" />
|
||||
<option name="HEIGHT" value="300" />
|
||||
<option name="POLICY_FILE" value="$APPLICATION_HOME_DIR$/bin/appletviewer.policy" />
|
||||
<module />
|
||||
</configuration>
|
||||
<configuration default="true" type="Application" factoryName="Application">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="VM_PARAMETERS" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="ENABLE_SWING_INSPECTOR" value="false" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<module name="" />
|
||||
<envs />
|
||||
</configuration>
|
||||
<configuration default="true" type="JUnit" factoryName="JUnit">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<module name="" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="PACKAGE_NAME" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="METHOD_NAME" />
|
||||
<option name="TEST_OBJECT" value="class" />
|
||||
<option name="VM_PARAMETERS" value="-ea" />
|
||||
<option name="PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<option name="TEST_SEARCH_SCOPE">
|
||||
<value defaultName="singleModule" />
|
||||
</option>
|
||||
<envs />
|
||||
<patterns />
|
||||
</configuration>
|
||||
<configuration default="true" type="#org.jetbrains.idea.devkit.run.PluginConfigurationType" factoryName="Plugin">
|
||||
<module name="" />
|
||||
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -ea" />
|
||||
<option name="PROGRAM_PARAMETERS" />
|
||||
<predefined_log_file id="idea.log" enabled="true" />
|
||||
</configuration>
|
||||
<configuration default="true" type="Remote" factoryName="Remote">
|
||||
<option name="USE_SOCKET_TRANSPORT" value="true" />
|
||||
<option name="SERVER_MODE" value="false" />
|
||||
<option name="SHMEM_ADDRESS" value="javadebug" />
|
||||
<option name="HOST" value="localhost" />
|
||||
<option name="PORT" value="5005" />
|
||||
</configuration>
|
||||
<configuration default="true" type="TestNG" factoryName="TestNG">
|
||||
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
|
||||
<module name="" />
|
||||
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />
|
||||
<option name="ALTERNATIVE_JRE_PATH" />
|
||||
<option name="SUITE_NAME" />
|
||||
<option name="PACKAGE_NAME" />
|
||||
<option name="MAIN_CLASS_NAME" />
|
||||
<option name="METHOD_NAME" />
|
||||
<option name="GROUP_NAME" />
|
||||
<option name="TEST_OBJECT" value="CLASS" />
|
||||
<option name="VM_PARAMETERS" value="-ea" />
|
||||
<option name="PARAMETERS" />
|
||||
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
|
||||
<option name="OUTPUT_DIRECTORY" />
|
||||
<option name="ANNOTATION_TYPE" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<option name="TEST_SEARCH_SCOPE">
|
||||
<value defaultName="singleModule" />
|
||||
</option>
|
||||
<option name="USE_DEFAULT_REPORTERS" value="false" />
|
||||
<option name="PROPERTIES_FILE" />
|
||||
<envs />
|
||||
<properties />
|
||||
<listeners />
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="ShelveChangesManager" show_recycled="false">
|
||||
<option name="remove_strategy" value="false" />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="cfe387cf-a053-48a5-8f86-a28a9b3c09ce" name="Default" comment="" />
|
||||
<created>1507300015770</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1507300015770</updated>
|
||||
<workItem from="1507300017018" duration="795000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="795000" />
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="83" y="73" width="1144" height="842" extended-state="0" />
|
||||
<layout>
|
||||
<window_info id="Key Promoter X" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Palette" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32931727" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Palette	" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32931727" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32931727" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24954627" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="-1" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
</layout>
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
<component name="VcsContentAnnotationSettings">
|
||||
<option name="myLimit" value="2678400000" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager />
|
||||
<watches-manager />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/gen/com/simpleplugin/parser/SimpleParser.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/gen/com/simpleplugin/psi/SimpleTypes.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/gen/com/simpleplugin/psi/SimpleVisitor.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/com/simpleplugin/Simple.flex">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/com/simpleplugin/SimpleLexer.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="323">
|
||||
<caret line="22" column="0" lean-forward="true" selection-start-line="22" selection-start-column="0" selection-end-line="22" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/com/simpleplugin/Simple.bnf">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="170">
|
||||
<caret line="10" column="49" lean-forward="false" selection-start-line="10" selection-start-column="49" selection-end-line="10" selection-end-column="49" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/gen/com/simpleplugin/psi/SimpleProperty.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="85">
|
||||
<caret line="8" column="17" lean-forward="false" selection-start-line="8" selection-start-column="17" selection-end-line="8" selection-end-column="17" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/com/simpleplugin/SimpleUtil.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="510">
|
||||
<caret line="38" column="30" lean-forward="false" selection-start-line="38" selection-start-column="30" selection-end-line="38" selection-end-column="30" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/com/simpleplugin/psi/impl/SimplePsiImplUtil.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="381">
|
||||
<caret line="36" column="15" lean-forward="false" selection-start-line="36" selection-start-column="15" selection-end-line="36" selection-end-column="15" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
<state key="ArtifactsStructureConfigurable.UI">
|
||||
<settings>
|
||||
<artifact-editor />
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="FacetStructureConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>No facets are configured</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="GlobalLibrariesConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>JFlex & idea-flex.skeleton</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="JdkListConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>1.8</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="ModuleStructureConfigurable.UI">
|
||||
<settings>
|
||||
<last-edited>simple_language_plugin</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="ProjectJDKs.UI">
|
||||
<settings>
|
||||
<last-edited>1.8</last-edited>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
<state key="ProjectLibrariesConfigurable.UI">
|
||||
<settings>
|
||||
<splitter-proportions>
|
||||
<option name="proportions">
|
||||
<list>
|
||||
<option value="0.2" />
|
||||
</list>
|
||||
</option>
|
||||
</splitter-proportions>
|
||||
</settings>
|
||||
</state>
|
||||
</states>
|
||||
</component>
|
||||
</project>
|
@ -1,121 +0,0 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package com.simpleplugin.parser;
|
||||
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import com.intellij.lang.PsiBuilder.Marker;
|
||||
import static com.simpleplugin.psi.SimpleTypes.*;
|
||||
import static com.intellij.lang.parser.GeneratedParserUtilBase.*;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.lang.PsiParser;
|
||||
import com.intellij.lang.LightPsiParser;
|
||||
|
||||
@SuppressWarnings({"SimplifiableIfStatement", "UnusedAssignment"})
|
||||
public class SimpleParser implements PsiParser, LightPsiParser {
|
||||
|
||||
public ASTNode parse(IElementType t, PsiBuilder b) {
|
||||
parseLight(t, b);
|
||||
return b.getTreeBuilt();
|
||||
}
|
||||
|
||||
public void parseLight(IElementType t, PsiBuilder b) {
|
||||
boolean r;
|
||||
b = adapt_builder_(t, b, this, null);
|
||||
Marker m = enter_section_(b, 0, _COLLAPSE_, null);
|
||||
if (t == PROPERTY) {
|
||||
r = property(b, 0);
|
||||
}
|
||||
else {
|
||||
r = parse_root_(t, b, 0);
|
||||
}
|
||||
exit_section_(b, 0, m, t, r, true, TRUE_CONDITION);
|
||||
}
|
||||
|
||||
protected boolean parse_root_(IElementType t, PsiBuilder b, int l) {
|
||||
return simpleFile(b, l + 1);
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// (KEY SEPARATOR VALUE?)|KEY
|
||||
public static boolean property(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "property")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _NONE_, PROPERTY, "<property>");
|
||||
r = property_0(b, l + 1);
|
||||
if (!r) r = consumeToken(b, KEY);
|
||||
exit_section_(b, l, m, r, false, recover_property_parser_);
|
||||
return r;
|
||||
}
|
||||
|
||||
// KEY SEPARATOR VALUE?
|
||||
private static boolean property_0(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "property_0")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = consumeTokens(b, 0, KEY, SEPARATOR);
|
||||
r = r && property_0_2(b, l + 1);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
// VALUE?
|
||||
private static boolean property_0_2(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "property_0_2")) return false;
|
||||
consumeToken(b, VALUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// !(KEY|SEPARATOR|COMMENT)
|
||||
static boolean recover_property(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "recover_property")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b, l, _NOT_);
|
||||
r = !recover_property_0(b, l + 1);
|
||||
exit_section_(b, l, m, r, false, null);
|
||||
return r;
|
||||
}
|
||||
|
||||
// KEY|SEPARATOR|COMMENT
|
||||
private static boolean recover_property_0(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "recover_property_0")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = consumeToken(b, KEY);
|
||||
if (!r) r = consumeToken(b, SEPARATOR);
|
||||
if (!r) r = consumeToken(b, COMMENT);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ********************************************************** */
|
||||
// (property|COMMENT)*
|
||||
static boolean simpleFile(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "simpleFile")) return false;
|
||||
int c = current_position_(b);
|
||||
while (true) {
|
||||
if (!simpleFile_0(b, l + 1)) break;
|
||||
if (!empty_element_parsed_guard_(b, "simpleFile", c)) break;
|
||||
c = current_position_(b);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// property|COMMENT
|
||||
private static boolean simpleFile_0(PsiBuilder b, int l) {
|
||||
if (!recursion_guard_(b, l, "simpleFile_0")) return false;
|
||||
boolean r;
|
||||
Marker m = enter_section_(b);
|
||||
r = property(b, l + 1);
|
||||
if (!r) r = consumeToken(b, COMMENT);
|
||||
exit_section_(b, m, null, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
final static Parser recover_property_parser_ = new Parser() {
|
||||
public boolean parse(PsiBuilder b, int l) {
|
||||
return recover_property(b, l + 1);
|
||||
}
|
||||
};
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package com.simpleplugin.psi;
|
||||
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
|
||||
public interface SimpleProperty extends SimpleNamedElement {
|
||||
|
||||
String getKey();
|
||||
|
||||
String getValue();
|
||||
|
||||
String getName();
|
||||
|
||||
PsiElement setName(String newName);
|
||||
|
||||
PsiElement getNameIdentifier();
|
||||
|
||||
ItemPresentation getPresentation();
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package com.simpleplugin.psi;
|
||||
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.simpleplugin.psi.impl.*;
|
||||
|
||||
public interface SimpleTypes {
|
||||
|
||||
IElementType PROPERTY = new SimpleElementType("PROPERTY");
|
||||
|
||||
IElementType COMMENT = new SimpleTokenType("COMMENT");
|
||||
IElementType KEY = new SimpleTokenType("KEY");
|
||||
IElementType SEPARATOR = new SimpleTokenType("SEPARATOR");
|
||||
IElementType VALUE = new SimpleTokenType("VALUE");
|
||||
|
||||
class Factory {
|
||||
public static PsiElement createElement(ASTNode node) {
|
||||
IElementType type = node.getElementType();
|
||||
if (type == PROPERTY) {
|
||||
return new SimplePropertyImpl(node);
|
||||
}
|
||||
throw new AssertionError("Unknown element type: " + type);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package com.simpleplugin.psi;
|
||||
|
||||
import org.jetbrains.annotations.*;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
|
||||
public class SimpleVisitor extends PsiElementVisitor {
|
||||
|
||||
public void visitProperty(@NotNull SimpleProperty o) {
|
||||
visitNamedElement(o);
|
||||
}
|
||||
|
||||
public void visitNamedElement(@NotNull SimpleNamedElement o) {
|
||||
visitPsiElement(o);
|
||||
}
|
||||
|
||||
public void visitPsiElement(@NotNull PsiElement o) {
|
||||
visitElement(o);
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
// This is a generated file. Not intended for manual editing.
|
||||
package com.simpleplugin.psi.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.jetbrains.annotations.*;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import static com.simpleplugin.psi.SimpleTypes.*;
|
||||
import com.simpleplugin.psi.*;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
|
||||
public class SimplePropertyImpl extends SimpleNamedElementImpl implements SimpleProperty {
|
||||
|
||||
public SimplePropertyImpl(ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
public void accept(@NotNull SimpleVisitor visitor) {
|
||||
visitor.visitProperty(this);
|
||||
}
|
||||
|
||||
public void accept(@NotNull PsiElementVisitor visitor) {
|
||||
if (visitor instanceof SimpleVisitor) accept((SimpleVisitor)visitor);
|
||||
else super.accept(visitor);
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return SimplePsiImplUtil.getKey(this);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return SimplePsiImplUtil.getValue(this);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return SimplePsiImplUtil.getName(this);
|
||||
}
|
||||
|
||||
public PsiElement setName(String newName) {
|
||||
return SimplePsiImplUtil.setName(this, newName);
|
||||
}
|
||||
|
||||
public PsiElement getNameIdentifier() {
|
||||
return SimplePsiImplUtil.getNameIdentifier(this);
|
||||
}
|
||||
|
||||
public ItemPresentation getPresentation() {
|
||||
return SimplePsiImplUtil.getPresentation(this);
|
||||
}
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<idea-plugin>
|
||||
<id>com.simpleplugin.unique.plugin.id</id>
|
||||
<name>Simple Language</name>
|
||||
<version>1.0</version>
|
||||
<vendor>JetBrains</vendor>
|
||||
|
||||
<description><![CDATA[Simple language plugin for
|
||||
<a href="http://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support_tutorial.html">Custom Language Support Tutorial</a>]]></description>
|
||||
|
||||
<idea-version since-build="183.3283.2"/>
|
||||
|
||||
<!-- Product and plugin compatibility requirements -->
|
||||
<depends>com.intellij.modules.java</depends>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<fileTypeFactory implementation="com.simpleplugin.SimpleFileTypeFactory"/>
|
||||
<lang.parserDefinition language="Simple" implementationClass="com.simpleplugin.SimpleParserDefinition"/>
|
||||
<lang.syntaxHighlighterFactory key="Simple"
|
||||
language="Simple"
|
||||
implementationClass="com.simpleplugin.SimpleSyntaxHighlighterFactory"/>
|
||||
<colorSettingsPage implementation="com.simpleplugin.SimpleColorSettingsPage"/>
|
||||
<annotator language="JAVA" implementationClass="com.simpleplugin.SimpleAnnotator"/>
|
||||
<codeInsight.lineMarkerProvider language="JAVA" implementationClass="com.simpleplugin.SimpleLineMarkerProvider"/>
|
||||
<completion.contributor language="Simple" implementationClass="com.simpleplugin.SimpleCompletionContributor"/>
|
||||
<psi.referenceContributor implementation="com.simpleplugin.SimpleReferenceContributor"/>
|
||||
<lang.findUsagesProvider language="Simple" implementationClass="com.simpleplugin.SimpleFindUsagesProvider"/>
|
||||
<lang.refactoringSupport language="Simple" implementationClass="com.simpleplugin.SimpleRefactoringSupportProvider"/>
|
||||
<lang.foldingBuilder language="JAVA" implementationClass="com.simpleplugin.SimpleFoldingBuilder"/>
|
||||
<gotoSymbolContributor implementation="com.simpleplugin.SimpleChooseByNameContributor"/>
|
||||
<lang.psiStructureViewFactory language="Simple" implementationClass="com.simpleplugin.SimpleStructureViewFactory"/>
|
||||
<lang.formatter language="Simple" implementationClass="com.simpleplugin.SimpleFormattingModelBuilder"/>
|
||||
<codeStyleSettingsProvider implementation="com.simpleplugin.SimpleCodeStyleSettingsProvider"/>
|
||||
<langCodeStyleSettingsProvider implementation="com.simpleplugin.SimpleLanguageCodeStyleSettingsProvider"/>
|
||||
<lang.commenter language="Simple" implementationClass="com.simpleplugin.SimpleCommenter"/>
|
||||
<todoIndexer filetype="Simple file" implementationClass="com.simpleplugin.SimpleTodoIndexer"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
2
simple_language_plugin/settings.gradle
Normal file
2
simple_language_plugin/settings.gradle
Normal file
@ -0,0 +1,2 @@
|
||||
rootProject.name = 'simple_language_plugin'
|
||||
|
@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PLUGIN_MODULE" version="4">
|
||||
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/resources/META-INF/plugin.xml" />
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<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" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/testData" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -1,91 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.search.FileTypeIndex;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.simpleplugin.psi.SimpleElementFactory;
|
||||
import com.simpleplugin.psi.SimpleFile;
|
||||
import com.simpleplugin.psi.SimpleProperty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
class CreatePropertyQuickFix extends BaseIntentionAction {
|
||||
private String key;
|
||||
|
||||
CreatePropertyQuickFix(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Create property";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Simple properties";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, final Editor editor, PsiFile file) throws
|
||||
IncorrectOperationException {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Collection<VirtualFile> virtualFiles =
|
||||
FileTypeIndex.getFiles(SimpleFileType.INSTANCE, GlobalSearchScope.allScope(project) );
|
||||
if (virtualFiles.size() == 1) {
|
||||
createProperty(project, virtualFiles.iterator().next());
|
||||
} else {
|
||||
final FileChooserDescriptor descriptor =
|
||||
FileChooserDescriptorFactory.createSingleFileDescriptor(SimpleFileType.INSTANCE);
|
||||
descriptor.setRoots(ProjectUtil.guessProjectDir(project));
|
||||
final VirtualFile file = FileChooser.chooseFile(descriptor, project, null);
|
||||
if (file != null) {
|
||||
createProperty(project, file);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createProperty(final Project project, final VirtualFile file) {
|
||||
WriteCommandAction.writeCommandAction(project).run(() -> {
|
||||
SimpleFile simpleFile = (SimpleFile) PsiManager.getInstance(project).findFile(file);
|
||||
ASTNode lastChildNode = simpleFile.getNode().getLastChildNode();
|
||||
// TODO: Add another check for CRLF
|
||||
if (lastChildNode != null/* && !lastChildNode.getElementType().equals(SimpleTypes.CRLF)*/) {
|
||||
simpleFile.getNode().addChild(SimpleElementFactory.createCRLF(project).getNode());
|
||||
}
|
||||
// IMPORTANT: change spaces to escaped spaces or the new node will only have the first word for the key
|
||||
SimpleProperty property = SimpleElementFactory.createProperty(project, key.replaceAll(" ", "\\\\ "), "");
|
||||
simpleFile.getNode().addChild(property.getNode());
|
||||
((Navigatable) property.getLastChild().getNavigationElement()).navigate(true);
|
||||
FileEditorManager.getInstance(project).getSelectedTextEditor().getCaretModel().moveCaretRelatively(2, 0, false, false, false);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
{
|
||||
parserClass="com.simpleplugin.parser.SimpleParser"
|
||||
|
||||
extends="com.intellij.extapi.psi.ASTWrapperPsiElement"
|
||||
|
||||
psiClassPrefix="Simple"
|
||||
psiImplClassSuffix="Impl"
|
||||
psiPackage="com.simpleplugin.psi"
|
||||
psiImplPackage="com.simpleplugin.psi.impl"
|
||||
|
||||
elementTypeHolderClass="com.simpleplugin.psi.SimpleTypes"
|
||||
elementTypeClass="com.simpleplugin.psi.SimpleElementType"
|
||||
tokenTypeClass="com.simpleplugin.psi.SimpleTokenType"
|
||||
|
||||
psiImplUtilClass="com.simpleplugin.psi.impl.SimplePsiImplUtil"
|
||||
}
|
||||
|
||||
simpleFile ::= (property|COMMENT)*
|
||||
|
||||
property ::= (KEY SEPARATOR VALUE?)|KEY {
|
||||
pin=3
|
||||
recoverWhile="recover_property"
|
||||
mixin="com.simpleplugin.psi.impl.SimpleNamedElementImpl"
|
||||
implements="com.simpleplugin.psi.SimpleNamedElement"
|
||||
methods=[getKey getValue getName setName getNameIdentifier getPresentation]
|
||||
}
|
||||
|
||||
private recover_property ::= !(KEY|SEPARATOR|COMMENT)
|
@ -1,44 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lexer.FlexLexer;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.simpleplugin.psi.SimpleTypes;
|
||||
import com.intellij.psi.TokenType;
|
||||
|
||||
%%
|
||||
|
||||
%class SimpleLexer
|
||||
%implements FlexLexer
|
||||
%unicode
|
||||
%function advance
|
||||
%type IElementType
|
||||
%eof{ return;
|
||||
%eof}
|
||||
|
||||
CRLF=\R
|
||||
WHITE_SPACE=[\ \n\t\f]
|
||||
FIRST_VALUE_CHARACTER=[^ \n\f\\] | "\\"{CRLF} | "\\".
|
||||
VALUE_CHARACTER=[^\n\f\\] | "\\"{CRLF} | "\\".
|
||||
END_OF_LINE_COMMENT=("#"|"!")[^\r\n]*
|
||||
SEPARATOR=[:=]
|
||||
KEY_CHARACTER=[^:=\ \n\t\f\\] | "\\ "
|
||||
|
||||
%state WAITING_VALUE
|
||||
|
||||
%%
|
||||
|
||||
<YYINITIAL> {END_OF_LINE_COMMENT} { yybegin(YYINITIAL); return SimpleTypes.COMMENT; }
|
||||
|
||||
<YYINITIAL> {KEY_CHARACTER}+ { yybegin(YYINITIAL); return SimpleTypes.KEY; }
|
||||
|
||||
<YYINITIAL> {SEPARATOR} { yybegin(WAITING_VALUE); return SimpleTypes.SEPARATOR; }
|
||||
|
||||
<WAITING_VALUE> {CRLF}({CRLF}|{WHITE_SPACE})+ { yybegin(YYINITIAL); return TokenType.WHITE_SPACE; }
|
||||
|
||||
<WAITING_VALUE> {WHITE_SPACE}+ { yybegin(WAITING_VALUE); return TokenType.WHITE_SPACE; }
|
||||
|
||||
<WAITING_VALUE> {FIRST_VALUE_CHARACTER}{VALUE_CHARACTER}* { yybegin(YYINITIAL); return SimpleTypes.VALUE; }
|
||||
|
||||
({CRLF}|{WHITE_SPACE})+ { yybegin(YYINITIAL); return TokenType.WHITE_SPACE; }
|
||||
|
||||
[^] { return TokenType.BAD_CHARACTER; }
|
@ -1,37 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lang.annotation.*;
|
||||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.simpleplugin.psi.SimpleProperty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SimpleAnnotator implements Annotator {
|
||||
@Override
|
||||
public void annotate(@NotNull final PsiElement element, @NotNull AnnotationHolder holder) {
|
||||
if (element instanceof PsiLiteralExpression) {
|
||||
PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
|
||||
String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
|
||||
|
||||
if (value != null && value.startsWith("simple" + ":")) {
|
||||
Project project = element.getProject();
|
||||
String key = value.substring(7);
|
||||
List<SimpleProperty> properties = SimpleUtil.findProperties(project, key);
|
||||
if (properties.size() == 1) {
|
||||
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 8,
|
||||
element.getTextRange().getEndOffset() - 1);
|
||||
Annotation annotation = holder.createInfoAnnotation(range, null);
|
||||
annotation.setTextAttributes(DefaultLanguageHighlighterColors.LINE_COMMENT);
|
||||
} else if (properties.size() == 0) {
|
||||
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 8,
|
||||
element.getTextRange().getEndOffset() - 1);
|
||||
holder.createErrorAnnotation(range, "Unresolved property");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.formatting.*;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.formatter.common.AbstractBlock;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SimpleBlock extends AbstractBlock {
|
||||
private SpacingBuilder spacingBuilder;
|
||||
|
||||
protected SimpleBlock(@NotNull ASTNode node, @Nullable Wrap wrap, @Nullable Alignment alignment,
|
||||
SpacingBuilder spacingBuilder) {
|
||||
super(node, wrap, alignment);
|
||||
this.spacingBuilder = spacingBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Block> buildChildren() {
|
||||
List<Block> blocks = new ArrayList<Block>();
|
||||
ASTNode child = myNode.getFirstChildNode();
|
||||
while (child != null) {
|
||||
if (child.getElementType() != TokenType.WHITE_SPACE) {
|
||||
Block block = new SimpleBlock(child, Wrap.createWrap(WrapType.NONE, false), Alignment.createAlignment(),
|
||||
spacingBuilder);
|
||||
blocks.add(block);
|
||||
}
|
||||
child = child.getTreeNext();
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Indent getIndent() {
|
||||
return Indent.getNoneIndent();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Spacing getSpacing(@Nullable Block child1, @NotNull Block child2) {
|
||||
return spacingBuilder.getSpacing(this, child1, child2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLeaf() {
|
||||
return myNode.getFirstChildNode() == null;
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.navigation.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.simpleplugin.psi.SimpleProperty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SimpleChooseByNameContributor implements ChooseByNameContributor {
|
||||
@NotNull
|
||||
@Override
|
||||
public String[] getNames(Project project, boolean includeNonProjectItems) {
|
||||
List<SimpleProperty> properties = SimpleUtil.findProperties(project);
|
||||
List<String> names = new ArrayList<String>(properties.size());
|
||||
for (SimpleProperty property : properties) {
|
||||
if (property.getKey() != null && property.getKey().length() > 0) {
|
||||
names.add(property.getKey());
|
||||
}
|
||||
}
|
||||
return names.toArray(new String[names.size()]);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
|
||||
// todo include non project items
|
||||
List<SimpleProperty> properties = SimpleUtil.findProperties(project, name);
|
||||
return properties.toArray(new NavigationItem[properties.size()]);
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.psi.codeStyle.*;
|
||||
|
||||
public class SimpleCodeStyleSettings extends CustomCodeStyleSettings {
|
||||
public SimpleCodeStyleSettings(CodeStyleSettings settings) {
|
||||
super("SimpleCodeStyleSettings", settings);
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.application.options.*;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.psi.codeStyle.*;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class SimpleCodeStyleSettingsProvider extends CodeStyleSettingsProvider {
|
||||
@Override
|
||||
public CustomCodeStyleSettings createCustomSettings(CodeStyleSettings settings) {
|
||||
return new SimpleCodeStyleSettings(settings);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getConfigurableDisplayName() {
|
||||
return "Simple";
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public CodeStyleConfigurable createConfigurable(@NotNull CodeStyleSettings settings, @NotNull CodeStyleSettings modelSettings) {
|
||||
return new CodeStyleAbstractConfigurable(settings, modelSettings, this.getConfigurableDisplayName()) {
|
||||
@Override
|
||||
protected CodeStyleAbstractPanel createPanel(CodeStyleSettings settings) {
|
||||
return new SimpleCodeStyleMainPanel(getCurrentSettings(), settings);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static class SimpleCodeStyleMainPanel extends TabbedLanguageCodeStylePanel {
|
||||
public SimpleCodeStyleMainPanel(CodeStyleSettings currentSettings, CodeStyleSettings settings) {
|
||||
super(SimpleLanguage.INSTANCE, currentSettings, settings);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
import com.intellij.openapi.options.colors.*;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.Map;
|
||||
|
||||
public class SimpleColorSettingsPage implements ColorSettingsPage {
|
||||
private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[]{
|
||||
new AttributesDescriptor("Key", SimpleSyntaxHighlighter.KEY),
|
||||
new AttributesDescriptor("Separator", SimpleSyntaxHighlighter.SEPARATOR),
|
||||
new AttributesDescriptor("Value", SimpleSyntaxHighlighter.VALUE),
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return SimpleIcons.FILE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SyntaxHighlighter getHighlighter() {
|
||||
return new SimpleSyntaxHighlighter();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDemoText() {
|
||||
return "# You are reading the \".properties\" entry.\n" +
|
||||
"! The exclamation mark can also mark text as comments.\n" +
|
||||
"website = http://en.wikipedia.org/\n" +
|
||||
"language = English\n" +
|
||||
"# The backslash below tells the application to continue reading\n" +
|
||||
"# the value onto the next line.\n" +
|
||||
"message = Welcome to \\\n" +
|
||||
" Wikipedia!\n" +
|
||||
"# Add spaces to the key\n" +
|
||||
"key\\ with\\ spaces = This is the value that could be looked up with the key \"key with spaces\".\n" +
|
||||
"# Unicode\n" +
|
||||
"tab : \\u0009";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Map<String, TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AttributesDescriptor[] getAttributeDescriptors() {
|
||||
return DESCRIPTORS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ColorDescriptor[] getColorDescriptors() {
|
||||
return ColorDescriptor.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "Simple";
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lang.Commenter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SimpleCommenter implements Commenter {
|
||||
@Nullable
|
||||
@Override
|
||||
public String getLineCommentPrefix() {
|
||||
return "#";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getBlockCommentPrefix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getBlockCommentSuffix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getCommentedBlockCommentPrefix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getCommentedBlockCommentSuffix() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.codeInsight.completion.*;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.patterns.PlatformPatterns;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import com.simpleplugin.psi.SimpleTypes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimpleCompletionContributor extends CompletionContributor {
|
||||
public SimpleCompletionContributor() {
|
||||
extend(CompletionType.BASIC,
|
||||
PlatformPatterns.psiElement(SimpleTypes.VALUE).withLanguage(SimpleLanguage.INSTANCE),
|
||||
new CompletionProvider<CompletionParameters>() {
|
||||
public void addCompletions(@NotNull CompletionParameters parameters,
|
||||
ProcessingContext context,
|
||||
@NotNull CompletionResultSet resultSet) {
|
||||
resultSet.addElement(LookupElementBuilder.create("Hello"));
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class SimpleFileType extends LanguageFileType {
|
||||
public static final SimpleFileType INSTANCE = new SimpleFileType();
|
||||
|
||||
private SimpleFileType() {
|
||||
super(SimpleLanguage.INSTANCE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Simple file";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Simple language file";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDefaultExtension() {
|
||||
return "simple";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Icon getIcon() {
|
||||
return SimpleIcons.FILE;
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.openapi.fileTypes.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimpleFileTypeFactory extends FileTypeFactory {
|
||||
@Override
|
||||
public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) {
|
||||
fileTypeConsumer.consume(SimpleFileType.INSTANCE);
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.psi.impl.cache.impl.*;
|
||||
import com.intellij.psi.search.UsageSearchContext;
|
||||
|
||||
public class SimpleFilterLexer extends BaseFilterLexer {
|
||||
public SimpleFilterLexer(final Lexer originalLexer, final OccurrenceConsumer table) {
|
||||
super(originalLexer, table);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void advance() {
|
||||
scanWordsInToken(UsageSearchContext.IN_COMMENTS, false, false);
|
||||
advanceTodoItemCountsInToken();
|
||||
myDelegate.advance();
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lang.cacheBuilder.*;
|
||||
import com.intellij.lang.findUsages.FindUsagesProvider;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.simpleplugin.psi.*;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class SimpleFindUsagesProvider implements FindUsagesProvider {
|
||||
@Nullable
|
||||
@Override
|
||||
public WordsScanner getWordsScanner() {
|
||||
return new DefaultWordsScanner(new SimpleLexerAdapter(),
|
||||
TokenSet.create(SimpleTypes.KEY),
|
||||
TokenSet.create(SimpleTypes.COMMENT),
|
||||
TokenSet.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFindUsagesFor(@NotNull PsiElement psiElement) {
|
||||
return psiElement instanceof PsiNamedElement;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getHelpId(@NotNull PsiElement psiElement) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getType(@NotNull PsiElement element) {
|
||||
if (element instanceof SimpleProperty) {
|
||||
return "simple property";
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDescriptiveName(@NotNull PsiElement element) {
|
||||
if (element instanceof SimpleProperty) {
|
||||
return ((SimpleProperty) element).getKey();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getNodeText(@NotNull PsiElement element, boolean useFullName) {
|
||||
if (element instanceof SimpleProperty) {
|
||||
return ((SimpleProperty) element).getKey() + ":" + ((SimpleProperty) element).getValue();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.folding.*;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.simpleplugin.psi.SimpleProperty;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SimpleFoldingBuilder extends FoldingBuilderEx implements DumbAware {
|
||||
@NotNull
|
||||
@Override
|
||||
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
|
||||
FoldingGroup group = FoldingGroup.newGroup("simple");
|
||||
|
||||
List<FoldingDescriptor> descriptors = new ArrayList<FoldingDescriptor>();
|
||||
Collection<PsiLiteralExpression> literalExpressions =
|
||||
PsiTreeUtil.findChildrenOfType(root, PsiLiteralExpression.class);
|
||||
for (final PsiLiteralExpression literalExpression : literalExpressions) {
|
||||
String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
|
||||
|
||||
if (value != null && value.startsWith("simple:")) {
|
||||
Project project = literalExpression.getProject();
|
||||
String key = value.substring(7);
|
||||
final List<SimpleProperty> properties = SimpleUtil.findProperties(project, key);
|
||||
if (properties.size() == 1) {
|
||||
descriptors.add(new FoldingDescriptor(literalExpression.getNode(),
|
||||
new TextRange(literalExpression.getTextRange().getStartOffset() + 1,
|
||||
literalExpression.getTextRange().getEndOffset() - 1),
|
||||
group) {
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPlaceholderText() {
|
||||
// IMPORTANT: keys can come with no values, so a test for null is needed
|
||||
// IMPORTANT: Convert embedded \n to backslash n, so that the string will look like it has LF embedded
|
||||
// in it and embedded " to escaped "
|
||||
String valueOf = properties.get(0).getValue();
|
||||
return valueOf == null ? "" : valueOf.replaceAll("\n", "\\n").replaceAll("\"", "\\\\\"");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPlaceholderText(@NotNull ASTNode node) {
|
||||
String retTxt = "...";
|
||||
if ( node.getPsi() instanceof PsiLiteralExpression ) {
|
||||
PsiLiteralExpression nodeElement = (PsiLiteralExpression) node.getPsi();
|
||||
String key = ((String) nodeElement.getValue()).substring("simple:".length());
|
||||
final List< SimpleProperty > properties = SimpleUtil.findProperties(nodeElement.getProject(), key);
|
||||
String place = properties.get(0).getValue();
|
||||
// IMPORTANT: keys can come with no values, so a test for null is needed
|
||||
// IMPORTANT: Convert embedded \n to backslash n, so that the string will look
|
||||
// like it has LF embedded in it and embedded " to escaped "
|
||||
return place == null ? retTxt : place.replaceAll("\n", "\\n").replaceAll("\"", "\\\\\"");
|
||||
}
|
||||
return retTxt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollapsedByDefault(@NotNull ASTNode node) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.formatting.*;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.simpleplugin.psi.SimpleTypes;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class SimpleFormattingModelBuilder implements FormattingModelBuilder {
|
||||
@NotNull
|
||||
@Override
|
||||
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
|
||||
return FormattingModelProvider
|
||||
.createFormattingModelForPsiFile(element.getContainingFile(),
|
||||
new SimpleBlock(element.getNode(),
|
||||
Wrap.createWrap(WrapType.NONE, false),
|
||||
Alignment.createAlignment(),
|
||||
createSpaceBuilder(settings)),
|
||||
settings);
|
||||
}
|
||||
|
||||
private static SpacingBuilder createSpaceBuilder(CodeStyleSettings settings) {
|
||||
return new SpacingBuilder(settings, SimpleLanguage.INSTANCE)
|
||||
.around(SimpleTypes.SEPARATOR)
|
||||
.spaceIf(settings.getCommonSettings(SimpleLanguage.INSTANCE.getID()).SPACE_AROUND_ASSIGNMENT_OPERATORS)
|
||||
.before(SimpleTypes.PROPERTY)
|
||||
.none();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class SimpleIcons {
|
||||
public static final Icon FILE = IconLoader.getIcon("/com/simpleplugin/icons/jar-gray.png");
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.psi.impl.cache.impl.OccurrenceConsumer;
|
||||
import com.intellij.psi.impl.cache.impl.id.LexerBasedIdIndexer;
|
||||
|
||||
public class SimpleIdIndexer extends LexerBasedIdIndexer {
|
||||
|
||||
public static Lexer createIndexingLexer(OccurrenceConsumer consumer) {
|
||||
return new SimpleFilterLexer(new SimpleLexerAdapter(), consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Lexer createLexer(final OccurrenceConsumer consumer) {
|
||||
return createIndexingLexer(consumer);
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
|
||||
public class SimpleLanguage extends Language {
|
||||
public static final SimpleLanguage INSTANCE = new SimpleLanguage();
|
||||
|
||||
private SimpleLanguage() {
|
||||
super("Simple");
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.psi.codeStyle.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimpleLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider {
|
||||
@NotNull
|
||||
@Override
|
||||
public Language getLanguage() {
|
||||
return SimpleLanguage.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) {
|
||||
if (settingsType == SettingsType.SPACING_SETTINGS) {
|
||||
consumer.showStandardOptions("SPACE_AROUND_ASSIGNMENT_OPERATORS");
|
||||
consumer.renameStandardOption("SPACE_AROUND_ASSIGNMENT_OPERATORS", "Separator");
|
||||
} else if (settingsType == SettingsType.BLANK_LINES_SETTINGS) {
|
||||
consumer.showStandardOptions("KEEP_BLANK_LINES_IN_CODE");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCodeSample(@NotNull SettingsType settingsType) {
|
||||
return "# You are reading the \".properties\" entry.\n" +
|
||||
"! The exclamation mark can also mark text as comments.\n" +
|
||||
"website = http://en.wikipedia.org/\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"language = English\n" +
|
||||
"# The backslash below tells the application to continue reading\n" +
|
||||
"# the value onto the next line.\n" +
|
||||
"message = Welcome to \\\n" +
|
||||
" Wikipedia!\n" +
|
||||
"# Add spaces to the key\n" +
|
||||
"key\\ with\\ spaces = This is the value that could be looked up with the key \"key with spaces\".\n" +
|
||||
"# Unicode\n" +
|
||||
"tab : \\u0009";
|
||||
}
|
||||
}
|
@ -1,528 +0,0 @@
|
||||
/* The following code was generated by JFlex 1.7.0-SNAPSHOT tweaked for IntelliJ platform */
|
||||
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lexer.FlexLexer;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.simpleplugin.psi.SimpleTypes;
|
||||
import com.intellij.psi.TokenType;
|
||||
|
||||
|
||||
/**
|
||||
* This class is a scanner generated by
|
||||
* <a href="http://www.jflex.de/">JFlex</a> 1.7.0-SNAPSHOT
|
||||
* from the specification file <tt>Simple.flex</tt>
|
||||
*/
|
||||
class SimpleLexer implements FlexLexer {
|
||||
|
||||
/** This character denotes the end of file */
|
||||
public static final int YYEOF = -1;
|
||||
|
||||
/** initial size of the lookahead buffer */
|
||||
private static final int ZZ_BUFFERSIZE = 16384;
|
||||
|
||||
/** lexical states */
|
||||
public static final int YYINITIAL = 0;
|
||||
public static final int WAITING_VALUE = 2;
|
||||
|
||||
/**
|
||||
* 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
|
||||
};
|
||||
|
||||
/**
|
||||
* Translates characters to character classes
|
||||
* Chosen bits are [9, 6, 6]
|
||||
* Total runtime size is 1568 bytes
|
||||
*/
|
||||
public static int ZZ_CMAP(int ch) {
|
||||
return ZZ_CMAP_A[(ZZ_CMAP_Y[ZZ_CMAP_Z[ch>>12]|((ch>>6)&0x3f)]<<6)|(ch&0x3f)];
|
||||
}
|
||||
|
||||
/* The ZZ_CMAP_Z table has 272 entries */
|
||||
static final char ZZ_CMAP_Z[] = zzUnpackCMap(
|
||||
"\1\0\1\100\1\200\u010d\100");
|
||||
|
||||
/* The ZZ_CMAP_Y table has 192 entries */
|
||||
static final char ZZ_CMAP_Y[] = zzUnpackCMap(
|
||||
"\1\0\1\1\1\2\175\3\1\4\77\3");
|
||||
|
||||
/* The ZZ_CMAP_A table has 320 entries */
|
||||
static final char ZZ_CMAP_A[] = zzUnpackCMap(
|
||||
"\11\0\1\4\1\2\1\1\1\5\1\3\22\0\1\7\1\10\1\0\1\10\26\0\1\11\2\0\1\11\36\0\1"+
|
||||
"\6\50\0\1\1\242\0\2\1\26\0");
|
||||
|
||||
/**
|
||||
* Translates DFA states to action switch labels.
|
||||
*/
|
||||
private static final int [] ZZ_ACTION = zzUnpackAction();
|
||||
|
||||
private static final String ZZ_ACTION_PACKED_0 =
|
||||
"\2\0\2\1\1\2\1\3\1\4\1\5\2\6\2\7"+
|
||||
"\1\3\1\7\1\0\2\4\1\0\1\2\2\6";
|
||||
|
||||
private static int [] zzUnpackAction() {
|
||||
int [] result = new int[21];
|
||||
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\12\0\24\0\36\0\50\0\62\0\74\0\106"+
|
||||
"\0\120\0\132\0\50\0\144\0\156\0\170\0\62\0\202"+
|
||||
"\0\214\0\156\0\132\0\226\0\240";
|
||||
|
||||
private static int [] zzUnpackRowMap() {
|
||||
int [] result = new int[21];
|
||||
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\3\1\4\1\5\1\4\2\5\1\6\1\5\1\7"+
|
||||
"\1\10\1\11\1\12\1\13\1\12\1\14\1\13\1\15"+
|
||||
"\1\16\2\11\2\3\1\0\1\3\2\0\1\17\1\0"+
|
||||
"\1\3\1\0\1\3\1\4\1\5\1\4\2\5\1\17"+
|
||||
"\1\5\1\3\2\0\5\5\1\0\1\5\11\0\1\3"+
|
||||
"\2\0\2\7\1\0\1\3\2\20\1\21\1\20\1\7"+
|
||||
"\1\20\12\0\2\11\1\0\2\11\1\0\1\22\4\11"+
|
||||
"\1\23\1\5\2\23\1\5\1\22\1\23\3\11\1\24"+
|
||||
"\1\16\1\24\1\14\1\16\1\22\1\14\5\11\1\25"+
|
||||
"\6\11\1\0\1\5\1\16\1\5\2\16\1\0\1\16"+
|
||||
"\2\0\2\20\2\0\10\20\2\0\3\20\1\7\2\20"+
|
||||
"\1\11\1\24\1\5\2\24\1\5\1\22\1\24\7\11"+
|
||||
"\1\0\1\22\3\11";
|
||||
|
||||
private static int [] zzUnpackTrans() {
|
||||
int [] result = new int[170];
|
||||
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;
|
||||
|
||||
/* error messages for the codes above */
|
||||
private static final String[] ZZ_ERROR_MSG = {
|
||||
"Unknown 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 =
|
||||
"\2\0\5\1\1\11\6\1\1\0\2\1\1\0\3\1";
|
||||
|
||||
private static int [] zzUnpackAttribute() {
|
||||
int [] result = new int[21];
|
||||
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 input device */
|
||||
private java.io.Reader zzReader;
|
||||
|
||||
/** 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 = "";
|
||||
|
||||
/** the textposition at the last accepting state */
|
||||
private int zzMarkedPos;
|
||||
|
||||
/** 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;
|
||||
|
||||
/** denotes if the user-EOF-code has already been executed */
|
||||
private boolean zzEOFDone;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new scanner
|
||||
*
|
||||
* @param in the java.io.Reader to read input from.
|
||||
*/
|
||||
SimpleLexer(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) {
|
||||
int size = 0;
|
||||
for (int i = 0, length = packed.length(); i < length; i += 2) {
|
||||
size += packed.charAt(i);
|
||||
}
|
||||
char[] map = new char[size];
|
||||
int i = 0; /* index in packed string */
|
||||
int j = 0; /* index in unpacked array */
|
||||
while (i < packed.length()) {
|
||||
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;
|
||||
zzCurrentPos = zzMarkedPos = zzStartRead = start;
|
||||
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 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;
|
||||
|
||||
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];
|
||||
|
||||
// set up zzAction for empty match case:
|
||||
int zzAttributes = zzAttrL[zzState];
|
||||
if ( (zzAttributes & 1) == 1 ) {
|
||||
zzAction = zzState;
|
||||
}
|
||||
|
||||
|
||||
zzForAction: {
|
||||
while (true) {
|
||||
|
||||
if (zzCurrentPosL < zzEndReadL) {
|
||||
zzInput = Character.codePointAt(zzBufferL, zzCurrentPosL/*, zzEndReadL*/);
|
||||
zzCurrentPosL += Character.charCount(zzInput);
|
||||
}
|
||||
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 = Character.codePointAt(zzBufferL, zzCurrentPosL/*, zzEndReadL*/);
|
||||
zzCurrentPosL += Character.charCount(zzInput);
|
||||
}
|
||||
}
|
||||
int zzNext = zzTransL[ zzRowMapL[zzState] + ZZ_CMAP(zzInput) ];
|
||||
if (zzNext == -1) break zzForAction;
|
||||
zzState = zzNext;
|
||||
|
||||
zzAttributes = zzAttrL[zzState];
|
||||
if ( (zzAttributes & 1) == 1 ) {
|
||||
zzAction = zzState;
|
||||
zzMarkedPosL = zzCurrentPosL;
|
||||
if ( (zzAttributes & 8) == 8 ) break zzForAction;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// store back cached position
|
||||
zzMarkedPos = zzMarkedPosL;
|
||||
|
||||
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
|
||||
zzAtEOF = true;
|
||||
zzDoEOF();
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
|
||||
case 1:
|
||||
{ yybegin(YYINITIAL); return SimpleTypes.KEY;
|
||||
}
|
||||
case 8: break;
|
||||
case 2:
|
||||
{ yybegin(YYINITIAL); return TokenType.WHITE_SPACE;
|
||||
}
|
||||
case 9: break;
|
||||
case 3:
|
||||
{ return TokenType.BAD_CHARACTER;
|
||||
}
|
||||
case 10: break;
|
||||
case 4:
|
||||
{ yybegin(YYINITIAL); return SimpleTypes.COMMENT;
|
||||
}
|
||||
case 11: break;
|
||||
case 5:
|
||||
{ yybegin(WAITING_VALUE); return SimpleTypes.SEPARATOR;
|
||||
}
|
||||
case 12: break;
|
||||
case 6:
|
||||
{ yybegin(YYINITIAL); return SimpleTypes.VALUE;
|
||||
}
|
||||
case 13: break;
|
||||
case 7:
|
||||
{ yybegin(WAITING_VALUE); return TokenType.WHITE_SPACE;
|
||||
}
|
||||
case 14: break;
|
||||
default:
|
||||
zzScanError(ZZ_NO_MATCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lexer.FlexAdapter;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
public class SimpleLexerAdapter extends FlexAdapter {
|
||||
public SimpleLexerAdapter() {
|
||||
super(new SimpleLexer((Reader) null));
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.codeInsight.daemon.*;
|
||||
import com.intellij.codeInsight.navigation.NavigationGutterIconBuilder;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.java.PsiJavaTokenImpl;
|
||||
import com.simpleplugin.psi.SimpleProperty;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SimpleLineMarkerProvider extends RelatedItemLineMarkerProvider {
|
||||
@Override
|
||||
protected void collectNavigationMarkers(@NotNull PsiElement element,
|
||||
@NotNull Collection<? super RelatedItemLineMarkerInfo> result) {
|
||||
if (element instanceof PsiJavaTokenImpl && element.getParent() instanceof PsiLiteralExpression) {
|
||||
PsiLiteralExpression literalExpression = (PsiLiteralExpression) element.getParent();
|
||||
String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
|
||||
if (value != null && value.startsWith("simple" + ":")) {
|
||||
Project project = element.getProject();
|
||||
final List<SimpleProperty> properties = SimpleUtil.findProperties(project, value.substring(7));
|
||||
if (properties.size() > 0) {
|
||||
NavigationGutterIconBuilder<PsiElement> builder =
|
||||
NavigationGutterIconBuilder.create(SimpleIcons.FILE).
|
||||
setTargets(properties).
|
||||
setTooltipText("Navigate to a simple property");
|
||||
result.add(builder.createLineMarkerInfo(element));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.tree.*;
|
||||
import com.simpleplugin.parser.SimpleParser;
|
||||
import com.simpleplugin.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimpleParserDefinition implements ParserDefinition {
|
||||
public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
|
||||
public static final TokenSet COMMENTS = TokenSet.create(SimpleTypes.COMMENT);
|
||||
|
||||
public static final IFileElementType FILE = new IFileElementType(SimpleLanguage.INSTANCE);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Lexer createLexer(Project project) {
|
||||
return new SimpleLexerAdapter();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TokenSet getWhitespaceTokens() {
|
||||
return WHITE_SPACES;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TokenSet getCommentTokens() {
|
||||
return COMMENTS;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TokenSet getStringLiteralElements() {
|
||||
return TokenSet.EMPTY;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiParser createParser(final Project project) {
|
||||
return new SimpleParser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IFileElementType getFileNodeType() {
|
||||
return FILE;
|
||||
}
|
||||
|
||||
public PsiFile createFile(FileViewProvider viewProvider) {
|
||||
return new SimpleFile(viewProvider);
|
||||
}
|
||||
|
||||
public SpaceRequirements spaceExistenceTypeBetweenTokens(ASTNode left, ASTNode right) {
|
||||
return SpaceRequirements.MAY;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiElement createElement(ASTNode node) {
|
||||
return SimpleTypes.Factory.createElement(node);
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lang.refactoring.RefactoringSupportProvider;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.simpleplugin.psi.SimpleProperty;
|
||||
|
||||
public class SimpleRefactoringSupportProvider extends RefactoringSupportProvider {
|
||||
@Override
|
||||
public boolean isMemberInplaceRenameAvailable(PsiElement element, PsiElement context) {
|
||||
return element instanceof SimpleProperty;
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.codeInsight.lookup.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.simpleplugin.psi.SimpleProperty;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SimpleReference extends PsiReferenceBase<PsiElement> implements PsiPolyVariantReference {
|
||||
private String key;
|
||||
|
||||
public SimpleReference(@NotNull PsiElement element, TextRange textRange) {
|
||||
super(element, textRange);
|
||||
key = element.getText().substring(textRange.getStartOffset(), textRange.getEndOffset());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ResolveResult[] multiResolve(boolean incompleteCode) {
|
||||
Project project = myElement.getProject();
|
||||
final List<SimpleProperty> properties = SimpleUtil.findProperties(project, key);
|
||||
List<ResolveResult> results = new ArrayList<ResolveResult>();
|
||||
for (SimpleProperty property : properties) {
|
||||
results.add(new PsiElementResolveResult(property));
|
||||
}
|
||||
return results.toArray(new ResolveResult[results.size()]);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public PsiElement resolve() {
|
||||
ResolveResult[] resolveResults = multiResolve(false);
|
||||
return resolveResults.length == 1 ? resolveResults[0].getElement() : null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Object[] getVariants() {
|
||||
Project project = myElement.getProject();
|
||||
List<SimpleProperty> properties = SimpleUtil.findProperties(project);
|
||||
List<LookupElement> variants = new ArrayList<LookupElement>();
|
||||
for (final SimpleProperty property : properties) {
|
||||
if (property.getKey() != null && property.getKey().length() > 0) {
|
||||
variants.add(LookupElementBuilder.create(property).
|
||||
withIcon(SimpleIcons.FILE).
|
||||
withTypeText(property.getContainingFile().getName())
|
||||
);
|
||||
}
|
||||
}
|
||||
return variants.toArray();
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.patterns.PlatformPatterns;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.util.ProcessingContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimpleReferenceContributor extends PsiReferenceContributor {
|
||||
@Override
|
||||
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
|
||||
registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class),
|
||||
new PsiReferenceProvider() {
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
|
||||
@NotNull ProcessingContext
|
||||
context) {
|
||||
PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
|
||||
String value = literalExpression.getValue() instanceof String ?
|
||||
(String) literalExpression.getValue() : null;
|
||||
if (value != null && value.startsWith("simple" + ":")) {
|
||||
return new PsiReference[]{
|
||||
new SimpleReference(element, new TextRange(8, value.length() + 1))};
|
||||
}
|
||||
return PsiReference.EMPTY_ARRAY;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.ide.structureView.StructureViewTreeElement;
|
||||
import com.intellij.ide.util.treeView.smartTree.SortableTreeElement;
|
||||
import com.intellij.ide.util.treeView.smartTree.TreeElement;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.psi.NavigatablePsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.simpleplugin.psi.SimpleFile;
|
||||
import com.simpleplugin.psi.SimpleProperty;
|
||||
import com.simpleplugin.psi.impl.SimplePropertyImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SimpleStructureViewElement implements StructureViewTreeElement, SortableTreeElement {
|
||||
private NavigatablePsiElement element;
|
||||
|
||||
public SimpleStructureViewElement(NavigatablePsiElement element) {
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigate(boolean requestFocus) {
|
||||
element.navigate(requestFocus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigate() {
|
||||
return element.canNavigate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canNavigateToSource() {
|
||||
return element.canNavigateToSource();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getAlphaSortKey() {
|
||||
String name = element.getName();
|
||||
return name != null ? name : "";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemPresentation getPresentation() {
|
||||
ItemPresentation presentation = element.getPresentation();
|
||||
return presentation != null ? presentation : new PresentationData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeElement[] getChildren() {
|
||||
if (element instanceof SimpleFile) {
|
||||
SimpleProperty[] properties = PsiTreeUtil.getChildrenOfType(element, SimpleProperty.class);
|
||||
List<TreeElement> treeElements = new ArrayList<TreeElement>(properties.length);
|
||||
for (SimpleProperty property : properties) {
|
||||
treeElements.add(new SimpleStructureViewElement((SimplePropertyImpl) property));
|
||||
}
|
||||
return treeElements.toArray(new TreeElement[treeElements.size()]);
|
||||
} else {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.ide.structureView.*;
|
||||
import com.intellij.lang.PsiStructureViewFactory;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class SimpleStructureViewFactory implements PsiStructureViewFactory {
|
||||
@Nullable
|
||||
@Override
|
||||
public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
|
||||
return new TreeBasedStructureViewBuilder() {
|
||||
@NotNull
|
||||
@Override
|
||||
public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
|
||||
return new SimpleStructureViewModel(psiFile);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.ide.structureView.*;
|
||||
import com.intellij.ide.util.treeView.smartTree.Sorter;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.simpleplugin.psi.SimpleFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimpleStructureViewModel extends StructureViewModelBase implements
|
||||
StructureViewModel.ElementInfoProvider {
|
||||
public SimpleStructureViewModel(PsiFile psiFile) {
|
||||
super(psiFile, new SimpleStructureViewElement(psiFile));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Sorter[] getSorters() {
|
||||
return new Sorter[]{Sorter.ALPHA_SORTER};
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysShowsPlus(StructureViewTreeElement element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAlwaysLeaf(StructureViewTreeElement element) {
|
||||
return element instanceof SimpleFile;
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.editor.*;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.simpleplugin.psi.SimpleTypes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey;
|
||||
|
||||
public class SimpleSyntaxHighlighter extends SyntaxHighlighterBase {
|
||||
public static final TextAttributesKey SEPARATOR =
|
||||
createTextAttributesKey("SIMPLE_SEPARATOR", DefaultLanguageHighlighterColors.OPERATION_SIGN);
|
||||
public static final TextAttributesKey KEY =
|
||||
createTextAttributesKey("SIMPLE_KEY", DefaultLanguageHighlighterColors.KEYWORD);
|
||||
public static final TextAttributesKey VALUE =
|
||||
createTextAttributesKey("SIMPLE_VALUE", DefaultLanguageHighlighterColors.STRING);
|
||||
public static final TextAttributesKey COMMENT =
|
||||
createTextAttributesKey("SIMPLE_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);
|
||||
public static final TextAttributesKey BAD_CHARACTER =
|
||||
createTextAttributesKey("SIMPLE_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER);
|
||||
|
||||
private static final TextAttributesKey[] BAD_CHAR_KEYS = new TextAttributesKey[]{BAD_CHARACTER};
|
||||
private static final TextAttributesKey[] SEPARATOR_KEYS = new TextAttributesKey[]{SEPARATOR};
|
||||
private static final TextAttributesKey[] KEY_KEYS = new TextAttributesKey[]{KEY};
|
||||
private static final TextAttributesKey[] VALUE_KEYS = new TextAttributesKey[]{VALUE};
|
||||
private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[]{COMMENT};
|
||||
private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0];
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Lexer getHighlightingLexer() {
|
||||
return new SimpleLexerAdapter();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
|
||||
if (tokenType.equals(SimpleTypes.SEPARATOR)) {
|
||||
return SEPARATOR_KEYS;
|
||||
} else if (tokenType.equals(SimpleTypes.KEY)) {
|
||||
return KEY_KEYS;
|
||||
} else if (tokenType.equals(SimpleTypes.VALUE)) {
|
||||
return VALUE_KEYS;
|
||||
} else if (tokenType.equals(SimpleTypes.COMMENT)) {
|
||||
return COMMENT_KEYS;
|
||||
} else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
|
||||
return BAD_CHAR_KEYS;
|
||||
} else {
|
||||
return EMPTY_KEYS;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.openapi.fileTypes.*;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SimpleSyntaxHighlighterFactory extends SyntaxHighlighterFactory {
|
||||
@NotNull
|
||||
@Override
|
||||
public SyntaxHighlighter getSyntaxHighlighter(Project project, VirtualFile virtualFile) {
|
||||
return new SimpleSyntaxHighlighter();
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.psi.impl.cache.impl.OccurrenceConsumer;
|
||||
import com.intellij.psi.impl.cache.impl.todo.LexerBasedTodoIndexer;
|
||||
|
||||
public class SimpleTodoIndexer extends LexerBasedTodoIndexer {
|
||||
@Override
|
||||
public Lexer createLexer(OccurrenceConsumer consumer) {
|
||||
return SimpleIdIndexer.createIndexingLexer(consumer);
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.search.*;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.simpleplugin.psi.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SimpleUtil {
|
||||
public static List<SimpleProperty> findProperties(Project project, String key) {
|
||||
List<SimpleProperty> result = null;
|
||||
Collection<VirtualFile> virtualFiles =
|
||||
FileTypeIndex.getFiles(SimpleFileType.INSTANCE, GlobalSearchScope.allScope(project));
|
||||
for (VirtualFile virtualFile : virtualFiles) {
|
||||
SimpleFile simpleFile = (SimpleFile) PsiManager.getInstance(project).findFile(virtualFile);
|
||||
if (simpleFile != null) {
|
||||
SimpleProperty[] properties = PsiTreeUtil.getChildrenOfType(simpleFile, SimpleProperty.class);
|
||||
if (properties != null) {
|
||||
for (SimpleProperty property : properties) {
|
||||
if (key.equals(property.getKey())) {
|
||||
if (result == null) {
|
||||
result = new ArrayList<SimpleProperty>();
|
||||
}
|
||||
result.add(property);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result != null ? result : Collections.<SimpleProperty>emptyList();
|
||||
}
|
||||
|
||||
public static List<SimpleProperty> findProperties(Project project) {
|
||||
List<SimpleProperty> result = new ArrayList<SimpleProperty>();
|
||||
Collection<VirtualFile> virtualFiles =
|
||||
FileTypeIndex.getFiles(SimpleFileType.INSTANCE, GlobalSearchScope.allScope(project));
|
||||
for (VirtualFile virtualFile : virtualFiles) {
|
||||
SimpleFile simpleFile = (SimpleFile) PsiManager.getInstance(project).findFile(virtualFile);
|
||||
if (simpleFile != null) {
|
||||
SimpleProperty[] properties = PsiTreeUtil.getChildrenOfType(simpleFile, SimpleProperty.class);
|
||||
if (properties != null) {
|
||||
Collections.addAll(result, properties);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 717 B |
@ -1,28 +0,0 @@
|
||||
package com.simpleplugin.psi;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.simpleplugin.SimpleFileType;
|
||||
|
||||
public class SimpleElementFactory {
|
||||
public static SimpleProperty createProperty(Project project, String name, String value) {
|
||||
final SimpleFile file = createFile(project, name + " = " + value);
|
||||
return (SimpleProperty) file.getFirstChild();
|
||||
}
|
||||
|
||||
public static SimpleProperty createProperty(Project project, String name) {
|
||||
final SimpleFile file = createFile(project, name);
|
||||
return (SimpleProperty) file.getFirstChild();
|
||||
}
|
||||
|
||||
public static PsiElement createCRLF(Project project) {
|
||||
final SimpleFile file = createFile(project, "\n");
|
||||
return file.getFirstChild();
|
||||
}
|
||||
|
||||
public static SimpleFile createFile(Project project, String text) {
|
||||
String name = "dummy.simple";
|
||||
return (SimpleFile) PsiFileFactory.getInstance(project).
|
||||
createFileFromText(name, SimpleFileType.INSTANCE, text);
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package com.simpleplugin.psi;
|
||||
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.simpleplugin.SimpleLanguage;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class SimpleElementType extends IElementType {
|
||||
public SimpleElementType(@NotNull @NonNls String debugName) {
|
||||
super(debugName, SimpleLanguage.INSTANCE);
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package com.simpleplugin.psi;
|
||||
|
||||
import com.intellij.extapi.psi.PsiFileBase;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.psi.FileViewProvider;
|
||||
import com.simpleplugin.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class SimpleFile extends PsiFileBase {
|
||||
public SimpleFile(@NotNull FileViewProvider viewProvider) {
|
||||
super(viewProvider, SimpleLanguage.INSTANCE);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FileType getFileType() {
|
||||
return SimpleFileType.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Simple File";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(int flags) {
|
||||
return super.getIcon(flags);
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package com.simpleplugin.psi;
|
||||
|
||||
import com.intellij.psi.PsiNameIdentifierOwner;
|
||||
|
||||
public interface SimpleNamedElement extends PsiNameIdentifierOwner {
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package com.simpleplugin.psi;
|
||||
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.simpleplugin.SimpleLanguage;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class SimpleTokenType extends IElementType {
|
||||
public SimpleTokenType(@NotNull @NonNls String debugName) {
|
||||
super(debugName, SimpleLanguage.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SimpleTokenType." + super.toString();
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.simpleplugin.psi.impl;
|
||||
|
||||
import com.intellij.extapi.psi.ASTWrapperPsiElement;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.simpleplugin.psi.SimpleNamedElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class SimpleNamedElementImpl extends ASTWrapperPsiElement implements SimpleNamedElement {
|
||||
public SimpleNamedElementImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
package com.simpleplugin.psi.impl;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.navigation.ItemPresentation;
|
||||
import com.intellij.psi.*;
|
||||
import com.simpleplugin.SimpleIcons;
|
||||
import com.simpleplugin.psi.*;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class SimplePsiImplUtil {
|
||||
public static String getKey(SimpleProperty element) {
|
||||
ASTNode keyNode = element.getNode().findChildByType(SimpleTypes.KEY);
|
||||
if (keyNode != null) {
|
||||
// IMPORTANT: Convert embedded escaped spaces to simple spaces
|
||||
return keyNode.getText().replaceAll("\\\\ ", " ");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getValue(SimpleProperty element) {
|
||||
ASTNode valueNode = element.getNode().findChildByType(SimpleTypes.VALUE);
|
||||
if (valueNode != null) {
|
||||
return valueNode.getText();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getName(SimpleProperty element) {
|
||||
return getKey(element);
|
||||
}
|
||||
|
||||
public static PsiElement setName(SimpleProperty element, String newName) {
|
||||
ASTNode keyNode = element.getNode().findChildByType(SimpleTypes.KEY);
|
||||
if (keyNode != null) {
|
||||
SimpleProperty property = SimpleElementFactory.createProperty(element.getProject(), newName);
|
||||
ASTNode newKeyNode = property.getFirstChild().getNode();
|
||||
element.getNode().replaceChild(keyNode, newKeyNode);
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
public static PsiElement getNameIdentifier(SimpleProperty element) {
|
||||
ASTNode keyNode = element.getNode().findChildByType(SimpleTypes.KEY);
|
||||
if (keyNode != null) {
|
||||
return keyNode.getPsi();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemPresentation getPresentation(final SimpleProperty element) {
|
||||
return new ItemPresentation() {
|
||||
@Nullable
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return element.getKey();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getLocationString() {
|
||||
PsiFile containingFile = element.getContainingFile();
|
||||
return containingFile == null ? null : containingFile.getName();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Icon getIcon(boolean unused) {
|
||||
return SimpleIcons.FILE;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user