mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix possible NPE because Kotlin toBoolean doesn't accept null opposite to Java API.
This commit is contained in:
+4
-19
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.profile.codeInspection
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfile
|
||||
@@ -37,6 +23,7 @@ import com.intellij.project.isDirectoryBased
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopeManager
|
||||
import com.intellij.psi.search.scope.packageSet.NamedScopesHolder
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import com.intellij.util.getAttributeBooleanValue
|
||||
import com.intellij.util.loadElement
|
||||
import com.intellij.util.xmlb.Accessor
|
||||
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters
|
||||
@@ -238,10 +225,8 @@ class ProjectInspectionProfileManager(val project: Project,
|
||||
if (data != null && data.getChild("version")?.getAttributeValue("value") != VERSION) {
|
||||
for (o in data.getChildren("option")) {
|
||||
if (o.getAttributeValue("name") == "USE_PROJECT_LEVEL_SETTINGS") {
|
||||
if (o.getAttributeValue("value").toBoolean()) {
|
||||
if (newState.projectProfile != null) {
|
||||
currentProfile.convert(data, project)
|
||||
}
|
||||
if (o.getAttributeBooleanValue("value") && newState.projectProfile != null) {
|
||||
currentProfile.convert(data, project)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
+15
-17
@@ -1,18 +1,16 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o.
|
||||
//
|
||||
// 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.intellij.codeInsight.hints.settings
|
||||
|
||||
import com.intellij.lang.Language
|
||||
@@ -20,6 +18,7 @@ import com.intellij.openapi.components.PersistentStateComponent
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.components.State
|
||||
import com.intellij.openapi.components.Storage
|
||||
import com.intellij.util.getAttributeBooleanValue
|
||||
import org.jdom.Element
|
||||
|
||||
|
||||
@@ -133,8 +132,7 @@ class ParameterNameHintsSettings : PersistentStateComponent<Element> {
|
||||
|
||||
state.getChildren("option").forEach {
|
||||
val id = it.getAttributeValue("id")
|
||||
val value = it.getAttributeValue("value").toBoolean()
|
||||
options[id] = value
|
||||
options[id] = it.getAttributeBooleanValue("value")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.util.IconUtil
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.containers.*
|
||||
import com.intellij.util.getAttributeBooleanValue
|
||||
import com.intellij.util.text.UniqueNameGenerator
|
||||
import gnu.trove.THashMap
|
||||
import org.jdom.Element
|
||||
@@ -605,7 +606,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
|
||||
|
||||
for (element in parentNode.children) {
|
||||
val config = loadConfiguration(element, false)
|
||||
if (selectedConfigurationId == null && element.getAttributeValue(SELECTED_ATTR).toBoolean()) {
|
||||
if (selectedConfigurationId == null && element.getAttributeBooleanValue(SELECTED_ATTR)) {
|
||||
selectedConfigurationId = config.uniqueID
|
||||
}
|
||||
}
|
||||
@@ -693,7 +694,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi
|
||||
}
|
||||
else {
|
||||
addConfiguration(settings)
|
||||
if (element.getAttributeValue(SELECTED_ATTR).toBoolean()) {
|
||||
if (element.getAttributeBooleanValue(SELECTED_ATTR)) {
|
||||
// to support old style
|
||||
selectedConfiguration = settings
|
||||
}
|
||||
|
||||
+4
-3
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.*
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.util.PathUtilRt
|
||||
import com.intellij.util.SmartList
|
||||
import com.intellij.util.getAttributeBooleanValue
|
||||
import gnu.trove.THashMap
|
||||
import gnu.trove.THashSet
|
||||
import org.jdom.Element
|
||||
@@ -148,16 +149,16 @@ class RunnerAndConfigurationSettingsImpl @JvmOverloads constructor(private val m
|
||||
override fun getFolderName() = folderName
|
||||
|
||||
fun readExternal(element: Element, isShared: Boolean) {
|
||||
isTemplate = element.getAttributeValue(TEMPLATE_FLAG_ATTRIBUTE).toBoolean()
|
||||
isTemplate = element.getAttributeBooleanValue(TEMPLATE_FLAG_ATTRIBUTE)
|
||||
|
||||
if (isShared) {
|
||||
level = RunConfigurationLevel.PROJECT
|
||||
}
|
||||
else {
|
||||
level = if (element.getAttributeValue(TEMPORARY_ATTRIBUTE).toBoolean() || TEMP_CONFIGURATION == element.name) RunConfigurationLevel.TEMPORARY else RunConfigurationLevel.WORKSPACE
|
||||
level = if (element.getAttributeBooleanValue(TEMPORARY_ATTRIBUTE) || TEMP_CONFIGURATION == element.name) RunConfigurationLevel.TEMPORARY else RunConfigurationLevel.WORKSPACE
|
||||
}
|
||||
|
||||
isEditBeforeRun = (element.getAttributeValue(EDIT_BEFORE_RUN)).toBoolean()
|
||||
isEditBeforeRun = (element.getAttributeBooleanValue(EDIT_BEFORE_RUN))
|
||||
val value = element.getAttributeValue(ACTIVATE_TOOLWINDOW_BEFORE_RUN)
|
||||
isActivateToolWindowBeforeRun = value == null || value.toBoolean()
|
||||
folderName = element.getAttributeValue(FOLDER_NAME)
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util
|
||||
|
||||
import com.intellij.openapi.util.JDOMUtil
|
||||
@@ -140,4 +126,6 @@ fun Parent.toBufferExposingByteArray(lineSeparator: String = "\n"): BufferExposi
|
||||
val out = BufferExposingByteArrayOutputStream(512)
|
||||
JDOMUtil.write(this, out, lineSeparator)
|
||||
return out
|
||||
}
|
||||
}
|
||||
|
||||
fun Element.getAttributeBooleanValue(name: String): Boolean = java.lang.Boolean.parseBoolean(getAttributeValue(name))
|
||||
Reference in New Issue
Block a user