XmlAttribute#getValue|getDisplayValue are @Nullable: fix some potential NPEs

This commit is contained in:
Yann Cébron
2013-03-08 08:58:46 +01:00
parent 4754c9007f
commit 8ac3b416f9
3 changed files with 7 additions and 6 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -86,7 +86,7 @@ public class AddSchemaPrefixIntention extends PsiElementBaseIntentionAction {
tag.accept(new XmlRecursiveElementVisitor() {
@Override
public void visitXmlTag(XmlTag tag) {
if (namespace.equals(tag.getNamespace()) && tag.getNamespacePrefix().length() == 0) {
if (tag.getNamespace().equals(namespace) && tag.getNamespacePrefix().length() == 0) {
tags.add(tag);
}
super.visitXmlTag(tag);
@@ -109,7 +109,7 @@ public class AddSchemaPrefixIntention extends PsiElementBaseIntentionAction {
if (xmlElement instanceof XmlElement) {
final XmlTag tag = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class, false);
if (tag != null) {
if (namespace.equals(tag.getNamespace())) {
if (tag.getNamespace().equals(namespace)) {
if (ref.getRangeInElement().getLength() == value.getValue().length()) { //no ns prefix
values.add(value);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -92,6 +92,7 @@ public class ConvertSchemaPrefixToDefaultIntention extends PsiElementBaseIntenti
}
}
for (XmlAttribute attr : attrs) {
//noinspection ConstantConditions
attr.setValue(attr.getValue().substring(index));
}
xmlns.setName("xmlns");
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -229,7 +229,7 @@ public class DefaultXmlExtension extends XmlExtension {
rootTag.add(xmlAttribute);
} else {
final String value = xmlAttribute.getValue();
if (!value.contains(namespace)) {
if (value != null && !value.contains(namespace)) {
if (StringUtil.isEmptyOrSpaces(value)) {
xmlAttribute.setValue(pair);
} else {