Ilya Ryzhenkov
2 years ago
14 changed files with 134 additions and 69 deletions
@ -0,0 +1,35 @@
|
||||
/* |
||||
* Copyright (C) 2020 The Android Open Source Project |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package com.android.tools.compose |
||||
|
||||
import androidx.compose.compiler.plugins.kotlin.ComposeIrGenerationExtension |
||||
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension |
||||
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext |
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment |
||||
|
||||
@Suppress("INVISIBLE_REFERENCE", "EXPERIMENTAL_IS_NOT_ENABLED") |
||||
@OptIn(org.jetbrains.kotlin.extensions.internal.InternalNonStableExtensionPoints::class) |
||||
class ComposePluginIrGenerationExtension : IrGenerationExtension { |
||||
override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) { |
||||
try { |
||||
ComposeIrGenerationExtension(reportsDestination = null, |
||||
metricsDestination = null).generate(moduleFragment, pluginContext); |
||||
} catch (t : Throwable) { |
||||
t.printStackTrace() |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
/* |
||||
* Copyright (C) 2021 The Android Open Source Project |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.android.tools.compose.settings; |
||||
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings; |
||||
import com.intellij.psi.codeStyle.CustomCodeStyleSettings; |
||||
|
||||
// Don't convert to Kotlin due to the serialization implementation for Settings.
|
||||
public class ComposeCustomCodeStyleSettings extends CustomCodeStyleSettings { |
||||
public boolean USE_CUSTOM_FORMATTING_FOR_MODIFIERS = true; |
||||
|
||||
protected ComposeCustomCodeStyleSettings(CodeStyleSettings container) { |
||||
super("ComposeCustomCodeStyleSettings", container); |
||||
} |
||||
|
||||
public static ComposeCustomCodeStyleSettings getInstance(CodeStyleSettings settings) { |
||||
return settings.getCustomSettings(ComposeCustomCodeStyleSettings.class); |
||||
} |
||||
} |
@ -1,31 +0,0 @@
|
||||
/* |
||||
* Copyright (C) 2021 The Android Open Source Project |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package com.android.tools.compose.settings |
||||
|
||||
import com.intellij.configurationStore.* |
||||
import com.intellij.psi.codeStyle.* |
||||
|
||||
class ComposeCustomCodeStyleSettings(settings: CodeStyleSettings) : CustomCodeStyleSettings("ComposeCustomCodeStyleSettings", settings) { |
||||
@Property(externalName = "use_custom_formatting_for_modifiers") |
||||
@JvmField |
||||
var USE_CUSTOM_FORMATTING_FOR_MODIFIERS = true |
||||
|
||||
companion object { |
||||
fun getInstance(settings: CodeStyleSettings): ComposeCustomCodeStyleSettings { |
||||
return settings.getCustomSettings(ComposeCustomCodeStyleSettings::class.java) |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue