diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackagePrefixFileSystemItemImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackagePrefixFileSystemItemImpl.java index 8cd24dc08baf..f4f88c34679a 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackagePrefixFileSystemItemImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackagePrefixFileSystemItemImpl.java @@ -202,7 +202,7 @@ class PackagePrefixFileSystemItemImpl extends PsiElementBase implements PsiFileS } @Override - public boolean processChildren(final PsiElementProcessor processor) { + public boolean processChildren(@NotNull final PsiElementProcessor processor) { if (myIndex == myPackages.length - 1) { return myDirectory.processChildren(processor); } diff --git a/java/testFramework/src/com/intellij/mock/MockPsiDirectory.java b/java/testFramework/src/com/intellij/mock/MockPsiDirectory.java index 0d84806498a4..57eb6e303dd7 100644 --- a/java/testFramework/src/com/intellij/mock/MockPsiDirectory.java +++ b/java/testFramework/src/com/intellij/mock/MockPsiDirectory.java @@ -135,7 +135,7 @@ public class MockPsiDirectory extends MockPsiElement implements PsiDirectory { } @Override - public boolean processChildren(final PsiElementProcessor processor) { + public boolean processChildren(@NotNull final PsiElementProcessor processor) { throw new UnsupportedOperationException("Method processChildren is not yet implemented in " + getClass().getName()); } diff --git a/platform/core-api/src/com/intellij/psi/PsiFileSystemItem.java b/platform/core-api/src/com/intellij/psi/PsiFileSystemItem.java index ce4c7b697641..78e0771657f8 100644 --- a/platform/core-api/src/com/intellij/psi/PsiFileSystemItem.java +++ b/platform/core-api/src/com/intellij/psi/PsiFileSystemItem.java @@ -36,8 +36,9 @@ public interface PsiFileSystemItem extends PsiCheckedRenameElement, NavigatableP VirtualFile getVirtualFile(); @Override - @NotNull @NonNls + @NotNull + @NonNls String getName(); - boolean processChildren(PsiElementProcessor processor); + boolean processChildren(@NotNull PsiElementProcessor processor); } diff --git a/platform/core-api/src/com/intellij/psi/util/PsiUtilCore.java b/platform/core-api/src/com/intellij/psi/util/PsiUtilCore.java index c2a2f6bbb8b1..7afe35ac94ca 100644 --- a/platform/core-api/src/com/intellij/psi/util/PsiUtilCore.java +++ b/platform/core-api/src/com/intellij/psi/util/PsiUtilCore.java @@ -671,7 +671,7 @@ public class PsiUtilCore { } @Override - public boolean processChildren(PsiElementProcessor processor) { + public boolean processChildren(@NotNull PsiElementProcessor processor) { throw createException(); } diff --git a/platform/core-impl/src/com/intellij/psi/impl/file/PsiBinaryFileImpl.java b/platform/core-impl/src/com/intellij/psi/impl/file/PsiBinaryFileImpl.java index 6ec4a959f423..d19583e2ebbc 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/file/PsiBinaryFileImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/file/PsiBinaryFileImpl.java @@ -55,7 +55,7 @@ public class PsiBinaryFileImpl extends PsiElementBase implements PsiBinaryFile, } @Override - public boolean processChildren(final PsiElementProcessor processor) { + public boolean processChildren(@NotNull final PsiElementProcessor processor) { return true; } diff --git a/platform/core-impl/src/com/intellij/psi/impl/file/PsiDirectoryImpl.java b/platform/core-impl/src/com/intellij/psi/impl/file/PsiDirectoryImpl.java index 2d0a8e702abd..4f916fee54fb 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/file/PsiDirectoryImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/file/PsiDirectoryImpl.java @@ -172,7 +172,7 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory, Qu } @Override - public boolean processChildren(PsiElementProcessor processor) { + public boolean processChildren(@NotNull PsiElementProcessor processor) { checkValid(); for (VirtualFile vFile : myFile.getChildren()) { diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java index 2e36a3c9a4cb..f095402a1394 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java @@ -124,7 +124,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF } @Override - public boolean processChildren(final PsiElementProcessor processor) { + public boolean processChildren(@NotNull final PsiElementProcessor processor) { return true; } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/LightPsiFileImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/source/LightPsiFileImpl.java index 578b93a39b2a..201c19bd5eb5 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/LightPsiFileImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/LightPsiFileImpl.java @@ -42,7 +42,7 @@ public abstract class LightPsiFileImpl extends PsiElementBase implements PsiFile } @Override - public boolean processChildren(final PsiElementProcessor processor) { + public boolean processChildren(@NotNull final PsiElementProcessor processor) { return true; } diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java index 66efc2946589..a41f3a39835e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/newvfs/VfsImplUtil.java @@ -125,7 +125,7 @@ public class VfsImplUtil { @Nullable private static Pair> prepare(@NotNull NewVirtualFileSystem vfs, @NotNull String path) { - String normalizedPath = normalize(vfs, path); + String normalizedPath = vfs.normalize(path); if (StringUtil.isEmptyOrSpaces(normalizedPath)) { return null; } diff --git a/platform/testFramework/src/com/intellij/mock/MockPsiFile.java b/platform/testFramework/src/com/intellij/mock/MockPsiFile.java index 95e2094b84b5..8891e5e97d6a 100644 --- a/platform/testFramework/src/com/intellij/mock/MockPsiFile.java +++ b/platform/testFramework/src/com/intellij/mock/MockPsiFile.java @@ -63,7 +63,7 @@ public class MockPsiFile extends MockPsiElement implements PsiFile { } @Override - public boolean processChildren(final PsiElementProcessor processor) { + public boolean processChildren(@NotNull final PsiElementProcessor processor) { return true; } diff --git a/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/psi/PropertiesFile.java b/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/psi/PropertiesFile.java index 8be7d42ee118..18b89de410a6 100644 --- a/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/psi/PropertiesFile.java +++ b/plugins/properties/properties-psi-api/src/com/intellij/lang/properties/psi/PropertiesFile.java @@ -45,7 +45,8 @@ public interface PropertiesFile { /** * @return All properties found in this file. */ - @NotNull List getProperties(); + @NotNull + List getProperties(); /** * @@ -57,13 +58,16 @@ public interface PropertiesFile { IProperty findPropertyByKey(@NotNull @NonNls String key); /** - * @param key * @return All properties found in this file with the name specified. */ - @NotNull List findPropertiesByKey(@NotNull @NonNls String key); + @NotNull + List findPropertiesByKey(@NotNull @NonNls String key); - @NotNull ResourceBundle getResourceBundle(); - @NotNull Locale getLocale(); + @NotNull + ResourceBundle getResourceBundle(); + + @NotNull + Locale getLocale(); /** * Adds property to the end of the file. @@ -71,12 +75,12 @@ public interface PropertiesFile { * @param property to add. Typically you create the property via {@link PropertiesElementFactory}. * @return newly added property. * It is this value you use to do actual PSI work, e.g. call {@link PsiElement#delete()} to remove this property from the file. - * @throws IncorrectOperationException - * @deprecated + * @deprecated use {@link #addProperty(String, String)} instead * @see #addProperty(String, String) */ @Deprecated - @NotNull PsiElement addProperty(@NotNull IProperty property) throws IncorrectOperationException; + @NotNull + PsiElement addProperty(@NotNull IProperty property) throws IncorrectOperationException; /** * Adds property to the the file after the specified property. @@ -88,9 +92,9 @@ public interface PropertiesFile { * @param anchor property after which to add the new property * @return newly added property. * It is this value you use to do actual PSI work, e.g. call {@link PsiElement#delete()} to remove this property from the file. - * @throws IncorrectOperationException */ - @NotNull PsiElement addPropertyAfter(@NotNull IProperty property, @Nullable IProperty anchor) throws IncorrectOperationException; + @NotNull + PsiElement addPropertyAfter(@NotNull IProperty property, @Nullable IProperty anchor) throws IncorrectOperationException; /** * Adds property to the the file after the specified property. @@ -100,18 +104,21 @@ public interface PropertiesFile { * @param value of a property to add. * @param anchor property after which to add the new property * @return newly added property. - * @throws IncorrectOperationException */ - IProperty addPropertyAfter(String key, String value, IProperty anchor) throws IncorrectOperationException; + @NotNull + IProperty addPropertyAfter(@NotNull String key, @NotNull String value, IProperty anchor) throws IncorrectOperationException; - IProperty addProperty(String key, String value); + @NotNull + IProperty addProperty(@NotNull String key, @NotNull String value); /** * @return Property key to the property value map. * Do not modify this map. It's no use anyway. */ - @NotNull Map getNamesMap(); + @NotNull + Map getNamesMap(); + @NotNull String getName(); VirtualFile getVirtualFile(); @@ -121,6 +128,7 @@ public interface PropertiesFile { */ PsiDirectory getParent(); + @NotNull Project getProject(); String getText(); diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/psi/impl/PropertiesFileImpl.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/psi/impl/PropertiesFileImpl.java index e00b4a1618f1..9fcdf8b23bbe 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/psi/impl/PropertiesFileImpl.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/psi/impl/PropertiesFileImpl.java @@ -67,7 +67,8 @@ public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile { if (stub != null) { PropertiesListStub propertiesListStub = stub.findChildStubByType(PropertiesElementTypes.PROPERTIES_LIST); propertiesList = propertiesListStub == null ? null : propertiesListStub.getPsi(); - } else { + } + else { propertiesList = PsiTreeUtil.findChildOfType(this, PropertiesList.class); } return Collections.unmodifiableList(PsiTreeUtil.getStubChildrenOfTypeAsList(propertiesList, Property.class)); @@ -123,10 +124,8 @@ public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile { List properties = getProperties(); ASTNode anchorBefore = anchor == null ? properties.isEmpty() ? null : properties.get(0).getPsiElement().getNode() : anchor.getPsiElement().getNode().getTreeNext(); - if (anchorBefore != null) { - if (anchorBefore.getElementType() == TokenType.WHITE_SPACE) { - anchorBefore = anchorBefore.getTreeNext(); - } + if (anchorBefore != null && anchorBefore.getElementType() == TokenType.WHITE_SPACE) { + anchorBefore = anchorBefore.getTreeNext(); } if (anchorBefore == null && haveToAddNewLine()) { insertLineBreakBefore(null); @@ -140,21 +139,22 @@ public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile { @NotNull @Override - public IProperty addProperty(String key, String value) { + public IProperty addProperty(@NotNull String key, @NotNull String value) { return (IProperty)addProperty(PropertiesElementFactory.createProperty(getProject(), key, value, null)); } @NotNull @Override - public IProperty addPropertyAfter(String key, String value, @Nullable IProperty anchor) { + public IProperty addPropertyAfter(@NotNull String key, @NotNull String value, @Nullable IProperty anchor) { return (IProperty)addPropertyAfter(PropertiesElementFactory.createProperty(getProject(), key, value, null), anchor); } - private void insertLineBreakBefore(final ASTNode anchorBefore) { + private void insertLineBreakBefore(ASTNode anchorBefore) { ASTNode propertiesList = getPropertiesList(); if (anchorBefore == null && propertiesList.getFirstChildNode() == null) { getNode().addChild(ASTFactory.whitespace("\n"), propertiesList); - } else { + } + else { propertiesList.addChild(ASTFactory.whitespace("\n"), anchorBefore); } } @@ -199,14 +199,13 @@ public class PropertiesFileImpl extends PsiFileBase implements PropertiesFile { return ContainerUtil.getLastItem(properties); } + @NotNull private Stream propertiesByKey(@NotNull String key) { if (shouldReadIndex()) { return PropertyKeyIndex.getInstance().get(key, getProject(), GlobalSearchScope.fileScope(this)).stream(); } - else { - // see PropertiesElementFactory.createPropertiesFile(Project, Properties, String) - return getProperties().stream().filter(p -> key.equals(p.getUnescapedKey())); - } + // see PropertiesElementFactory.createPropertiesFile(Project, Properties, String) + return getProperties().stream().filter(p -> key.equals(p.getUnescapedKey())); } private boolean shouldReadIndex() { diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/xml/XmlPropertiesFileImpl.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/xml/XmlPropertiesFileImpl.java index 866ecabc96e2..50884615cbc5 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/xml/XmlPropertiesFileImpl.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/xml/XmlPropertiesFileImpl.java @@ -140,8 +140,9 @@ public class XmlPropertiesFileImpl extends XmlPropertiesFile { return addPropertyAfter(property.getKey(), property.getValue(), anchor).getPsiElement().getNavigationElement(); } + @NotNull @Override - public IProperty addPropertyAfter(String key, String value, IProperty anchor) { + public IProperty addPropertyAfter(@NotNull String key, @NotNull String value, IProperty anchor) { return addPropertyAfter(key, value, anchor, true); } @@ -156,7 +157,7 @@ public class XmlPropertiesFileImpl extends XmlPropertiesFile { @NotNull @Override - public IProperty addProperty(String key, String value) { + public IProperty addProperty(@NotNull String key, @NotNull String value) { final XmlTag entry = createPropertyTag(key, value); synchronized (myLock) { ensurePropertiesLoaded(); @@ -221,6 +222,7 @@ public class XmlPropertiesFileImpl extends XmlPropertiesFile { return result; } + @NotNull @Override public String getName() { return getContainingFile().getName(); @@ -236,6 +238,7 @@ public class XmlPropertiesFileImpl extends XmlPropertiesFile { return getContainingFile().getParent(); } + @NotNull @Override public Project getProject() { return getContainingFile().getProject(); diff --git a/plugins/properties/src/com/intellij/lang/properties/editor/PropertiesCopyHandler.java b/plugins/properties/src/com/intellij/lang/properties/editor/PropertiesCopyHandler.java index 4ccf8a558069..092e8d24d24a 100644 --- a/plugins/properties/src/com/intellij/lang/properties/editor/PropertiesCopyHandler.java +++ b/plugins/properties/src/com/intellij/lang/properties/editor/PropertiesCopyHandler.java @@ -314,7 +314,7 @@ public class PropertiesCopyHandler extends CopyHandlerDelegateBase { } @Override - public boolean processChildren(PsiElementProcessor processor) { + public boolean processChildren(@NotNull PsiElementProcessor processor) { for (PropertiesFile propertiesFile : myResourceBundle.getPropertiesFiles()) { if (!propertiesFile.getContainingFile().processChildren(processor)) { return false;