-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,130 additions
and
6 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
...ain/gen/com/justint/usdidea/USDLexer.java → .../justint/usdidea/lang/lexer/USDLexer.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...in/gen/com/justint/usdidea/USDParser.java → ...ustint/usdidea/lang/parser/USDParser.java
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
123 changes: 123 additions & 0 deletions
123
src/main/java/com/justint/usdidea/codeinsight/highlighting/USDColorSettingsPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package com.justint.usdidea.codeinsight.highlighting; | ||
|
||
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 com.justint.usdidea.util.USDIcons; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.*; | ||
import java.util.Map; | ||
|
||
public class USDColorSettingsPage implements ColorSettingsPage { | ||
private static final AttributesDescriptor[] DESCRIPTORS = new AttributesDescriptor[] { | ||
new AttributesDescriptor("Number", USDSyntaxHighlighter.NUMBER), | ||
new AttributesDescriptor("String", USDSyntaxHighlighter.STRING), | ||
new AttributesDescriptor("Comment", USDSyntaxHighlighter.COMMENT), | ||
new AttributesDescriptor("USD Declaration", USDSyntaxHighlighter.USDDECLARATION) | ||
}; | ||
|
||
@Nullable | ||
@Override | ||
public Icon getIcon() { | ||
return USDIcons.FILE; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public SyntaxHighlighter getHighlighter() { | ||
return new USDSyntaxHighlighter(); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getDemoText() { | ||
// TODO: replace with custom demo text | ||
return "#usda 1.0\n" + | ||
"\n" + | ||
"(\n" + | ||
" upAxis = \"Y\"\n" + | ||
" doc = \"\"\"This layer represents the various geometric forms that curves\n" + | ||
" may be used to represent.\"\"\"\n" + | ||
")\n" + | ||
"\n" + | ||
"\n" + | ||
"def Xform \"Linear\" {\n" + | ||
" uniform token[] xformOpOrder = [\"xformOp:translate\"]\n" + | ||
" float3 xformOp:translate = (0, 9, 0)\n" + | ||
" def Scope \"Tubes\"{\n" + | ||
" def BasisCurves \"ConstantWidth\" (){\n" + | ||
" uniform token[] xformOpOrder = [\"xformOp:translate\"]\n" + | ||
" float3 xformOp:translate = (3, 0, 0)\n" + | ||
"\n" + | ||
" uniform token type = \"linear\"\n" + | ||
" int[] curveVertexCounts = [7]\n" + | ||
" point3f[] points = [(0, 0, 0), (1, 1, 0), (1, 2, 0), (0, 3, 0), (-1, 4, 0), (-1, 5, 0), (0, 6, 0)]\n" + | ||
" float[] widths = [.5] (interpolation = \"constant\")\n" + | ||
" color3f[] primvars:displayColor = [(1, 0, 0)]\n" + | ||
" }\n" + | ||
" def BasisCurves \"VaryingWidth\" (){\n" + | ||
" uniform token[] xformOpOrder = [\"xformOp:translate\"]\n" + | ||
" float3 xformOp:translate = (6, 0, 0)\n" + | ||
"\n" + | ||
" uniform token type = \"linear\"\n" + | ||
" int[] curveVertexCounts = [7]\n" + | ||
" point3f[] points = [(0, 0, 0), (1, 1, 0), (1, 2, 0), (0, 3, 0), (-1, 4, 0), (-1, 5, 0), (0, 6, 0)]\n" + | ||
" float[] widths = [0, .5, .5, .8, .5, .5, 0] (interpolation = \"varying\")\n" + | ||
" color3f[] primvars:displayColor = [(0, 0, 1)]\n" + | ||
" }\n" + | ||
" }\n" + | ||
" def Scope \"Ribbons\"{\n" + | ||
" def BasisCurves \"VaryingWidth\" (){\n" + | ||
" uniform token[] xformOpOrder = [\"xformOp:translate\"]\n" + | ||
" float3 xformOp:translate = (12, 0, 0)\n" + | ||
"\n" + | ||
" uniform token type = \"linear\"\n" + | ||
" int[] curveVertexCounts = [7]\n" + | ||
" point3f[] points = [(0, 0, 0), (1, 1, 0), (1, 2, 0), (0, 3, 0), (-1, 4, 0), (-1, 5, 0), (0, 6, 0)]\n" + | ||
" float[] widths = [0, .5, .5, .8, .5, .5, 0] (interpolation = \"varying\")\n" + | ||
" normal3f[] normals = [(1, 0, 0), (.98, 0, .44), (.98, 0, .44), (.707, 0, .707), (.98, 0, .44), (.98, 0, .44), (1, 0, 0)] (interpolation = \"varying\")\n" + | ||
" color3f[] primvars:displayColor = [(0, 1, 0)]\n" + | ||
" }\n" + | ||
" def BasisCurves \"ConstantWidth\" (){\n" + | ||
" uniform token[] xformOpOrder = [\"xformOp:translate\"]\n" + | ||
" float3 xformOp:translate = (15, 0, 0)\n" + | ||
"\n" + | ||
" uniform token type = \"linear\"\n" + | ||
" int[] curveVertexCounts = [7]\n" + | ||
" point3f[] points = [(0, 0, 0), (1, 1, 0), (1, 2, 0), (0, 3, 0), (-1, 4, 0), (-1, 5, 0), (0, 6, 0)]\n" + | ||
" float[] widths = [.5] (interpolation = \"constant\")\n" + | ||
" normal3f[] normals = [(1, 0, 0), (.98, 0, .44), (.98, 0, .44), (.707, 0, .707), (.98, 0, .44), (.98, 0, .44), (1, 0, 0)] (interpolation = \"varying\")\n" + | ||
" color3f[] primvars:displayColor = [(1, 1, 1)]\n" + | ||
" }\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 "USD"; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/justint/usdidea/codeinsight/highlighting/USDHighlighterColors.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.justint.usdidea.codeinsight.highlighting; | ||
|
||
import com.intellij.openapi.editor.colors.TextAttributesKey; | ||
|
||
import static com.intellij.openapi.editor.colors.CodeInsightColors.HYPERLINK_ATTRIBUTES; | ||
|
||
public class USDHighlighterColors { | ||
public static final TextAttributesKey ASSETREFERENCE_KEY = TextAttributesKey.createTextAttributesKey("ASSETREFERENCE", HYPERLINK_ATTRIBUTES); | ||
public static final TextAttributesKey PATHREFERENCE_KEY = TextAttributesKey.createTextAttributesKey("PATHREFERENCE", HYPERLINK_ATTRIBUTES); | ||
} |
93 changes: 93 additions & 0 deletions
93
src/main/java/com/justint/usdidea/codeinsight/highlighting/USDSyntaxHighlighter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.justint.usdidea.codeinsight.highlighting; | ||
|
||
import com.intellij.lexer.Lexer; | ||
import com.intellij.openapi.editor.*; | ||
import com.intellij.openapi.editor.colors.TextAttributesKey; | ||
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase; | ||
import com.intellij.psi.tree.IElementType; | ||
import com.intellij.util.containers.ContainerUtil; | ||
import com.justint.usdidea.lang.lexer.USDLexerAdapter; | ||
import com.justint.usdidea.lang.parser.USDParserDefinition; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Map; | ||
|
||
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey; | ||
|
||
|
||
public class USDSyntaxHighlighter extends SyntaxHighlighterBase { | ||
|
||
// TextAttributesKey instances | ||
public static final TextAttributesKey USDDECLARATION = | ||
createTextAttributesKey("USDDECLARATION", DefaultLanguageHighlighterColors.CONSTANT); | ||
public static final TextAttributesKey STRING = | ||
createTextAttributesKey("STRING", DefaultLanguageHighlighterColors.STRING); | ||
public static final TextAttributesKey NUMBER = | ||
createTextAttributesKey("NUMBER", DefaultLanguageHighlighterColors.NUMBER); | ||
public static final TextAttributesKey COMMENT = | ||
createTextAttributesKey("COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT); | ||
|
||
// | ||
// // TextAttributesKey arrays | ||
// private static final TextAttributesKey[] CONSTANTS = new TextAttributesKey[] {USD_DECLARATION}; | ||
// private static final TextAttributesKey[] IDENTIFIERS = new TextAttributesKey[]{ | ||
// createTextAttributesKey("ALPHA", DefaultLanguageHighlighterColors.IDENTIFIER) | ||
// }; | ||
// private static final TextAttributesKey[] INSTANCE_FIELDS = new TextAttributesKey[]{ | ||
// createTextAttributesKey("ATTRIBUTE_NAME", DefaultLanguageHighlighterColors.INSTANCE_FIELD), | ||
// createTextAttributesKey("PRIM_NAME", DefaultLanguageHighlighterColors.INSTANCE_FIELD) | ||
// }; | ||
// private static final TextAttributesKey[] KEYWORDS = new TextAttributesKey[]{ | ||
// createTextAttributesKey("ADD", DefaultLanguageHighlighterColors.KEYWORD), | ||
// createTextAttributesKey("ALPHA", DefaultLanguageHighlighterColors.KEYWORD), | ||
// createTextAttributesKey("APPEND", DefaultLanguageHighlighterColors.KEYWORD), | ||
// createTextAttributesKey("CLASS", DefaultLanguageHighlighterColors.KEYWORD), | ||
// createTextAttributesKey("DEF", DefaultLanguageHighlighterColors.KEYWORD), | ||
// createTextAttributesKey("DELETE", DefaultLanguageHighlighterColors.KEYWORD), | ||
// createTextAttributesKey("OVER", DefaultLanguageHighlighterColors.KEYWORD), | ||
// createTextAttributesKey("PREPEND", DefaultLanguageHighlighterColors.KEYWORD), | ||
// | ||
// }; | ||
// private static final TextAttributesKey[] BAD_CHAR_KEYS = new TextAttributesKey[]{BAD_CHARACTER}; | ||
// private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[]{COMMENT}; | ||
// private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0]; | ||
// | ||
// private static final IElementType[] USD_KEYWORDS = { | ||
// USDTypes.ADD, | ||
// USDTypes.ALPHA, | ||
// USDTypes.APPEND, | ||
// USDTypes.CLASS, | ||
// USDTypes.DEF, | ||
// USDTypes.DELETE, | ||
// USDTypes.OVER, | ||
// USDTypes.PREPEND | ||
// }; | ||
|
||
private static final Map<IElementType, TextAttributesKey> ATTRIBUTES = ContainerUtil.newHashMap(); | ||
|
||
static { | ||
SyntaxHighlighterBase.fillMap(ATTRIBUTES, USDParserDefinition.USDDECLARATION, DefaultLanguageHighlighterColors.CONSTANT); | ||
SyntaxHighlighterBase.fillMap(ATTRIBUTES, USDParserDefinition.BRACKETS, DefaultLanguageHighlighterColors.BRACKETS); | ||
SyntaxHighlighterBase.fillMap(ATTRIBUTES, USDParserDefinition.KEYWORDS, DefaultLanguageHighlighterColors.KEYWORD); | ||
SyntaxHighlighterBase.fillMap(ATTRIBUTES, USDParserDefinition.STRINGS, DefaultLanguageHighlighterColors.STRING); | ||
SyntaxHighlighterBase.fillMap(ATTRIBUTES, USDParserDefinition.NUMBERS, DefaultLanguageHighlighterColors.NUMBER); | ||
SyntaxHighlighterBase.fillMap(ATTRIBUTES, USDParserDefinition.LINE_COMMENTS, DefaultLanguageHighlighterColors.LINE_COMMENT); | ||
SyntaxHighlighterBase.fillMap(ATTRIBUTES, USDParserDefinition.BLOCK_COMMENTS, DefaultLanguageHighlighterColors.BLOCK_COMMENT); | ||
SyntaxHighlighterBase.fillMap(ATTRIBUTES, USDParserDefinition.IDENTIFIERS, DefaultLanguageHighlighterColors.IDENTIFIER); | ||
SyntaxHighlighterBase.fillMap(ATTRIBUTES, USDParserDefinition.ASSETREFERENCES, USDHighlighterColors.ASSETREFERENCE_KEY); | ||
SyntaxHighlighterBase.fillMap(ATTRIBUTES, USDParserDefinition.PATHREFERENCES, USDHighlighterColors.PATHREFERENCE_KEY); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public Lexer getHighlightingLexer() { | ||
return new USDLexerAdapter(); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { | ||
return pack(ATTRIBUTES.get(tokenType)); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/justint/usdidea/codeinsight/highlighting/USDSyntaxHighlighterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.justint.usdidea.codeinsight.highlighting; | ||
|
||
import com.intellij.openapi.fileTypes.SyntaxHighlighter; | ||
import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class USDSyntaxHighlighterFactory extends SyntaxHighlighterFactory { | ||
|
||
@NotNull | ||
@Override | ||
public SyntaxHighlighter getSyntaxHighlighter(Project project, VirtualFile virtualFile) { | ||
return new USDSyntaxHighlighter(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.justint.usdidea.file; | ||
|
||
import com.intellij.openapi.fileTypes.LanguageFileType; | ||
import com.justint.usdidea.util.USDIcons; | ||
import com.justint.usdidea.lang.USDLanguage; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.*; | ||
|
||
public class USDFileType extends LanguageFileType { | ||
public static final USDFileType INSTANCE = new USDFileType(); | ||
|
||
private USDFileType() { | ||
super(USDLanguage.INSTANCE); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getName() { | ||
return "USD"; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getDescription() { | ||
return "Universal Scene Description File"; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getDefaultExtension() { | ||
return "usda"; | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public Icon getIcon() { | ||
return USDIcons.FILE; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/justint/usdidea/file/USDFileTypeFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.justint.usdidea.file; | ||
|
||
import com.intellij.openapi.fileTypes.FileTypeConsumer; | ||
import com.intellij.openapi.fileTypes.FileTypeFactory; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class USDFileTypeFactory extends FileTypeFactory { | ||
@Override | ||
public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) { | ||
fileTypeConsumer.consume(USDFileType.INSTANCE, "usd;usda"); | ||
} | ||
} |
Oops, something went wrong.