mirror of
https://github.com/JetBrains/intellij-sdk-code-samples.git
synced 2025-07-30 18:27:49 +08:00
made it compilable for IDEA 14 platform
fixed compilation errors fixed tests replaced deprecated methods adjusted VM options
This commit is contained in:
parent
033d4a0245
commit
14aea0c236
3
.idea/copyright/profiles_settings.xml
generated
Normal file
3
.idea/copyright/profiles_settings.xml
generated
Normal file
@ -0,0 +1,3 @@
|
||||
<component name="CopyrightManager">
|
||||
<settings default="" />
|
||||
</component>
|
8
.idea/misc.xml
generated
8
.idea/misc.xml
generated
@ -1,8 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CopyrightManager" default="">
|
||||
<module2copyright />
|
||||
</component>
|
||||
<component name="EntryPointsManager">
|
||||
<entry_points version="2.0" />
|
||||
</component>
|
||||
@ -14,8 +11,7 @@
|
||||
<PropertiesSettings />
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA IC-133.162" project-jdk-type="IDEA JDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" default="false" assert-keyword="true" jdk-15="true" project-jdk-name="IntelliJ IDEA Community Edition IC-141.1532.4" project-jdk-type="IDEA JDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
</project>
|
2
.idea/runConfigurations/Plugin.xml
generated
2
.idea/runConfigurations/Plugin.xml
generated
@ -3,7 +3,7 @@
|
||||
<module name="SimplePlugin" />
|
||||
<option name="VM_PARAMETERS" value="-Xmx512m -Xms256m -XX:MaxPermSize=250m -Didea.is.internal=true" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<log_file path="$USER_HOME$/Library/Caches/IdeaIC13/plugins-sandbox/system/log/idea.log" checked="false" skipped="true" show_all="false" alias="IDEA LOG" />
|
||||
<log_file path="$USER_HOME$/Library/Caches/IntelliJIdea14/plugins-sandbox/system/log/idea.log" checked="false" skipped="true" show_all="false" alias="IDEA LOG" />
|
||||
<RunnerSettings RunnerId="Debug">
|
||||
<option name="DEBUG_PORT" value="" />
|
||||
<option name="TRANSPORT" value="0" />
|
||||
|
4
.idea/runConfigurations/Tests.xml
generated
4
.idea/runConfigurations/Tests.xml
generated
@ -13,9 +13,9 @@
|
||||
<option name="MAIN_CLASS_NAME" value="" />
|
||||
<option name="METHOD_NAME" value="" />
|
||||
<option name="TEST_OBJECT" value="directory" />
|
||||
<option name="VM_PARAMETERS" value="-ea -Xbootclasspath/p:../out/classes/production/boot -XX:+HeapDumpOnOutOfMemoryError -Xmx512m -XX:MaxPermSize=320m -Didea.system.path=../test-system -Didea.home.path=../ -Didea.config.path=../test-config -Didea.test.group=ALL_EXCLUDE_DEFINED" />
|
||||
<option name="VM_PARAMETERS" value="-ea -Xbootclasspath/p:../out/classes/production/boot -XX:+HeapDumpOnOutOfMemoryError -Xmx512m -XX:MaxPermSize=320m -Didea.system.path=../test-system -Didea.home.path=. -Didea.config.path=../test-config -Didea.test.group=ALL_EXCLUDE_DEFINED" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="file://$USER_HOME$/ultimate/community" />
|
||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/../idea/intellij-community" />
|
||||
<option name="ENV_VARIABLES" />
|
||||
<option name="PASS_PARENT_ENVS" value="true" />
|
||||
<option name="TEST_SEARCH_SCOPE">
|
||||
|
@ -3,6 +3,7 @@ package com.simpleplugin;
|
||||
import com.intellij.codeInsight.intention.impl.BaseIntentionAction;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
@ -74,16 +75,21 @@ class CreatePropertyQuickFix extends BaseIntentionAction {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleFile simpleFile = (SimpleFile) PsiManager.getInstance(project).findFile(file);
|
||||
ASTNode lastChildNode = simpleFile.getNode().getLastChildNode();
|
||||
if (lastChildNode != null && !lastChildNode.getElementType().equals(SimpleTypes.CRLF)) {
|
||||
simpleFile.getNode().addChild(SimpleElementFactory.createCRLF(project).getNode());
|
||||
}
|
||||
SimpleProperty property = SimpleElementFactory.createProperty(project, key, "");
|
||||
simpleFile.getNode().addChild(property.getNode());
|
||||
((Navigatable) property.getLastChild().getNavigationElement()).navigate(true);
|
||||
FileEditorManager.getInstance(project).getSelectedTextEditor().getCaretModel().
|
||||
moveCaretRelatively(2, 0, false, false, false);
|
||||
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleFile simpleFile = (SimpleFile) PsiManager.getInstance(project).findFile(file);
|
||||
ASTNode lastChildNode = simpleFile.getNode().getLastChildNode();
|
||||
if (lastChildNode != null && !lastChildNode.getElementType().equals(SimpleTypes.CRLF)) {
|
||||
simpleFile.getNode().addChild(SimpleElementFactory.createCRLF(project).getNode());
|
||||
}
|
||||
SimpleProperty property = SimpleElementFactory.createProperty(project, key, "");
|
||||
simpleFile.getNode().addChild(property.getNode());
|
||||
((Navigatable) property.getLastChild().getNavigationElement()).navigate(true);
|
||||
FileEditorManager.getInstance(project).getSelectedTextEditor().getCaretModel().
|
||||
moveCaretRelatively(2, 0, false, false, false);
|
||||
}
|
||||
}, null, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.simpleplugin;
|
||||
import com.intellij.lang.annotation.Annotation;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.openapi.editor.SyntaxHighlighterColors;
|
||||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@ -27,7 +27,7 @@ public class SimpleAnnotator implements Annotator {
|
||||
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 7,
|
||||
element.getTextRange().getStartOffset() + 7);
|
||||
Annotation annotation = holder.createInfoAnnotation(range, null);
|
||||
annotation.setTextAttributes(SyntaxHighlighterColors.LINE_COMMENT);
|
||||
annotation.setTextAttributes(DefaultLanguageHighlighterColors.LINE_COMMENT);
|
||||
} else if (properties.size() == 0) {
|
||||
TextRange range = new TextRange(element.getTextRange().getStartOffset() + 8,
|
||||
element.getTextRange().getEndOffset());
|
||||
|
@ -1,10 +1,8 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.find.impl.HelpID;
|
||||
import com.intellij.lang.cacheBuilder.DefaultWordsScanner;
|
||||
import com.intellij.lang.cacheBuilder.WordsScanner;
|
||||
import com.intellij.lang.findUsages.FindUsagesProvider;
|
||||
import com.intellij.lexer.FlexAdapter;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
@ -13,8 +11,6 @@ import com.simpleplugin.psi.SimpleTypes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.Reader;
|
||||
|
||||
public class SimpleFindUsagesProvider implements FindUsagesProvider {
|
||||
private static final DefaultWordsScanner WORDS_SCANNER =
|
||||
new DefaultWordsScanner(new SimpleLexerAdapter(),
|
||||
@ -34,7 +30,7 @@ public class SimpleFindUsagesProvider implements FindUsagesProvider {
|
||||
@Nullable
|
||||
@Override
|
||||
public String getHelpId(@NotNull PsiElement psiElement) {
|
||||
return HelpID.FIND_OTHER_USAGES;
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -20,7 +20,7 @@ public class SimpleFormattingModelBuilder implements FormattingModelBuilder {
|
||||
}
|
||||
|
||||
private static SpacingBuilder createSpaceBuilder(CodeStyleSettings settings) {
|
||||
return new SpacingBuilder(settings).
|
||||
return new SpacingBuilder(settings, SimpleLanguage.INSTANCE).
|
||||
around(SimpleTypes.SEPARATOR).spaceIf(settings.SPACE_AROUND_ASSIGNMENT_OPERATORS).
|
||||
before(SimpleTypes.PROPERTY).none();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.intellij.ide.structureView.StructureViewBuilder;
|
||||
import com.intellij.ide.structureView.StructureViewModel;
|
||||
import com.intellij.ide.structureView.TreeBasedStructureViewBuilder;
|
||||
import com.intellij.lang.PsiStructureViewFactory;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -15,7 +16,7 @@ public class SimpleStructureViewFactory implements PsiStructureViewFactory {
|
||||
return new TreeBasedStructureViewBuilder() {
|
||||
@NotNull
|
||||
@Override
|
||||
public StructureViewModel createStructureViewModel() {
|
||||
public StructureViewModel createStructureViewModel(@Nullable Editor editor) {
|
||||
return new SimpleStructureViewModel(psiFile);
|
||||
}
|
||||
};
|
||||
|
@ -1,29 +1,23 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.lexer.FlexAdapter;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.editor.SyntaxHighlighterColors;
|
||||
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors;
|
||||
import com.intellij.openapi.editor.HighlighterColors;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighterBase;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.simpleplugin.psi.SimpleTypes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.Reader;
|
||||
|
||||
import static com.intellij.openapi.editor.colors.TextAttributesKey.createTextAttributesKey;
|
||||
|
||||
public class SimpleSyntaxHighlighter extends SyntaxHighlighterBase {
|
||||
public static final TextAttributesKey SEPARATOR = createTextAttributesKey("SIMPLE_SEPARATOR", SyntaxHighlighterColors.OPERATION_SIGN);
|
||||
public static final TextAttributesKey KEY = createTextAttributesKey("SIMPLE_KEY", SyntaxHighlighterColors.KEYWORD);
|
||||
public static final TextAttributesKey VALUE = createTextAttributesKey("SIMPLE_VALUE", SyntaxHighlighterColors.STRING);
|
||||
public static final TextAttributesKey COMMENT = createTextAttributesKey("SIMPLE_COMMENT", SyntaxHighlighterColors.LINE_COMMENT);
|
||||
|
||||
static final TextAttributesKey BAD_CHARACTER = createTextAttributesKey("SIMPLE_BAD_CHARACTER",
|
||||
new TextAttributes(Color.RED, null, null, null, Font.BOLD));
|
||||
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};
|
||||
|
@ -1,17 +0,0 @@
|
||||
package com.simpleplugin;
|
||||
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.simpleplugin.SimpleLanguage;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SimpleTokenType." + super.toString();
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
public class Test {
|
||||
public static void main(String[] args) <fold text='{...}'>{
|
||||
System.out.println("<fold text='http://en.wikipedia.org/'>simple:website</fold>");
|
||||
public static void main(String[] args)<fold text=' { '> {
|
||||
</fold>System.out.println("<fold text='http://en.wikipedia.org/'>simple:website</fold>");<fold text=' }'>
|
||||
}</fold>
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.simpleplugin;
|
||||
import com.intellij.codeInsight.completion.CompletionType;
|
||||
import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
@ -39,7 +40,12 @@ public class SimpleCodeInsightTest extends LightCodeInsightFixtureTestCase {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CodeStyleManager.getInstance(getProject()).reformat(myFixture.getFile());
|
||||
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CodeStyleManager.getInstance(getProject()).reformat(myFixture.getFile());
|
||||
}
|
||||
}, null, null);
|
||||
}
|
||||
});
|
||||
myFixture.checkResultByFile("DefaultTestData.simple");
|
||||
|
Loading…
x
Reference in New Issue
Block a user