Commit 366198c2 authored by Stephan Jaetzold's avatar Stephan Jaetzold Committed by Jacob Potter

Intellij plugin for .djinni files

This plugin adds support for some basic navigation, code-completion and error highlighting in .djinni files
to the [jetbrains](http://www.jetbrains.com) family of IDE's.
parent ae11beb3
......@@ -28,3 +28,6 @@ DerivedData
# djinni output directories
djinni-output-temp/
# intellij-plugin build artifact
intellij-plugin/djinni.jar
<!--
~ Copyright 2015 Dropbox, Inc.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<idea-plugin version="2">
<id>com.dropbox.djinni.ideaplugin</id>
<name>Djinni interface definition language file support</name>
<version>0.8</version>
<vendor email="jaetzold@dropbox.com" url="http://www.dropbox.com">Dropbox</vendor>
<description><![CDATA[
Add some basic navigation, code-completion and error highlighting support to .djinni files.
]]></description>
<change-notes><![CDATA[
Initial release.
]]>
</change-notes>
<!-- please see https://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
<idea-version since-build="131"/>
<!-- please see https://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
on how to target different products -->
<depends>com.intellij.modules.lang</depends>
<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<fileTypeFactory implementation="com.dropbox.djinni.ideaplugin.DjinniFileTypeFactory"/>
<lang.parserDefinition language="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniParserDefinition"/>
<lang.parserDefinition language="DjinniYaml" implementationClass="com.dropbox.djinni.ideaplugin.YamlParserDefinition"/>
<lang.syntaxHighlighterFactory key="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniSyntaxHighlighterFactory"/>
<colorSettingsPage implementation="com.dropbox.djinni.ideaplugin.DjinniColorSettingsPage"/>
<annotator language="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniAnnotator"/>
<completion.contributor language="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniCompletionContributor"/>
<psi.referenceContributor implementation="com.dropbox.djinni.ideaplugin.DjinniReferenceContributor"/>
<lang.findUsagesProvider language="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniFindUsagesProvider"/>
<lang.foldingBuilder language="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniFoldingBuilder"/>
<gotoSymbolContributor implementation="com.dropbox.djinni.ideaplugin.DjinniChooseByNameContributor"/>
<lang.psiStructureViewFactory language="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniStructureViewFactory"/>
<lang.formatter language="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniFormattingModelBuilder"/>
<lang.commenter language="Djinni" implementationClass="com.dropbox.djinni.ideaplugin.DjinniCommenter"/>
</extensions>
<application-components>
<!-- Add your application components here -->
</application-components>
<project-components>
<!-- Add your project components here -->
</project-components>
<actions>
<!-- Add your actions here -->
</actions>
</idea-plugin>
\ No newline at end of file
Djinni intellij plugin
======================
This plugin adds support for some basic navigation, code-completion and error highlighting in .djinni files
to the [jetbrains][1] family of IDE's.
### Development
Setup an environment to develop plugins for the intellij platform. There is a [section on how to do that][2]
in the [IntelliJPlatform SDK DevGuide][3]. But instead of creating an entirely new plugin as part of that with "File | New | Module"
you choose "File | New | Module from Existing Sources" and select the djinni.iml file right beside this readme.
Another good starting point for information about intellij plugin development is the JetBrains blog category [Plugin development][4].
### Deployment
This plugin will be available in the jetbrains 3rd party plugin repository at some point.
Until then, or for custom builds, the plugin can be deployed as follows:
1. Set up the dev environment as described above.
2. Navigate to the djinni plugin in the Project Navigation view.
3. Right click on the djinni plugin module there.
4. Choose "Prepare Plugin Module 'djinni' For Deployment". Choose a place and name for the .jar file that results from this.
5. Install this plugin into a jetbrains IDE from the plugins tab in the preferences by clicking "Install plugin from disk..."
[1]: http://www.jetbrains.com
[2]: http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/setting_up_environment.html
[3]: http://www.jetbrains.org/intellij/sdk/docs/
[4]: http://blog.jetbrains.com/idea/category/plugin-development/
<?xml version="1.0" encoding="UTF-8"?>
<module type="PLUGIN_MODULE" version="4">
<component name="DevKit.ModuleBuildProperties" url="file://$MODULE_DIR$/META-INF/plugin.xml" />
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
</content>
<orderEntry type="jdk" jdkName="IntelliJ IDEA SDK" jdkType="IDEA JDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.parser;
import com.intellij.lang.PsiBuilder;
import com.intellij.lang.PsiBuilder.Marker;
import static com.dropbox.djinni.ideaplugin.psi.YamlTypes.*;
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 YamlParser 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 == ENTRY) {
r = entry(b, 0);
}
else if (t == LHS) {
r = lhs(b, 0);
}
else if (t == RHS) {
r = rhs(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);
}
/* ********************************************************** */
// (lhs? SEPARATOR rhs?) | lhs
public static boolean entry(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "entry")) return false;
if (!nextTokenIs(b, "<entry>", KEY, SEPARATOR)) return false;
boolean r;
Marker m = enter_section_(b, l, _NONE_, "<entry>");
r = entry_0(b, l + 1);
if (!r) r = lhs(b, l + 1);
exit_section_(b, l, m, ENTRY, r, false, null);
return r;
}
// lhs? SEPARATOR rhs?
private static boolean entry_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "entry_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = entry_0_0(b, l + 1);
r = r && consumeToken(b, SEPARATOR);
r = r && entry_0_2(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// lhs?
private static boolean entry_0_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "entry_0_0")) return false;
lhs(b, l + 1);
return true;
}
// rhs?
private static boolean entry_0_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "entry_0_2")) return false;
rhs(b, l + 1);
return true;
}
/* ********************************************************** */
// entry|COMMENT|CRLF
static boolean item_(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "item_")) return false;
boolean r;
Marker m = enter_section_(b);
r = entry(b, l + 1);
if (!r) r = consumeToken(b, COMMENT);
if (!r) r = consumeToken(b, CRLF);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// KEY
public static boolean lhs(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "lhs")) return false;
if (!nextTokenIs(b, KEY)) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, KEY);
exit_section_(b, m, LHS, r);
return r;
}
/* ********************************************************** */
// VALUE
public static boolean rhs(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "rhs")) return false;
if (!nextTokenIs(b, VALUE)) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, VALUE);
exit_section_(b, m, RHS, r);
return r;
}
/* ********************************************************** */
// item_*
static boolean simpleFile(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "simpleFile")) return false;
int c = current_position_(b);
while (true) {
if (!item_(b, l + 1)) break;
if (!empty_element_parsed_guard_(b, "simpleFile", c)) break;
c = current_position_(b);
}
return true;
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniBasicType extends PsiElement {
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniConstMember extends PsiElement {
@NotNull
DjinniConstNamedValue getConstNamedValue();
@NotNull
DjinniConstValue getConstValue();
@NotNull
DjinniTypeReference getTypeReference();
@NotNull
PsiElement getColon();
@NotNull
PsiElement getEq();
@NotNull
PsiElement getSemicolon();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniConstNamedValue extends DjinniNamedElement {
@NotNull
PsiElement getIdentifier();
String getName();
PsiElement setName(String newName);
@Nullable
PsiElement getNameIdentifier();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniConstRecordMemberElement extends PsiElement {
@NotNull
DjinniConstValue getConstValue();
@NotNull
PsiElement getEq();
@NotNull
PsiElement getIdentifier();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniConstReference extends DjinniNamedElement {
@NotNull
PsiElement getIdentifier();
String getName();
PsiElement setName(String newName);
@Nullable
PsiElement getNameIdentifier();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniConstValue extends PsiElement {
@NotNull
List<DjinniConstRecordMemberElement> getConstRecordMemberElementList();
@Nullable
DjinniConstReference getConstReference();
@Nullable
PsiElement getLeftBlockBrace();
@Nullable
PsiElement getRightBlockBrace();
@Nullable
PsiElement getNumberLiteral();
@Nullable
PsiElement getStringLiteral();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniDerivingParam extends PsiElement {
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniDerivingParamList extends PsiElement {
@NotNull
DjinniDerivingParam getDerivingParam();
@Nullable
DjinniDerivingParamList getDerivingParamList();
@Nullable
PsiElement getListSeparator();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniEnumMember extends PsiElement {
@NotNull
DjinniEnumValue getEnumValue();
@NotNull
PsiElement getSemicolon();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniEnumTypeVariant extends PsiElement {
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniEnumValue extends DjinniNamedElement {
@NotNull
PsiElement getIdentifier();
String getName();
PsiElement setName(String newName);
@Nullable
PsiElement getNameIdentifier();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.openapi.util.TextRange;
public interface DjinniExternStatement extends PsiNamedElement {
@NotNull
PsiElement getAt();
@NotNull
PsiElement getStringLiteral();
@NotNull
String getName();
PsiElement setName(String newName);
TextRange getRangeOfPath();
@NotNull
String getPath();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniGenerator extends PsiElement {
@NotNull
PsiElement getPlus();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniGenericBasicType extends PsiElement {
@Nullable
DjinniGenericBasicTypeDualParameter getGenericBasicTypeDualParameter();
@Nullable
DjinniGenericBasicTypeSingleParameter getGenericBasicTypeSingleParameter();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniGenericBasicTypeDualParameter extends PsiElement {
@NotNull
List<DjinniTypeReference> getTypeReferenceList();
@NotNull
PsiElement getLeftGenericsBrace();
@NotNull
PsiElement getListSeparator();
@NotNull
PsiElement getRightGenericsBrace();
@NotNull
PsiElement getMap();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniGenericBasicTypeSingleParameter extends PsiElement {
@NotNull
DjinniTypeReference getTypeReference();
@NotNull
PsiElement getLeftGenericsBrace();
@NotNull
PsiElement getRightGenericsBrace();
@Nullable
PsiElement getList();
@Nullable
PsiElement getOptional();
@Nullable
PsiElement getSet();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.openapi.util.TextRange;
public interface DjinniImportStatement extends PsiNamedElement {
@NotNull
PsiElement getAt();
@NotNull
PsiElement getStringLiteral();
@NotNull
String getName();
PsiElement setName(String newName);
TextRange getRangeOfPath();
@NotNull
String getPath();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniInterfaceFunctionParam extends PsiElement {
@NotNull
DjinniTypeReference getTypeReference();
@NotNull
PsiElement getColon();
@NotNull
PsiElement getIdentifier();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniInterfaceFunctionParamList extends PsiElement {
@NotNull
DjinniInterfaceFunctionParam getInterfaceFunctionParam();
@Nullable
DjinniInterfaceFunctionParamList getInterfaceFunctionParamList();
@Nullable
PsiElement getListSeparator();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniInterfaceMember extends PsiElement {
@Nullable
DjinniConstMember getConstMember();
@Nullable
DjinniInterfaceMemberFunction getInterfaceMemberFunction();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniInterfaceMemberFunction extends PsiElement {
@Nullable
DjinniInterfaceFunctionParamList getInterfaceFunctionParamList();
@Nullable
DjinniTypeReference getTypeReference();
@Nullable
PsiElement getColon();
@NotNull
PsiElement getLeftParamBrace();
@NotNull
PsiElement getRightParamBrace();
@NotNull
PsiElement getSemicolon();
@NotNull
PsiElement getIdentifier();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniInterfaceTypeVariant extends PsiElement {
@NotNull
List<DjinniGenerator> getGeneratorList();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniPredefinedType extends PsiElement {
@Nullable
DjinniBasicType getBasicType();
@Nullable
DjinniGenericBasicType getGenericBasicType();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniRecordMember extends PsiElement {
@Nullable
DjinniConstMember getConstMember();
@Nullable
DjinniRecordMemberVariable getRecordMemberVariable();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniRecordMemberVariable extends PsiElement {
@NotNull
DjinniTypeReference getTypeReference();
@NotNull
PsiElement getColon();
@NotNull
PsiElement getSemicolon();
@NotNull
PsiElement getIdentifier();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniRecordTypeVariant extends PsiElement {
@NotNull
List<DjinniGenerator> getGeneratorList();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
import com.dropbox.djinni.ideaplugin.psi.impl.DjinniPsiImplUtil.DjinniType;
import com.intellij.navigation.ItemPresentation;
public interface DjinniTypeDefinition extends DjinniNamedElement {
@Nullable
DjinniDerivingParamList getDerivingParamList();
@NotNull
List<DjinniEnumMember> getEnumMemberList();
@Nullable
DjinniEnumTypeVariant getEnumTypeVariant();
@NotNull
List<DjinniInterfaceMember> getInterfaceMemberList();
@Nullable
DjinniInterfaceTypeVariant getInterfaceTypeVariant();
@NotNull
List<DjinniRecordMember> getRecordMemberList();
@Nullable
DjinniRecordTypeVariant getRecordTypeVariant();
@NotNull
PsiElement getEq();
@NotNull
PsiElement getLeftBlockBrace();
@Nullable
PsiElement getLeftParamBrace();
@NotNull
PsiElement getRightBlockBrace();
@Nullable
PsiElement getRightParamBrace();
@NotNull
PsiElement getIdentifier();
String getTypeName();
@NotNull
DjinniType getDjinniType();
String getName();
PsiElement setName(String newName);
@Nullable
PsiElement getNameIdentifier();
ItemPresentation getPresentation();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface DjinniTypeReference extends DjinniNamedElement {
@Nullable
DjinniPredefinedType getPredefinedType();
@Nullable
PsiElement getIdentifier();
String getName();
PsiElement setName(String newName);
@Nullable
PsiElement getNameIdentifier();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.PsiElement;
import com.intellij.lang.ASTNode;
import com.dropbox.djinni.ideaplugin.psi.impl.*;
public interface DjinniTypes {
IElementType BASIC_TYPE = new DjinniElementType("BASIC_TYPE");
IElementType CONST_MEMBER = new DjinniElementType("CONST_MEMBER");
IElementType CONST_NAMED_VALUE = new DjinniElementType("CONST_NAMED_VALUE");
IElementType CONST_RECORD_MEMBER_ELEMENT = new DjinniElementType("CONST_RECORD_MEMBER_ELEMENT");
IElementType CONST_REFERENCE = new DjinniElementType("CONST_REFERENCE");
IElementType CONST_VALUE = new DjinniElementType("CONST_VALUE");
IElementType DERIVING_PARAM = new DjinniElementType("DERIVING_PARAM");
IElementType DERIVING_PARAM_LIST = new DjinniElementType("DERIVING_PARAM_LIST");
IElementType ENUM_MEMBER = new DjinniElementType("ENUM_MEMBER");
IElementType ENUM_TYPE_VARIANT = new DjinniElementType("ENUM_TYPE_VARIANT");
IElementType ENUM_VALUE = new DjinniElementType("ENUM_VALUE");
IElementType EXTERN_STATEMENT = new DjinniElementType("EXTERN_STATEMENT");
IElementType GENERATOR = new DjinniElementType("GENERATOR");
IElementType GENERIC_BASIC_TYPE = new DjinniElementType("GENERIC_BASIC_TYPE");
IElementType GENERIC_BASIC_TYPE_DUAL_PARAMETER = new DjinniElementType("GENERIC_BASIC_TYPE_DUAL_PARAMETER");
IElementType GENERIC_BASIC_TYPE_SINGLE_PARAMETER = new DjinniElementType("GENERIC_BASIC_TYPE_SINGLE_PARAMETER");
IElementType IMPORT_STATEMENT = new DjinniElementType("IMPORT_STATEMENT");
IElementType INTERFACE_FUNCTION_PARAM = new DjinniElementType("INTERFACE_FUNCTION_PARAM");
IElementType INTERFACE_FUNCTION_PARAM_LIST = new DjinniElementType("INTERFACE_FUNCTION_PARAM_LIST");
IElementType INTERFACE_MEMBER = new DjinniElementType("INTERFACE_MEMBER");
IElementType INTERFACE_MEMBER_FUNCTION = new DjinniElementType("INTERFACE_MEMBER_FUNCTION");
IElementType INTERFACE_TYPE_VARIANT = new DjinniElementType("INTERFACE_TYPE_VARIANT");
IElementType PREDEFINED_TYPE = new DjinniElementType("PREDEFINED_TYPE");
IElementType RECORD_MEMBER = new DjinniElementType("RECORD_MEMBER");
IElementType RECORD_MEMBER_VARIABLE = new DjinniElementType("RECORD_MEMBER_VARIABLE");
IElementType RECORD_TYPE_VARIANT = new DjinniElementType("RECORD_TYPE_VARIANT");
IElementType TYPE_DEFINITION = new DjinniElementType("TYPE_DEFINITION");
IElementType TYPE_REFERENCE = new DjinniElementType("TYPE_REFERENCE");
IElementType AT = new DjinniTokenType("@");
IElementType COLON = new DjinniTokenType(":");
IElementType COMMENT = new DjinniTokenType("comment");
IElementType EQ = new DjinniTokenType("=");
IElementType IDENTIFIER = new DjinniTokenType("identifier");
IElementType LEFT_BLOCK_BRACE = new DjinniTokenType("{");
IElementType LEFT_GENERICS_BRACE = new DjinniTokenType("<");
IElementType LEFT_PARAM_BRACE = new DjinniTokenType("(");
IElementType LIST = new DjinniTokenType("list");
IElementType LIST_SEPARATOR = new DjinniTokenType(",");
IElementType MAP = new DjinniTokenType("map");
IElementType NUMBER_LITERAL = new DjinniTokenType("number_literal");
IElementType OPTIONAL = new DjinniTokenType("optional");
IElementType PLUS = new DjinniTokenType("+");
IElementType RIGHT_BLOCK_BRACE = new DjinniTokenType("}");
IElementType RIGHT_GENERICS_BRACE = new DjinniTokenType(">");
IElementType RIGHT_PARAM_BRACE = new DjinniTokenType(")");
IElementType SEMICOLON = new DjinniTokenType(";");
IElementType SET = new DjinniTokenType("set");
IElementType SPACE = new DjinniTokenType("space");
IElementType STRING_LITERAL = new DjinniTokenType("string_literal");
IElementType TEXT = new DjinniTokenType("text");
class Factory {
public static PsiElement createElement(ASTNode node) {
IElementType type = node.getElementType();
if (type == BASIC_TYPE) {
return new DjinniBasicTypeImpl(node);
}
else if (type == CONST_MEMBER) {
return new DjinniConstMemberImpl(node);
}
else if (type == CONST_NAMED_VALUE) {
return new DjinniConstNamedValueImpl(node);
}
else if (type == CONST_RECORD_MEMBER_ELEMENT) {
return new DjinniConstRecordMemberElementImpl(node);
}
else if (type == CONST_REFERENCE) {
return new DjinniConstReferenceImpl(node);
}
else if (type == CONST_VALUE) {
return new DjinniConstValueImpl(node);
}
else if (type == DERIVING_PARAM) {
return new DjinniDerivingParamImpl(node);
}
else if (type == DERIVING_PARAM_LIST) {
return new DjinniDerivingParamListImpl(node);
}
else if (type == ENUM_MEMBER) {
return new DjinniEnumMemberImpl(node);
}
else if (type == ENUM_TYPE_VARIANT) {
return new DjinniEnumTypeVariantImpl(node);
}
else if (type == ENUM_VALUE) {
return new DjinniEnumValueImpl(node);
}
else if (type == EXTERN_STATEMENT) {
return new DjinniExternStatementImpl(node);
}
else if (type == GENERATOR) {
return new DjinniGeneratorImpl(node);
}
else if (type == GENERIC_BASIC_TYPE) {
return new DjinniGenericBasicTypeImpl(node);
}
else if (type == GENERIC_BASIC_TYPE_DUAL_PARAMETER) {
return new DjinniGenericBasicTypeDualParameterImpl(node);
}
else if (type == GENERIC_BASIC_TYPE_SINGLE_PARAMETER) {
return new DjinniGenericBasicTypeSingleParameterImpl(node);
}
else if (type == IMPORT_STATEMENT) {
return new DjinniImportStatementImpl(node);
}
else if (type == INTERFACE_FUNCTION_PARAM) {
return new DjinniInterfaceFunctionParamImpl(node);
}
else if (type == INTERFACE_FUNCTION_PARAM_LIST) {
return new DjinniInterfaceFunctionParamListImpl(node);
}
else if (type == INTERFACE_MEMBER) {
return new DjinniInterfaceMemberImpl(node);
}
else if (type == INTERFACE_MEMBER_FUNCTION) {
return new DjinniInterfaceMemberFunctionImpl(node);
}
else if (type == INTERFACE_TYPE_VARIANT) {
return new DjinniInterfaceTypeVariantImpl(node);
}
else if (type == PREDEFINED_TYPE) {
return new DjinniPredefinedTypeImpl(node);
}
else if (type == RECORD_MEMBER) {
return new DjinniRecordMemberImpl(node);
}
else if (type == RECORD_MEMBER_VARIABLE) {
return new DjinniRecordMemberVariableImpl(node);
}
else if (type == RECORD_TYPE_VARIANT) {
return new DjinniRecordTypeVariantImpl(node);
}
else if (type == TYPE_DEFINITION) {
return new DjinniTypeDefinitionImpl(node);
}
else if (type == TYPE_REFERENCE) {
return new DjinniTypeReferenceImpl(node);
}
throw new AssertionError("Unknown element type: " + type);
}
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
public class DjinniVisitor extends PsiElementVisitor {
public void visitBasicType(@NotNull DjinniBasicType o) {
visitPsiElement(o);
}
public void visitConstMember(@NotNull DjinniConstMember o) {
visitPsiElement(o);
}
public void visitConstNamedValue(@NotNull DjinniConstNamedValue o) {
visitNamedElement(o);
}
public void visitConstRecordMemberElement(@NotNull DjinniConstRecordMemberElement o) {
visitPsiElement(o);
}
public void visitConstReference(@NotNull DjinniConstReference o) {
visitNamedElement(o);
}
public void visitConstValue(@NotNull DjinniConstValue o) {
visitPsiElement(o);
}
public void visitDerivingParam(@NotNull DjinniDerivingParam o) {
visitPsiElement(o);
}
public void visitDerivingParamList(@NotNull DjinniDerivingParamList o) {
visitPsiElement(o);
}
public void visitEnumMember(@NotNull DjinniEnumMember o) {
visitPsiElement(o);
}
public void visitEnumTypeVariant(@NotNull DjinniEnumTypeVariant o) {
visitPsiElement(o);
}
public void visitEnumValue(@NotNull DjinniEnumValue o) {
visitNamedElement(o);
}
public void visitExternStatement(@NotNull DjinniExternStatement o) {
visitPsiNamedElement(o);
}
public void visitGenerator(@NotNull DjinniGenerator o) {
visitPsiElement(o);
}
public void visitGenericBasicType(@NotNull DjinniGenericBasicType o) {
visitPsiElement(o);
}
public void visitGenericBasicTypeDualParameter(@NotNull DjinniGenericBasicTypeDualParameter o) {
visitPsiElement(o);
}
public void visitGenericBasicTypeSingleParameter(@NotNull DjinniGenericBasicTypeSingleParameter o) {
visitPsiElement(o);
}
public void visitImportStatement(@NotNull DjinniImportStatement o) {
visitPsiNamedElement(o);
}
public void visitInterfaceFunctionParam(@NotNull DjinniInterfaceFunctionParam o) {
visitPsiElement(o);
}
public void visitInterfaceFunctionParamList(@NotNull DjinniInterfaceFunctionParamList o) {
visitPsiElement(o);
}
public void visitInterfaceMember(@NotNull DjinniInterfaceMember o) {
visitPsiElement(o);
}
public void visitInterfaceMemberFunction(@NotNull DjinniInterfaceMemberFunction o) {
visitPsiElement(o);
}
public void visitInterfaceTypeVariant(@NotNull DjinniInterfaceTypeVariant o) {
visitPsiElement(o);
}
public void visitPredefinedType(@NotNull DjinniPredefinedType o) {
visitPsiElement(o);
}
public void visitRecordMember(@NotNull DjinniRecordMember o) {
visitPsiElement(o);
}
public void visitRecordMemberVariable(@NotNull DjinniRecordMemberVariable o) {
visitPsiElement(o);
}
public void visitRecordTypeVariant(@NotNull DjinniRecordTypeVariant o) {
visitPsiElement(o);
}
public void visitTypeDefinition(@NotNull DjinniTypeDefinition o) {
visitNamedElement(o);
}
public void visitTypeReference(@NotNull DjinniTypeReference o) {
visitNamedElement(o);
}
public void visitNamedElement(@NotNull DjinniNamedElement o) {
visitPsiElement(o);
}
public void visitPsiNamedElement(@NotNull PsiNamedElement o) {
visitElement(o);
}
public void visitPsiElement(@NotNull PsiElement o) {
visitElement(o);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface YamlEntry extends PsiElement {
@Nullable
YamlLhs getLhs();
@Nullable
YamlRhs getRhs();
@Nullable
PsiElement getSeparator();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
public interface YamlLhs extends PsiElement {
@NotNull
PsiElement getKey();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import java.util.List;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElement;
import com.intellij.navigation.ItemPresentation;
public interface YamlRhs extends PsiElement {
@NotNull
PsiElement getValue();
String getName();
ItemPresentation getPresentation();
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.PsiElement;
import com.intellij.lang.ASTNode;
import com.dropbox.djinni.ideaplugin.psi.impl.*;
public interface YamlTypes {
IElementType ENTRY = new YamlElementType("ENTRY");
IElementType LHS = new YamlElementType("LHS");
IElementType RHS = new YamlElementType("RHS");
IElementType COMMENT = new YamlTokenType("COMMENT");
IElementType CRLF = new YamlTokenType("CRLF");
IElementType KEY = new YamlTokenType("KEY");
IElementType SEPARATOR = new YamlTokenType("SEPARATOR");
IElementType VALUE = new YamlTokenType("VALUE");
class Factory {
public static PsiElement createElement(ASTNode node) {
IElementType type = node.getElementType();
if (type == ENTRY) {
return new YamlEntryImpl(node);
}
else if (type == LHS) {
return new YamlLhsImpl(node);
}
else if (type == RHS) {
return new YamlRhsImpl(node);
}
throw new AssertionError("Unknown element type: " + type);
}
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.psi;
import org.jetbrains.annotations.*;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.PsiElement;
public class YamlVisitor extends PsiElementVisitor {
public void visitEntry(@NotNull YamlEntry o) {
visitPsiElement(o);
}
public void visitLhs(@NotNull YamlLhs o) {
visitPsiElement(o);
}
public void visitRhs(@NotNull YamlRhs o) {
visitPsiElement(o);
}
public void visitPsiElement(@NotNull PsiElement o) {
visitElement(o);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniBasicTypeImpl extends ASTWrapperPsiElement implements DjinniBasicType {
public DjinniBasicTypeImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitBasicType(this);
else super.accept(visitor);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniConstMemberImpl extends ASTWrapperPsiElement implements DjinniConstMember {
public DjinniConstMemberImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitConstMember(this);
else super.accept(visitor);
}
@Override
@NotNull
public DjinniConstNamedValue getConstNamedValue() {
return findNotNullChildByClass(DjinniConstNamedValue.class);
}
@Override
@NotNull
public DjinniConstValue getConstValue() {
return findNotNullChildByClass(DjinniConstValue.class);
}
@Override
@NotNull
public DjinniTypeReference getTypeReference() {
return findNotNullChildByClass(DjinniTypeReference.class);
}
@Override
@NotNull
public PsiElement getColon() {
return findNotNullChildByType(COLON);
}
@Override
@NotNull
public PsiElement getEq() {
return findNotNullChildByType(EQ);
}
@Override
@NotNull
public PsiElement getSemicolon() {
return findNotNullChildByType(SEMICOLON);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniConstNamedValueImpl extends DjinniReferenceImpl implements DjinniConstNamedValue {
public DjinniConstNamedValueImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitConstNamedValue(this);
else super.accept(visitor);
}
@Override
@NotNull
public PsiElement getIdentifier() {
return findNotNullChildByType(IDENTIFIER);
}
public String getName() {
return DjinniPsiImplUtil.getName(this);
}
public PsiElement setName(String newName) {
return DjinniPsiImplUtil.setName(this, newName);
}
@Nullable
public PsiElement getNameIdentifier() {
return DjinniPsiImplUtil.getNameIdentifier(this);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniConstRecordMemberElementImpl extends ASTWrapperPsiElement implements DjinniConstRecordMemberElement {
public DjinniConstRecordMemberElementImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitConstRecordMemberElement(this);
else super.accept(visitor);
}
@Override
@NotNull
public DjinniConstValue getConstValue() {
return findNotNullChildByClass(DjinniConstValue.class);
}
@Override
@NotNull
public PsiElement getEq() {
return findNotNullChildByType(EQ);
}
@Override
@NotNull
public PsiElement getIdentifier() {
return findNotNullChildByType(IDENTIFIER);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniConstReferenceImpl extends DjinniReferenceImpl implements DjinniConstReference {
public DjinniConstReferenceImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitConstReference(this);
else super.accept(visitor);
}
@Override
@NotNull
public PsiElement getIdentifier() {
return findNotNullChildByType(IDENTIFIER);
}
public String getName() {
return DjinniPsiImplUtil.getName(this);
}
public PsiElement setName(String newName) {
return DjinniPsiImplUtil.setName(this, newName);
}
@Nullable
public PsiElement getNameIdentifier() {
return DjinniPsiImplUtil.getNameIdentifier(this);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniConstValueImpl extends ASTWrapperPsiElement implements DjinniConstValue {
public DjinniConstValueImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitConstValue(this);
else super.accept(visitor);
}
@Override
@NotNull
public List<DjinniConstRecordMemberElement> getConstRecordMemberElementList() {
return PsiTreeUtil.getChildrenOfTypeAsList(this, DjinniConstRecordMemberElement.class);
}
@Override
@Nullable
public DjinniConstReference getConstReference() {
return findChildByClass(DjinniConstReference.class);
}
@Override
@Nullable
public PsiElement getLeftBlockBrace() {
return findChildByType(LEFT_BLOCK_BRACE);
}
@Override
@Nullable
public PsiElement getRightBlockBrace() {
return findChildByType(RIGHT_BLOCK_BRACE);
}
@Override
@Nullable
public PsiElement getNumberLiteral() {
return findChildByType(NUMBER_LITERAL);
}
@Override
@Nullable
public PsiElement getStringLiteral() {
return findChildByType(STRING_LITERAL);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniDerivingParamImpl extends ASTWrapperPsiElement implements DjinniDerivingParam {
public DjinniDerivingParamImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitDerivingParam(this);
else super.accept(visitor);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniDerivingParamListImpl extends ASTWrapperPsiElement implements DjinniDerivingParamList {
public DjinniDerivingParamListImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitDerivingParamList(this);
else super.accept(visitor);
}
@Override
@NotNull
public DjinniDerivingParam getDerivingParam() {
return findNotNullChildByClass(DjinniDerivingParam.class);
}
@Override
@Nullable
public DjinniDerivingParamList getDerivingParamList() {
return findChildByClass(DjinniDerivingParamList.class);
}
@Override
@Nullable
public PsiElement getListSeparator() {
return findChildByType(LIST_SEPARATOR);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniEnumMemberImpl extends ASTWrapperPsiElement implements DjinniEnumMember {
public DjinniEnumMemberImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitEnumMember(this);
else super.accept(visitor);
}
@Override
@NotNull
public DjinniEnumValue getEnumValue() {
return findNotNullChildByClass(DjinniEnumValue.class);
}
@Override
@NotNull
public PsiElement getSemicolon() {
return findNotNullChildByType(SEMICOLON);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniEnumTypeVariantImpl extends ASTWrapperPsiElement implements DjinniEnumTypeVariant {
public DjinniEnumTypeVariantImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitEnumTypeVariant(this);
else super.accept(visitor);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniEnumValueImpl extends DjinniReferenceImpl implements DjinniEnumValue {
public DjinniEnumValueImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitEnumValue(this);
else super.accept(visitor);
}
@Override
@NotNull
public PsiElement getIdentifier() {
return findNotNullChildByType(IDENTIFIER);
}
public String getName() {
return DjinniPsiImplUtil.getName(this);
}
public PsiElement setName(String newName) {
return DjinniPsiImplUtil.setName(this, newName);
}
@Nullable
public PsiElement getNameIdentifier() {
return DjinniPsiImplUtil.getNameIdentifier(this);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.dropbox.djinni.ideaplugin.psi.*;
import com.intellij.openapi.util.TextRange;
public class DjinniExternStatementImpl extends DjinniImportStatementBaseImpl implements DjinniExternStatement {
public DjinniExternStatementImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitExternStatement(this);
else super.accept(visitor);
}
@Override
@NotNull
public PsiElement getAt() {
return findNotNullChildByType(AT);
}
@Override
@NotNull
public PsiElement getStringLiteral() {
return findNotNullChildByType(STRING_LITERAL);
}
@NotNull
public String getName() {
return DjinniPsiImplUtil.getName(this);
}
public PsiElement setName(String newName) {
return DjinniPsiImplUtil.setName(this, newName);
}
public TextRange getRangeOfPath() {
return DjinniPsiImplUtil.getRangeOfPath(this);
}
@NotNull
public String getPath() {
return DjinniPsiImplUtil.getPath(this);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniGeneratorImpl extends ASTWrapperPsiElement implements DjinniGenerator {
public DjinniGeneratorImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitGenerator(this);
else super.accept(visitor);
}
@Override
@NotNull
public PsiElement getPlus() {
return findNotNullChildByType(PLUS);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniGenericBasicTypeDualParameterImpl extends ASTWrapperPsiElement implements DjinniGenericBasicTypeDualParameter {
public DjinniGenericBasicTypeDualParameterImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitGenericBasicTypeDualParameter(this);
else super.accept(visitor);
}
@Override
@NotNull
public List<DjinniTypeReference> getTypeReferenceList() {
return PsiTreeUtil.getChildrenOfTypeAsList(this, DjinniTypeReference.class);
}
@Override
@NotNull
public PsiElement getLeftGenericsBrace() {
return findNotNullChildByType(LEFT_GENERICS_BRACE);
}
@Override
@NotNull
public PsiElement getListSeparator() {
return findNotNullChildByType(LIST_SEPARATOR);
}
@Override
@NotNull
public PsiElement getRightGenericsBrace() {
return findNotNullChildByType(RIGHT_GENERICS_BRACE);
}
@Override
@NotNull
public PsiElement getMap() {
return findNotNullChildByType(MAP);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniGenericBasicTypeImpl extends ASTWrapperPsiElement implements DjinniGenericBasicType {
public DjinniGenericBasicTypeImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitGenericBasicType(this);
else super.accept(visitor);
}
@Override
@Nullable
public DjinniGenericBasicTypeDualParameter getGenericBasicTypeDualParameter() {
return findChildByClass(DjinniGenericBasicTypeDualParameter.class);
}
@Override
@Nullable
public DjinniGenericBasicTypeSingleParameter getGenericBasicTypeSingleParameter() {
return findChildByClass(DjinniGenericBasicTypeSingleParameter.class);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniGenericBasicTypeSingleParameterImpl extends ASTWrapperPsiElement implements DjinniGenericBasicTypeSingleParameter {
public DjinniGenericBasicTypeSingleParameterImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitGenericBasicTypeSingleParameter(this);
else super.accept(visitor);
}
@Override
@NotNull
public DjinniTypeReference getTypeReference() {
return findNotNullChildByClass(DjinniTypeReference.class);
}
@Override
@NotNull
public PsiElement getLeftGenericsBrace() {
return findNotNullChildByType(LEFT_GENERICS_BRACE);
}
@Override
@NotNull
public PsiElement getRightGenericsBrace() {
return findNotNullChildByType(RIGHT_GENERICS_BRACE);
}
@Override
@Nullable
public PsiElement getList() {
return findChildByType(LIST);
}
@Override
@Nullable
public PsiElement getOptional() {
return findChildByType(OPTIONAL);
}
@Override
@Nullable
public PsiElement getSet() {
return findChildByType(SET);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.dropbox.djinni.ideaplugin.psi.*;
import com.intellij.openapi.util.TextRange;
public class DjinniImportStatementImpl extends DjinniImportStatementBaseImpl implements DjinniImportStatement {
public DjinniImportStatementImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitImportStatement(this);
else super.accept(visitor);
}
@Override
@NotNull
public PsiElement getAt() {
return findNotNullChildByType(AT);
}
@Override
@NotNull
public PsiElement getStringLiteral() {
return findNotNullChildByType(STRING_LITERAL);
}
@NotNull
public String getName() {
return DjinniPsiImplUtil.getName(this);
}
public PsiElement setName(String newName) {
return DjinniPsiImplUtil.setName(this, newName);
}
public TextRange getRangeOfPath() {
return DjinniPsiImplUtil.getRangeOfPath(this);
}
@NotNull
public String getPath() {
return DjinniPsiImplUtil.getPath(this);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniInterfaceFunctionParamImpl extends ASTWrapperPsiElement implements DjinniInterfaceFunctionParam {
public DjinniInterfaceFunctionParamImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitInterfaceFunctionParam(this);
else super.accept(visitor);
}
@Override
@NotNull
public DjinniTypeReference getTypeReference() {
return findNotNullChildByClass(DjinniTypeReference.class);
}
@Override
@NotNull
public PsiElement getColon() {
return findNotNullChildByType(COLON);
}
@Override
@NotNull
public PsiElement getIdentifier() {
return findNotNullChildByType(IDENTIFIER);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniInterfaceFunctionParamListImpl extends ASTWrapperPsiElement implements DjinniInterfaceFunctionParamList {
public DjinniInterfaceFunctionParamListImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitInterfaceFunctionParamList(this);
else super.accept(visitor);
}
@Override
@NotNull
public DjinniInterfaceFunctionParam getInterfaceFunctionParam() {
return findNotNullChildByClass(DjinniInterfaceFunctionParam.class);
}
@Override
@Nullable
public DjinniInterfaceFunctionParamList getInterfaceFunctionParamList() {
return findChildByClass(DjinniInterfaceFunctionParamList.class);
}
@Override
@Nullable
public PsiElement getListSeparator() {
return findChildByType(LIST_SEPARATOR);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniInterfaceMemberFunctionImpl extends ASTWrapperPsiElement implements DjinniInterfaceMemberFunction {
public DjinniInterfaceMemberFunctionImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitInterfaceMemberFunction(this);
else super.accept(visitor);
}
@Override
@Nullable
public DjinniInterfaceFunctionParamList getInterfaceFunctionParamList() {
return findChildByClass(DjinniInterfaceFunctionParamList.class);
}
@Override
@Nullable
public DjinniTypeReference getTypeReference() {
return findChildByClass(DjinniTypeReference.class);
}
@Override
@Nullable
public PsiElement getColon() {
return findChildByType(COLON);
}
@Override
@NotNull
public PsiElement getLeftParamBrace() {
return findNotNullChildByType(LEFT_PARAM_BRACE);
}
@Override
@NotNull
public PsiElement getRightParamBrace() {
return findNotNullChildByType(RIGHT_PARAM_BRACE);
}
@Override
@NotNull
public PsiElement getSemicolon() {
return findNotNullChildByType(SEMICOLON);
}
@Override
@NotNull
public PsiElement getIdentifier() {
return findNotNullChildByType(IDENTIFIER);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniInterfaceMemberImpl extends ASTWrapperPsiElement implements DjinniInterfaceMember {
public DjinniInterfaceMemberImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitInterfaceMember(this);
else super.accept(visitor);
}
@Override
@Nullable
public DjinniConstMember getConstMember() {
return findChildByClass(DjinniConstMember.class);
}
@Override
@Nullable
public DjinniInterfaceMemberFunction getInterfaceMemberFunction() {
return findChildByClass(DjinniInterfaceMemberFunction.class);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniInterfaceTypeVariantImpl extends ASTWrapperPsiElement implements DjinniInterfaceTypeVariant {
public DjinniInterfaceTypeVariantImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitInterfaceTypeVariant(this);
else super.accept(visitor);
}
@Override
@NotNull
public List<DjinniGenerator> getGeneratorList() {
return PsiTreeUtil.getChildrenOfTypeAsList(this, DjinniGenerator.class);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniPredefinedTypeImpl extends ASTWrapperPsiElement implements DjinniPredefinedType {
public DjinniPredefinedTypeImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitPredefinedType(this);
else super.accept(visitor);
}
@Override
@Nullable
public DjinniBasicType getBasicType() {
return findChildByClass(DjinniBasicType.class);
}
@Override
@Nullable
public DjinniGenericBasicType getGenericBasicType() {
return findChildByClass(DjinniGenericBasicType.class);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniRecordMemberImpl extends ASTWrapperPsiElement implements DjinniRecordMember {
public DjinniRecordMemberImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitRecordMember(this);
else super.accept(visitor);
}
@Override
@Nullable
public DjinniConstMember getConstMember() {
return findChildByClass(DjinniConstMember.class);
}
@Override
@Nullable
public DjinniRecordMemberVariable getRecordMemberVariable() {
return findChildByClass(DjinniRecordMemberVariable.class);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniRecordMemberVariableImpl extends ASTWrapperPsiElement implements DjinniRecordMemberVariable {
public DjinniRecordMemberVariableImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitRecordMemberVariable(this);
else super.accept(visitor);
}
@Override
@NotNull
public DjinniTypeReference getTypeReference() {
return findNotNullChildByClass(DjinniTypeReference.class);
}
@Override
@NotNull
public PsiElement getColon() {
return findNotNullChildByType(COLON);
}
@Override
@NotNull
public PsiElement getSemicolon() {
return findNotNullChildByType(SEMICOLON);
}
@Override
@NotNull
public PsiElement getIdentifier() {
return findNotNullChildByType(IDENTIFIER);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniRecordTypeVariantImpl extends ASTWrapperPsiElement implements DjinniRecordTypeVariant {
public DjinniRecordTypeVariantImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitRecordTypeVariant(this);
else super.accept(visitor);
}
@Override
@NotNull
public List<DjinniGenerator> getGeneratorList() {
return PsiTreeUtil.getChildrenOfTypeAsList(this, DjinniGenerator.class);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.dropbox.djinni.ideaplugin.psi.*;
import com.dropbox.djinni.ideaplugin.psi.impl.DjinniPsiImplUtil.DjinniType;
import com.intellij.navigation.ItemPresentation;
public class DjinniTypeDefinitionImpl extends DjinniNamedElementImpl implements DjinniTypeDefinition {
public DjinniTypeDefinitionImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitTypeDefinition(this);
else super.accept(visitor);
}
@Override
@Nullable
public DjinniDerivingParamList getDerivingParamList() {
return findChildByClass(DjinniDerivingParamList.class);
}
@Override
@NotNull
public List<DjinniEnumMember> getEnumMemberList() {
return PsiTreeUtil.getChildrenOfTypeAsList(this, DjinniEnumMember.class);
}
@Override
@Nullable
public DjinniEnumTypeVariant getEnumTypeVariant() {
return findChildByClass(DjinniEnumTypeVariant.class);
}
@Override
@NotNull
public List<DjinniInterfaceMember> getInterfaceMemberList() {
return PsiTreeUtil.getChildrenOfTypeAsList(this, DjinniInterfaceMember.class);
}
@Override
@Nullable
public DjinniInterfaceTypeVariant getInterfaceTypeVariant() {
return findChildByClass(DjinniInterfaceTypeVariant.class);
}
@Override
@NotNull
public List<DjinniRecordMember> getRecordMemberList() {
return PsiTreeUtil.getChildrenOfTypeAsList(this, DjinniRecordMember.class);
}
@Override
@Nullable
public DjinniRecordTypeVariant getRecordTypeVariant() {
return findChildByClass(DjinniRecordTypeVariant.class);
}
@Override
@NotNull
public PsiElement getEq() {
return findNotNullChildByType(EQ);
}
@Override
@NotNull
public PsiElement getLeftBlockBrace() {
return findNotNullChildByType(LEFT_BLOCK_BRACE);
}
@Override
@Nullable
public PsiElement getLeftParamBrace() {
return findChildByType(LEFT_PARAM_BRACE);
}
@Override
@NotNull
public PsiElement getRightBlockBrace() {
return findNotNullChildByType(RIGHT_BLOCK_BRACE);
}
@Override
@Nullable
public PsiElement getRightParamBrace() {
return findChildByType(RIGHT_PARAM_BRACE);
}
@Override
@NotNull
public PsiElement getIdentifier() {
return findNotNullChildByType(IDENTIFIER);
}
public String getTypeName() {
return DjinniPsiImplUtil.getTypeName(this);
}
@NotNull
public DjinniType getDjinniType() {
return DjinniPsiImplUtil.getDjinniType(this);
}
public String getName() {
return DjinniPsiImplUtil.getName(this);
}
public PsiElement setName(String newName) {
return DjinniPsiImplUtil.setName(this, newName);
}
@Nullable
public PsiElement getNameIdentifier() {
return DjinniPsiImplUtil.getNameIdentifier(this);
}
public ItemPresentation getPresentation() {
return DjinniPsiImplUtil.getPresentation(this);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.DjinniTypes.*;
import com.dropbox.djinni.ideaplugin.psi.*;
public class DjinniTypeReferenceImpl extends DjinniReferenceImpl implements DjinniTypeReference {
public DjinniTypeReferenceImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof DjinniVisitor) ((DjinniVisitor)visitor).visitTypeReference(this);
else super.accept(visitor);
}
@Override
@Nullable
public DjinniPredefinedType getPredefinedType() {
return findChildByClass(DjinniPredefinedType.class);
}
@Override
@Nullable
public PsiElement getIdentifier() {
return findChildByType(IDENTIFIER);
}
public String getName() {
return DjinniPsiImplUtil.getName(this);
}
public PsiElement setName(String newName) {
return DjinniPsiImplUtil.setName(this, newName);
}
@Nullable
public PsiElement getNameIdentifier() {
return DjinniPsiImplUtil.getNameIdentifier(this);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.YamlTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class YamlEntryImpl extends ASTWrapperPsiElement implements YamlEntry {
public YamlEntryImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof YamlVisitor) ((YamlVisitor)visitor).visitEntry(this);
else super.accept(visitor);
}
@Override
@Nullable
public YamlLhs getLhs() {
return findChildByClass(YamlLhs.class);
}
@Override
@Nullable
public YamlRhs getRhs() {
return findChildByClass(YamlRhs.class);
}
@Override
@Nullable
public PsiElement getSeparator() {
return findChildByType(SEPARATOR);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.YamlTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
public class YamlLhsImpl extends ASTWrapperPsiElement implements YamlLhs {
public YamlLhsImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof YamlVisitor) ((YamlVisitor)visitor).visitLhs(this);
else super.accept(visitor);
}
@Override
@NotNull
public PsiElement getKey() {
return findNotNullChildByType(KEY);
}
}
// This is a generated file. Not intended for manual editing.
package com.dropbox.djinni.ideaplugin.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.dropbox.djinni.ideaplugin.psi.YamlTypes.*;
import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.dropbox.djinni.ideaplugin.psi.*;
import com.intellij.navigation.ItemPresentation;
public class YamlRhsImpl extends ASTWrapperPsiElement implements YamlRhs {
public YamlRhsImpl(ASTNode node) {
super(node);
}
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof YamlVisitor) ((YamlVisitor)visitor).visitRhs(this);
else super.accept(visitor);
}
@Override
@NotNull
public PsiElement getValue() {
return findNotNullChildByType(VALUE);
}
public String getName() {
return YamlPsiImplUtil.getName(this);
}
public ItemPresentation getPresentation() {
return YamlPsiImplUtil.getPresentation(this);
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
{
parserClass="com.dropbox.djinni.ideaplugin.parser.DjinniParser"
extends="com.intellij.extapi.psi.ASTWrapperPsiElement"
psiClassPrefix="Djinni"
psiImplClassSuffix="Impl"
psiPackage="com.dropbox.djinni.ideaplugin.psi"
psiImplPackage="com.dropbox.djinni.ideaplugin.psi.impl"
elementTypeHolderClass="com.dropbox.djinni.ideaplugin.psi.DjinniTypes"
elementTypeClass="com.dropbox.djinni.ideaplugin.psi.DjinniElementType"
tokenTypeClass="com.dropbox.djinni.ideaplugin.psi.DjinniTokenType"
psiImplUtilClass="com.dropbox.djinni.ideaplugin.psi.impl.DjinniPsiImplUtil"
generateTokenAccessors=true
tokens = [
EQ="="
COLON=":"
SEMICOLON=";"
LIST_SEPARATOR=","
PLUS="+"
LEFT_BLOCK_BRACE="{"
RIGHT_BLOCK_BRACE="}"
LEFT_GENERICS_BRACE="<"
RIGHT_GENERICS_BRACE=">"
LEFT_PARAM_BRACE="("
RIGHT_PARAM_BRACE=")"
AT="@"
space="regexp:\s+"
comment="regexp:#.*"
string_literal="regexp:('([^'\\]|\\.)*'|\"([^\"\\]|\\\"|\\\'|\\)*\")"
number_literal="regexp:-?(\d+(\.\d*)?)|(\.\d+)"
identifier="regexp:\p{Alpha}\w*"
text="regexp:\w+"
]
}
djinniFile ::= item_*
private item_ ::= importStatement | externStatement | typeDefinition
typeDefinition ::= identifier EQ typeDescription {
mixin="com.dropbox.djinni.ideaplugin.psi.impl.DjinniNamedElementImpl"
implements="com.dropbox.djinni.ideaplugin.psi.DjinniNamedElement"
methods=[getTypeName getDjinniType getName setName getNameIdentifier getPresentation]
}
private typeDescription ::= enumDescription | recordDescription | interfaceDescription
generator ::= (PLUS 'c') | (PLUS 'j') | (PLUS 'o')
// enum
private enumDescription ::= enumTypeVariant LEFT_BLOCK_BRACE enumMember* RIGHT_BLOCK_BRACE
enumTypeVariant ::= 'enum'
enumMember ::= enumValue SEMICOLON
enumValue ::= identifier {
mixin="com.dropbox.djinni.ideaplugin.psi.impl.DjinniReferenceImpl"
implements="com.dropbox.djinni.ideaplugin.psi.DjinniNamedElement"
methods=[getName setName getNameIdentifier]
}
// record
private recordDescription ::= recordTypeVariant LEFT_BLOCK_BRACE recordMember* RIGHT_BLOCK_BRACE ['deriving' LEFT_PARAM_BRACE derivingParamList RIGHT_PARAM_BRACE]
recordTypeVariant ::= 'record' generator*
derivingParamList ::= (derivingParam ',' derivingParamList) | derivingParam
derivingParam ::= 'eq' | 'ord'
recordMember ::= constMember | recordMemberVariable
recordMemberVariable ::= identifier COLON typeReference SEMICOLON
// interface.
private interfaceDescription ::= interfaceTypeVariant LEFT_BLOCK_BRACE interfaceMember* RIGHT_BLOCK_BRACE
interfaceTypeVariant ::= 'interface' generator*
interfaceMember ::= constMember | interfaceMemberFunction
interfaceMemberFunction ::= ['static'] identifier LEFT_PARAM_BRACE interfaceFunctionParamList? RIGHT_PARAM_BRACE [COLON typeReference] SEMICOLON
interfaceFunctionParamList ::= (interfaceFunctionParam ',' interfaceFunctionParamList) | interfaceFunctionParam
interfaceFunctionParam ::= identifier COLON typeReference
//
// type references
//
typeReference ::= predefinedType | identifier {
mixin="com.dropbox.djinni.ideaplugin.psi.impl.DjinniReferenceImpl"
implements="com.dropbox.djinni.ideaplugin.psi.DjinniNamedElement"
methods=[getName setName getNameIdentifier]
}
predefinedType ::= basicType | genericBasicType
basicType ::= 'bool' | 'i8' | 'i16' | 'i32' | 'i64' | 'f32' | 'f64' | 'string' | 'binary' | 'date'
genericBasicType ::= genericBasicTypeSingleParameter | genericBasicTypeDualParameter
// The [space] there is not really part of the definition. It just needed to be used somewhere to show up in DjinniTypes.java :-(
genericBasicTypeSingleParameter ::= (list | set | optional) !space LEFT_GENERICS_BRACE typeReference RIGHT_GENERICS_BRACE
//genericBasicTypeSingleParameter ::= (list | set | optional) LEFT_GENERICS_BRACE typeReference RIGHT_GENERICS_BRACE
genericBasicTypeDualParameter ::= map LEFT_GENERICS_BRACE typeReference LIST_SEPARATOR typeReference RIGHT_GENERICS_BRACE
//
// const definitions
//
constMember ::= 'const' constNamedValue COLON typeReference EQ constValue SEMICOLON
constNamedValue ::= identifier {
mixin="com.dropbox.djinni.ideaplugin.psi.impl.DjinniReferenceImpl"
implements="com.dropbox.djinni.ideaplugin.psi.DjinniNamedElement"
methods=[getName setName getNameIdentifier]
}
constValue ::= string_literal | number_literal | constReference | constRecord
constReference ::= identifier {
mixin="com.dropbox.djinni.ideaplugin.psi.impl.DjinniReferenceImpl"
implements="com.dropbox.djinni.ideaplugin.psi.DjinniNamedElement"
methods=[getName setName getNameIdentifier]
}
private constRecord ::= LEFT_BLOCK_BRACE constRecordMemberList RIGHT_BLOCK_BRACE
private constRecordMemberList ::= (constRecordMemberElement ',' constRecordMemberList) | (constRecordMemberElement [','])
constRecordMemberElement ::= identifier EQ constValue
//
// import
//
importStatement ::= AT'import' string_literal {
mixin="com.dropbox.djinni.ideaplugin.psi.impl.DjinniImportStatementBaseImpl"
implements="com.intellij.psi.PsiNamedElement"
methods=[getName setName getRangeOfPath getPath]
}
//
// extern
//
externStatement ::= AT'extern' string_literal {
mixin="com.dropbox.djinni.ideaplugin.psi.impl.DjinniImportStatementBaseImpl"
implements="com.intellij.psi.PsiNamedElement"
methods=[getName setName getRangeOfPath getPath]
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.dropbox.djinni.ideaplugin.psi.DjinniConstReference;
import com.dropbox.djinni.ideaplugin.psi.DjinniFile;
import com.dropbox.djinni.ideaplugin.psi.DjinniImportStatement;
import com.dropbox.djinni.ideaplugin.psi.DjinniTypeReference;
import com.dropbox.djinni.ideaplugin.psi.impl.DjinniPsiImplUtil;
import com.intellij.lang.annotation.Annotation;
import com.intellij.lang.annotation.AnnotationHolder;
import com.intellij.lang.annotation.Annotator;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
/**
* Created by jaetzold on 7/27/15.
*/
public class DjinniAnnotator implements Annotator {
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if(element instanceof DjinniTypeReference) {
DjinniTypeReference typeReference = (DjinniTypeReference)element;
boolean validReference = typeReference.getPredefinedType() != null
|| !DjinniUtil.findTypeDefinitionsForName(element.getProject(), typeReference.getText(), element).isEmpty()
|| !DjinniUtil.findExternalTypeForName(element.getProject(), typeReference.getText(), element).isEmpty();
if(!validReference) {
Annotation annotation = holder.createErrorAnnotation(element, "Unresolved type");
annotation.setNeedsUpdateOnTyping(true);
annotation.registerFix(new DjinniCreateTypeDefinitionQuickFix(typeReference.getText(), DjinniPsiImplUtil.DjinniType.RECORD));
annotation.registerFix(new DjinniCreateTypeDefinitionQuickFix(typeReference.getText(), DjinniPsiImplUtil.DjinniType.INTERFACE));
annotation.registerFix(new DjinniCreateTypeDefinitionQuickFix(typeReference.getText(), DjinniPsiImplUtil.DjinniType.ENUM));
}
} else if(element instanceof DjinniConstReference) {
DjinniConstReference constReference = (DjinniConstReference)element;
String typeName = DjinniUtil.getTypeNameOfConstReference(constReference);
boolean validReference = !DjinniUtil.findReferencableValuesWithNameAndTypename(element.getProject(), constReference.getName(), typeName, element).isEmpty();
if(!validReference) {
Annotation annotation = holder.createErrorAnnotation(element, "Unresolved value");
annotation.setNeedsUpdateOnTyping(true);
}
} else if(element instanceof DjinniImportStatement) {
DjinniImportStatement importStatement = (DjinniImportStatement)element;
DjinniFile importedFile =
DjinniUtil.djinniFileRelativeResolve(element.getProject(), element.getContainingFile(), importStatement.getPath());
if(importedFile == null) {
TextRange textRange = importStatement.getTextRange();
TextRange rangeOfPathInImport = importStatement.getRangeOfPath();
TextRange range = new TextRange(textRange.getStartOffset() + rangeOfPathInImport.getStartOffset(),
textRange.getStartOffset() + rangeOfPathInImport.getEndOffset());
holder.createErrorAnnotation(range, "File does not exist");
}
}
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.dropbox.djinni.ideaplugin.psi.DjinniTypes;
import com.intellij.formatting.*;
import com.intellij.lang.ASTNode;
import com.intellij.psi.TokenType;
import com.intellij.psi.formatter.common.AbstractBlock;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Created by jaetzold on 7/30/15.
*/
public class DjinniBlock extends AbstractBlock {
private SpacingBuilder spacingBuilder;
private Indent indent;
private int spaceIndent;
protected DjinniBlock(@NotNull ASTNode node,
@Nullable Wrap wrap,
@Nullable Alignment alignment,
SpacingBuilder spacingBuilder,
Indent indent,
int spaceIndent) {
super(node, wrap, alignment);
this.spacingBuilder = spacingBuilder;
this.indent = indent;
this.spaceIndent = spaceIndent;
}
static List<IElementType> memberTypes = Arrays.asList(DjinniTypes.ENUM_MEMBER, DjinniTypes.RECORD_MEMBER, DjinniTypes.INTERFACE_MEMBER, DjinniTypes.CONST_RECORD_MEMBER_ELEMENT);
@Override
protected List<Block> buildChildren() {
List<Block> blocks = new ArrayList<Block>();
ASTNode child = myNode.getFirstChildNode();
IElementType previousChildType = null;
while (child != null) {
IElementType currentChildType = child.getElementType();
if (currentChildType != TokenType.WHITE_SPACE && currentChildType != DjinniTypes.SPACE) {
Indent indent;
if (memberTypes.contains(currentChildType) && previousChildType != currentChildType) {
// TODO: Add our own code style settings page
indent = Indent.getNormalIndent();
} else if(currentChildType == DjinniTypes.COMMENT && myNode.getTreeParent() != null) {
indent = Indent.getNormalIndent();
} else {
indent = Indent.getNoneIndent();
}
Block block = new DjinniBlock(child, Wrap.createWrap(WrapType.NONE, false), Alignment.createAlignment(), spacingBuilder, indent,
spaceIndent);
blocks.add(block);
}
previousChildType = currentChildType;
child = child.getTreeNext();
}
return blocks;
}
@Override
public Indent getIndent() {
return indent;
}
@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;
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.dropbox.djinni.ideaplugin.psi.DjinniTypeDefinition;
import com.intellij.navigation.ChooseByNameContributor;
import com.intellij.navigation.NavigationItem;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
/**
* Created by jaetzold on 7/29/15.
*/
public class DjinniChooseByNameContributor implements ChooseByNameContributor {
@NotNull
@Override
public String[] getNames(Project project, boolean includeNonProjectItems) {
List<String> result = new ArrayList<String>();
List<DjinniTypeDefinition> typeDefinitions = DjinniUtil.findAllTypeDefinitions(project, null);
for (DjinniTypeDefinition typeDefinition : typeDefinitions) {
result.add(typeDefinition.getTypeName());
}
final List<PsiElement> externalTypes = DjinniUtil.findAllExternalTypes(project, null);
for (PsiElement externalType : externalTypes) {
String text = externalType.getText();
if(text != null && text.length() > 0) {
result.add(text);
}
}
return ArrayUtil.toStringArray(result);
}
@NotNull
@Override
public NavigationItem[] getItemsByName(String name, String pattern, Project project, boolean includeNonProjectItems) {
List<PsiElement> result = new ArrayList<PsiElement>();
result.addAll(DjinniUtil.findTypeDefinitionsForName(project, name, null));
result.addAll(DjinniUtil.findExternalTypeForName(project, name, null));
//noinspection SuspiciousToArrayCall
return result.toArray(new NavigationItem[result.size()]);
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.intellij.openapi.editor.colors.TextAttributesKey;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.options.colors.AttributesDescriptor;
import com.intellij.openapi.options.colors.ColorDescriptor;
import com.intellij.openapi.options.colors.ColorSettingsPage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.util.Map;
/**
* Created by jaetzold on 7/23/15.
*/
public class DjinniColorSettingsPage implements ColorSettingsPage {
private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[] {
new AttributesDescriptor("Comment", DjinniSyntaxHighlighter.COMMENT),
new AttributesDescriptor("Identifier", DjinniSyntaxHighlighter.IDENTIFIER),
new AttributesDescriptor("String literal", DjinniSyntaxHighlighter.STRING_LITERAL),
new AttributesDescriptor("Number literal", DjinniSyntaxHighlighter.NUMBER_LITERAL),
};
@Nullable
@Override
public Icon getIcon() {
return DjinniIcons.FILE;
}
@NotNull
@Override
public SyntaxHighlighter getHighlighter() {
return new DjinniSyntaxHighlighter();
}
@NotNull
@Override
public String getDemoText() {
return "# Multi-line comments can be added here. This comment will be propagated\n" +
"# to each generated definition.\n" +
"my_enum = enum {\n" +
" option1;\n" +
" option2;\n" +
" option3;\n" +
"}\n" +
"\n" +
"my_record = record {\n" +
" id: i32;\n" +
" info: string;\n" +
" store: set<string>;\n" +
" hash: map<string, i32>;\n" +
"\n" +
" values: list<another_record>;\n" +
"\n" +
" # Comments can also be put here\n" +
"\n" +
" # Constants can be included\n" +
" const string_const: string = \"Constants can be put here\";\n" +
" const min_value: another_record = {\n" +
" key1 = 0,\n" +
" key2 = \"\",\n" +
" };\n" +
"}\n" +
"\n" +
"another_record = record {\n" +
" key1: i32;\n" +
" key2: string;\n" +
"} deriving (eq, ord)\n" +
"\n" +
"# This interface will be implemented in C++ and can be called from any language.\n" +
"my_cpp_interface = interface +c {\n" +
" method_returning_nothing(value: i32);\n" +
" method_returning_some_type(key: string): another_record;\n" +
" static get_version(): i32;\n" +
"\n" +
" # Interfaces can also have constants\n" +
" const version: i32 = 1;\n" +
"}\n" +
"\n" +
"# This interface will be implemented in Java and ObjC and can be called from C++.\n" +
"my_client_interface = interface +j +o {\n" +
" log_string(str: string): bool;\n" +
"}\n";
}
@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 "Djinni";
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.intellij.lang.Commenter;
import org.jetbrains.annotations.Nullable;
/**
* Created by jaetzold on 7/31/15.
*/
public class DjinniCommenter implements Commenter {
@Nullable
@Override
public String getLineCommentPrefix() {
return "#";
}
@Nullable
@Override
public String getBlockCommentPrefix() {
return null;
}
@Nullable
@Override
public String getBlockCommentSuffix() {
return null;
}
@Nullable
@Override
public String getCommentedBlockCommentPrefix() {
return null;
}
@Nullable
@Override
public String getCommentedBlockCommentSuffix() {
return null;
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.dropbox.djinni.ideaplugin.psi.DjinniTypeReference;
import com.dropbox.djinni.ideaplugin.psi.DjinniTypes;
import com.intellij.codeInsight.completion.*;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.patterns.PlatformPatterns;
import com.intellij.psi.PsiElement;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* Created by jaetzold on 7/27/15.
*/
public class DjinniCompletionContributor extends CompletionContributor {
public DjinniCompletionContributor() {
// TODO: make completion work for more complex elements, for references it already works automatically through the reference relationship
extend(CompletionType.BASIC, PlatformPatterns.psiElement(DjinniTypes.IDENTIFIER).withLanguage(DjinniLanguage.INSTANCE),
new CompletionProvider<CompletionParameters>() {
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement element = parameters.getPosition().getParent();
if(element instanceof DjinniTypeReference) {
List<String> typeNames = DjinniUtil.getBuiltinTypeNames(parameters.getEditor().getProject(), element);
for (String typeName : typeNames) {
result.addElement(LookupElementBuilder.create(typeName));
}
}
}
}
);
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.dropbox.djinni.ideaplugin.psi.DjinniElementFactory;
import com.dropbox.djinni.ideaplugin.psi.DjinniFile;
import com.dropbox.djinni.ideaplugin.psi.DjinniTypeDefinition;
import com.dropbox.djinni.ideaplugin.psi.impl.DjinniPsiImplUtil;
import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import java.util.Locale;
/**
* Created by jaetzold on 8/3/15.
*/
public class DjinniCreateTypeDefinitionQuickFix extends BaseIntentionAction {
private String typeName;
private DjinniPsiImplUtil.DjinniType djinniType;
public DjinniCreateTypeDefinitionQuickFix(@NotNull String typeName, @NotNull DjinniPsiImplUtil.DjinniType djinniType) {
this.typeName = typeName;
this.djinniType = djinniType;
}
@NotNull
@Override
public String getText() {
return "Create djinni " + djinniType.toString().toLowerCase(Locale.US);
}
@Nls
@NotNull
@Override
public String getFamilyName() {
return "Djinni types";
}
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
return file instanceof DjinniFile;
}
@Override
public void invoke(@NotNull final Project project, final Editor editor, final PsiFile file) throws IncorrectOperationException {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
int offset = editor.getCaretModel().getCurrentCaret().getOffset();
PsiReference reference = file.findReferenceAt(offset);
if (reference == null && offset > 0) {
reference = file.findReferenceAt(offset - 1);
}
if (reference != null) {
PsiElement topLevelContext = reference.getElement();
do {
topLevelContext = topLevelContext.getContext();
} while (topLevelContext != null && !(topLevelContext instanceof DjinniTypeDefinition));
if (topLevelContext != null) {
// TODO: Try to make this a generic type creation that uses a live template where the record/interface/enum part is just done by using autocompletion
DjinniTypeDefinition newTypeDefinition = DjinniElementFactory.createTypeDefinition(project, typeName, djinniType);
file.addAfter(newTypeDefinition, topLevelContext);
}
}
}
});
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
/**
* Very similar to DjinniImportReference. Merge them?
*
* Created by jaetzold on 8/7/15.
*/
public class DjinniExternReference extends PsiReferenceBase<PsiElement> implements PsiPolyVariantReference {
private String relativePath;
public DjinniExternReference(@NotNull PsiElement element, @NotNull TextRange rangeInElement) {
super(element, rangeInElement);
relativePath = element.getText().substring(rangeInElement.getStartOffset(), rangeInElement.getEndOffset());
}
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
final PsiFile targetFile = DjinniUtil.fileRelativeResolve(myElement.getProject(), myElement.getContainingFile(), relativePath);
if (targetFile != null) {
return new ResolveResult[] {new PsiElementResolveResult(targetFile)};
} else {
return ResolveResult.EMPTY_ARRAY;
}
}
@Nullable
@Override
public PsiElement resolve() {
ResolveResult[] resolveResults = multiResolve(false);
return resolveResults.length == 1 ? resolveResults[0].getElement() : null;
}
@NotNull
@Override
public Object[] getVariants() {
return Collections.EMPTY_LIST.toArray();
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.intellij.lang.Language;
import com.intellij.openapi.fileTypes.LanguageFileType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* Created by jaetzold on 7/20/15.
*/
public class DjinniFileType extends LanguageFileType {
public static final DjinniFileType INSTANCE = new DjinniFileType();
private DjinniFileType() {
super(DjinniLanguage.INSTANCE);
}
@NotNull
@Override
public String getName() {
return "Djinni";
}
@NotNull
@Override
public String getDescription() {
return "Djinni interface definition file";
}
@NotNull
@Override
public String getDefaultExtension() {
return "djinni";
}
@Nullable
@Override
public Icon getIcon() {
return DjinniIcons.FILE;
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.intellij.openapi.fileTypes.FileTypeConsumer;
import com.intellij.openapi.fileTypes.FileTypeFactory;
import org.jetbrains.annotations.NotNull;
/**
* Created by jaetzold on 7/20/15.
*/
public class DjinniFileTypeFactory extends FileTypeFactory {
@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
consumer.consume(DjinniFileType.INSTANCE, "djinni");
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.dropbox.djinni.ideaplugin.psi.*;
import com.intellij.lang.cacheBuilder.DefaultWordsScanner;
import com.intellij.lang.cacheBuilder.WordsScanner;
import com.intellij.lang.findUsages.FindUsagesProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Locale;
/**
* Created by jaetzold on 7/29/15.
*/
public class DjinniFindUsagesProvider implements FindUsagesProvider {
private static final DefaultWordsScanner WORDS_SCANNER =
new DefaultWordsScanner(new DjinniLexerAdapter(),
TokenSet.create(DjinniTypes.IDENTIFIER), TokenSet.create(DjinniTypes.COMMENT), TokenSet.create(DjinniTypes.STRING_LITERAL, DjinniTypes.NUMBER_LITERAL));
@Nullable
@Override
public WordsScanner getWordsScanner() {
// The tutorial docs say this should return WORDS_SCANNER. But find usages works without it and with it there is sometimes
// an error on lexing djinni files. See here for more context:
// https://devnet.jetbrains.com/message/5537369
return null;
}
@Override
public boolean canFindUsagesFor(@NotNull PsiElement psiElement) {
return psiElement instanceof DjinniNamedElement;
}
@Nullable
@Override
public String getHelpId(@NotNull PsiElement psiElement) {
return null;
}
@NotNull
@Override
public String getType(@NotNull PsiElement element) {
if(element instanceof DjinniTypeDefinition) {
return "djinni " +((DjinniTypeDefinition)element).getDjinniType().toString().toLowerCase(Locale.US);
} else if(element instanceof DjinniEnumValue) {
return "djinni enum value";
} else if(element instanceof DjinniConstNamedValue) {
return "djinni const value";
} else {
return "getType";
}
}
@NotNull
@Override
public String getDescriptiveName(@NotNull PsiElement element) {
if(element instanceof DjinniTypeDefinition) {
return ((DjinniTypeDefinition)element).getTypeName();
} else {
return "getDescriptiveName";
}
}
@NotNull
@Override
public String getNodeText(@NotNull PsiElement element, boolean useFullName) {
if(element instanceof DjinniTypeDefinition) {
DjinniTypeDefinition typeDefinition = (DjinniTypeDefinition)element;
return typeDefinition.getTypeName();
} else {
return "getNodeText";
}
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.dropbox.djinni.ideaplugin.psi.DjinniTypeDefinition;
import com.dropbox.djinni.ideaplugin.psi.DjinniTypes;
import com.dropbox.djinni.ideaplugin.psi.impl.DjinniPsiImplUtil;
import com.intellij.lang.ASTNode;
import com.intellij.lang.folding.FoldingBuilderEx;
import com.intellij.lang.folding.FoldingDescriptor;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.FoldingGroup;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
/**
* Created by jaetzold on 7/29/15.
*/
public class DjinniFoldingBuilder extends FoldingBuilderEx {
@NotNull
@Override
public FoldingDescriptor[] buildFoldRegions(@NotNull PsiElement root, @NotNull Document document, boolean quick) {
List<FoldingDescriptor> descriptors = new ArrayList<FoldingDescriptor>();
Collection<DjinniTypeDefinition> typeDefinitions = PsiTreeUtil.findChildrenOfType(root, DjinniTypeDefinition.class);
for (DjinniTypeDefinition typeDefinition : typeDefinitions) {
String typeName = typeDefinition.getTypeName();
DjinniPsiImplUtil.DjinniType djinniType = typeDefinition.getDjinniType();
if (djinniType != null) {
final String placeholderText = typeName +" = " +djinniType.toString().toLowerCase(Locale.US) + " {...}";
FoldingGroup group = FoldingGroup.newGroup("Djinni");
descriptors.add(new FoldingDescriptor(
typeDefinition.getNode(),
new TextRange(typeDefinition.getTextRange().getStartOffset(), typeDefinition.getTextRange().getEndOffset()),
group) {
@Nullable
@Override
public String getPlaceholderText() {
return placeholderText;
}
});
}
}
return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
}
@Nullable
@Override
public String getPlaceholderText(@NotNull ASTNode node) {
ASTNode identifier = node.findChildByType(DjinniTypes.IDENTIFIER);
return identifier != null ? identifier.getText() : "...";
}
@Override
public boolean isCollapsedByDefault(@NotNull ASTNode node) {
return false;
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.dropbox.djinni.ideaplugin.psi.DjinniTypes;
import com.intellij.formatting.*;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Created by jaetzold on 7/31/15.
*/
public class DjinniFormattingModelBuilder implements FormattingModelBuilder {
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(),
new DjinniBlock(element.getNode(), Wrap.createWrap(WrapType.NONE, false),
Alignment.createAlignment(),
createSpaceBuilder(settings),
Indent.getNoneIndent(), settings.OTHER_INDENT_OPTIONS.INDENT_SIZE),
settings);
}
private static SpacingBuilder createSpaceBuilder(CodeStyleSettings settings) {
return new SpacingBuilder(settings, DjinniLanguage.INSTANCE)
.around(DjinniTypes.EQ).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)
.before(DjinniTypes.LEFT_BLOCK_BRACE).spaceIf(settings.SPACE_BEFORE_CLASS_LBRACE)
.after(DjinniTypes.LEFT_BLOCK_BRACE).lineBreakInCode()
// TODO: How to define a space after the initial '#' in a comment? Do we need to add '#' as a separate token?
.after(DjinniTypes.TYPE_DEFINITION).blankLines(settings.BLANK_LINES_AROUND_CLASS)
.before(DjinniTypes.PLUS).spaceIf(true);
}
@Nullable
@Override
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
return null;
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.intellij.openapi.util.IconLoader;
import javax.swing.*;
/**
* Created by jaetzold on 7/20/15.
*/
public class DjinniIcons {
public static final Icon FILE = IconLoader.getIcon("/com/dropbox/djinni/resources/djinni.png");
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.dropbox.djinni.ideaplugin.psi.DjinniFile;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/**
* Created by jaetzold on 8/3/15.
*/
public class DjinniImportReference extends PsiReferenceBase<PsiElement> implements PsiPolyVariantReference {
private String relativePath;
public DjinniImportReference(@NotNull PsiElement element, @NotNull TextRange rangeInElement) {
super(element, rangeInElement);
relativePath = element.getText().substring(rangeInElement.getStartOffset(), rangeInElement.getEndOffset());
}
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
final PsiFile targetFile = DjinniUtil.djinniFileRelativeResolve(myElement.getProject(), myElement.getContainingFile(), relativePath);
if (targetFile != null) {
return new ResolveResult[] {new PsiElementResolveResult(targetFile)};
} else {
return ResolveResult.EMPTY_ARRAY;
}
}
@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<DjinniFile> djinniFiles = DjinniUtil.findAllDjinniFiles(project, null);
List<LookupElement> variants = new ArrayList<LookupElement>();
for (DjinniFile djinniFile : djinniFiles) {
if(djinniFile.getName().length() > 0) {
variants.add(LookupElementBuilder.create(djinniFile)
.withIcon(DjinniIcons.FILE)
.withTypeText(djinniFile.getName()));
}
}
return variants.toArray();
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.intellij.lang.Language;
/**
* Created by jaetzold on 7/20/15.
*/
public class DjinniLanguage extends Language {
public static final DjinniLanguage INSTANCE = new DjinniLanguage();
private DjinniLanguage() {
super("Djinni");
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.intellij.lexer.FlexAdapter;
import java.io.Reader;
/**
* Created by jaetzold on 7/22/15.
*/
public class DjinniLexerAdapter extends FlexAdapter {
public DjinniLexerAdapter() {
super(new _DjinniLexer((Reader)null));
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.dropbox.djinni.ideaplugin.parser.DjinniParser;
import com.dropbox.djinni.ideaplugin.psi.DjinniFile;
import com.dropbox.djinni.ideaplugin.psi.DjinniTypes;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.lang.ParserDefinition;
import com.intellij.lang.PsiParser;
import com.intellij.lexer.Lexer;
import com.intellij.openapi.project.Project;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IFileElementType;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;
/**
* Created by jaetzold on 7/22/15.
*/
public class DjinniParserDefinition implements ParserDefinition {
public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
public static final TokenSet COMMENTS = TokenSet.create(DjinniTypes.COMMENT);
public static final TokenSet STRING_LITERALS = TokenSet.create(DjinniTypes.STRING_LITERAL);
public static final IFileElementType FILE = new IFileElementType(Language.<DjinniLanguage>findInstance(DjinniLanguage.class));
@NotNull
@Override
public Lexer createLexer(Project project) {
return new DjinniLexerAdapter();
}
@Override
public PsiParser createParser(Project project) {
return new DjinniParser();
}
@Override
public IFileElementType getFileNodeType() {
return FILE;
}
@NotNull
@Override
public TokenSet getWhitespaceTokens() {
return WHITE_SPACES;
}
@NotNull
@Override
public TokenSet getCommentTokens() {
return COMMENTS;
}
@NotNull
@Override
public TokenSet getStringLiteralElements() {
return STRING_LITERALS;
}
@NotNull
@Override
public PsiElement createElement(ASTNode node) {
return DjinniTypes.Factory.createElement(node);
}
@Override
public PsiFile createFile(FileViewProvider viewProvider) {
return new DjinniFile(viewProvider);
}
@Override
public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
return SpaceRequirements.MAY;
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.dropbox.djinni.ideaplugin.psi.DjinniTypeDefinition;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.*;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
/**
* Created by jaetzold on 7/28/15.
*/
public class DjinniReference extends PsiReferenceBase<PsiElement> implements PsiPolyVariantReference {
private String name;
public DjinniReference(@NotNull PsiElement element, @NotNull TextRange rangeInElement) {
super(element, rangeInElement);
name = element.getText().substring(rangeInElement.getStartOffset(), rangeInElement.getEndOffset());
}
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
List<ResolveResult> result = new ArrayList<ResolveResult>();
Project project = myElement.getProject();
final List<DjinniTypeDefinition> typeDefinitions = DjinniUtil.findTypeDefinitionsForName(project, name, myElement);
for (DjinniTypeDefinition typeDefinition : typeDefinitions) {
result.add(new PsiElementResolveResult(typeDefinition));
}
final List<PsiElement> externalTypes = DjinniUtil.findExternalTypeForName(project, name, myElement);
for (PsiElement externalElement : externalTypes) {
result.add(new PsiElementResolveResult(externalElement));
}
return result.toArray(new ResolveResult[result.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();
final List<DjinniTypeDefinition> typeDefinitions = DjinniUtil.findAllTypeDefinitions(project, myElement);
List<LookupElement> variants = new ArrayList<LookupElement>();
for (DjinniTypeDefinition typeDefinition : typeDefinitions) {
if(typeDefinition.getTypeName() != null && typeDefinition.getTypeName().length() > 0) {
variants.add(LookupElementBuilder.create(typeDefinition)
.withIcon(DjinniIcons.FILE)
.withTypeText(typeDefinition.getContainingFile().getName()));
}
}
final List<PsiElement> externalTypes = DjinniUtil.findAllExternalTypes(project, myElement);
for (PsiElement externalType : externalTypes) {
if(externalType.getText() != null && externalType.getText().length() > 0) {
variants.add(LookupElementBuilder.create(externalType.getText())
.withIcon(DjinniIcons.FILE)
.withTypeText(externalType.getContainingFile().getName()));
}
}
return variants.toArray();
}
// todo: Test later whether there is a more indirect way to achieve this.
@Override
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
if(myElement instanceof PsiNamedElement) {
PsiNamedElement namedElement = (PsiNamedElement)myElement;
return namedElement.setName(newElementName);
}
return myElement;
}
}
/*
* Copyright 2015 Dropbox, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.dropbox.djinni.ideaplugin;
import com.intellij.ide.structureView.StructureViewBuilder;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
import com.intellij.lang.PsiStructureViewFactory;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Created by jaetzold on 7/30/15.
*/
public class DjinniStructureViewFactory implements PsiStructureViewFactory {
@Nullable
@Override
public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
return new TreeBasedStructureViewBuilder() {
@NotNull
@Override
public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
return new DjinniStructureViewModel(psiFile);
}
};
}
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment