Search in sources :

Example 91 with CodeStyleSettings

use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-plugins by JetBrains.

the class ActionScriptFormatterTest method testCdataDamaged.

public void testCdataDamaged() throws Exception {
    final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
    final XmlCodeStyleSettings xmlSettings = styleSettings.getCustomSettings(XmlCodeStyleSettings.class);
    int before = styleSettings.getTabSize(StdFileTypes.XML);
    int aroundCDataBefore = xmlSettings.XML_WHITE_SPACE_AROUND_CDATA;
    try {
        styleSettings.getIndentOptions(StdFileTypes.XML).TAB_SIZE = 4;
        xmlSettings.XML_WHITE_SPACE_AROUND_CDATA = XmlCodeStyleSettings.WS_AROUND_CDATA_NEW_LINES;
        myUseReformatText = true;
        doTestFromFile("mxml");
    } finally {
        styleSettings.getIndentOptions(StdFileTypes.XML).TAB_SIZE = before;
        xmlSettings.XML_WHITE_SPACE_AROUND_CDATA = aroundCDataBefore;
        myUseReformatText = false;
    }
}
Also used : JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings) CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) XmlCodeStyleSettings(com.intellij.psi.formatter.xml.XmlCodeStyleSettings) ECMA4CodeStyleSettings(com.intellij.lang.javascript.formatter.ECMA4CodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) XmlCodeStyleSettings(com.intellij.psi.formatter.xml.XmlCodeStyleSettings)

Example 92 with CodeStyleSettings

use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-plugins by JetBrains.

the class ActionScriptFormatterTest method testActionScriptRestParameter.

public void testActionScriptRestParameter() throws Exception {
    final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings();
    final JSCodeStyleSettings jsSettings = settings.getCustomSettings(ECMA4CodeStyleSettings.class);
    jsSettings.SPACE_AFTER_DOTS_IN_REST_PARAMETER = false;
    doTest("class Bar {\n" + "    public function foo(...    rest):void {\n" + "    }\n" + "}", "class Bar {\n" + "    public function foo(...rest):void {\n" + "    }\n" + "}", ".as");
    jsSettings.SPACE_AFTER_DOTS_IN_REST_PARAMETER = true;
    doTest("class Bar {\n" + "    public function foo(...    rest):void {\n" + "    }\n" + "}", "class Bar {\n" + "    public function foo(... rest):void {\n" + "    }\n" + "}", ".as");
}
Also used : JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings) CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) XmlCodeStyleSettings(com.intellij.psi.formatter.xml.XmlCodeStyleSettings) ECMA4CodeStyleSettings(com.intellij.lang.javascript.formatter.ECMA4CodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings)

Example 93 with CodeStyleSettings

use of com.intellij.psi.codeStyle.CodeStyleSettings in project android by JetBrains.

the class AndroidCodeStyleNotificationProvider method createNotificationPanel.

@Nullable
@Override
public MyPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
    if (file.getFileType() != XmlFileType.INSTANCE || !(fileEditor instanceof TextEditor)) {
        return null;
    }
    final Module module = ModuleUtilCore.findModuleForFile(file, myProject);
    if (module == null) {
        return null;
    }
    final AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet == null) {
        return null;
    }
    final VirtualFile parent = file.getParent();
    final VirtualFile resDir = parent != null ? parent.getParent() : null;
    if (resDir == null || !facet.getLocalResourceManager().isResourceDir(resDir)) {
        return null;
    }
    final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(myProject);
    final AndroidXmlCodeStyleSettings androidSettings = AndroidXmlCodeStyleSettings.getInstance(settings);
    if (androidSettings.USE_CUSTOM_SETTINGS) {
        return null;
    }
    if (NotificationsConfigurationImpl.getSettings(ANDROID_XML_CODE_STYLE_NOTIFICATION_GROUP).getDisplayType() == NotificationDisplayType.NONE) {
        return null;
    }
    NotificationsConfiguration.getNotificationsConfiguration().register(ANDROID_XML_CODE_STYLE_NOTIFICATION_GROUP, NotificationDisplayType.BALLOON, false);
    return new MyPanel();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) TextEditor(com.intellij.openapi.fileEditor.TextEditor) Module(com.intellij.openapi.module.Module) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

Example 94 with CodeStyleSettings

use of com.intellij.psi.codeStyle.CodeStyleSettings in project android-butterknife-zelezny by avast.

the class Utils method getPrefix.

/**
 * Load field name prefix from code style
 *
 * @return
 */
public static String getPrefix() {
    if (PropertiesComponent.getInstance().isValueSet(Settings.PREFIX)) {
        return PropertiesComponent.getInstance().getValue(Settings.PREFIX);
    } else {
        CodeStyleSettingsManager manager = CodeStyleSettingsManager.getInstance();
        CodeStyleSettings settings = manager.getCurrentSettings();
        return settings.FIELD_NAME_PREFIX;
    }
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) CodeStyleSettingsManager(com.intellij.psi.codeStyle.CodeStyleSettingsManager)

Example 95 with CodeStyleSettings

use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-plugins by JetBrains.

the class RubyMotionOverriddenMethodGenerator method generateObjCOverride.

private static PsiElement generateObjCOverride(Project project, Function function, @NotNull final LanguageLevel languageLevel) {
    final StringBuilder text = new StringBuilder();
    text.append("def ");
    text.append(MotionSymbolUtil.getSelectorNames(function).get(0));
    final List<Pair<String, String>> arguments = function.getArguments();
    if (arguments.size() > 0) {
        final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);
        final boolean generateParenthesesAroundArguments = settings.PARENTHESES_AROUND_METHOD_ARGUMENTS;
        text.append(generateParenthesesAroundArguments ? "(" : " ");
        text.append(arguments.get(0).first);
        final String[] namedArguments = function.getName().split(":");
        for (int i = 1; i < namedArguments.length; i++) {
            String argument = namedArguments[i];
            text.append(", ").append(argument).append(":").append(arguments.get(i).first);
        }
        text.append(generateParenthesesAroundArguments ? ")" : "");
    }
    text.append("\n").append("  super\nend\n");
    return RubyElementFactory.createElementFromText(project, text.toString(), languageLevel);
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) Pair(com.intellij.openapi.util.Pair)

Aggregations

CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)190 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)84 Project (com.intellij.openapi.project.Project)12 XmlCodeStyleSettings (com.intellij.psi.formatter.xml.XmlCodeStyleSettings)12 ECMA4CodeStyleSettings (com.intellij.lang.javascript.formatter.ECMA4CodeStyleSettings)9 JSCodeStyleSettings (com.intellij.lang.javascript.formatter.JSCodeStyleSettings)9 Document (com.intellij.openapi.editor.Document)9 JavaCodeStyleSettings (com.intellij.psi.codeStyle.JavaCodeStyleSettings)9 NotNull (org.jetbrains.annotations.NotNull)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 PsiFile (com.intellij.psi.PsiFile)5 Nullable (org.jetbrains.annotations.Nullable)5 FormattingModel (com.intellij.formatting.FormattingModel)4 PsiElement (com.intellij.psi.PsiElement)4 CodeStyleSettingsManager (com.intellij.psi.codeStyle.CodeStyleSettingsManager)4 File (java.io.File)4 FormattingModelBuilder (com.intellij.formatting.FormattingModelBuilder)3 ASTNode (com.intellij.lang.ASTNode)3 Language (com.intellij.lang.Language)3 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)3