properties = SimpleUtil.findProperties(project, key);
+ if (properties.size() == 1) {
+ descriptors.add(new FoldingDescriptor(literalExpression.getNode(),
+ new TextRange(literalExpression.getTextRange().getStartOffset() + 1,
+ literalExpression.getTextRange().getEndOffset() - 1),
+ group) {
+ @Nullable
+ @Override
+ public String getPlaceholderText() {
+ // IMPORTANT: keys can come with no values, so a test for null is needed
+ // IMPORTANT: Convert embedded \n to backslash n, so that the string will look like it has LF embedded
+ // in it and embedded " to escaped "
+ String valueOf = properties.get(0).getValue();
+ return valueOf == null ? "" : valueOf.replaceAll("\n", "\\n").replaceAll("\"", "\\\\\"");
}
+ });
}
- return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
+ }
}
+ return descriptors.toArray(new FoldingDescriptor[descriptors.size()]);
+ }
- @Nullable
- @Override
- public String getPlaceholderText(@NotNull ASTNode node) {
- return "...";
- }
+ @Nullable
+ @Override
+ public String getPlaceholderText(@NotNull ASTNode node) {
+ return "...";
+ }
- @Override
- public boolean isCollapsedByDefault(@NotNull ASTNode node) {
- return true;
- }
+ @Override
+ public boolean isCollapsedByDefault(@NotNull ASTNode node) {
+ return true;
+ }
}
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleFormattingModelBuilder.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleFormattingModelBuilder.java
index b20468c77..c509934c1 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleFormattingModelBuilder.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleFormattingModelBuilder.java
@@ -11,23 +11,30 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class SimpleFormattingModelBuilder implements FormattingModelBuilder {
- @NotNull
- @Override
- public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
- return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(),
- new SimpleBlock(element.getNode(), Wrap.createWrap(WrapType.NONE, false),
- Alignment.createAlignment(), createSpaceBuilder(settings)), settings);
- }
+ @NotNull
+ @Override
+ public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
+ return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(),
+ new SimpleBlock(element.getNode(),
+ Wrap.createWrap(WrapType.NONE,
+ false),
+ Alignment.createAlignment(),
+ createSpaceBuilder(settings)),
+ settings);
+ }
- private static SpacingBuilder createSpaceBuilder(CodeStyleSettings settings) {
- return new SpacingBuilder(settings, SimpleLanguage.INSTANCE).
- around(SimpleTypes.SEPARATOR).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS).
- before(SimpleTypes.PROPERTY).none();
- }
+ private static SpacingBuilder createSpaceBuilder(CodeStyleSettings settings) {
+ return new SpacingBuilder(settings, SimpleLanguage.INSTANCE).
+ around(SimpleTypes.SEPARATOR)
+ .spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS)
+ .
+ before(SimpleTypes.PROPERTY)
+ .none();
+ }
- @Nullable
- @Override
- public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
- return null;
- }
+ @Nullable
+ @Override
+ public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
+ return null;
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleIcons.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleIcons.java
index 2719cf69e..f191c0ce3 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleIcons.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleIcons.java
@@ -5,5 +5,5 @@ import com.intellij.openapi.util.IconLoader;
import javax.swing.*;
public class SimpleIcons {
- public static final Icon FILE = IconLoader.getIcon("/com/simpleplugin/icons/jar-gray.png");
+ public static final Icon FILE = IconLoader.getIcon("/com/simpleplugin/icons/jar-gray.png");
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleIdIndexer.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleIdIndexer.java
index bfc0a75ac..613636ed5 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleIdIndexer.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleIdIndexer.java
@@ -6,12 +6,12 @@ import com.intellij.psi.impl.cache.impl.id.LexerBasedIdIndexer;
public class SimpleIdIndexer extends LexerBasedIdIndexer {
- public static Lexer createIndexingLexer(OccurrenceConsumer consumer) {
- return new SimpleFilterLexer(new SimpleLexerAdapter(), consumer);
- }
+ public static Lexer createIndexingLexer(OccurrenceConsumer consumer) {
+ return new SimpleFilterLexer(new SimpleLexerAdapter(), consumer);
+ }
- @Override
- public Lexer createLexer(final OccurrenceConsumer consumer) {
- return createIndexingLexer(consumer);
- }
+ @Override
+ public Lexer createLexer(final OccurrenceConsumer consumer) {
+ return createIndexingLexer(consumer);
+ }
}
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLanguage.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLanguage.java
index 425e59019..9ac5f23f9 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLanguage.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLanguage.java
@@ -3,9 +3,9 @@ package com.simpleplugin;
import com.intellij.lang.Language;
public class SimpleLanguage extends Language {
- public static final SimpleLanguage INSTANCE = new SimpleLanguage();
+ public static final SimpleLanguage INSTANCE = new SimpleLanguage();
- private SimpleLanguage() {
- super("Simple");
- }
+ private SimpleLanguage() {
+ super("Simple");
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLanguageCodeStyleSettingsProvider.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLanguageCodeStyleSettingsProvider.java
index 5df02eb89..a8e9e811d 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLanguageCodeStyleSettingsProvider.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLanguageCodeStyleSettingsProvider.java
@@ -6,38 +6,38 @@ import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
import org.jetbrains.annotations.NotNull;
public class SimpleLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider {
- @NotNull
- @Override
- public Language getLanguage() {
- return SimpleLanguage.INSTANCE;
- }
+ @NotNull
+ @Override
+ public Language getLanguage() {
+ return SimpleLanguage.INSTANCE;
+ }
- @Override
- public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) {
- if (settingsType == SettingsType.SPACING_SETTINGS) {
- consumer.showStandardOptions("SPACE_AROUND_ASSIGNMENT_OPERATORS");
- consumer.renameStandardOption("SPACE_AROUND_ASSIGNMENT_OPERATORS", "Separator");
- } else if (settingsType == SettingsType.BLANK_LINES_SETTINGS) {
- consumer.showStandardOptions("KEEP_BLANK_LINES_IN_CODE");
- }
+ @Override
+ public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) {
+ if (settingsType == SettingsType.SPACING_SETTINGS) {
+ consumer.showStandardOptions("SPACE_AROUND_ASSIGNMENT_OPERATORS");
+ consumer.renameStandardOption("SPACE_AROUND_ASSIGNMENT_OPERATORS", "Separator");
+ } else if (settingsType == SettingsType.BLANK_LINES_SETTINGS) {
+ consumer.showStandardOptions("KEEP_BLANK_LINES_IN_CODE");
}
+ }
- @Override
- public String getCodeSample(@NotNull SettingsType settingsType) {
- return "# You are reading the \".properties\" entry.\n" +
- "! The exclamation mark can also mark text as comments.\n" +
- "website = http://en.wikipedia.org/\n" +
- "\n" +
- "\n" +
- "\n" +
- "language = English\n" +
- "# The backslash below tells the application to continue reading\n" +
- "# the value onto the next line.\n" +
- "message = Welcome to \\\n" +
- " Wikipedia!\n" +
- "# Add spaces to the key\n" +
- "key\\ with\\ spaces = This is the value that could be looked up with the key \"key with spaces\".\n" +
- "# Unicode\n" +
- "tab : \\u0009";
- }
+ @Override
+ public String getCodeSample(@NotNull SettingsType settingsType) {
+ return "# You are reading the \".properties\" entry.\n" +
+ "! The exclamation mark can also mark text as comments.\n" +
+ "website = http://en.wikipedia.org/\n" +
+ "\n" +
+ "\n" +
+ "\n" +
+ "language = English\n" +
+ "# The backslash below tells the application to continue reading\n" +
+ "# the value onto the next line.\n" +
+ "message = Welcome to \\\n" +
+ " Wikipedia!\n" +
+ "# Add spaces to the key\n" +
+ "key\\ with\\ spaces = This is the value that could be looked up with the key \"key with spaces\".\n" +
+ "# Unicode\n" +
+ "tab : \\u0009";
+ }
}
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLexer.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLexer.java
index b18e92e45..fd66560c5 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLexer.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLexer.java
@@ -3,64 +3,68 @@
package com.simpleplugin;
import com.intellij.lexer.FlexLexer;
+import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import com.simpleplugin.psi.SimpleTypes;
-import com.intellij.psi.TokenType;
/**
- * This class is a scanner generated by
+ * This class is a scanner generated by
* JFlex 1.4.3
* on 02/09/15 10:04 AM from the specification file
* /Users/vlad/src/SimplePlugin/src/com/simpleplugin/Simple.flex
*/
class SimpleLexer implements FlexLexer {
- /** initial size of the lookahead buffer */
+ /**
+ * initial size of the lookahead buffer
+ */
private static final int ZZ_BUFFERSIZE = 16384;
- /** lexical states */
+ /**
+ * lexical states
+ */
public static final int WAITING_VALUE = 2;
public static final int YYINITIAL = 0;
/**
* ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
* ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
- * at the beginning of a line
+ * at the beginning of a line
* l is of the form l = 2*k, k a non negative integer
*/
- private static final int ZZ_LEXSTATE[] = {
- 0, 0, 1, 1
+ private static final int ZZ_LEXSTATE[] = {
+ 0, 0, 1, 1
};
- /**
+ /**
* Translates characters to character classes
*/
- private static final String ZZ_CMAP_PACKED =
- "\11\0\1\3\1\1\1\0\1\6\1\2\22\0\1\5\1\7\1\0"+
- "\1\7\26\0\1\10\2\0\1\10\36\0\1\4\uffa3\0";
+ private static final String ZZ_CMAP_PACKED =
+ "\11\0\1\3\1\1\1\0\1\6\1\2\22\0\1\5\1\7\1\0" +
+ "\1\7\26\0\1\10\2\0\1\10\36\0\1\4\uffa3\0";
- /**
+ /**
* Translates characters to character classes
*/
- private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
+ private static final char[] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
- /**
+ /**
* Translates DFA states to action switch labels.
*/
- private static final int [] ZZ_ACTION = zzUnpackAction();
+ private static final int[] ZZ_ACTION = zzUnpackAction();
private static final String ZZ_ACTION_PACKED_0 =
- "\2\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7"+
- "\1\3\1\7\2\0\1\6";
+ "\2\0\1\1\1\2\1\3\1\4\1\5\1\6\1\7" +
+ "\1\3\1\7\2\0\1\6";
- private static int [] zzUnpackAction() {
- int [] result = new int[14];
+ private static int[] zzUnpackAction() {
+ int[] result = new int[14];
int offset = 0;
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
return result;
}
- private static int zzUnpackAction(String packed, int offset, int [] result) {
+ private static int zzUnpackAction(String packed, int offset, int[] result) {
int i = 0; /* index in packed string */
int j = offset; /* index in unpacked array */
int l = packed.length();
@@ -73,23 +77,23 @@ class SimpleLexer implements FlexLexer {
}
- /**
+ /**
* Translates a state to a row index in the transition table
*/
- private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
+ private static final int[] ZZ_ROWMAP = zzUnpackRowMap();
private static final String ZZ_ROWMAP_PACKED_0 =
- "\0\0\0\11\0\22\0\33\0\44\0\55\0\66\0\77"+
- "\0\110\0\121\0\132\0\44\0\121\0\143";
+ "\0\0\0\11\0\22\0\33\0\44\0\55\0\66\0\77" +
+ "\0\110\0\121\0\132\0\44\0\121\0\143";
- private static int [] zzUnpackRowMap() {
- int [] result = new int[14];
+ private static int[] zzUnpackRowMap() {
+ int[] result = new int[14];
int offset = 0;
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
return result;
}
- private static int zzUnpackRowMap(String packed, int offset, int [] result) {
+ private static int zzUnpackRowMap(String packed, int offset, int[] result) {
int i = 0; /* index in packed string */
int j = offset; /* index in unpacked array */
int l = packed.length();
@@ -100,28 +104,28 @@ class SimpleLexer implements FlexLexer {
return j;
}
- /**
+ /**
* The transition table of the DFA
*/
- private static final int [] ZZ_TRANS = zzUnpackTrans();
+ private static final int[] ZZ_TRANS = zzUnpackTrans();
private static final String ZZ_TRANS_PACKED_0 =
- "\1\3\3\4\1\5\2\4\1\6\1\7\1\10\2\4"+
- "\1\11\1\12\2\13\2\10\1\3\3\0\1\14\2\0"+
- "\1\3\2\0\3\4\1\0\2\4\7\0\1\3\3\0"+
- "\1\6\2\0\6\6\11\0\1\10\2\0\1\10\1\15"+
- "\1\10\1\0\3\10\2\4\1\11\1\15\1\11\1\13"+
- "\4\10\1\16\6\10\1\0\2\4\1\13\1\0\2\13"+
- "\2\0\2\10\1\0\1\10\1\15\1\10\1\0\2\10";
+ "\1\3\3\4\1\5\2\4\1\6\1\7\1\10\2\4" +
+ "\1\11\1\12\2\13\2\10\1\3\3\0\1\14\2\0" +
+ "\1\3\2\0\3\4\1\0\2\4\7\0\1\3\3\0" +
+ "\1\6\2\0\6\6\11\0\1\10\2\0\1\10\1\15" +
+ "\1\10\1\0\3\10\2\4\1\11\1\15\1\11\1\13" +
+ "\4\10\1\16\6\10\1\0\2\4\1\13\1\0\2\13" +
+ "\2\0\2\10\1\0\1\10\1\15\1\10\1\0\2\10";
- private static int [] zzUnpackTrans() {
- int [] result = new int[108];
+ private static int[] zzUnpackTrans() {
+ int[] result = new int[108];
int offset = 0;
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
return result;
}
- private static int zzUnpackTrans(String packed, int offset, int [] result) {
+ private static int zzUnpackTrans(String packed, int offset, int[] result) {
int i = 0; /* index in packed string */
int j = offset; /* index in unpacked array */
int l = packed.length();
@@ -145,27 +149,27 @@ class SimpleLexer implements FlexLexer {
/* error messages for the codes above */
private static final String ZZ_ERROR_MSG[] = {
- "Unkown internal scanner error",
- "Error: could not match input",
- "Error: pushback value was too large"
+ "Unkown internal scanner error",
+ "Error: could not match input",
+ "Error: pushback value was too large"
};
/**
* ZZ_ATTRIBUTE[aState] contains the attributes of state aState
*/
- private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
+ private static final int[] ZZ_ATTRIBUTE = zzUnpackAttribute();
private static final String ZZ_ATTRIBUTE_PACKED_0 =
- "\2\0\4\1\1\11\4\1\2\0\1\1";
+ "\2\0\4\1\1\11\4\1\2\0\1\1";
- private static int [] zzUnpackAttribute() {
- int [] result = new int[14];
+ private static int[] zzUnpackAttribute() {
+ int[] result = new int[14];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;
}
- private static int zzUnpackAttribute(String packed, int offset, int [] result) {
+ private static int zzUnpackAttribute(String packed, int offset, int[] result) {
int i = 0; /* index in packed string */
int j = offset; /* index in unpacked array */
int l = packed.length();
@@ -177,33 +181,51 @@ class SimpleLexer implements FlexLexer {
return j;
}
- /** the current state of the DFA */
+ /**
+ * the current state of the DFA
+ */
private int zzState;
- /** the current lexical state */
+ /**
+ * the current lexical state
+ */
private int zzLexicalState = YYINITIAL;
- /** this buffer contains the current text to be matched and is
- the source of the yytext() string */
+ /**
+ * this buffer contains the current text to be matched and is
+ * the source of the yytext() string
+ */
private CharSequence zzBuffer = "";
- /** this buffer may contains the current text array to be matched when it is cheap to acquire it */
+ /**
+ * this buffer may contains the current text array to be matched when it is cheap to acquire it
+ */
private char[] zzBufferArray;
- /** the textposition at the last accepting state */
+ /**
+ * the textposition at the last accepting state
+ */
private int zzMarkedPos;
- /** the textposition at the last state to be included in yytext */
+ /**
+ * the textposition at the last state to be included in yytext
+ */
private int zzPushbackPos;
- /** the current text position in the buffer */
+ /**
+ * the current text position in the buffer
+ */
private int zzCurrentPos;
- /** startRead marks the beginning of the yytext() string in the buffer */
+ /**
+ * startRead marks the beginning of the yytext() string in the buffer
+ */
private int zzStartRead;
- /** endRead marks the last character in the buffer, that has been read
- from input */
+ /**
+ * endRead marks the last character in the buffer, that has been read
+ * from input
+ */
private int zzEndRead;
/**
@@ -211,10 +233,14 @@ class SimpleLexer implements FlexLexer {
*/
private boolean zzAtBOL = true;
- /** zzAtEOF == true <=> the scanner is at the EOF */
+ /**
+ * zzAtEOF == true <=> the scanner is at the EOF
+ */
private boolean zzAtEOF;
- /** denotes if the user-EOF-code has already been executed */
+ /**
+ * denotes if the user-EOF-code has already been executed
+ */
private boolean zzEOFDone;
@@ -226,44 +252,44 @@ class SimpleLexer implements FlexLexer {
* Creates a new scanner.
* There is also java.io.Reader version of this constructor.
*
- * @param in the java.io.Inputstream to read input from.
+ * @param in the java.io.Inputstream to read input from.
*/
SimpleLexer(java.io.InputStream in) {
this(new java.io.InputStreamReader(in));
}
- /**
+ /**
* Unpacks the compressed character translation table.
*
- * @param packed the packed character translation table
- * @return the unpacked character translation table
+ * @param packed the packed character translation table
+ * @return the unpacked character translation table
*/
- private static char [] zzUnpackCMap(String packed) {
- char [] map = new char[0x10000];
+ private static char[] zzUnpackCMap(String packed) {
+ char[] map = new char[0x10000];
int i = 0; /* index in packed string */
int j = 0; /* index in unpacked array */
while (i < 36) {
- int count = packed.charAt(i++);
+ int count = packed.charAt(i++);
char value = packed.charAt(i++);
do map[j++] = value; while (--count > 0);
}
return map;
}
- public final int getTokenStart(){
+ public final int getTokenStart() {
return zzStartRead;
}
- public final int getTokenEnd(){
+ public final int getTokenEnd() {
return getTokenStart() + yylength();
}
- public void reset(CharSequence buffer, int start, int end,int initialState){
+ public void reset(CharSequence buffer, int start, int end, int initialState) {
zzBuffer = buffer;
zzBufferArray = com.intellij.util.text.CharArrayUtil.fromSequenceWithoutCopying(buffer);
zzCurrentPos = zzMarkedPos = zzStartRead = start;
zzPushbackPos = 0;
- zzAtEOF = false;
+ zzAtEOF = false;
zzAtBOL = true;
zzEndRead = end;
yybegin(initialState);
@@ -272,9 +298,8 @@ class SimpleLexer implements FlexLexer {
/**
* Refills the input buffer.
*
- * @return false
, iff there was new input.
- *
- * @exception java.io.IOException if any I/O-Error occurs
+ * @return false
, iff there was new input.
+ * @throws java.io.IOException if any I/O-Error occurs
*/
private boolean zzRefill() throws java.io.IOException {
return true;
@@ -310,16 +335,15 @@ class SimpleLexer implements FlexLexer {
/**
* Returns the character at position pos from the
* matched text.
- *
+ *
* It is equivalent to yytext().charAt(pos), but faster
*
* @param pos the position of the character to fetch.
* A value from 0 to yylength()-1.
- *
* @return the character at position pos
*/
public final char yycharat(int pos) {
- return zzBufferArray != null ? zzBufferArray[zzStartRead+pos]:zzBuffer.charAt(zzStartRead+pos);
+ return zzBufferArray != null ? zzBufferArray[zzStartRead + pos] : zzBuffer.charAt(zzStartRead + pos);
}
@@ -327,30 +351,29 @@ class SimpleLexer implements FlexLexer {
* Returns the length of the matched text region.
*/
public final int yylength() {
- return zzMarkedPos-zzStartRead;
+ return zzMarkedPos - zzStartRead;
}
/**
* Reports an error that occured while scanning.
- *
+ *
* In a wellformed scanner (no or only correct usage of
* yypushback(int) and a match-all fallback rule) this method
* will only be called with things that "Can't Possibly Happen".
* If this method is called, something is seriously wrong
* (e.g. a JFlex bug producing a faulty scanner etc.).
- *
+ *
* Usual syntax/scanner level error handling should be done
* in error fallback rules.
*
- * @param errorCode the code of the errormessage to display
+ * @param errorCode the code of the errormessage to display
*/
private void zzScanError(int errorCode) {
String message;
try {
message = ZZ_ERROR_MSG[errorCode];
- }
- catch (ArrayIndexOutOfBoundsException e) {
+ } catch (ArrayIndexOutOfBoundsException e) {
message = ZZ_ERROR_MSG[ZZ_UNKNOWN_ERROR];
}
@@ -360,14 +383,14 @@ class SimpleLexer implements FlexLexer {
/**
* Pushes the specified amount of characters back into the input stream.
- *
+ *
* They will be read again by then next call of the scanning method
*
- * @param number the number of characters to be read again.
- * This number must not be greater than yylength()!
+ * @param number the number of characters to be read again.
+ * This number must not be greater than yylength()!
*/
- public void yypushback(int number) {
- if ( number > yylength() )
+ public void yypushback(int number) {
+ if (number > yylength())
zzScanError(ZZ_PUSHBACK_2BIG);
zzMarkedPos -= number;
@@ -381,7 +404,7 @@ class SimpleLexer implements FlexLexer {
private void zzDoEOF() {
if (!zzEOFDone) {
zzEOFDone = true;
-
+
}
}
@@ -390,8 +413,8 @@ class SimpleLexer implements FlexLexer {
* Resumes scanning until the next regular expression is matched,
* the end of input is encountered or an I/O-Error occurs.
*
- * @return the next token
- * @exception java.io.IOException if any I/O-Error occurs
+ * @return the next token
+ * @throws java.io.IOException if any I/O-Error occurs
*/
public IElementType advance() throws java.io.IOException {
int zzInput;
@@ -403,11 +426,11 @@ class SimpleLexer implements FlexLexer {
int zzEndReadL = zzEndRead;
CharSequence zzBufferL = zzBuffer;
char[] zzBufferArrayL = zzBufferArray;
- char [] zzCMapL = ZZ_CMAP;
+ char[] zzCMapL = ZZ_CMAP;
- int [] zzTransL = ZZ_TRANS;
- int [] zzRowMapL = ZZ_ROWMAP;
- int [] zzAttrL = ZZ_ATTRIBUTE;
+ int[] zzTransL = ZZ_TRANS;
+ int[] zzRowMapL = ZZ_ROWMAP;
+ int[] zzAttrL = ZZ_ATTRIBUTE;
while (true) {
zzMarkedPosL = zzMarkedPos;
@@ -419,7 +442,8 @@ class SimpleLexer implements FlexLexer {
zzState = ZZ_LEXSTATE[zzLexicalState];
- zzForAction: {
+ zzForAction:
+ {
while (true) {
if (zzCurrentPosL < zzEndReadL)
@@ -427,34 +451,32 @@ class SimpleLexer implements FlexLexer {
else if (zzAtEOF) {
zzInput = YYEOF;
break zzForAction;
- }
- else {
+ } else {
// store back cached positions
- zzCurrentPos = zzCurrentPosL;
- zzMarkedPos = zzMarkedPosL;
+ zzCurrentPos = zzCurrentPosL;
+ zzMarkedPos = zzMarkedPosL;
boolean eof = zzRefill();
// get translated positions and possibly new buffer
- zzCurrentPosL = zzCurrentPos;
- zzMarkedPosL = zzMarkedPos;
- zzBufferL = zzBuffer;
- zzEndReadL = zzEndRead;
+ zzCurrentPosL = zzCurrentPos;
+ zzMarkedPosL = zzMarkedPos;
+ zzBufferL = zzBuffer;
+ zzEndReadL = zzEndRead;
if (eof) {
zzInput = YYEOF;
break zzForAction;
- }
- else {
+ } else {
zzInput = (zzBufferArrayL != null ? zzBufferArrayL[zzCurrentPosL++] : zzBufferL.charAt(zzCurrentPosL++));
}
}
- int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ];
+ int zzNext = zzTransL[zzRowMapL[zzState] + zzCMapL[zzInput]];
if (zzNext == -1) break zzForAction;
zzState = zzNext;
int zzAttributes = zzAttrL[zzState];
- if ( (zzAttributes & 1) == 1 ) {
+ if ((zzAttributes & 1) == 1) {
zzAction = zzState;
zzMarkedPosL = zzCurrentPosL;
- if ( (zzAttributes & 8) == 8 ) break zzForAction;
+ if ((zzAttributes & 8) == 8) break zzForAction;
}
}
@@ -464,41 +486,53 @@ class SimpleLexer implements FlexLexer {
zzMarkedPos = zzMarkedPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
- case 6:
- { yybegin(YYINITIAL); return SimpleTypes.VALUE;
- }
- case 8: break;
- case 5:
- { yybegin(WAITING_VALUE); return SimpleTypes.SEPARATOR;
- }
- case 9: break;
- case 4:
- { yybegin(YYINITIAL); return SimpleTypes.COMMENT;
- }
- case 10: break;
- case 3:
- { return TokenType.BAD_CHARACTER;
- }
- case 11: break;
- case 2:
- { yybegin(YYINITIAL); return TokenType.WHITE_SPACE;
- }
- case 12: break;
- case 7:
- { yybegin(WAITING_VALUE); return TokenType.WHITE_SPACE;
- }
- case 13: break;
- case 1:
- { yybegin(YYINITIAL); return SimpleTypes.KEY;
- }
- case 14: break;
+ case 6: {
+ yybegin(YYINITIAL);
+ return SimpleTypes.VALUE;
+ }
+ case 8:
+ break;
+ case 5: {
+ yybegin(WAITING_VALUE);
+ return SimpleTypes.SEPARATOR;
+ }
+ case 9:
+ break;
+ case 4: {
+ yybegin(YYINITIAL);
+ return SimpleTypes.COMMENT;
+ }
+ case 10:
+ break;
+ case 3: {
+ return TokenType.BAD_CHARACTER;
+ }
+ case 11:
+ break;
+ case 2: {
+ yybegin(YYINITIAL);
+ return TokenType.WHITE_SPACE;
+ }
+ case 12:
+ break;
+ case 7: {
+ yybegin(WAITING_VALUE);
+ return TokenType.WHITE_SPACE;
+ }
+ case 13:
+ break;
+ case 1: {
+ yybegin(YYINITIAL);
+ return SimpleTypes.KEY;
+ }
+ case 14:
+ break;
default:
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
zzAtEOF = true;
zzDoEOF();
return null;
- }
- else {
+ } else {
zzScanError(ZZ_NO_MATCH);
}
}
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLexerAdapter.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLexerAdapter.java
index 662acb59a..40c89a0d5 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLexerAdapter.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLexerAdapter.java
@@ -5,7 +5,7 @@ import com.intellij.lexer.FlexAdapter;
import java.io.Reader;
public class SimpleLexerAdapter extends FlexAdapter {
- public SimpleLexerAdapter() {
- super(new SimpleLexer((Reader) null));
- }
+ public SimpleLexerAdapter() {
+ super(new SimpleLexer((Reader) null));
+ }
}
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLineMarkerProvider.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLineMarkerProvider.java
index d6dc43d96..07b9e08b7 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLineMarkerProvider.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleLineMarkerProvider.java
@@ -13,22 +13,23 @@ import java.util.Collection;
import java.util.List;
public class SimpleLineMarkerProvider extends RelatedItemLineMarkerProvider {
- @Override
- protected void collectNavigationMarkers(@NotNull PsiElement element, Collection super RelatedItemLineMarkerInfo> result) {
- if (element instanceof PsiLiteralExpression) {
- PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
- String value = literalExpression.getValue() instanceof String ? (String)literalExpression.getValue() : null;
- if (value != null && value.startsWith("simple"+":")) {
- Project project = element.getProject();
- final List properties = SimpleUtil.findProperties(project, value.substring(7));
- if (properties.size() > 0) {
- NavigationGutterIconBuilder builder =
- NavigationGutterIconBuilder.create(SimpleIcons.FILE).
- setTargets(properties).
- setTooltipText("Navigate to a simple property");
- result.add(builder.createLineMarkerInfo(element));
- }
- }
+ @Override
+ protected void collectNavigationMarkers(@NotNull PsiElement element,
+ Collection super RelatedItemLineMarkerInfo> result) {
+ if (element instanceof PsiLiteralExpression) {
+ PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
+ String value = literalExpression.getValue() instanceof String ? (String) literalExpression.getValue() : null;
+ if (value != null && value.startsWith("simple" + ":")) {
+ Project project = element.getProject();
+ final List properties = SimpleUtil.findProperties(project, value.substring(7));
+ if (properties.size() > 0) {
+ NavigationGutterIconBuilder builder =
+ NavigationGutterIconBuilder.create(SimpleIcons.FILE).
+ setTargets(properties).
+ setTooltipText("Navigate to a simple property");
+ result.add(builder.createLineMarkerInfo(element));
}
+ }
}
+ }
}
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleParserDefinition.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleParserDefinition.java
index c9de1df95..4d56eeeda 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleParserDefinition.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleParserDefinition.java
@@ -17,53 +17,54 @@ import com.simpleplugin.psi.SimpleFile;
import com.simpleplugin.psi.SimpleTypes;
import org.jetbrains.annotations.NotNull;
-public class SimpleParserDefinition implements ParserDefinition{
- public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
- public static final TokenSet COMMENTS = TokenSet.create(SimpleTypes.COMMENT);
+public class SimpleParserDefinition implements ParserDefinition {
+ public static final TokenSet WHITE_SPACES = TokenSet.create(TokenType.WHITE_SPACE);
+ public static final TokenSet COMMENTS = TokenSet.create(SimpleTypes.COMMENT);
- public static final IFileElementType FILE = new IFileElementType(Language.findInstance(SimpleLanguage.class));
+ public static final IFileElementType FILE =
+ new IFileElementType(Language.findInstance(SimpleLanguage.class));
- @NotNull
- @Override
- public Lexer createLexer(Project project) {
- return new SimpleLexerAdapter();
- }
+ @NotNull
+ @Override
+ public Lexer createLexer(Project project) {
+ return new SimpleLexerAdapter();
+ }
- @NotNull
- public TokenSet getWhitespaceTokens() {
- return WHITE_SPACES;
- }
+ @NotNull
+ public TokenSet getWhitespaceTokens() {
+ return WHITE_SPACES;
+ }
- @NotNull
- public TokenSet getCommentTokens() {
- return COMMENTS;
- }
+ @NotNull
+ public TokenSet getCommentTokens() {
+ return COMMENTS;
+ }
- @NotNull
- public TokenSet getStringLiteralElements() {
- return TokenSet.EMPTY;
- }
+ @NotNull
+ public TokenSet getStringLiteralElements() {
+ return TokenSet.EMPTY;
+ }
- @NotNull
- public PsiParser createParser(final Project project) {
- return new SimpleParser();
- }
+ @NotNull
+ public PsiParser createParser(final Project project) {
+ return new SimpleParser();
+ }
- @Override
- public IFileElementType getFileNodeType() {
- return FILE;
- }
+ @Override
+ public IFileElementType getFileNodeType() {
+ return FILE;
+ }
- public PsiFile createFile(FileViewProvider viewProvider) {
- return new SimpleFile(viewProvider);
- }
+ public PsiFile createFile(FileViewProvider viewProvider) {
+ return new SimpleFile(viewProvider);
+ }
- public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
- return SpaceRequirements.MAY;
- }
+ public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) {
+ return SpaceRequirements.MAY;
+ }
- @NotNull
- public PsiElement createElement(ASTNode node) {
- return SimpleTypes.Factory.createElement(node);
- }
+ @NotNull
+ public PsiElement createElement(ASTNode node) {
+ return SimpleTypes.Factory.createElement(node);
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleRefactoringSupportProvider.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleRefactoringSupportProvider.java
index 8040801d7..a538c7c54 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleRefactoringSupportProvider.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleRefactoringSupportProvider.java
@@ -5,8 +5,8 @@ import com.intellij.psi.PsiElement;
import com.simpleplugin.psi.SimpleProperty;
public class SimpleRefactoringSupportProvider extends RefactoringSupportProvider {
- @Override
- public boolean isMemberInplaceRenameAvailable(PsiElement element, PsiElement context) {
- return element instanceof SimpleProperty;
- }
+ @Override
+ public boolean isMemberInplaceRenameAvailable(PsiElement element, PsiElement context) {
+ return element instanceof SimpleProperty;
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleReference.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleReference.java
index cbb9b295d..6290c5a21 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleReference.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleReference.java
@@ -13,46 +13,46 @@ import java.util.ArrayList;
import java.util.List;
public class SimpleReference extends PsiReferenceBase implements PsiPolyVariantReference {
- private String key;
+ private String key;
- public SimpleReference(@NotNull PsiElement element, TextRange textRange) {
- super(element, textRange);
- key = element.getText().substring(textRange.getStartOffset(), textRange.getEndOffset());
- }
+ public SimpleReference(@NotNull PsiElement element, TextRange textRange) {
+ super(element, textRange);
+ key = element.getText().substring(textRange.getStartOffset(), textRange.getEndOffset());
+ }
- @NotNull
- @Override
- public ResolveResult[] multiResolve(boolean incompleteCode) {
- Project project = myElement.getProject();
- final List properties = SimpleUtil.findProperties(project, key);
- List results = new ArrayList();
- for (SimpleProperty property : properties) {
- results.add(new PsiElementResolveResult(property));
- }
- return results.toArray(new ResolveResult[results.size()]);
+ @NotNull
+ @Override
+ public ResolveResult[] multiResolve(boolean incompleteCode) {
+ Project project = myElement.getProject();
+ final List properties = SimpleUtil.findProperties(project, key);
+ List results = new ArrayList();
+ for (SimpleProperty property : properties) {
+ results.add(new PsiElementResolveResult(property));
}
+ return results.toArray(new ResolveResult[results.size()]);
+ }
- @Nullable
- @Override
- public PsiElement resolve() {
- ResolveResult[] resolveResults = multiResolve(false);
- return resolveResults.length == 1 ? resolveResults[0].getElement() : null;
- }
+ @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 properties = SimpleUtil.findProperties(project);
- List variants = new ArrayList();
- for (final SimpleProperty property : properties) {
- if (property.getKey() != null && property.getKey().length() > 0) {
- variants.add(LookupElementBuilder.create(property).
- withIcon(SimpleIcons.FILE).
- withTypeText(property.getContainingFile().getName())
- );
- }
- }
- return variants.toArray();
+ @NotNull
+ @Override
+ public Object[] getVariants() {
+ Project project = myElement.getProject();
+ List properties = SimpleUtil.findProperties(project);
+ List variants = new ArrayList();
+ for (final SimpleProperty property : properties) {
+ if (property.getKey() != null && property.getKey().length() > 0) {
+ variants.add(LookupElementBuilder.create(property).
+ withIcon(SimpleIcons.FILE).
+ withTypeText(property.getContainingFile().getName())
+ );
+ }
}
+ return variants.toArray();
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleReferenceContributor.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleReferenceContributor.java
index 99806e74f..7d234422b 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleReferenceContributor.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleReferenceContributor.java
@@ -7,20 +7,24 @@ import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
public class SimpleReferenceContributor extends PsiReferenceContributor {
- @Override
- public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
- registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class),
- new PsiReferenceProvider() {
- @NotNull
- @Override
- public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) {
- PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
- String value = literalExpression.getValue() instanceof String ? (String)literalExpression.getValue() : null;
- if (value != null && value.startsWith("simple"+":")) {
- return new PsiReference[]{new SimpleReference(element, new TextRange(8, value.length() + 1))};
- }
- return PsiReference.EMPTY_ARRAY;
- }
- });
- }
+ @Override
+ public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
+ registrar.registerReferenceProvider(PlatformPatterns.psiElement(PsiLiteralExpression.class),
+ new PsiReferenceProvider() {
+ @NotNull
+ @Override
+ public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
+ @NotNull ProcessingContext
+ context) {
+ PsiLiteralExpression literalExpression = (PsiLiteralExpression) element;
+ String value = literalExpression.getValue() instanceof String ?
+ (String) literalExpression.getValue() : null;
+ if (value != null && value.startsWith("simple" + ":")) {
+ return new PsiReference[]{
+ new SimpleReference(element, new TextRange(8, value.length() + 1))};
+ }
+ return PsiReference.EMPTY_ARRAY;
+ }
+ });
+ }
}
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleStructureViewElement.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleStructureViewElement.java
index 29ba22956..065b1f09b 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleStructureViewElement.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleStructureViewElement.java
@@ -15,58 +15,58 @@ import java.util.ArrayList;
import java.util.List;
public class SimpleStructureViewElement implements StructureViewTreeElement, SortableTreeElement {
- private PsiElement element;
+ private PsiElement element;
- public SimpleStructureViewElement(PsiElement element) {
- this.element = element;
- }
+ public SimpleStructureViewElement(PsiElement element) {
+ this.element = element;
+ }
- @Override
- public Object getValue() {
- return element;
- }
+ @Override
+ public Object getValue() {
+ return element;
+ }
- @Override
- public void navigate(boolean requestFocus) {
- if (element instanceof NavigationItem) {
- ((NavigationItem) element).navigate(requestFocus);
- }
+ @Override
+ public void navigate(boolean requestFocus) {
+ if (element instanceof NavigationItem) {
+ ((NavigationItem) element).navigate(requestFocus);
}
+ }
- @Override
- public boolean canNavigate() {
- return element instanceof NavigationItem &&
- ((NavigationItem)element).canNavigate();
- }
+ @Override
+ public boolean canNavigate() {
+ return element instanceof NavigationItem &&
+ ((NavigationItem) element).canNavigate();
+ }
- @Override
- public boolean canNavigateToSource() {
- return element instanceof NavigationItem &&
- ((NavigationItem)element).canNavigateToSource();
- }
+ @Override
+ public boolean canNavigateToSource() {
+ return element instanceof NavigationItem &&
+ ((NavigationItem) element).canNavigateToSource();
+ }
- @Override
- public String getAlphaSortKey() {
- return element instanceof PsiNamedElement ? ((PsiNamedElement) element).getName() : null;
- }
+ @Override
+ public String getAlphaSortKey() {
+ return element instanceof PsiNamedElement ? ((PsiNamedElement) element).getName() : null;
+ }
- @Override
- public ItemPresentation getPresentation() {
- return element instanceof NavigationItem ?
- ((NavigationItem) element).getPresentation() : null;
- }
+ @Override
+ public ItemPresentation getPresentation() {
+ return element instanceof NavigationItem ?
+ ((NavigationItem) element).getPresentation() : null;
+ }
- @Override
- public TreeElement[] getChildren() {
- if (element instanceof SimpleFile) {
- SimpleProperty[] properties = PsiTreeUtil.getChildrenOfType(element, SimpleProperty.class);
- List treeElements = new ArrayList(properties.length);
- for (SimpleProperty property : properties) {
- treeElements.add(new SimpleStructureViewElement(property));
- }
- return treeElements.toArray(new TreeElement[treeElements.size()]);
- } else {
- return EMPTY_ARRAY;
- }
+ @Override
+ public TreeElement[] getChildren() {
+ if (element instanceof SimpleFile) {
+ SimpleProperty[] properties = PsiTreeUtil.getChildrenOfType(element, SimpleProperty.class);
+ List treeElements = new ArrayList(properties.length);
+ for (SimpleProperty property : properties) {
+ treeElements.add(new SimpleStructureViewElement(property));
+ }
+ return treeElements.toArray(new TreeElement[treeElements.size()]);
+ } else {
+ return EMPTY_ARRAY;
}
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleStructureViewFactory.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleStructureViewFactory.java
index 937fe85a6..16323e9b4 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleStructureViewFactory.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleStructureViewFactory.java
@@ -10,15 +10,15 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class SimpleStructureViewFactory implements PsiStructureViewFactory {
- @Nullable
- @Override
- public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
- return new TreeBasedStructureViewBuilder() {
- @NotNull
- @Override
- public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
- return new SimpleStructureViewModel(psiFile);
- }
- };
- }
+ @Nullable
+ @Override
+ public StructureViewBuilder getStructureViewBuilder(final PsiFile psiFile) {
+ return new TreeBasedStructureViewBuilder() {
+ @NotNull
+ @Override
+ public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
+ return new SimpleStructureViewModel(psiFile);
+ }
+ };
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleStructureViewModel.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleStructureViewModel.java
index 3d2318087..db53751c6 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleStructureViewModel.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleStructureViewModel.java
@@ -9,24 +9,24 @@ import com.simpleplugin.psi.SimpleFile;
import org.jetbrains.annotations.NotNull;
public class SimpleStructureViewModel extends StructureViewModelBase implements
- StructureViewModel.ElementInfoProvider {
- public SimpleStructureViewModel(PsiFile psiFile) {
- super(psiFile, new SimpleStructureViewElement(psiFile));
- }
+ StructureViewModel.ElementInfoProvider {
+ public SimpleStructureViewModel(PsiFile psiFile) {
+ super(psiFile, new SimpleStructureViewElement(psiFile));
+ }
- @NotNull
- public Sorter[] getSorters() {
- return new Sorter[] {Sorter.ALPHA_SORTER};
- }
+ @NotNull
+ public Sorter[] getSorters() {
+ return new Sorter[]{Sorter.ALPHA_SORTER};
+ }
- @Override
- public boolean isAlwaysShowsPlus(StructureViewTreeElement element) {
- return false;
- }
+ @Override
+ public boolean isAlwaysShowsPlus(StructureViewTreeElement element) {
+ return false;
+ }
- @Override
- public boolean isAlwaysLeaf(StructureViewTreeElement element) {
- return element instanceof SimpleFile;
- }
+ @Override
+ public boolean isAlwaysLeaf(StructureViewTreeElement element) {
+ return element instanceof SimpleFile;
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleSyntaxHighlighter.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleSyntaxHighlighter.java
index 530581d58..a65f43e0e 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleSyntaxHighlighter.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleSyntaxHighlighter.java
@@ -13,40 +13,45 @@ import org.jetbrains.annotations.NotNull;
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey;
public class SimpleSyntaxHighlighter extends SyntaxHighlighterBase {
- public static final TextAttributesKey SEPARATOR = createTextAttributesKey("SIMPLE_SEPARATOR", DefaultLanguageHighlighterColors.OPERATION_SIGN);
- public static final TextAttributesKey KEY = createTextAttributesKey("SIMPLE_KEY", DefaultLanguageHighlighterColors.KEYWORD);
- public static final TextAttributesKey VALUE = createTextAttributesKey("SIMPLE_VALUE", DefaultLanguageHighlighterColors.STRING);
- public static final TextAttributesKey COMMENT = createTextAttributesKey("SIMPLE_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);
- public static final TextAttributesKey BAD_CHARACTER = createTextAttributesKey("SIMPLE_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER);
+ public static final TextAttributesKey SEPARATOR =
+ createTextAttributesKey("SIMPLE_SEPARATOR", DefaultLanguageHighlighterColors.OPERATION_SIGN);
+ public static final TextAttributesKey KEY =
+ createTextAttributesKey("SIMPLE_KEY", DefaultLanguageHighlighterColors.KEYWORD);
+ public static final TextAttributesKey VALUE =
+ createTextAttributesKey("SIMPLE_VALUE", DefaultLanguageHighlighterColors.STRING);
+ public static final TextAttributesKey COMMENT =
+ createTextAttributesKey("SIMPLE_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);
+ public static final TextAttributesKey BAD_CHARACTER =
+ createTextAttributesKey("SIMPLE_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER);
- private static final TextAttributesKey[] BAD_CHAR_KEYS = new TextAttributesKey[]{BAD_CHARACTER};
- private static final TextAttributesKey[] SEPARATOR_KEYS = new TextAttributesKey[]{SEPARATOR};
- private static final TextAttributesKey[] KEY_KEYS = new TextAttributesKey[]{KEY};
- private static final TextAttributesKey[] VALUE_KEYS = new TextAttributesKey[]{VALUE};
- private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[]{COMMENT};
- private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0];
+ private static final TextAttributesKey[] BAD_CHAR_KEYS = new TextAttributesKey[]{BAD_CHARACTER};
+ private static final TextAttributesKey[] SEPARATOR_KEYS = new TextAttributesKey[]{SEPARATOR};
+ private static final TextAttributesKey[] KEY_KEYS = new TextAttributesKey[]{KEY};
+ private static final TextAttributesKey[] VALUE_KEYS = new TextAttributesKey[]{VALUE};
+ private static final TextAttributesKey[] COMMENT_KEYS = new TextAttributesKey[]{COMMENT};
+ private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0];
- @NotNull
- @Override
- public Lexer getHighlightingLexer() {
- return new SimpleLexerAdapter();
- }
-
- @NotNull
- @Override
- public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
- if (tokenType.equals(SimpleTypes.SEPARATOR)) {
- return SEPARATOR_KEYS;
- } else if (tokenType.equals(SimpleTypes.KEY)) {
- return KEY_KEYS;
- } else if (tokenType.equals(SimpleTypes.VALUE)) {
- return VALUE_KEYS;
- } else if (tokenType.equals(SimpleTypes.COMMENT)) {
- return COMMENT_KEYS;
- } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
- return BAD_CHAR_KEYS;
- } else {
- return EMPTY_KEYS;
- }
+ @NotNull
+ @Override
+ public Lexer getHighlightingLexer() {
+ return new SimpleLexerAdapter();
+ }
+
+ @NotNull
+ @Override
+ public TextAttributesKey[] getTokenHighlights(IElementType tokenType) {
+ if (tokenType.equals(SimpleTypes.SEPARATOR)) {
+ return SEPARATOR_KEYS;
+ } else if (tokenType.equals(SimpleTypes.KEY)) {
+ return KEY_KEYS;
+ } else if (tokenType.equals(SimpleTypes.VALUE)) {
+ return VALUE_KEYS;
+ } else if (tokenType.equals(SimpleTypes.COMMENT)) {
+ return COMMENT_KEYS;
+ } else if (tokenType.equals(TokenType.BAD_CHARACTER)) {
+ return BAD_CHAR_KEYS;
+ } else {
+ return EMPTY_KEYS;
}
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleSyntaxHighlighterFactory.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleSyntaxHighlighterFactory.java
index e3a6fe428..49bd0addb 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleSyntaxHighlighterFactory.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleSyntaxHighlighterFactory.java
@@ -7,9 +7,9 @@ import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
public class SimpleSyntaxHighlighterFactory extends SyntaxHighlighterFactory {
- @NotNull
- @Override
- public SyntaxHighlighter getSyntaxHighlighter(Project project, VirtualFile virtualFile) {
- return new SimpleSyntaxHighlighter();
- }
+ @NotNull
+ @Override
+ public SyntaxHighlighter getSyntaxHighlighter(Project project, VirtualFile virtualFile) {
+ return new SimpleSyntaxHighlighter();
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleTodoIndexer.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleTodoIndexer.java
index 505c0acce..bee9bd730 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleTodoIndexer.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleTodoIndexer.java
@@ -5,8 +5,8 @@ import com.intellij.psi.impl.cache.impl.OccurrenceConsumer;
import com.intellij.psi.impl.cache.impl.todo.LexerBasedTodoIndexer;
public class SimpleTodoIndexer extends LexerBasedTodoIndexer {
- @Override
- public Lexer createLexer(OccurrenceConsumer consumer) {
- return SimpleIdIndexer.createIndexingLexer(consumer);
- }
+ @Override
+ public Lexer createLexer(OccurrenceConsumer consumer) {
+ return SimpleIdIndexer.createIndexingLexer(consumer);
+ }
}
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleUtil.java b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleUtil.java
index c2bb98218..03e31235a 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleUtil.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/SimpleUtil.java
@@ -16,42 +16,44 @@ import java.util.Collections;
import java.util.List;
public class SimpleUtil {
- public static List findProperties(Project project, String key) {
- List result = null;
- Collection virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SimpleFileType.INSTANCE,
- GlobalSearchScope.allScope(project));
- for (VirtualFile virtualFile : virtualFiles) {
- SimpleFile simpleFile = (SimpleFile) PsiManager.getInstance(project).findFile(virtualFile);
- if (simpleFile != null) {
- SimpleProperty[] properties = PsiTreeUtil.getChildrenOfType(simpleFile, SimpleProperty.class);
- if (properties != null) {
- for (SimpleProperty property : properties) {
- if (key.equals(property.getKey())) {
- if (result == null) {
- result = new ArrayList();
- }
- result.add(property);
- }
- }
- }
+ public static List findProperties(Project project, String key) {
+ List result = null;
+ Collection virtualFiles =
+ FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SimpleFileType.INSTANCE,
+ GlobalSearchScope.allScope(project));
+ for (VirtualFile virtualFile : virtualFiles) {
+ SimpleFile simpleFile = (SimpleFile) PsiManager.getInstance(project).findFile(virtualFile);
+ if (simpleFile != null) {
+ SimpleProperty[] properties = PsiTreeUtil.getChildrenOfType(simpleFile, SimpleProperty.class);
+ if (properties != null) {
+ for (SimpleProperty property : properties) {
+ if (key.equals(property.getKey())) {
+ if (result == null) {
+ result = new ArrayList();
+ }
+ result.add(property);
}
+ }
}
- return result != null ? result : Collections.emptyList();
+ }
}
+ return result != null ? result : Collections.emptyList();
+ }
- public static List findProperties(Project project) {
- List result = new ArrayList();
- Collection virtualFiles = FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SimpleFileType.INSTANCE,
- GlobalSearchScope.allScope(project));
- for (VirtualFile virtualFile : virtualFiles) {
- SimpleFile simpleFile = (SimpleFile) PsiManager.getInstance(project).findFile(virtualFile);
- if (simpleFile != null) {
- SimpleProperty[] properties = PsiTreeUtil.getChildrenOfType(simpleFile, SimpleProperty.class);
- if (properties != null) {
- Collections.addAll(result, properties);
- }
- }
+ public static List findProperties(Project project) {
+ List result = new ArrayList();
+ Collection virtualFiles =
+ FileBasedIndex.getInstance().getContainingFiles(FileTypeIndex.NAME, SimpleFileType.INSTANCE,
+ GlobalSearchScope.allScope(project));
+ for (VirtualFile virtualFile : virtualFiles) {
+ SimpleFile simpleFile = (SimpleFile) PsiManager.getInstance(project).findFile(virtualFile);
+ if (simpleFile != null) {
+ SimpleProperty[] properties = PsiTreeUtil.getChildrenOfType(simpleFile, SimpleProperty.class);
+ if (properties != null) {
+ Collections.addAll(result, properties);
}
- return result;
+ }
}
+ return result;
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleElementFactory.java b/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleElementFactory.java
index 91e10ba09..3b94792a9 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleElementFactory.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleElementFactory.java
@@ -6,24 +6,24 @@ import com.intellij.psi.PsiFileFactory;
import com.simpleplugin.SimpleFileType;
public class SimpleElementFactory {
- public static SimpleProperty createProperty(Project project, String name, String value) {
- final SimpleFile file = createFile(project, name + " = " + value);
- return (SimpleProperty) file.getFirstChild();
- }
+ public static SimpleProperty createProperty(Project project, String name, String value) {
+ final SimpleFile file = createFile(project, name + " = " + value);
+ return (SimpleProperty) file.getFirstChild();
+ }
- public static SimpleProperty createProperty(Project project, String name) {
- final SimpleFile file = createFile(project, name);
- return (SimpleProperty) file.getFirstChild();
- }
+ public static SimpleProperty createProperty(Project project, String name) {
+ final SimpleFile file = createFile(project, name);
+ return (SimpleProperty) file.getFirstChild();
+ }
- public static PsiElement createCRLF(Project project) {
- final SimpleFile file = createFile(project, "\n");
- return file.getFirstChild();
- }
+ public static PsiElement createCRLF(Project project) {
+ final SimpleFile file = createFile(project, "\n");
+ return file.getFirstChild();
+ }
- public static SimpleFile createFile(Project project, String text) {
- String name = "dummy.simple";
- return (SimpleFile) PsiFileFactory.getInstance(project).
- createFileFromText(name, SimpleFileType.INSTANCE, text);
- }
+ public static SimpleFile createFile(Project project, String text) {
+ String name = "dummy.simple";
+ return (SimpleFile) PsiFileFactory.getInstance(project).
+ createFileFromText(name, SimpleFileType.INSTANCE, text);
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleElementType.java b/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleElementType.java
index 34e5c3464..4ff00b6a8 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleElementType.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleElementType.java
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class SimpleElementType extends IElementType {
- public SimpleElementType(@NotNull @NonNls String debugName) {
- super(debugName, SimpleLanguage.INSTANCE);
- }
+ public SimpleElementType(@NotNull @NonNls String debugName) {
+ super(debugName, SimpleLanguage.INSTANCE);
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleFile.java b/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleFile.java
index 21c8adc3b..133916e7f 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleFile.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleFile.java
@@ -10,23 +10,23 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.*;
public class SimpleFile extends PsiFileBase {
- public SimpleFile(@NotNull FileViewProvider viewProvider) {
- super(viewProvider, SimpleLanguage.INSTANCE);
- }
+ public SimpleFile(@NotNull FileViewProvider viewProvider) {
+ super(viewProvider, SimpleLanguage.INSTANCE);
+ }
- @NotNull
- @Override
- public FileType getFileType() {
- return SimpleFileType.INSTANCE;
- }
+ @NotNull
+ @Override
+ public FileType getFileType() {
+ return SimpleFileType.INSTANCE;
+ }
- @Override
- public String toString() {
- return "Simple File";
- }
+ @Override
+ public String toString() {
+ return "Simple File";
+ }
- @Override
- public Icon getIcon(int flags) {
- return super.getIcon(flags);
- }
+ @Override
+ public Icon getIcon(int flags) {
+ return super.getIcon(flags);
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleTokenType.java b/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleTokenType.java
index 6bdb585b4..188392218 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleTokenType.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/psi/SimpleTokenType.java
@@ -6,12 +6,12 @@ import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
public class SimpleTokenType extends IElementType {
- public SimpleTokenType(@NotNull @NonNls String debugName) {
- super(debugName, SimpleLanguage.INSTANCE);
- }
+ public SimpleTokenType(@NotNull @NonNls String debugName) {
+ super(debugName, SimpleLanguage.INSTANCE);
+ }
- @Override
- public String toString() {
- return "SimpleTokenType." + super.toString();
- }
+ @Override
+ public String toString() {
+ return "SimpleTokenType." + super.toString();
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/psi/impl/SimpleNamedElementImpl.java b/code_samples/simple_language_plugin/src/com/simpleplugin/psi/impl/SimpleNamedElementImpl.java
index dcb333a62..e727d873d 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/psi/impl/SimpleNamedElementImpl.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/psi/impl/SimpleNamedElementImpl.java
@@ -6,7 +6,7 @@ import com.simpleplugin.psi.SimpleNamedElement;
import org.jetbrains.annotations.NotNull;
public abstract class SimpleNamedElementImpl extends ASTWrapperPsiElement implements SimpleNamedElement {
- public SimpleNamedElementImpl(@NotNull ASTNode node) {
- super(node);
- }
+ public SimpleNamedElementImpl(@NotNull ASTNode node) {
+ super(node);
+ }
}
\ No newline at end of file
diff --git a/code_samples/simple_language_plugin/src/com/simpleplugin/psi/impl/SimplePsiImplUtil.java b/code_samples/simple_language_plugin/src/com/simpleplugin/psi/impl/SimplePsiImplUtil.java
index 3e58dc070..399d96ccc 100644
--- a/code_samples/simple_language_plugin/src/com/simpleplugin/psi/impl/SimplePsiImplUtil.java
+++ b/code_samples/simple_language_plugin/src/com/simpleplugin/psi/impl/SimplePsiImplUtil.java
@@ -9,73 +9,72 @@ import com.simpleplugin.psi.SimpleElementFactory;
import com.simpleplugin.psi.SimpleProperty;
import com.simpleplugin.psi.SimpleTypes;
import org.jetbrains.annotations.Nullable;
-import java.lang.String;
import javax.swing.*;
public class SimplePsiImplUtil {
- public static String getKey(SimpleProperty element) {
- ASTNode keyNode = element.getNode().findChildByType(SimpleTypes.KEY);
- if (keyNode != null) {
- // IMPORTANT: Convert embedded escaped spaces to simple spaces
- return keyNode.getText().replaceAll("\\\\ "," ");
- } else {
- return null;
- }
+ public static String getKey(SimpleProperty element) {
+ ASTNode keyNode = element.getNode().findChildByType(SimpleTypes.KEY);
+ if (keyNode != null) {
+ // IMPORTANT: Convert embedded escaped spaces to simple spaces
+ return keyNode.getText().replaceAll("\\\\ ", " ");
+ } else {
+ return null;
}
+ }
- public static String getValue(SimpleProperty element) {
- ASTNode valueNode = element.getNode().findChildByType(SimpleTypes.VALUE);
- if (valueNode != null) {
- return valueNode.getText();
- } else {
- return null;
- }
+ public static String getValue(SimpleProperty element) {
+ ASTNode valueNode = element.getNode().findChildByType(SimpleTypes.VALUE);
+ if (valueNode != null) {
+ return valueNode.getText();
+ } else {
+ return null;
}
+ }
- public static String getName(SimpleProperty element) {
- return getKey(element);
+ public static String getName(SimpleProperty element) {
+ return getKey(element);
+ }
+
+ public static PsiElement setName(SimpleProperty element, String newName) {
+ ASTNode keyNode = element.getNode().findChildByType(SimpleTypes.KEY);
+ if (keyNode != null) {
+ SimpleProperty property = SimpleElementFactory.createProperty(element.getProject(), newName);
+ ASTNode newKeyNode = property.getFirstChild().getNode();
+ element.getNode().replaceChild(keyNode, newKeyNode);
}
+ return element;
+ }
- public static PsiElement setName(SimpleProperty element, String newName) {
- ASTNode keyNode = element.getNode().findChildByType(SimpleTypes.KEY);
- if (keyNode != null) {
- SimpleProperty property = SimpleElementFactory.createProperty(element.getProject(), newName);
- ASTNode newKeyNode = property.getFirstChild().getNode();
- element.getNode().replaceChild(keyNode, newKeyNode);
- }
- return element;
+ public static PsiElement getNameIdentifier(SimpleProperty element) {
+ ASTNode keyNode = element.getNode().findChildByType(SimpleTypes.KEY);
+ if (keyNode != null) {
+ return keyNode.getPsi();
+ } else {
+ return null;
}
+ }
- public static PsiElement getNameIdentifier(SimpleProperty element) {
- ASTNode keyNode = element.getNode().findChildByType(SimpleTypes.KEY);
- if (keyNode != null) {
- return keyNode.getPsi();
- } else {
- return null;
- }
- }
+ public static ItemPresentation getPresentation(final SimpleProperty element) {
+ return new ItemPresentation() {
+ @Nullable
+ @Override
+ public String getPresentableText() {
+ return element.getKey();
+ }
- public static ItemPresentation getPresentation(final SimpleProperty element) {
- return new ItemPresentation() {
- @Nullable
- @Override
- public String getPresentableText() {
- return element.getKey();
- }
+ @Nullable
+ @Override
+ public String getLocationString() {
+ PsiFile containingFile = element.getContainingFile();
+ return containingFile == null ? null : containingFile.getName();
+ }
- @Nullable
- @Override
- public String getLocationString() {
- PsiFile containingFile = element.getContainingFile();
- return containingFile == null ? null : containingFile.getName();
- }
-
- @Nullable
- @Override
- public Icon getIcon(boolean unused) {
- return SimpleIcons.FILE;
- }
- };
- }
+ @Nullable
+ @Override
+ public Icon getIcon(boolean unused) {
+ return SimpleIcons.FILE;
+ }
+ };
+ }
}
diff --git a/code_samples/simple_language_plugin/testData/AnnotatorTestData.java b/code_samples/simple_language_plugin/testData/AnnotatorTestData.java
index 699bba52c..afb27b17a 100644
--- a/code_samples/simple_language_plugin/testData/AnnotatorTestData.java
+++ b/code_samples/simple_language_plugin/testData/AnnotatorTestData.java
@@ -1,7 +1,7 @@
public class Test {
- public static void main(String[] args) {
- System.out.println("simple:website");
- System.out.println("simple:key with spaces");
- System.out.println("simple:websit");
- }
+ public static void main(String[] args) {
+ System.out.println("simple:website");
+ System.out.println("simple:key with spaces");
+ System.out.println("simple:websit" < / error >);
+ }
}
diff --git a/code_samples/simple_language_plugin/testData/CompleteTestData.java b/code_samples/simple_language_plugin/testData/CompleteTestData.java
index 4a883daec..7c2c666a1 100644
--- a/code_samples/simple_language_plugin/testData/CompleteTestData.java
+++ b/code_samples/simple_language_plugin/testData/CompleteTestData.java
@@ -1,5 +1,5 @@
public class Test {
- public static void main(String[] args) {
- System.out.println("simple:");
- }
+ public static void main(String[] args) {
+ System.out.println("simple:");
+ }
}
diff --git a/code_samples/simple_language_plugin/testData/FindUsagesTestData.java b/code_samples/simple_language_plugin/testData/FindUsagesTestData.java
index 401d8c782..727681239 100644
--- a/code_samples/simple_language_plugin/testData/FindUsagesTestData.java
+++ b/code_samples/simple_language_plugin/testData/FindUsagesTestData.java
@@ -1,5 +1,5 @@
public class Test {
- public static void main(String[] args) {
- System.out.println("simple:key with spaces");
- }
+ public static void main(String[] args) {
+ System.out.println("simple:key with spaces");
+ }
}
diff --git a/code_samples/simple_language_plugin/testData/FoldingTestData.java b/code_samples/simple_language_plugin/testData/FoldingTestData.java
index 1920b5fae..8c53505df 100644
--- a/code_samples/simple_language_plugin/testData/FoldingTestData.java
+++ b/code_samples/simple_language_plugin/testData/FoldingTestData.java
@@ -1,11 +1,35 @@
public class Test {
- public static void main(String[] args) {
- System.out.println("simple:website");
- }
- public static void main1(String[] args) {
- System.out.println("simple:key with spaces");
- }
- public static void main2(String[] args) {
- System.out.println("simple:message");
- }
+ public static void main(String[] args)
+
+
+
+ {
+ System.out.println("simple:website");
+ }
+
+
+
+ public static void main1(String[] args)
+
+
+
+ {
+ System.out.println(
+ "simple:key with " +
+ "spaces");<
+ fold text = ' }' >
+ }
+
+
+
+ public static void main2(String[] args)
+
+
+
+ {
+ System.out.println("simple:message");<
+ fold text = ' }' >
+ }
+
+
}
diff --git a/code_samples/simple_language_plugin/testData/ReferenceTestData.java b/code_samples/simple_language_plugin/testData/ReferenceTestData.java
index 384347eda..92c55dfd5 100644
--- a/code_samples/simple_language_plugin/testData/ReferenceTestData.java
+++ b/code_samples/simple_language_plugin/testData/ReferenceTestData.java
@@ -1,5 +1,5 @@
public class Test {
- public static void main(String[] args) {
- System.out.println("simple:website");
- }
+ public static void main(String[] args) {
+ System.out.println("simple:website");
+ }
}
diff --git a/code_samples/simple_language_plugin/testData/RenameTestData.java b/code_samples/simple_language_plugin/testData/RenameTestData.java
index 384347eda..92c55dfd5 100644
--- a/code_samples/simple_language_plugin/testData/RenameTestData.java
+++ b/code_samples/simple_language_plugin/testData/RenameTestData.java
@@ -1,5 +1,5 @@
public class Test {
- public static void main(String[] args) {
- System.out.println("simple:website");
- }
+ public static void main(String[] args) {
+ System.out.println("simple:website");
+ }
}
diff --git a/code_samples/simple_language_plugin/tests/com/simpleplugin/SimpleCodeInsightTest.java b/code_samples/simple_language_plugin/tests/com/simpleplugin/SimpleCodeInsightTest.java
index f7a703264..b965fdf20 100644
--- a/code_samples/simple_language_plugin/tests/com/simpleplugin/SimpleCodeInsightTest.java
+++ b/code_samples/simple_language_plugin/tests/com/simpleplugin/SimpleCodeInsightTest.java
@@ -16,71 +16,71 @@ import java.util.Collection;
import java.util.List;
public class SimpleCodeInsightTest extends LightCodeInsightFixtureTestCase {
- @Override
- protected void setUp() throws Exception {
- VfsRootAccess.SHOULD_PERFORM_ACCESS_CHECK = false; // TODO: a workaround for v15
- super.setUp();
- }
+ @Override
+ protected void setUp() throws Exception {
+ VfsRootAccess.SHOULD_PERFORM_ACCESS_CHECK = false; // TODO: a workaround for v15
+ super.setUp();
+ }
- @Override
- protected String getTestDataPath() {
- return "code_samples/simple_language_plugin/testData";
- }
+ @Override
+ protected String getTestDataPath() {
+ return "code_samples/simple_language_plugin/testData";
+ }
- public void testCompletion() {
- myFixture.configureByFiles("CompleteTestData.java", "DefaultTestData.simple");
- myFixture.complete(CompletionType.BASIC, 1);
- List strings = myFixture.getLookupElementStrings();
- assertTrue(strings.containsAll(Arrays.asList("key with spaces", "language", "message", "tab", "website")));
- assertEquals(5, strings.size());
- }
+ public void testCompletion() {
+ myFixture.configureByFiles("CompleteTestData.java", "DefaultTestData.simple");
+ myFixture.complete(CompletionType.BASIC, 1);
+ List strings = myFixture.getLookupElementStrings();
+ assertTrue(strings.containsAll(Arrays.asList("key with spaces", "language", "message", "tab", "website")));
+ assertEquals(5, strings.size());
+ }
- public void testAnnotator() {
- myFixture.configureByFiles("AnnotatorTestData.java", "DefaultTestData.simple");
- myFixture.checkHighlighting(false, false, true);
- }
+ public void testAnnotator() {
+ myFixture.configureByFiles("AnnotatorTestData.java", "DefaultTestData.simple");
+ myFixture.checkHighlighting(false, false, true);
+ }
- public void testFormatter() {
- myFixture.configureByFiles("FormatterTestData.simple");
- CodeStyleSettingsManager.getSettings(getProject()).SPACE_AROUND_ASSIGNMENT_OPERATORS = true;
- CodeStyleSettingsManager.getSettings(getProject()).KEEP_BLANK_LINES_IN_CODE = 2;
- new WriteCommandAction.Simple(getProject()) {
- @Override
- protected void run() throws Throwable {
- CodeStyleManager.getInstance(getProject()).reformat(myFixture.getFile());
- }
- }.execute();
- myFixture.checkResultByFile("DefaultTestData.simple");
- }
+ public void testFormatter() {
+ myFixture.configureByFiles("FormatterTestData.simple");
+ CodeStyleSettingsManager.getSettings(getProject()).SPACE_AROUND_ASSIGNMENT_OPERATORS = true;
+ CodeStyleSettingsManager.getSettings(getProject()).KEEP_BLANK_LINES_IN_CODE = 2;
+ new WriteCommandAction.Simple(getProject()) {
+ @Override
+ protected void run() throws Throwable {
+ CodeStyleManager.getInstance(getProject()).reformat(myFixture.getFile());
+ }
+ }.execute();
+ myFixture.checkResultByFile("DefaultTestData.simple");
+ }
- public void testRename() {
- myFixture.configureByFiles("RenameTestData.java", "RenameTestData.simple");
- myFixture.renameElementAtCaret("websiteUrl");
- myFixture.checkResultByFile("RenameTestData.simple", "RenameTestDataAfter.simple", false);
- }
+ public void testRename() {
+ myFixture.configureByFiles("RenameTestData.java", "RenameTestData.simple");
+ myFixture.renameElementAtCaret("websiteUrl");
+ myFixture.checkResultByFile("RenameTestData.simple", "RenameTestDataAfter.simple", false);
+ }
- public void testFolding() {
- myFixture.configureByFiles("DefaultTestData.simple");
- myFixture.testFolding(getTestDataPath() + "/FoldingTestData.java");
- }
+ public void testFolding() {
+ myFixture.configureByFiles("DefaultTestData.simple");
+ myFixture.testFolding(getTestDataPath() + "/FoldingTestData.java");
+ }
- public void testFindUsages() {
- Collection usageInfos = myFixture.testFindUsages("FindUsagesTestData.simple", "FindUsagesTestData.java");
- assertEquals(1, usageInfos.size());
- }
+ public void testFindUsages() {
+ Collection usageInfos = myFixture.testFindUsages("FindUsagesTestData.simple", "FindUsagesTestData.java");
+ assertEquals(1, usageInfos.size());
+ }
- public void testCommenter() {
- myFixture.configureByText(SimpleFileType.INSTANCE, "website = http://en.wikipedia.org/");
- CommentByLineCommentAction commentAction = new CommentByLineCommentAction();
- commentAction.actionPerformedImpl(getProject(), myFixture.getEditor());
- myFixture.checkResult("#website = http://en.wikipedia.org/");
- commentAction.actionPerformedImpl(getProject(), myFixture.getEditor());
- myFixture.checkResult("website = http://en.wikipedia.org/");
- }
+ public void testCommenter() {
+ myFixture.configureByText(SimpleFileType.INSTANCE, "website = http://en.wikipedia.org/");
+ CommentByLineCommentAction commentAction = new CommentByLineCommentAction();
+ commentAction.actionPerformedImpl(getProject(), myFixture.getEditor());
+ myFixture.checkResult("#website = http://en.wikipedia.org/");
+ commentAction.actionPerformedImpl(getProject(), myFixture.getEditor());
+ myFixture.checkResult("website = http://en.wikipedia.org/");
+ }
- public void testReference() {
- myFixture.configureByFiles("ReferenceTestData.java", "DefaultTestData.simple");
- PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent();
- assertEquals("http://en.wikipedia.org/", ((SimpleProperty) element.getReferences()[0].resolve()).getValue());
- }
+ public void testReference() {
+ myFixture.configureByFiles("ReferenceTestData.java", "DefaultTestData.simple");
+ PsiElement element = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent();
+ assertEquals("http://en.wikipedia.org/", ((SimpleProperty) element.getReferences()[0].resolve()).getValue());
+ }
}
diff --git a/code_samples/simple_language_plugin/tests/com/simpleplugin/SimpleParsingTest.java b/code_samples/simple_language_plugin/tests/com/simpleplugin/SimpleParsingTest.java
index 83119a1a6..31543cf21 100644
--- a/code_samples/simple_language_plugin/tests/com/simpleplugin/SimpleParsingTest.java
+++ b/code_samples/simple_language_plugin/tests/com/simpleplugin/SimpleParsingTest.java
@@ -3,26 +3,26 @@ package com.simpleplugin;
import com.intellij.testFramework.ParsingTestCase;
public class SimpleParsingTest extends ParsingTestCase {
- public SimpleParsingTest() {
- super("", "simple", new SimpleParserDefinition());
- }
+ public SimpleParsingTest() {
+ super("", "simple", new SimpleParserDefinition());
+ }
- public void testParsingTestData() {
- doTest(true);
- }
+ public void testParsingTestData() {
+ doTest(true);
+ }
- @Override
- protected String getTestDataPath() {
- return "code_samples/simple_language_plugin/testData";
- }
+ @Override
+ protected String getTestDataPath() {
+ return "code_samples/simple_language_plugin/testData";
+ }
- @Override
- protected boolean skipSpaces() {
- return false;
- }
+ @Override
+ protected boolean skipSpaces() {
+ return false;
+ }
- @Override
- protected boolean includeRanges() {
- return true;
- }
+ @Override
+ protected boolean includeRanges() {
+ return true;
+ }
}
diff --git a/code_samples/tool_window/resources/META-INF/plugin.xml b/code_samples/tool_window/resources/META-INF/plugin.xml
index 332a2a997..33986b761 100644
--- a/code_samples/tool_window/resources/META-INF/plugin.xml
+++ b/code_samples/tool_window/resources/META-INF/plugin.xml
@@ -1,33 +1,33 @@
- org.jetbrains.plugins.sample.ToolWindow
- Tool Window
- This sample plugin illustrates how to create your custom tool window.
- 2.0
- YourCompany
+ org.jetbrains.plugins.sample.ToolWindow
+ Tool Window
+ This sample plugin illustrates how to create your custom tool window.
+ 2.0
+ YourCompany
-
most HTML tags may be used
]]>
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
\ No newline at end of file
diff --git a/code_samples/tool_window/src/myToolWindow/MyToolWindowFactory.java b/code_samples/tool_window/src/myToolWindow/MyToolWindowFactory.java
index 1082183c6..29829ba54 100644
--- a/code_samples/tool_window/src/myToolWindow/MyToolWindowFactory.java
+++ b/code_samples/tool_window/src/myToolWindow/MyToolWindowFactory.java
@@ -19,61 +19,62 @@ import java.util.Calendar;
*/
public class MyToolWindowFactory implements ToolWindowFactory {
- private JButton refreshToolWindowButton;
- private JButton hideToolWindowButton;
- private JLabel currentDate;
- private JLabel currentTime;
- private JLabel timeZone;
- private JPanel myToolWindowContent;
- private ToolWindow myToolWindow;
+ private JButton refreshToolWindowButton;
+ private JButton hideToolWindowButton;
+ private JLabel currentDate;
+ private JLabel currentTime;
+ private JLabel timeZone;
+ private JPanel myToolWindowContent;
+ private ToolWindow myToolWindow;
- public MyToolWindowFactory() {
- hideToolWindowButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- myToolWindow.hide(null);
- }
- });
- refreshToolWindowButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- MyToolWindowFactory.this.currentDateTime();
- }
- });
+ public MyToolWindowFactory() {
+ hideToolWindowButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ myToolWindow.hide(null);
+ }
+ });
+ refreshToolWindowButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ MyToolWindowFactory.this.currentDateTime();
+ }
+ });
+ }
+
+ // Create the tool window content.
+ public void createToolWindowContent(Project project, ToolWindow toolWindow) {
+ myToolWindow = toolWindow;
+ this.currentDateTime();
+ ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
+ Content content = contentFactory.createContent(myToolWindowContent, "", false);
+ toolWindow.getContentManager().addContent(content);
+
+ }
+
+ public void currentDateTime() {
+ // Get current date and time
+ Calendar instance = Calendar.getInstance();
+ currentDate.setText(String.valueOf(instance.get(Calendar.DAY_OF_MONTH)) + "/"
+ + String.valueOf(instance.get(Calendar.MONTH) + 1) + "/" +
+ String.valueOf(instance.get(Calendar.YEAR)));
+ currentDate.setIcon(new ImageIcon(getClass().getResource("/myToolWindow/Calendar-icon.png")));
+ int min = instance.get(Calendar.MINUTE);
+ String strMin;
+ if (min < 10) {
+ strMin = "0" + String.valueOf(min);
+ } else {
+ strMin = String.valueOf(min);
}
-
- // Create the tool window content.
- public void createToolWindowContent(Project project, ToolWindow toolWindow) {
- myToolWindow = toolWindow;
- this.currentDateTime();
- ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
- Content content = contentFactory.createContent(myToolWindowContent, "", false);
- toolWindow.getContentManager().addContent(content);
-
- }
-
- public void currentDateTime() {
- // Get current date and time
- Calendar instance = Calendar.getInstance();
- currentDate.setText(String.valueOf(instance.get(Calendar.DAY_OF_MONTH)) + "/"
- + String.valueOf(instance.get(Calendar.MONTH) + 1) + "/" + String.valueOf(instance.get(Calendar.YEAR)));
- currentDate.setIcon(new ImageIcon(getClass().getResource("/myToolWindow/Calendar-icon.png")));
- int min = instance.get(Calendar.MINUTE);
- String strMin;
- if (min < 10) {
- strMin = "0" + String.valueOf(min);
- } else {
- strMin = String.valueOf(min);
- }
- currentTime.setText(instance.get(Calendar.HOUR_OF_DAY) + ":" + strMin);
- currentTime.setIcon(new ImageIcon(getClass().getResource("/myToolWindow/Time-icon.png")));
- // Get time zone
- long gmt_Offset = instance.get(Calendar.ZONE_OFFSET); // offset from GMT in milliseconds
- String str_gmt_Offset = String.valueOf(gmt_Offset / 3600000);
- str_gmt_Offset = (gmt_Offset > 0) ? "GMT + " + str_gmt_Offset : "GMT - " + str_gmt_Offset;
- timeZone.setText(str_gmt_Offset);
- timeZone.setIcon(new ImageIcon(getClass().getResource("/myToolWindow/Time-zone-icon.png")));
+ currentTime.setText(instance.get(Calendar.HOUR_OF_DAY) + ":" + strMin);
+ currentTime.setIcon(new ImageIcon(getClass().getResource("/myToolWindow/Time-icon.png")));
+ // Get time zone
+ long gmt_Offset = instance.get(Calendar.ZONE_OFFSET); // offset from GMT in milliseconds
+ String str_gmt_Offset = String.valueOf(gmt_Offset / 3600000);
+ str_gmt_Offset = (gmt_Offset > 0) ? "GMT + " + str_gmt_Offset : "GMT - " + str_gmt_Offset;
+ timeZone.setText(str_gmt_Offset);
+ timeZone.setIcon(new ImageIcon(getClass().getResource("/myToolWindow/Time-zone-icon.png")));
- }
+ }
}
diff --git a/code_samples/tree_structure_provider/src/org/jetbrains/tutorials/tree/structure/TextOnlyTreeStructureProvider.java b/code_samples/tree_structure_provider/src/org/jetbrains/tutorials/tree/structure/TextOnlyTreeStructureProvider.java
index 58fb2b216..610d3e998 100644
--- a/code_samples/tree_structure_provider/src/org/jetbrains/tutorials/tree/structure/TextOnlyTreeStructureProvider.java
+++ b/code_samples/tree_structure_provider/src/org/jetbrains/tutorials/tree/structure/TextOnlyTreeStructureProvider.java
@@ -16,25 +16,27 @@ import java.util.Collection;
* @author Anna Bulenkova
*/
public class TextOnlyTreeStructureProvider implements TreeStructureProvider {
- @NotNull
- @Override
- public Collection modify(@NotNull AbstractTreeNode parent, @NotNull Collection children, ViewSettings settings) {
- ArrayList nodes = new ArrayList();
- for (AbstractTreeNode child : children) {
- if (child instanceof PsiFileNode) {
- VirtualFile file = ((PsiFileNode) child).getVirtualFile();
- if (file != null && !file.isDirectory() && !(file.getFileType() instanceof PlainTextFileType)) {
- continue;
- }
- }
- nodes.add(child);
+ @NotNull
+ @Override
+ public Collection modify(@NotNull AbstractTreeNode parent,
+ @NotNull Collection children,
+ ViewSettings settings) {
+ ArrayList nodes = new ArrayList();
+ for (AbstractTreeNode child : children) {
+ if (child instanceof PsiFileNode) {
+ VirtualFile file = ((PsiFileNode) child).getVirtualFile();
+ if (file != null && !file.isDirectory() && !(file.getFileType() instanceof PlainTextFileType)) {
+ continue;
}
- return nodes;
+ }
+ nodes.add(child);
}
+ return nodes;
+ }
- @Nullable
- @Override
- public Object getData(Collection collection, String s) {
- return null;
- }
+ @Nullable
+ @Override
+ public Object getData(Collection collection, String s) {
+ return null;
+ }
}
\ No newline at end of file