From 6bdf2d1d390240a88c664aae7082165e10765cd7 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Wed, 30 Oct 2013 19:40:12 +0400 Subject: [PATCH] made fields final, cleanup --- .../JavadocWhiteSpaceFormattingStrategy.java | 4 +-- .../java/BlockContainingJavaBlock.java | 8 +++--- .../psi/formatter/java/CodeBlockBlock.java | 8 +++--- .../java/CommentWithInjectionBlock.java | 4 +-- .../psi/formatter/java/DocCommentBlock.java | 4 +-- .../beanProperties/CreateBeanPropertyFix.java | 4 +-- .../impl/file/PsiJavaDirectoryFactory.java | 4 +-- .../psi/impl/light/LightMethodBuilder.java | 8 +++--- .../source/codeStyle/ImportsFormatter.java | 6 ++--- .../codeStyle/JavaCodeStyleManagerImpl.java | 2 +- ...edFormatterModelWithShiftIndentInside.java | 6 ++--- .../codeStyle/ShiftIndentInsideHelper.java | 6 ++--- .../source/codeStyle/javadoc/JDComment.java | 6 ++--- .../codeStyle/javadoc/JDMethodComment.java | 4 +-- .../source/codeStyle/javadoc/JDParser.java | 12 ++++----- .../providers/FilePathReferenceProvider.java | 6 ++--- .../providers/JavaClassReferenceProvider.java | 4 +-- .../source/tree/injected/MyTestInjector.java | 4 +-- .../PatternPackageSetParserExtension.java | 4 +-- .../com/intellij/psi/PsiDisjunctionType.java | 2 +- .../src/com/intellij/psi/util/ClassUtil.java | 6 ++--- .../ConditionalGoToInstruction.java | 4 +-- .../psi/controlFlow/ControlFlowUtil.java | 4 +-- .../psi/impl/compiled/ClsClassImpl.java | 8 +++--- .../psi/impl/compiled/ClsFileImpl.java | 2 +- .../impl/java/stubs/JavaClassElementType.java | 2 +- .../java/stubs/JavaMethodElementType.java | 2 +- .../impl/PsiImportStatementStubImpl.java | 4 +-- .../light/LightTypeParameterListBuilder.java | 4 +-- .../PsiJavaCodeReferenceElementImpl.java | 2 +- .../psi/impl/source/PsiJavaFileBaseImpl.java | 4 +-- .../psi/impl/source/PsiTypeElementImpl.java | 6 ++--- .../javadoc/PsiDocMethodOrFieldRef.java | 4 +-- .../impl/source/javadoc/SeeDocTagInfo.java | 2 +- .../resolve/StaticImportResolveProcessor.java | 4 +-- .../InferenceIncorporationPhase.java | 2 +- .../graphInference/InferenceSession.java | 2 +- .../graphInference/InferenceVariable.java | 4 +-- .../InferenceVariablesOrder.java | 2 +- .../graphInference/PsiPolyExpressionUtil.java | 2 +- .../ExpressionCompatibilityConstraint.java | 2 +- .../constraints/SubtypingConstraint.java | 2 +- .../psi/impl/source/tree/SourceUtil.java | 2 +- .../java/ClassPresentationProvider.java | 4 +-- .../JavaMethodsConflictResolver.java | 2 +- .../impl/source/jsp/JspContextManager.java | 11 +++++--- .../psi/impl/source/jsp/JspManager.java | 4 +-- .../scope/packageSet/PatternPackageSet.java | 4 +-- .../impl/providers/FileReference.java | 2 +- .../impl/providers/FileReferenceSet.java | 16 ++++++------ .../providers/NullFileReferenceHelper.java | 4 +-- .../com/intellij/psi/FileContextProvider.java | 6 ++--- .../com/intellij/psi/PsiReferenceBase.java | 4 +-- .../com/intellij/psi/util/QualifiedName.java | 23 ++++++++++++++--- .../reference/ReferenceProvidersRegistry.java | 4 +-- .../source/tree/ForeignLeafPsiElement.java | 4 +-- .../intellij/psi/search/FilenameIndex.java | 6 ++--- .../psi/codeStyle/PackageEntryTable.java | 4 +-- .../psi/codeStyle/PredefinedCodeStyle.java | 4 +-- .../psi/injection/ReferenceInjector.java | 2 +- ...ArrangementEntryMatcherSerializerTest.java | 4 +-- .../AbstractWhiteSpaceFormattingStrategy.java | 4 +-- .../intellij/psi/formatter/FormatterUtil.java | 19 +++++++------- .../psi/formatter/common/AbstractBlock.java | 4 +-- .../common/InjectedLanguageBlockBuilder.java | 4 +-- .../common/InjectedLanguageBlockWrapper.java | 10 ++++---- .../search/LexerEditorHighlighterLexer.java | 3 ++- .../CustomizingReferenceProvider.java | 4 +-- .../providers/PsiFileReferenceHelper.java | 4 +-- .../psi/codeStyle/MinusculeMatcher.java | 4 +-- .../intellij/psi/XmlElementFactoryImpl.java | 4 +-- .../psi/formatter/xml/AbstractXmlBlock.java | 4 +-- .../intellij/psi/formatter/xml/XmlBlock.java | 5 ++-- .../formatter/xml/XmlCodeStyleSettings.java | 8 +++--- .../xml/XmlInjectedLanguageBlockBuilder.java | 4 +-- .../psi/formatter/xml/XmlTagBlock.java | 4 +-- .../manipulators/XmlAttributeManipulator.java | 4 +-- .../impl/manipulators/XmlTagManipulator.java | 7 +++--- .../impl/manipulators/XmlTextManipulator.java | 6 ++--- .../CreateXmlElementIntentionAction.java | 2 +- .../psi/impl/source/xml/XsContentDFA.java | 4 +-- .../xml/behavior/EncodeEachSymbolPolicy.java | 6 ++--- .../psi/impl/source/html/HtmlTagImpl.java | 6 ++--- .../impl/source/html/ScriptSupportUtil.java | 4 +-- .../source/html/dtd/HtmlNSDescriptorImpl.java | 8 +++--- .../providers/SchemaReferencesProvider.java | 7 +++--- .../TypeOrElementOrAttributeReference.java | 25 +++++++++++++++---- .../impl/providers/URLReference.java | 21 +++++++++++++--- .../psi/impl/source/xml/TagNameReference.java | 4 +-- .../source/xml/TagNameVariantCollector.java | 2 +- .../psi/impl/source/xml/XmlAttributeImpl.java | 8 +++--- .../source/xml/XmlAttributeReference.java | 2 +- .../source/xml/XmlAttributeValueImpl.java | 4 +-- .../psi/impl/source/xml/XmlDocumentImpl.java | 8 +++--- .../xml/XmlElementContentGroupImpl.java | 4 +-- .../psi/impl/source/xml/XmlTagImpl.java | 18 ++++++------- .../psi/impl/source/xml/XmlTextImpl.java | 6 ++--- .../xml/behavior/CDATAOnAnyEncodedPolicy.java | 4 +-- 98 files changed, 293 insertions(+), 242 deletions(-) diff --git a/java/java-impl/src/com/intellij/psi/formatter/JavadocWhiteSpaceFormattingStrategy.java b/java/java-impl/src/com/intellij/psi/formatter/JavadocWhiteSpaceFormattingStrategy.java index 4f20b9225206..28ae06ea33c8 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/JavadocWhiteSpaceFormattingStrategy.java +++ b/java/java-impl/src/com/intellij/psi/formatter/JavadocWhiteSpaceFormattingStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -25,6 +25,6 @@ import org.jetbrains.annotations.NotNull; public class JavadocWhiteSpaceFormattingStrategy extends WhiteSpaceFormattingStrategyAdapter { @Override public boolean containsWhitespacesOnly(@NotNull final ASTNode node) { - return node.getElementType() == JavaDocTokenType.DOC_COMMENT_DATA && node.textContains('\n') && node.getText().trim().length() == 0; + return node.getElementType() == JavaDocTokenType.DOC_COMMENT_DATA && node.textContains('\n') && node.getText().trim().isEmpty(); } } diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java index 5bbd481b6e40..cb5139cdef91 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/BlockContainingJavaBlock.java @@ -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. @@ -38,9 +38,9 @@ public class BlockContainingJavaBlock extends AbstractJavaBlock{ JavaElementType.IF_STATEMENT, JavaElementType.WHILE_STATEMENT, JavaElementType.FOR_STATEMENT ); - private final static int BEFORE_FIRST = 0; - private final static int BEFORE_BLOCK = 1; - private final static int AFTER_ELSE = 2; + private static final int BEFORE_FIRST = 0; + private static final int BEFORE_BLOCK = 1; + private static final int AFTER_ELSE = 2; private final List myIndentsBefore = new ArrayList(); diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/CodeBlockBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/CodeBlockBlock.java index bcec4eff628e..574c93f950b5 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/CodeBlockBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/CodeBlockBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -36,9 +36,9 @@ import java.util.ArrayList; import java.util.List; public class CodeBlockBlock extends AbstractJavaBlock { - private final static int BEFORE_FIRST = 0; - private final static int BEFORE_LBRACE = 1; - private final static int INSIDE_BODY = 2; + private static final int BEFORE_FIRST = 0; + private static final int BEFORE_LBRACE = 1; + private static final int INSIDE_BODY = 2; private final int myChildrenIndent; diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/CommentWithInjectionBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/CommentWithInjectionBlock.java index 08bb1f44fb72..7e31f44230b0 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/CommentWithInjectionBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/CommentWithInjectionBlock.java @@ -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. @@ -30,7 +30,7 @@ import java.util.List; * @author nik */ public class CommentWithInjectionBlock extends AbstractJavaBlock { - private InjectedLanguageBlockBuilder myInjectedBlockBuilder; + private final InjectedLanguageBlockBuilder myInjectedBlockBuilder; public CommentWithInjectionBlock(ASTNode node, Wrap wrap, Alignment alignment, Indent indent, CommonCodeStyleSettings settings) { super(node, wrap, alignment, indent, settings); diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/DocCommentBlock.java b/java/java-impl/src/com/intellij/psi/formatter/java/DocCommentBlock.java index b65393f3a4b3..4bc6f6d2616b 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/DocCommentBlock.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/DocCommentBlock.java @@ -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. @@ -39,7 +39,7 @@ public class DocCommentBlock extends AbstractJavaBlock{ while (child != null) { if (child.getElementType() == JavaDocTokenType.DOC_COMMENT_START) { result.add(createJavaBlock(child, mySettings, Indent.getNoneIndent(), null, AlignmentStrategy.getNullStrategy())); - } else if (!FormatterUtil.containsWhiteSpacesOnly(child) && child.getText().trim().length() > 0){ + } else if (!FormatterUtil.containsWhiteSpacesOnly(child) && !child.getText().trim().isEmpty()){ result.add(createJavaBlock(child, mySettings, Indent.getSpaceIndent(1), null, AlignmentStrategy.getNullStrategy())); } child = child.getTreeNext(); diff --git a/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java b/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java index 47618f5594ae..053a534e0c98 100644 --- a/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java +++ b/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java @@ -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. @@ -39,7 +39,7 @@ import org.jetbrains.annotations.Nullable; */ public abstract class CreateBeanPropertyFix implements LocalQuickFix, IntentionAction { - private final static Logger LOG = Logger.getInstance("#com.intellij.psi.impl.beanProperties.CreateBeanPropertyFix"); + private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.beanProperties.CreateBeanPropertyFix"); private static final CreateBeanPropertyFix[] NO_FIXES = new CreateBeanPropertyFix[0]; protected final String myPropertyName; diff --git a/java/java-impl/src/com/intellij/psi/impl/file/PsiJavaDirectoryFactory.java b/java/java-impl/src/com/intellij/psi/impl/file/PsiJavaDirectoryFactory.java index e92396e00a2f..83761827f52d 100644 --- a/java/java-impl/src/com/intellij/psi/impl/file/PsiJavaDirectoryFactory.java +++ b/java/java-impl/src/com/intellij/psi/impl/file/PsiJavaDirectoryFactory.java @@ -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. @@ -48,7 +48,7 @@ public class PsiJavaDirectoryFactory extends PsiDirectoryFactory { final PsiPackage aPackage = JavaDirectoryService.getInstance().getPackage(directory); if (aPackage != null) { final String qualifiedName = aPackage.getQualifiedName(); - if (qualifiedName.length() > 0) return qualifiedName; + if (!qualifiedName.isEmpty()) return qualifiedName; if (presentable) { return PsiBundle.message("default.package.presentation") + " (" + directory.getVirtualFile().getPresentableUrl() + ")"; } diff --git a/java/java-impl/src/com/intellij/psi/impl/light/LightMethodBuilder.java b/java/java-impl/src/com/intellij/psi/impl/light/LightMethodBuilder.java index 70e7b8415990..d568db62854f 100644 --- a/java/java-impl/src/com/intellij/psi/impl/light/LightMethodBuilder.java +++ b/java/java-impl/src/com/intellij/psi/impl/light/LightMethodBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -46,9 +46,9 @@ public class LightMethodBuilder extends LightElement implements PsiMethod, Origi private final String myName; private Computable myReturnType; private final PsiModifierList myModifierList; - private PsiParameterList myParameterList; - private PsiTypeParameterList myTypeParameterList; - private PsiReferenceList myThrowsList; + private final PsiParameterList myParameterList; + private final PsiTypeParameterList myTypeParameterList; + private final PsiReferenceList myThrowsList; private Icon myBaseIcon; private PsiClass myContainingClass; private boolean myConstructor; diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportsFormatter.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportsFormatter.java index aaf5f98540e2..4e2f61db2624 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportsFormatter.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ImportsFormatter.java @@ -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. @@ -39,8 +39,8 @@ public class ImportsFormatter extends XmlRecursiveElementVisitor { private final FormattingDocumentModelImpl myDocumentModel; private final CommonCodeStyleSettings.IndentOptions myIndentOptions; - private static final @NonNls String PAGE_DIRECTIVE = "page"; - private static final @NonNls String IMPORT_ATT = "import"; + @NonNls private static final String PAGE_DIRECTIVE = "page"; + @NonNls private static final String IMPORT_ATT = "import"; private final PostFormatProcessorHelper myPostProcessor; diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java index 7c257dd8c83a..3056eccd9291 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/JavaCodeStyleManagerImpl.java @@ -779,7 +779,7 @@ public class JavaCodeStyleManagerImpl extends JavaCodeStyleManager { String prefix = getPrefixByVariableKind(variableKind); String name = propertyName; - if (name.length() > 0 && prefix.length() > 0 && !StringUtil.endsWithChar(prefix, '_')) { + if (!name.isEmpty() && !prefix.isEmpty() && !StringUtil.endsWithChar(prefix, '_')) { name = Character.toUpperCase(name.charAt(0)) + name.substring(1); } name = prefix + name + getSuffixByVariableKind(variableKind); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/PsiBasedFormatterModelWithShiftIndentInside.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/PsiBasedFormatterModelWithShiftIndentInside.java index 2eb7c78ca525..a819cbe3ca14 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/PsiBasedFormatterModelWithShiftIndentInside.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/PsiBasedFormatterModelWithShiftIndentInside.java @@ -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. @@ -84,7 +84,7 @@ public class PsiBasedFormatterModelWithShiftIndentInside extends PsiBasedFormatt if(type == TokenType.WHITE_SPACE) { final String text = prevNode.getText(); - final @NonNls String cdataStartMarker = ""; + @NonNls final String cdataEndMarker = "]]>"; if(type == XmlElementType.XML_CDATA_END && whiteSpace.indexOf(cdataEndMarker) == -1) { final ASTNode at = findElementAt(prevNode.getStartOffset()); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ShiftIndentInsideHelper.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ShiftIndentInsideHelper.java index f975f622407e..158e8b60cd2d 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ShiftIndentInsideHelper.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/ShiftIndentInsideHelper.java @@ -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. @@ -113,7 +113,7 @@ public class ShiftIndentInsideHelper { leafOffset = getStartOffset(element, leaf); } else { - if (newSpace.length() > 0) { + if (!newSpace.isEmpty()) { LeafElement newLeaf = ASTFactory.whitespace(newSpace); next.getTreeParent().addChild(newLeaf, next); } @@ -129,7 +129,7 @@ public class ShiftIndentInsideHelper { } String leafText = leaf.getText(); String newLeafText = leafText.substring(0, startOffset) + newSpace + leafText.substring(endOffset); - if (newLeafText.length() > 0) { + if (!newLeafText.isEmpty()) { LeafElement newLeaf = Factory.createSingleLeafElement(leaf.getElementType(), newLeafText,charTableByTree, SharedImplUtil.getManagerByTree(leaf)); if (leaf.getTreeParent() != null) { leaf.getTreeParent().replaceChild(leaf, newLeaf); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java index 740b77cb2228..0d51c0d2111f 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDComment.java @@ -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. @@ -43,11 +43,11 @@ public class JDComment { } protected static boolean isNull(@Nullable String s) { - return s == null || s.trim().length() == 0; + return s == null || s.trim().isEmpty(); } protected static boolean isNull(@Nullable List l) { - return l == null || l.size() == 0; + return l == null || l.isEmpty(); } public void setMultiLine(boolean value) { diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java index 0059b2f1274f..e541b0714c5b 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDMethodComment.java @@ -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. @@ -39,7 +39,7 @@ public class JDMethodComment extends JDParamListOwnerComment { super.generateSpecial(prefix, sb); if (myReturnTag != null) { - if (myFormatter.getSettings().JD_KEEP_EMPTY_RETURN || myReturnTag.trim().length() != 0) { + if (myFormatter.getSettings().JD_KEEP_EMPTY_RETURN || !myReturnTag.trim().isEmpty()) { JDTag tag = JDTag.RETURN; sb.append(prefix); sb.append(tag.getWithEndWhitespace()); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java index 7220876dc0e9..05e359137e72 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/codeStyle/javadoc/JDParser.java @@ -73,7 +73,7 @@ public class JDParser { for (int i = 0; i < size; i++) { String line = l.get(i); line = line.trim(); - if (line.length() > 0) { + if (!line.isEmpty()) { if (line.charAt(0) == '*') { if ((markers.get(i)).booleanValue()) { if (line.length() > 1 && line.charAt(1) == ' ') { @@ -95,7 +95,7 @@ public class JDParser { String tag = null; for (int i = 0; i <= size; i++) { String line = i == size ? null : l.get(i); - if (i == size || line.length() > 0) { + if (i == size || !line.isEmpty()) { if (i == size || line.charAt(0) == '@') { if (tag == null) { comment.setDescription(sb.toString()); @@ -157,7 +157,7 @@ public class JDParser { private List toArray(@Nullable String s, @NotNull String separators, @Nullable List markers) { if (s == null) return null; s = s.trim(); - if (s.length() == 0) return null; + if (s.isEmpty()) return null; boolean p2nl = markers != null && mySettings.JD_P_AT_EMPTY_LINES; List list = new ArrayList(); StringTokenizer st = new StringTokenizer(s, separators, true); @@ -232,7 +232,7 @@ public class JDParser { String seq = pair.getFirst(); boolean isMarked = pair.getSecond(); - if (seq.length() == 0) { + if (seq.isEmpty()) { // keep empty lines list.add(""); continue; @@ -514,9 +514,9 @@ public class JDParser { boolean insidePreTag = false; for (int i = 0; i < list.size(); i++) { String line = list.get(i); - if (line.length() == 0 && !mySettings.JD_KEEP_EMPTY_LINES) continue; + if (line.isEmpty() && !mySettings.JD_KEEP_EMPTY_LINES) continue; if (i != 0) sb.append(prefix); - if (line.length() == 0 && mySettings.JD_P_AT_EMPTY_LINES && !insidePreTag) { + if (line.isEmpty() && mySettings.JD_P_AT_EMPTY_LINES && !insidePreTag) { if (myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8)) { //Self-closing elements are not allowed for javadoc tool from JDK8 sb.append(P_START_TAG); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FilePathReferenceProvider.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FilePathReferenceProvider.java index c23cf728f500..4ca7694dfd5b 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FilePathReferenceProvider.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FilePathReferenceProvider.java @@ -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. @@ -53,7 +53,7 @@ public class FilePathReferenceProvider extends PsiReferenceProvider { String text, int offset, final boolean soft, - final @NotNull Module... forModules) { + @NotNull final Module... forModules) { return new FileReferenceSet(text, element, offset, this, true, myEndingSlashNotAllowed) { @@ -75,7 +75,7 @@ public class FilePathReferenceProvider extends PsiReferenceProvider { @Override public boolean absoluteUrlNeedsStartSlash() { final String s = getPathString(); - return s != null && s.length() > 0 && s.charAt(0) == '/'; + return s != null && !s.isEmpty() && s.charAt(0) == '/'; } @Override diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceProvider.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceProvider.java index ebc7ec1de80c..6e9e92dc4ff9 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceProvider.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceProvider.java @@ -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. @@ -61,7 +61,7 @@ public class JavaClassReferenceProvider extends GenericReferenceProvider impleme private boolean myAllowEmpty; - private ParameterizedCachedValueProvider, Project> myProvider = new ParameterizedCachedValueProvider, Project>() { + private final ParameterizedCachedValueProvider, Project> myProvider = new ParameterizedCachedValueProvider, Project>() { @Override public CachedValueProvider.Result> compute(Project project) { final List psiPackages = new ArrayList(); diff --git a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java index 2876f7611a15..5139b49efc16 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java @@ -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. @@ -293,7 +293,7 @@ public class MyTestInjector { if (!method.hasModifierProperty(PsiModifier.NATIVE) || !method.hasModifierProperty(PsiModifier.PUBLIC)) return; String paramList = ""; for (PsiParameter parameter : method.getParameterList().getParameters()) { - if (paramList.length()!=0) paramList += ","; + if (!paramList.isEmpty()) paramList += ","; paramList += parameter.getName(); } @NonNls String header = "function " + method.getName() + "("+paramList+") {"; diff --git a/java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java b/java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java index d009798075b2..0b46bfee4f0f 100644 --- a/java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java +++ b/java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java @@ -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. @@ -54,7 +54,7 @@ public class PatternPackageSetParserExtension implements PackageSetParserExtensi scope = PatternPackageSet.SCOPE_PROBLEM; } else if (PatternPackageSet.SCOPE_LIBRARY.equals(id)) { scope = PatternPackageSet.SCOPE_LIBRARY; - } else if (id.trim().length() > 0) { + } else if (!id.trim().isEmpty()) { scope = null; } final CharSequence buf = lexer.getBufferSequence(); diff --git a/java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.java b/java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.java index da0ecbe9d625..4b25ff574980 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiDisjunctionType.java @@ -62,7 +62,7 @@ public class PsiDisjunctionType extends PsiType { @NotNull public static PsiType createDisjunction(@NotNull List types, @NotNull PsiManager psiManager) { - assert types.size() > 0; + assert !types.isEmpty(); return types.size() == 1 ? types.get(0) : new PsiDisjunctionType(types, psiManager); } diff --git a/java/java-psi-api/src/com/intellij/psi/util/ClassUtil.java b/java/java-psi-api/src/com/intellij/psi/util/ClassUtil.java index ef0e9cfad666..bf860cf47937 100644 --- a/java/java-psi-api/src/com/intellij/psi/util/ClassUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/util/ClassUtil.java @@ -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. @@ -42,7 +42,7 @@ public class ClassUtil { if (className == null){ return null; } - if (qualifiedName == null || qualifiedName.length() == 0){ + if (qualifiedName == null || qualifiedName.isEmpty()){ return className; } return qualifiedName + "." + extractClassName(className); @@ -120,7 +120,7 @@ public class ClassUtil { public static PsiClass findNonQualifiedClassByIndex(final String indexName, @NotNull final PsiClass containingClass, final boolean jvmCompatible) { String prefix = getDigitPrefix(indexName); - final int idx = prefix.length() > 0 ? Integer.parseInt(prefix) : -1; + final int idx = !prefix.isEmpty() ? Integer.parseInt(prefix) : -1; final String name = prefix.length() < indexName.length() ? indexName.substring(prefix.length()) : null; final PsiClass[] result = new PsiClass[1]; containingClass.accept(new JavaRecursiveElementVisitor() { diff --git a/java/java-psi-impl/src/com/intellij/psi/controlFlow/ConditionalGoToInstruction.java b/java/java-psi-impl/src/com/intellij/psi/controlFlow/ConditionalGoToInstruction.java index 4b1bd8f66e54..5332fff79289 100644 --- a/java/java-psi-impl/src/com/intellij/psi/controlFlow/ConditionalGoToInstruction.java +++ b/java/java-psi-impl/src/com/intellij/psi/controlFlow/ConditionalGoToInstruction.java @@ -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. @@ -28,7 +28,7 @@ public class ConditionalGoToInstruction extends ConditionalBranchingInstruction } public String toString() { - final @NonNls String sRole = "["+role.toString()+"]"; + @NonNls final String sRole = "["+role.toString()+"]"; return "COND_GOTO " + sRole + " " + offset; } diff --git a/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowUtil.java b/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowUtil.java index e9b8cf98ecce..4884cb3c7206 100644 --- a/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowUtil.java @@ -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. @@ -1249,7 +1249,7 @@ public class ControlFlowUtil { // map of variable->PsiReferenceExpressions for all read before written variables for this point and below in control flow private final CopyOnWriteList[] readVariables; private final ControlFlow myFlow; - private boolean localVariablesOnly; + private final boolean localVariablesOnly; public ReadBeforeWriteClientVisitor(ControlFlow flow, boolean localVariablesOnly) { myFlow = flow; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsClassImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsClassImpl.java index 60e343b188e7..2005641364e8 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsClassImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsClassImpl.java @@ -336,7 +336,7 @@ public class ClsClassImpl extends ClsMemberImpl> implements PsiE List methods = getOwnMethods(); List classes = getOwnInnerClasses(); - if (fields.size() > 0) { + if (!fields.isEmpty()) { goNextLine(newIndentLevel, buffer); for (int i = 0; i < fields.size(); i++) { @@ -365,8 +365,8 @@ public class ClsClassImpl extends ClsMemberImpl> implements PsiE buffer.append(";"); } - if (methods.size() > 0) { - if (isEnum() || fields.size() > 0) { + if (!methods.isEmpty()) { + if (isEnum() || !fields.isEmpty()) { buffer.append('\n'); } goNextLine(newIndentLevel, buffer); @@ -381,7 +381,7 @@ public class ClsClassImpl extends ClsMemberImpl> implements PsiE } } - if (classes.size() > 0) { + if (!classes.isEmpty()) { if (fields.size() + methods.size() > 0) { buffer.append('\n'); } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java index 6191dc22dcb0..85c897641e60 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/compiled/ClsFileImpl.java @@ -315,7 +315,7 @@ public class ClsFileImpl extends ClsRepositoryPsiElement @NotNull public LanguageLevel getSourceLanguageLevel() { final List stubs = getStub().getChildrenStubs(); - return stubs.size() > 0 ? ((PsiClassStub)stubs.get(0)).getLanguageLevel() : LanguageLevel.HIGHEST; + return !stubs.isEmpty() ? ((PsiClassStub)stubs.get(0)).getLanguageLevel() : LanguageLevel.HIGHEST; } @Override diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaClassElementType.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaClassElementType.java index 8d6000647162..a389245410df 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaClassElementType.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaClassElementType.java @@ -120,7 +120,7 @@ public abstract class JavaClassElementType extends JavaStubElementType 0) qualifiedName = pkg + '.' + name; else qualifiedName = name; + if (!pkg.isEmpty()) qualifiedName = pkg + '.' + name; else qualifiedName = name; } else if (parentStub instanceof PsiClassStub) { final String parentFqn = ((PsiClassStub)parentStub).getQualifiedName(); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaMethodElementType.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaMethodElementType.java index 2d13eb9c8c20..dc35c3b380bf 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaMethodElementType.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/JavaMethodElementType.java @@ -92,7 +92,7 @@ public abstract class JavaMethodElementType extends JavaStubElementType params = LightTreeUtil.getChildrenOfType(tree, child, JavaElementType.PARAMETER); - if (params.size() > 0) { + if (!params.isEmpty()) { final LighterASTNode pType = LightTreeUtil.firstChildOfType(tree, params.get(params.size() - 1), JavaElementType.TYPE); if (pType != null) { isVarArgs = (LightTreeUtil.firstChildOfType(tree, pType, JavaTokenType.ELLIPSIS) != null); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/impl/PsiImportStatementStubImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/impl/PsiImportStatementStubImpl.java index 6a217d3466c0..1de00bfc002d 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/impl/PsiImportStatementStubImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/java/stubs/impl/PsiImportStatementStubImpl.java @@ -38,8 +38,8 @@ public class PsiImportStatementStubImpl extends StubBase private final StringRef myText; private SoftReference myReference = null; - private final static int ON_DEMAND = 0x01; - private final static int STATIC = 0x02; + private static final int ON_DEMAND = 0x01; + private static final int STATIC = 0x02; public PsiImportStatementStubImpl(final StubElement parent, final String text, final byte flags) { this(parent, StringRef.fromString(text), flags); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightTypeParameterListBuilder.java b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightTypeParameterListBuilder.java index 41e3a42d994e..e54dcddcc16d 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/light/LightTypeParameterListBuilder.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/light/LightTypeParameterListBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -51,7 +51,7 @@ public class LightTypeParameterListBuilder extends LightElement implements PsiTy @Override public PsiTypeParameter[] getTypeParameters() { if (cached == null) { - if (myParameters.size() == 0) { + if (myParameters.isEmpty()) { cached = PsiTypeParameter.EMPTY_ARRAY; } else { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java index 103b828b1873..70de663a3e06 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaCodeReferenceElementImpl.java @@ -584,7 +584,7 @@ public class PsiJavaCodeReferenceElementImpl extends CompositePsiElement impleme PsiModifierList modifierList = PsiImplUtil.findNeighbourModifierList(this); if (modifierList != null) { List typeAnnotations = PsiImplUtil.getTypeUseAnnotations(modifierList); - if (typeAnnotations != null && typeAnnotations.size() > 0) { + if (typeAnnotations != null && !typeAnnotations.isEmpty()) { annotations.addAll(typeAnnotations); } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java index 47a1b8e3f159..dd88a17396c9 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiJavaFileBaseImpl.java @@ -121,7 +121,7 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava final PsiPackageStatement packageStatement = getPackageStatement(); final PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory(); if (packageStatement != null) { - if (packageName.length() > 0) { + if (!packageName.isEmpty()) { final PsiJavaCodeReferenceElement reference = packageStatement.getPackageReference(); reference.replace(factory.createReferenceFromText(packageName, packageStatement)); } @@ -130,7 +130,7 @@ public abstract class PsiJavaFileBaseImpl extends PsiFileImpl implements PsiJava } } else { - if (packageName.length() > 0) { + if (!packageName.isEmpty()) { addBefore(factory.createPackageStatement(packageName), getFirstChild()); } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java index cc46b4bd5cd0..a747e0357505 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiTypeElementImpl.java @@ -138,14 +138,14 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl if (PsiUtil.isJavaToken(child, JavaTokenType.AND)) { List types = collectTypes(); - assert types.size() > 0 : this; + assert !types.isEmpty() : this; type = PsiIntersectionType.createIntersection(types); break; } if (PsiUtil.isJavaToken(child, JavaTokenType.OR)) { List types = collectTypes(); - assert types.size() > 0 : this; + assert !types.isEmpty() : this; type = PsiDisjunctionType.createDisjunction(types, getManager()); break; } @@ -161,7 +161,7 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl if (left instanceof PsiModifierList) { List annotations = PsiImplUtil.getTypeUseAnnotations((PsiModifierList)left); - if (annotations != null && annotations.size() > 0) { + if (annotations != null && !annotations.isEmpty()) { list.addAll(annotations); } break; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocMethodOrFieldRef.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocMethodOrFieldRef.java index a104ac21c353..43549c7dc40c 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocMethodOrFieldRef.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/PsiDocMethodOrFieldRef.java @@ -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. @@ -176,7 +176,7 @@ public class PsiDocMethodOrFieldRef extends CompositePsiElement implements PsiDo final String[] typeStrings = child.getText().split("[, ]"); //avoid param types list parsing hmm method(paramType1, paramType2, ...) -> typeElement1, identifier2, ... if (typeStrings != null) { for (String type : typeStrings) { - if (type.length() > 0) { + if (!type.isEmpty()) { types.add(type); } } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/SeeDocTagInfo.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/SeeDocTagInfo.java index 0b2d6a0123bb..45e8ddbd7edf 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/SeeDocTagInfo.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/SeeDocTagInfo.java @@ -36,7 +36,7 @@ import java.util.List; class SeeDocTagInfo implements JavadocTagInfo { private final String myName; private final boolean myInline; - private static final @NonNls String LINKPLAIN_TAG = "linkplain"; + @NonNls private static final String LINKPLAIN_TAG = "linkplain"; public SeeDocTagInfo(@NonNls String name, boolean isInline) { myName = name; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/StaticImportResolveProcessor.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/StaticImportResolveProcessor.java index f7adb3545e57..335969987d41 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/StaticImportResolveProcessor.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/StaticImportResolveProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -57,7 +57,7 @@ public class StaticImportResolveProcessor extends BaseScopeProcessor implements } private static boolean checkDomination(final PsiMember candidate, final List results) { - if (results.size() > 0) { + if (!results.isEmpty()) { for (ListIterator i = results.listIterator(results.size()); i.hasPrevious();) { final Domination domination = dominates(candidate, (PsiMember)i.previous().getElement()); if (domination == Domination.DOMINATED_BY) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java index 0a579e9e3bbb..455d448ba641 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceIncorporationPhase.java @@ -27,7 +27,7 @@ import java.util.List; * User: anna */ public class InferenceIncorporationPhase { - private InferenceSession mySession; + private final InferenceSession mySession; public InferenceIncorporationPhase(InferenceSession session) { mySession = session; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java index 7ff660151a47..27a949b84495 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceSession.java @@ -37,7 +37,7 @@ import java.util.*; public class InferenceSession { private static final Logger LOG = Logger.getInstance("#" + InferenceSession.class.getName()); - private Map myInferenceVariables = new LinkedHashMap(); + private final Map myInferenceVariables = new LinkedHashMap(); private final List myConstraints = new ArrayList(); private PsiSubstitutor mySiteSubstitutor; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java index 593194354b7d..f8dc21008af4 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariable.java @@ -29,8 +29,8 @@ public class InferenceVariable { return myParameter; } - private Map> myBounds = new HashMap>(); - private PsiTypeParameter myParameter; + private final Map> myBounds = new HashMap>(); + private final PsiTypeParameter myParameter; private PsiType myInstantiation = PsiType.NULL; public InferenceVariable(PsiTypeParameter parameter) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariablesOrder.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariablesOrder.java index 817002a1aa16..397f84b2ab1a 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariablesOrder.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/InferenceVariablesOrder.java @@ -78,7 +78,7 @@ public class InferenceVariablesOrder { public static class InferenceGraphNode { private final List myValue = new ArrayList(); - private Set> myDependencies = new HashSet>(); + private final Set> myDependencies = new HashSet>(); private int index = -1; private int lowlink; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/PsiPolyExpressionUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/PsiPolyExpressionUtil.java index e5cda246efbf..d03959af447a 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/PsiPolyExpressionUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/PsiPolyExpressionUtil.java @@ -76,7 +76,7 @@ public class PsiPolyExpressionUtil { if (isInAssignmentOrInvocationContext(expression) && ((PsiCallExpression)expression).getTypeArguments().length == 0) { if (method != null) { final Set typeParameters = new HashSet(Arrays.asList(method.getTypeParameters())); - if (typeParameters.size() > 0) { + if (!typeParameters.isEmpty()) { final PsiType returnType = method.getReturnType(); if (returnType != null) { return mentionsTypeParameters(returnType, typeParameters); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java index e758c874c48d..7ef2a7250030 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/ExpressionCompatibilityConstraint.java @@ -31,7 +31,7 @@ import java.util.*; * User: anna */ public class ExpressionCompatibilityConstraint extends InputOutputConstraintFormula { - private PsiExpression myExpression; + private final PsiExpression myExpression; private PsiType myT; public ExpressionCompatibilityConstraint(@NotNull PsiExpression expression, @NotNull PsiType type) { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/SubtypingConstraint.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/SubtypingConstraint.java index bb1b9abd2745..cfda8a0f0e36 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/SubtypingConstraint.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/graphInference/constraints/SubtypingConstraint.java @@ -29,7 +29,7 @@ import java.util.List; public class SubtypingConstraint implements ConstraintFormula { private PsiType myS; private PsiType myT; - private boolean myIsRefTypes; + private final boolean myIsRefTypes; public SubtypingConstraint(PsiType t, PsiType s, boolean isRefTypes) { myT = t; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/SourceUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/SourceUtil.java index 5e0865e0ec45..1380b68b9213 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/SourceUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/tree/SourceUtil.java @@ -47,7 +47,7 @@ public class SourceUtil { public void visitLeaf(LeafElement leaf) { if (!REF_FILTER.contains(leaf.getElementType())) { String leafText = leaf.getText(); - if (buffer.length() > 0 && leafText.length() > 0 && Character.isJavaIdentifierPart(leafText.charAt(0))) { + if (buffer.length() > 0 && !leafText.isEmpty() && Character.isJavaIdentifierPart(leafText.charAt(0))) { char lastInBuffer = buffer.charAt(buffer.length() - 1); if (lastInBuffer == '?' || Character.isJavaIdentifierPart(lastInBuffer)) { buffer.append(" "); diff --git a/java/java-psi-impl/src/com/intellij/psi/presentation/java/ClassPresentationProvider.java b/java/java-psi-impl/src/com/intellij/psi/presentation/java/ClassPresentationProvider.java index 5eb8a5d667c6..12b234d83451 100644 --- a/java/java-psi-impl/src/com/intellij/psi/presentation/java/ClassPresentationProvider.java +++ b/java/java-psi-impl/src/com/intellij/psi/presentation/java/ClassPresentationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -45,7 +45,7 @@ public class ClassPresentationProvider implements ItemPresentationProvider 0 && maxApplicabilityLevel != level) { toFilter = true; } diff --git a/java/jsp-spi/src/com/intellij/psi/impl/source/jsp/JspContextManager.java b/java/jsp-spi/src/com/intellij/psi/impl/source/jsp/JspContextManager.java index 21d1701b096d..5f877f46a0cd 100644 --- a/java/jsp-spi/src/com/intellij/psi/impl/source/jsp/JspContextManager.java +++ b/java/jsp-spi/src/com/intellij/psi/impl/source/jsp/JspContextManager.java @@ -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. @@ -37,12 +37,15 @@ public abstract class JspContextManager { public abstract void setContextFile(@NotNull PsiFile file, @Nullable BaseJspFile contextFile); - public abstract @Nullable + @Nullable + public abstract BaseJspFile getContextFile(@NotNull PsiFile file); - public abstract @Nullable JspFile getConfiguredContextFile(@NotNull PsiFile file); + @Nullable + public abstract JspFile getConfiguredContextFile(@NotNull PsiFile file); - public @NotNull + @NotNull + public BaseJspFile getRootContextFile(@NotNull BaseJspFile file) { BaseJspFile rootContext = file; HashSet recursionPreventer = new HashSet(); diff --git a/java/jsp-spi/src/com/intellij/psi/impl/source/jsp/JspManager.java b/java/jsp-spi/src/com/intellij/psi/impl/source/jsp/JspManager.java index 46d04cde530f..3fb2155d4b6a 100644 --- a/java/jsp-spi/src/com/intellij/psi/impl/source/jsp/JspManager.java +++ b/java/jsp-spi/src/com/intellij/psi/impl/source/jsp/JspManager.java @@ -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. @@ -59,7 +59,7 @@ public abstract class JspManager implements IBaseJspManager { public abstract List> getAvailableFunctions(@NotNull final JspFile context); @Nullable - public abstract String getPrefixForNamespace(@NotNull String namespaceUri, final @NotNull JspFile context); + public abstract String getPrefixForNamespace(@NotNull String namespaceUri, @NotNull final JspFile context); @Nullable public abstract String getDefaultPrefix(@NotNull XmlFile taglibFile); diff --git a/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java b/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java index 7950e60f1a81..363a57cd805b 100644 --- a/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java +++ b/java/openapi/src/com/intellij/psi/search/scope/packageSet/PatternPackageSet.java @@ -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. @@ -51,7 +51,7 @@ public class PatternPackageSet extends PatternBasedPackageSet { myModulePatternText = modulePattern; Pattern mmgp = null; Pattern mmp = null; - if (modulePattern == null || modulePattern.length() == 0) { + if (modulePattern == null || modulePattern.isEmpty()) { mmp = null; } else { diff --git a/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java b/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java index 207b819fff23..d4b493790fbd 100644 --- a/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java +++ b/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReference.java @@ -200,8 +200,8 @@ public class FileReference implements PsiFileReference, FileReferenceOwner, PsiP return decode(getCanonicalText()); } - public @Nullable + public String getNewFileTemplateName() { return null; } diff --git a/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java b/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java index de579d3714c2..33ea1392b671 100644 --- a/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java +++ b/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/FileReferenceSet.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -77,8 +77,8 @@ public class FileReferenceSet { private Collection myDefaultContexts; private final boolean myEndingSlashNotAllowed; private boolean myEmptyPathAllowed; - private @Nullable Map myOptions; - private @Nullable FileType[] mySuitableFileTypes; + @Nullable private Map myOptions; + @Nullable private FileType[] mySuitableFileTypes; public FileReferenceSet(String str, PsiElement element, @@ -174,7 +174,7 @@ public class FileReferenceSet { this(str, element, startInElement, provider, isCaseSensitive, endingSlashNotAllowed, null); } - public FileReferenceSet(final @NotNull PsiElement element) { + public FileReferenceSet(@NotNull final PsiElement element) { myElement = element; TextRange range = ElementManipulators.getValueTextRange(element); @@ -350,13 +350,13 @@ public class FileReferenceSet { final Project project = file.getProject(); for (FileReferenceHelper helper : helpers) { if (helper.isMine(project, virtualFile)) { - if (list.size() > 0 && helper.isFallback()) { + if (!list.isEmpty() && helper.isFallback()) { continue; } list.addAll(helper.getContexts(project, virtualFile)); } } - if (list.size() > 0) { + if (!list.isEmpty()) { return list; } final VirtualFile parent = virtualFile.getParent(); @@ -394,7 +394,7 @@ public class FileReferenceSet { } @NotNull - public static Collection getAbsoluteTopLevelDirLocations(final @NotNull PsiFile file) { + public static Collection getAbsoluteTopLevelDirLocations(@NotNull final PsiFile file) { final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) { @@ -410,7 +410,7 @@ public class FileReferenceSet { final ArrayList list = new ArrayList(); for (FileReferenceHelper helper : helpers) { if (helper.isMine(project, virtualFile)) { - if (helper.isFallback() && list.size() > 0) { + if (helper.isFallback() && !list.isEmpty()) { continue; } final Collection roots = helper.getRoots(module); diff --git a/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/NullFileReferenceHelper.java b/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/NullFileReferenceHelper.java index fad5ff49faca..c54d69f500db 100644 --- a/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/NullFileReferenceHelper.java +++ b/platform/analysis-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/NullFileReferenceHelper.java @@ -55,7 +55,7 @@ public class NullFileReferenceHelper extends FileReferenceHelper { @Override @NotNull - public Collection getContexts(final Project project, final @NotNull VirtualFile file) { + public Collection getContexts(final Project project, @NotNull final VirtualFile file) { final PsiFileSystemItem item = getPsiFileSystemItem(project, file); if (item != null) { final PsiFileSystemItem parent = item.getParent(); @@ -67,7 +67,7 @@ public class NullFileReferenceHelper extends FileReferenceHelper { } @Override - public boolean isMine(final Project project, final @NotNull VirtualFile file) { + public boolean isMine(final Project project, @NotNull final VirtualFile file) { return ProjectRootManager.getInstance(project).getFileIndex().isInContent(file); } diff --git a/platform/core-api/src/com/intellij/psi/FileContextProvider.java b/platform/core-api/src/com/intellij/psi/FileContextProvider.java index 0227e48ce801..83928ec97825 100644 --- a/platform/core-api/src/com/intellij/psi/FileContextProvider.java +++ b/platform/core-api/src/com/intellij/psi/FileContextProvider.java @@ -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. @@ -28,10 +28,10 @@ import java.util.Collection; */ public abstract class FileContextProvider { - public final static ExtensionPointName EP_NAME = new ExtensionPointName("com.intellij.fileContextProvider"); + public static final ExtensionPointName EP_NAME = new ExtensionPointName("com.intellij.fileContextProvider"); @Nullable - public static FileContextProvider getProvider(final @NotNull PsiFile file) { + public static FileContextProvider getProvider(@NotNull final PsiFile file) { for (FileContextProvider provider: Extensions.getExtensions(EP_NAME, file.getProject())) { if (provider.isAvailable(file)) { return provider; diff --git a/platform/core-api/src/com/intellij/psi/PsiReferenceBase.java b/platform/core-api/src/com/intellij/psi/PsiReferenceBase.java index f075f9a58a54..526da9afe2e1 100644 --- a/platform/core-api/src/com/intellij/psi/PsiReferenceBase.java +++ b/platform/core-api/src/com/intellij/psi/PsiReferenceBase.java @@ -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. @@ -149,7 +149,7 @@ public abstract class PsiReferenceBase implements PsiRefer return mySoft; } - public static abstract class Poly extends PsiReferenceBase implements PsiPolyVariantReference { + public abstract static class Poly extends PsiReferenceBase implements PsiPolyVariantReference { public Poly(final T psiElement) { super(psiElement); diff --git a/platform/core-api/src/com/intellij/psi/util/QualifiedName.java b/platform/core-api/src/com/intellij/psi/util/QualifiedName.java index 620e278340ac..9cdd11b48937 100644 --- a/platform/core-api/src/com/intellij/psi/util/QualifiedName.java +++ b/platform/core-api/src/com/intellij/psi/util/QualifiedName.java @@ -1,3 +1,18 @@ +/* + * 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. + * 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.psi.util; import com.intellij.openapi.util.text.StringUtil; @@ -59,7 +74,7 @@ public class QualifiedName { int size = myComponents.size(); QualifiedName result = new QualifiedName(size); result.myComponents.addAll(myComponents); - for (int i = 0; i < count && result.myComponents.size() > 0; i++) { + for (int i = 0; i < count && !result.myComponents.isEmpty(); i++) { result.myComponents.remove(result.myComponents.size()-1); } return result; @@ -70,7 +85,7 @@ public class QualifiedName { int size = myComponents.size(); QualifiedName result = new QualifiedName(size); result.myComponents.addAll(myComponents); - for (int i = 0; i < count && result.myComponents.size() > 0; i++) { + for (int i = 0; i < count && !result.myComponents.isEmpty(); i++) { result.myComponents.remove(0); } return result; @@ -145,7 +160,7 @@ public class QualifiedName { @Nullable public String getFirstComponent() { - if (myComponents.size() == 0) { + if (myComponents.isEmpty()) { return null; } return myComponents.get(0); @@ -153,7 +168,7 @@ public class QualifiedName { @Nullable public String getLastComponent() { - if (myComponents.size() == 0) { + if (myComponents.isEmpty()) { return null; } return myComponents.get(myComponents.size()-1); diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/resolve/reference/ReferenceProvidersRegistry.java b/platform/core-impl/src/com/intellij/psi/impl/source/resolve/reference/ReferenceProvidersRegistry.java index b39cb226ff2c..40f53afc588b 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/resolve/reference/ReferenceProvidersRegistry.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/resolve/reference/ReferenceProvidersRegistry.java @@ -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. @@ -31,7 +31,7 @@ import org.jetbrains.annotations.NotNull; * To change this template use Options | File Templates. */ public abstract class ReferenceProvidersRegistry { - public final static PsiReferenceProvider NULL_REFERENCE_PROVIDER = new PsiReferenceProvider() { + public static final PsiReferenceProvider NULL_REFERENCE_PROVIDER = new PsiReferenceProvider() { @NotNull @Override public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/tree/ForeignLeafPsiElement.java b/platform/core-impl/src/com/intellij/psi/impl/source/tree/ForeignLeafPsiElement.java index 71e25c4cb1f0..e55ea9c606dd 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/tree/ForeignLeafPsiElement.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/tree/ForeignLeafPsiElement.java @@ -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. @@ -26,7 +26,7 @@ import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; public class ForeignLeafPsiElement extends LeafPsiElement { - private ForeignLeafType myForeignType; + private final ForeignLeafType myForeignType; public ForeignLeafPsiElement(ForeignLeafType type, CharSequence text) { super(dereferenceElementType(type.getDelegate()), text); diff --git a/platform/indexing-impl/src/com/intellij/psi/search/FilenameIndex.java b/platform/indexing-impl/src/com/intellij/psi/search/FilenameIndex.java index 717f43c83a46..7c42954efe82 100644 --- a/platform/indexing-impl/src/com/intellij/psi/search/FilenameIndex.java +++ b/platform/indexing-impl/src/com/intellij/psi/search/FilenameIndex.java @@ -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. @@ -92,7 +92,7 @@ public class FilenameIndex extends ScalarIndexExtension { return (PsiFile[])getFilesByName(project, name, scope, false); } - public static boolean processFilesByName(final @NotNull String name, + public static boolean processFilesByName(@NotNull final String name, boolean includeDirs, @NotNull Processor processor, @NotNull GlobalSearchScope scope, @@ -134,7 +134,7 @@ public class FilenameIndex extends ScalarIndexExtension { public static PsiFileSystemItem[] getFilesByName(final Project project, final String name, - final @NotNull GlobalSearchScope scope, + @NotNull final GlobalSearchScope scope, boolean includeDirs) { SmartList result = new SmartList(); processFilesByName(name, includeDirs, new CommonProcessors.CollectProcessor(result), scope, project, null); diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/PackageEntryTable.java b/platform/lang-api/src/com/intellij/psi/codeStyle/PackageEntryTable.java index d92d05fc9552..bfde4ac17574 100755 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/PackageEntryTable.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/PackageEntryTable.java @@ -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. @@ -120,7 +120,7 @@ public class PackageEntryTable implements JDOMExternalizable, Cloneable { throw new InvalidDataException(); } PackageEntry entry; - if (packageName.length() == 0) { + if (packageName.isEmpty()) { entry = isStatic ? PackageEntry.ALL_OTHER_STATIC_IMPORTS_ENTRY : PackageEntry.ALL_OTHER_IMPORTS_ENTRY; } else { diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/PredefinedCodeStyle.java b/platform/lang-api/src/com/intellij/psi/codeStyle/PredefinedCodeStyle.java index 9229ceaa1e0b..9c1cc19fb606 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/PredefinedCodeStyle.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/PredefinedCodeStyle.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -27,7 +27,7 @@ public abstract class PredefinedCodeStyle { public static final ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.predefinedCodeStyle"); - public final static PredefinedCodeStyle[] EMPTY_ARRAY = new PredefinedCodeStyle[]{}; + public static final PredefinedCodeStyle[] EMPTY_ARRAY = new PredefinedCodeStyle[]{}; private final String myName; private final Language myLanguage; diff --git a/platform/lang-api/src/com/intellij/psi/injection/ReferenceInjector.java b/platform/lang-api/src/com/intellij/psi/injection/ReferenceInjector.java index 80ad118108d3..e13b11da85d4 100644 --- a/platform/lang-api/src/com/intellij/psi/injection/ReferenceInjector.java +++ b/platform/lang-api/src/com/intellij/psi/injection/ReferenceInjector.java @@ -33,7 +33,7 @@ import org.jetbrains.annotations.NotNull; */ public abstract class ReferenceInjector extends Injectable { - public final static ExtensionPointName EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.referenceInjector"); + public static final ExtensionPointName EXTENSION_POINT_NAME = ExtensionPointName.create("com.intellij.referenceInjector"); @Override public final Language getLanguage() { diff --git a/platform/lang-api/testSources/com/intellij/psi/codeStyle/arrangement/match/DefaultArrangementEntryMatcherSerializerTest.java b/platform/lang-api/testSources/com/intellij/psi/codeStyle/arrangement/match/DefaultArrangementEntryMatcherSerializerTest.java index 5b1c8cdc475d..b48426f516c4 100644 --- a/platform/lang-api/testSources/com/intellij/psi/codeStyle/arrangement/match/DefaultArrangementEntryMatcherSerializerTest.java +++ b/platform/lang-api/testSources/com/intellij/psi/codeStyle/arrangement/match/DefaultArrangementEntryMatcherSerializerTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -129,7 +129,7 @@ public class DefaultArrangementEntryMatcherSerializerTest { List children1 = expected.getChildren(); List children2 = actual.getChildren(); assertEquals(children1.size(), children2.size()); - if (children1.size() == 0) { + if (children1.isEmpty()) { assertTrue( String.format("Content mismatch - expected: '%s', actual: '%s'", expected.getText(), actual.getText()), Comparing.equal(expected.getText(), actual.getText()) diff --git a/platform/lang-impl/src/com/intellij/psi/formatter/AbstractWhiteSpaceFormattingStrategy.java b/platform/lang-impl/src/com/intellij/psi/formatter/AbstractWhiteSpaceFormattingStrategy.java index 71375c2a1ed2..d9035347f768 100644 --- a/platform/lang-impl/src/com/intellij/psi/formatter/AbstractWhiteSpaceFormattingStrategy.java +++ b/platform/lang-impl/src/com/intellij/psi/formatter/AbstractWhiteSpaceFormattingStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -89,7 +89,7 @@ public abstract class AbstractWhiteSpaceFormattingStrategy implements WhiteSpace } @Nullable - private static PsiElement next(final @NotNull PsiElement element) { + private static PsiElement next(@NotNull final PsiElement element) { for (PsiElement anchor = element; anchor != null; anchor = anchor.getParent()) { final PsiElement result = element.getNextSibling(); if (result != null) { diff --git a/platform/lang-impl/src/com/intellij/psi/formatter/FormatterUtil.java b/platform/lang-impl/src/com/intellij/psi/formatter/FormatterUtil.java index 5f08968683c6..70f3e8ebcfe1 100644 --- a/platform/lang-impl/src/com/intellij/psi/formatter/FormatterUtil.java +++ b/platform/lang-impl/src/com/intellij/psi/formatter/FormatterUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -291,7 +291,7 @@ public class FormatterUtil { public static void replaceWhiteSpace(final String whiteSpace, final ASTNode leafElement, final IElementType whiteSpaceToken, - final @Nullable TextRange textRange) { + @Nullable final TextRange textRange) { final CharTable charTable = SharedImplUtil.findCharTableByTree(leafElement); ASTNode treePrev = findPreviousWhiteSpace(leafElement, whiteSpaceToken); @@ -300,11 +300,10 @@ public class FormatterUtil { } if (treePrev != null && - treePrev.getText().trim().length() == 0 && + treePrev.getText().trim().isEmpty() && treePrev.getElementType() != whiteSpaceToken && treePrev.getTextLength() > 0 && - whiteSpace.length() > - 0) { + !whiteSpace.isEmpty()) { LeafElement whiteSpaceElement = Factory.createSingleLeafElement(treePrev.getElementType(), whiteSpace, charTable, SharedImplUtil.getManagerByTree(leafElement)); @@ -316,20 +315,20 @@ public class FormatterUtil { Factory.createSingleLeafElement(whiteSpaceToken, whiteSpace, charTable, SharedImplUtil.getManagerByTree(leafElement)); if (treePrev == null) { - if (whiteSpace.length() > 0) { + if (!whiteSpace.isEmpty()) { addWhiteSpace(leafElement, whiteSpaceElement); } } else { if (!(treePrev.getElementType() == whiteSpaceToken)) { - if (whiteSpace.length() > 0) { + if (!whiteSpace.isEmpty()) { addWhiteSpace(treePrev, whiteSpaceElement); } } else { if (treePrev.getElementType() == whiteSpaceToken) { final CompositeElement treeParent = (CompositeElement)treePrev.getTreeParent(); - if (whiteSpace.length() > 0) { + if (!whiteSpace.isEmpty()) { // LOG.assertTrue(textRange == null || treeParent.getTextRange().equals(textRange)); treeParent.replaceChild(treePrev, whiteSpaceElement); } @@ -438,10 +437,10 @@ public class FormatterUtil { if (lastWS != null && !lastWS.getTextRange().equals(textRange)) { return; } - if (whiteSpace.length() == 0 && lastWS == null) { + if (whiteSpace.isEmpty() && lastWS == null) { return; } - if (lastWS != null && whiteSpace.length() == 0) { + if (lastWS != null && whiteSpace.isEmpty()) { lastWS.getTreeParent().removeRange(lastWS, null); return; } diff --git a/platform/lang-impl/src/com/intellij/psi/formatter/common/AbstractBlock.java b/platform/lang-impl/src/com/intellij/psi/formatter/common/AbstractBlock.java index 3897c09db4a4..726006defceb 100644 --- a/platform/lang-impl/src/com/intellij/psi/formatter/common/AbstractBlock.java +++ b/platform/lang-impl/src/com/intellij/psi/formatter/common/AbstractBlock.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -61,7 +61,7 @@ public abstract class AbstractBlock implements ASTBlock { if (list.isEmpty()) { list = buildInjectedBlocks(); } - mySubBlocks = list.size() > 0 ? list : EMPTY; + mySubBlocks = !list.isEmpty() ? list : EMPTY; } return mySubBlocks; } diff --git a/platform/lang-impl/src/com/intellij/psi/formatter/common/InjectedLanguageBlockBuilder.java b/platform/lang-impl/src/com/intellij/psi/formatter/common/InjectedLanguageBlockBuilder.java index 2b6b723bb1a2..90046df5e08f 100644 --- a/platform/lang-impl/src/com/intellij/psi/formatter/common/InjectedLanguageBlockBuilder.java +++ b/platform/lang-impl/src/com/intellij/psi/formatter/common/InjectedLanguageBlockBuilder.java @@ -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. @@ -157,7 +157,7 @@ public abstract class InjectedLanguageBlockBuilder { final FormattingModel childModel = builder.createModel(childPsi, getSettings()); Block original = childModel.getRootBlock(); - if ((original.isLeaf() && injectedNode.getText().trim().length() > 0) || original.getSubBlocks().size() != 0) { + if ((original.isLeaf() && !injectedNode.getText().trim().isEmpty()) || !original.getSubBlocks().isEmpty()) { result.add(createInjectedBlock(injectedNode, original, indent, offset, range, childLanguage)); } } diff --git a/platform/lang-impl/src/com/intellij/psi/formatter/common/InjectedLanguageBlockWrapper.java b/platform/lang-impl/src/com/intellij/psi/formatter/common/InjectedLanguageBlockWrapper.java index 2a431f900e01..b094d5ae42d1 100644 --- a/platform/lang-impl/src/com/intellij/psi/formatter/common/InjectedLanguageBlockWrapper.java +++ b/platform/lang-impl/src/com/intellij/psi/formatter/common/InjectedLanguageBlockWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -45,11 +45,11 @@ public final class InjectedLanguageBlockWrapper implements BlockEx { * @param range range of code inside injected document which is really placed in the main document * @param indent */ - public InjectedLanguageBlockWrapper(final @NotNull Block original, final int offset, @Nullable TextRange range, @Nullable Indent indent) { + public InjectedLanguageBlockWrapper(@NotNull final Block original, final int offset, @Nullable TextRange range, @Nullable Indent indent) { this(original, offset, range, indent, null); } - public InjectedLanguageBlockWrapper(final @NotNull Block original, + public InjectedLanguageBlockWrapper(@NotNull final Block original, final int offset, @Nullable TextRange range, @Nullable Indent indent, @@ -102,7 +102,7 @@ public final class InjectedLanguageBlockWrapper implements BlockEx { private List buildBlocks() { final List list = myOriginal.getSubBlocks(); - if (list.size() == 0) return AbstractBlock.EMPTY; + if (list.isEmpty()) return AbstractBlock.EMPTY; if (myOffset == 0 && myRange == null) return list; final ArrayList result = new ArrayList(list.size()); @@ -117,7 +117,7 @@ public final class InjectedLanguageBlockWrapper implements BlockEx { return result; } - private void collectBlocksIntersectingRange(final List list, final List result, final @NotNull TextRange range) { + private void collectBlocksIntersectingRange(final List list, final List result, @NotNull final TextRange range) { for (Block block : list) { final TextRange textRange = block.getTextRange(); if (range.contains(textRange)) { diff --git a/platform/lang-impl/src/com/intellij/psi/impl/search/LexerEditorHighlighterLexer.java b/platform/lang-impl/src/com/intellij/psi/impl/search/LexerEditorHighlighterLexer.java index 52367fbfc295..90b6864b481a 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/search/LexerEditorHighlighterLexer.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/search/LexerEditorHighlighterLexer.java @@ -49,7 +49,8 @@ public class LexerEditorHighlighterLexer extends LexerBase { myAlreadyInitializedHighlighter = alreadyInitializedHighlighter; } - public static @Nullable Lexer getLexerBasedOnLexerHighlighter(CharSequence text, VirtualFile virtualFile, Project project) { + @Nullable + public static Lexer getLexerBasedOnLexerHighlighter(CharSequence text, VirtualFile virtualFile, Project project) { EditorHighlighter highlighter = null; PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/CustomizingReferenceProvider.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/CustomizingReferenceProvider.java index 43758457c270..8bfadd1e29da 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/CustomizingReferenceProvider.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/CustomizingReferenceProvider.java @@ -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. @@ -31,7 +31,7 @@ import java.util.Map; */ public class CustomizingReferenceProvider extends PsiReferenceProvider implements CustomizableReferenceProvider { private final CustomizableReferenceProvider myProvider; - private @Nullable Map myOptions; + @Nullable private Map myOptions; public CustomizingReferenceProvider(@NotNull CustomizableReferenceProvider provider) { myProvider = provider; diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PsiFileReferenceHelper.java b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PsiFileReferenceHelper.java index b2be349246cc..30741e602636 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PsiFileReferenceHelper.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PsiFileReferenceHelper.java @@ -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. @@ -92,7 +92,7 @@ public class PsiFileReferenceHelper extends FileReferenceHelper { for (SourceFolder sf : e.getSourceFolders(JavaModuleSourceRootTypes.SOURCES)) { if (root.equals(sf.getFile())) { String s = sf.getPackagePrefix(); - if (s.length() > 0) { + if (!s.isEmpty()) { path = s + "." + path; break; } diff --git a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java index eb3e4b60da6d..f93dfaad3443 100644 --- a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java +++ b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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. @@ -36,7 +36,7 @@ public class MinusculeMatcher implements Matcher { * Need either an explicit uppercase letter or the same separator character in prefix */ private static final String HARD_SEPARATORS = " ()"; - private ThreadLocal myMatchingState = new ThreadLocal() { + private final ThreadLocal myMatchingState = new ThreadLocal() { @Override protected MatchingState initialValue() { return new MatchingState(); diff --git a/xml/impl/src/com/intellij/psi/XmlElementFactoryImpl.java b/xml/impl/src/com/intellij/psi/XmlElementFactoryImpl.java index 0bc7e2e2d081..4f354001bcf7 100644 --- a/xml/impl/src/com/intellij/psi/XmlElementFactoryImpl.java +++ b/xml/impl/src/com/intellij/psi/XmlElementFactoryImpl.java @@ -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. @@ -115,5 +115,5 @@ public class XmlElementFactoryImpl extends XmlElementFactory { return document; } - private final static Logger LOG = Logger.getInstance(XmlElementFactoryImpl.class); + private static final Logger LOG = Logger.getInstance(XmlElementFactoryImpl.class); } diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/AbstractXmlBlock.java b/xml/impl/src/com/intellij/psi/formatter/xml/AbstractXmlBlock.java index 4fbc8328e5dd..778af86c53f9 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/AbstractXmlBlock.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/AbstractXmlBlock.java @@ -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. @@ -44,7 +44,7 @@ import java.util.List; public abstract class AbstractXmlBlock extends AbstractBlock { protected XmlFormattingPolicy myXmlFormattingPolicy; protected XmlInjectedLanguageBlockBuilder myInjectedBlockBuilder; - private boolean myPreserveSpace; + private final boolean myPreserveSpace; protected AbstractXmlBlock(final ASTNode node, final Wrap wrap, diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/XmlBlock.java b/xml/impl/src/com/intellij/psi/formatter/xml/XmlBlock.java index 89be0169aeeb..c4d8889e9e50 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/XmlBlock.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/XmlBlock.java @@ -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. @@ -215,7 +215,8 @@ public class XmlBlock extends AbstractXmlBlock { } } - protected @Nullable Wrap getDefaultWrap(ASTNode node) { + @Nullable + protected Wrap getDefaultWrap(ASTNode node) { return null; } diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/XmlCodeStyleSettings.java b/xml/impl/src/com/intellij/psi/formatter/xml/XmlCodeStyleSettings.java index 50f7c6c71328..5489e3f75b05 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/XmlCodeStyleSettings.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/XmlCodeStyleSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -25,9 +25,9 @@ import com.intellij.psi.codeStyle.CustomCodeStyleSettings; */ public class XmlCodeStyleSettings extends CustomCodeStyleSettings { - public final static int WS_AROUND_CDATA_PRESERVE = 0; - public final static int WS_AROUND_CDATA_NONE = 1; - public final static int WS_AROUND_CDATA_NEW_LINES = 2; + public static final int WS_AROUND_CDATA_PRESERVE = 0; + public static final int WS_AROUND_CDATA_NONE = 1; + public static final int WS_AROUND_CDATA_NEW_LINES = 2; public boolean XML_KEEP_WHITESPACES = false; public int XML_ATTRIBUTE_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/XmlInjectedLanguageBlockBuilder.java b/xml/impl/src/com/intellij/psi/formatter/xml/XmlInjectedLanguageBlockBuilder.java index 28aa043ce81e..011a982809c6 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/XmlInjectedLanguageBlockBuilder.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/XmlInjectedLanguageBlockBuilder.java @@ -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. @@ -76,7 +76,7 @@ public class XmlInjectedLanguageBlockBuilder extends InjectedLanguageBlockBuilde return true; } - return text.length() == 0; + return text.isEmpty(); } } diff --git a/xml/impl/src/com/intellij/psi/formatter/xml/XmlTagBlock.java b/xml/impl/src/com/intellij/psi/formatter/xml/XmlTagBlock.java index 79b32c9218ea..248adb2ea33a 100644 --- a/xml/impl/src/com/intellij/psi/formatter/xml/XmlTagBlock.java +++ b/xml/impl/src/com/intellij/psi/formatter/xml/XmlTagBlock.java @@ -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. @@ -134,8 +134,8 @@ public class XmlTagBlock extends AbstractXmlBlock{ return false; } - protected @Nullable + protected ASTNode processChild(List result, final ASTNode child, final Wrap wrap, final Alignment alignment, final Indent indent) { IElementType type = child.getElementType(); if (type == XmlElementType.XML_TEXT) { diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeManipulator.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeManipulator.java index 0039c32e2a75..92135dd7e3da 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeManipulator.java +++ b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlAttributeManipulator.java @@ -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. @@ -31,7 +31,7 @@ import com.intellij.util.IncorrectOperationException; */ public class XmlAttributeManipulator extends AbstractElementManipulator { - private final static Logger LOG = Logger.getInstance(XmlAttributeManipulator.class); + private static final Logger LOG = Logger.getInstance(XmlAttributeManipulator.class); public XmlAttribute handleContentChange(XmlAttribute attribute, TextRange range, String newContent) throws IncorrectOperationException { String attr = attribute.getText(); diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTagManipulator.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTagManipulator.java index 1803c58bfc01..cc6201e62f98 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTagManipulator.java +++ b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTagManipulator.java @@ -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. @@ -66,10 +66,11 @@ public class XmlTagManipulator extends AbstractElementManipulator { final String trimmed = value.trim(); final int i = value.indexOf(trimmed); final int start = xmlText.displayToPhysical(i) + offset; - return trimmed.length() == 0 ? new TextRange(start, start) : new TextRange(start, xmlText.displayToPhysical(i + trimmed.length() - 1) + offset + 1); + return trimmed.isEmpty() + ? new TextRange(start, start) : new TextRange(start, xmlText.displayToPhysical(i + trimmed.length() - 1) + offset + 1); } - public static TextRange[] getValueRanges(final @NotNull XmlTag tag) { + public static TextRange[] getValueRanges(@NotNull final XmlTag tag) { final XmlTagValue value = tag.getValue(); final XmlText[] texts = value.getTextElements(); if (texts.length == 0) { diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java index f7baccc14926..cb7297db97d5 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java +++ b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/manipulators/XmlTextManipulator.java @@ -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. @@ -43,7 +43,7 @@ public class XmlTextManipulator extends AbstractElementManipulator { newValue = replacement.toString(); } if (Comparing.equal(value, newValue)) return text; - if (newValue.length() > 0) { + if (!newValue.isEmpty()) { text.setValue(newValue); } else { @@ -60,6 +60,6 @@ public class XmlTextManipulator extends AbstractElementManipulator { final String value = xmlText.getValue(); final int i = value.indexOf(value); final int start = xmlText.displayToPhysical(i); - return value.length() == 0 ? new TextRange(start, start) : new TextRange(start, xmlText.displayToPhysical(i + value.length() - 1) + 1); + return value.isEmpty() ? new TextRange(start, start) : new TextRange(start, xmlText.displayToPhysical(i + value.length() - 1) + 1); } } \ No newline at end of file diff --git a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/CreateXmlElementIntentionAction.java b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/CreateXmlElementIntentionAction.java index b7bbaab2fd75..6e93313b99d3 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/CreateXmlElementIntentionAction.java +++ b/xml/impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/CreateXmlElementIntentionAction.java @@ -101,7 +101,7 @@ class CreateXmlElementIntentionAction implements IntentionAction { protected void addTextTo(Template template, XmlTag rootTag) { String schemaPrefix = rootTag.getPrefixByNamespace(XmlUtil.XML_SCHEMA_URI); - if (schemaPrefix.length() > 0) schemaPrefix += ":"; + if (!schemaPrefix.isEmpty()) schemaPrefix += ":"; template.addTextSegment( "<" + schemaPrefix + myDeclarationTagName + " name=\"" + XmlUtil.findLocalNameByQualifiedName(myRef.getCanonicalText()) + "\">" diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java b/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java index f9fa005c5113..a6fbc0c33c46 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/XsContentDFA.java @@ -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. @@ -131,7 +131,7 @@ class XsContentDFA extends XmlContentDFA { return new QName(tag.getNamespacePrefix().intern(), tag.getLocalName().intern(), tag.getName().intern(), - namespace.length() == 0 ? null : namespace.intern()); + namespace.isEmpty() ? null : namespace.intern()); } @Nullable diff --git a/xml/impl/src/com/intellij/psi/impl/source/xml/behavior/EncodeEachSymbolPolicy.java b/xml/impl/src/com/intellij/psi/impl/source/xml/behavior/EncodeEachSymbolPolicy.java index ebb0117210b6..64e9b28e39a7 100644 --- a/xml/impl/src/com/intellij/psi/impl/source/xml/behavior/EncodeEachSymbolPolicy.java +++ b/xml/impl/src/com/intellij/psi/impl/source/xml/behavior/EncodeEachSymbolPolicy.java @@ -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. @@ -35,7 +35,7 @@ public class EncodeEachSymbolPolicy extends DefaultXmlPsiPolicy{ while (offset < displayText.length()) { if (toCode(displayText.charAt(offset))) { final String plainSection = displayText.substring(sectionStartOffset, offset); - if (plainSection.length() > 0) { + if (!plainSection.isEmpty()) { dummyParent.rawAddChildren((TreeElement)super.encodeXmlTextContents(plainSection, text)); } dummyParent.rawAddChildren(createCharEntity(displayText.charAt(offset), dummyParent.getCharTable())); @@ -44,7 +44,7 @@ public class EncodeEachSymbolPolicy extends DefaultXmlPsiPolicy{ offset++; } final String plainSection = displayText.substring(sectionStartOffset, offset); - if (plainSection.length() > 0) { + if (!plainSection.isEmpty()) { dummyParent.rawAddChildren((TreeElement)super.encodeXmlTextContents(plainSection, text)); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlTagImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlTagImpl.java index 1d324137d85c..843514d4d88c 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlTagImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/HtmlTagImpl.java @@ -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. @@ -89,11 +89,11 @@ public class HtmlTagImpl extends XmlTagImpl implements HtmlTag { public String getNamespace() { final String xmlNamespace = super.getNamespace(); - if (getNamespacePrefix().length() > 0) { + if (!getNamespacePrefix().isEmpty()) { return xmlNamespace; } - if (xmlNamespace.length() == 0 || xmlNamespace.equals(XmlUtil.XHTML_URI)) { + if (xmlNamespace.isEmpty() || xmlNamespace.equals(XmlUtil.XHTML_URI)) { return XmlUtil.HTML_URI; } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/ScriptSupportUtil.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/ScriptSupportUtil.java index 0cb4c12407a8..2abbb5b9d775 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/ScriptSupportUtil.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/ScriptSupportUtil.java @@ -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. @@ -41,7 +41,7 @@ import java.util.List; public class ScriptSupportUtil { private static final Key> CachedScriptTagsKey = Key.create("script tags"); private static final ThreadLocal ProcessingDeclarationsFlag = new ThreadLocal(); - private static final @NonNls String SCRIPT_TAG = "script"; + @NonNls private static final String SCRIPT_TAG = "script"; private ScriptSupportUtil() { } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlNSDescriptorImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlNSDescriptorImpl.java index 840e33530910..368efbf89ea2 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlNSDescriptorImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/html/dtd/HtmlNSDescriptorImpl.java @@ -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. @@ -36,9 +36,9 @@ import java.util.Map; * @author Maxim.Mossienko */ public class HtmlNSDescriptorImpl implements XmlNSDescriptor, DumbAware, XmlNSTypeDescriptorProvider { - private XmlNSDescriptor myDelegate; - private boolean myRelaxed; - private boolean myCaseSensitive; + private final XmlNSDescriptor myDelegate; + private final boolean myRelaxed; + private final boolean myCaseSensitive; private static final SimpleFieldCache, HtmlNSDescriptorImpl> myCachedDeclsCache = new SimpleFieldCache, HtmlNSDescriptorImpl>() { protected Map compute(final HtmlNSDescriptorImpl htmlNSDescriptor) { diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java index c71da31cce97..23cb9dbee8f6 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/SchemaReferencesProvider.java @@ -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. @@ -212,14 +212,15 @@ public class SchemaReferencesProvider extends PsiReferenceProvider { if (element instanceof XmlAttributeValue) { final XmlAttributeValue attributeValue = (XmlAttributeValue)element; final String prefix = XmlUtil.findPrefixByQualifiedName(attributeValue.getValue()); - if (prefix.length() > 0) { + if (!prefix.isEmpty()) { return new SchemaPrefixReference(attributeValue, TextRange.from(1, prefix.length()), prefix, null); } } return null; } - public static @Nullable XmlNSDescriptorImpl findRedefinedDescriptor(XmlTag tag, String text) { + @Nullable + public static XmlNSDescriptorImpl findRedefinedDescriptor(XmlTag tag, String text) { final String localName = XmlUtil.findLocalNameByQualifiedName(text); for(XmlTag parentTag = tag.getParentTag(); parentTag != null; parentTag = parentTag.getParentTag()) { diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/TypeOrElementOrAttributeReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/TypeOrElementOrAttributeReference.java index 3ecff0d97045..df4b38a5a54a 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/TypeOrElementOrAttributeReference.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/TypeOrElementOrAttributeReference.java @@ -1,3 +1,18 @@ +/* + * 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. + * 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.psi.impl.source.resolve.reference.impl.providers; import com.intellij.openapi.util.TextRange; @@ -48,7 +63,7 @@ public class TypeOrElementOrAttributeReference implements PsiReference { this.nsPrefix = prefix; } - private final @Nullable ReferenceType myType; + @Nullable private final ReferenceType myType; protected TypeOrElementOrAttributeReference(PsiElement element, TextRange range, @Nullable ReferenceType type) { myElement = element; @@ -220,7 +235,7 @@ public class TypeOrElementOrAttributeReference implements PsiReference { private static String getNamespace(final XmlTag tag, final String text) { final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(text); final String namespaceByPrefix = tag.getNamespaceByPrefix(namespacePrefix); - if (namespaceByPrefix.length() > 0) return namespaceByPrefix; + if (!namespaceByPrefix.isEmpty()) return namespaceByPrefix; final XmlTag rootTag = ((XmlFile)tag.getContainingFile()).getRootTag(); if (rootTag != null && @@ -232,7 +247,7 @@ public class TypeOrElementOrAttributeReference implements PsiReference { final String targetNsPrefix = rootTag.getPrefixByNamespace(targetNS); if (namespacePrefix.equals(targetNsPrefix) || - (namespaceByPrefix.length() == 0 && targetNsPrefix == null)) { + (namespaceByPrefix.isEmpty() && targetNsPrefix == null)) { return targetNS; } } @@ -244,7 +259,7 @@ public class TypeOrElementOrAttributeReference implements PsiReference { public String getCanonicalText() { final String text = myElement.getText(); String name = myRange.getEndOffset() <= text.length() ? myRange.substring(text) : ""; - if (name.length() > 0 && nsPrefix != null && nsPrefix.length() > 0) { + if (!name.isEmpty() && nsPrefix != null && !nsPrefix.isEmpty()) { name = nsPrefix + ":" + name; } return name; @@ -366,7 +381,7 @@ public class TypeOrElementOrAttributeReference implements PsiReference { public boolean execute(@NotNull final XmlTag element) { String name = element.getAttributeValue(SchemaReferencesProvider.NAME_ATTR_NAME); final String prefixByNamespace = tag.getPrefixByNamespace(namespace); - if (prefixByNamespace != null && prefixByNamespace.length() > 0 && prefix == null) { + if (prefixByNamespace != null && !prefixByNamespace.isEmpty() && prefix == null) { name = prefixByNamespace + ":" + name; } myElements.add( name ); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URLReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URLReference.java index bb8a1036ab15..557e8e0b0878 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URLReference.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/URLReference.java @@ -1,3 +1,18 @@ +/* + * 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. + * 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.psi.impl.source.resolve.reference.impl.providers; import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider; @@ -62,12 +77,12 @@ public class URLReference implements PsiReference, EmptyResolveMessageProvider { myIncorrectResourceMapped = false; final String canonicalText = getCanonicalText(); - if (canonicalText.length() == 0) { + if (canonicalText.isEmpty()) { final XmlAttribute attr = PsiTreeUtil.getParentOfType(getElement(), XmlAttribute.class); if (attr != null && attr.isNamespaceDeclaration() && - attr.getNamespacePrefix().length() == 0 || + attr.getNamespacePrefix().isEmpty() || ExternalResourceManagerEx.getInstanceEx().isIgnoredResource(canonicalText) ) { // Namespaces in XML 1.0 2nd edition, Section 6.2, last paragraph @@ -219,7 +234,7 @@ public class URLReference implements PsiReference, EmptyResolveMessageProvider { public static void processWsdlSchemas(final XmlTag rootTag, Processor processor) { if ("definitions".equals(rootTag.getLocalName())) { final String nsPrefix = rootTag.getNamespacePrefix(); - final String types = nsPrefix.length() == 0 ? "types" : nsPrefix + ":types"; + final String types = nsPrefix.isEmpty() ? "types" : nsPrefix + ":types"; final XmlTag subTag = rootTag.findFirstSubTag(types); if (subTag != null) { diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java index 4032f36cea99..814b06805a09 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/TagNameReference.java @@ -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. @@ -132,7 +132,7 @@ public class TagNameReference implements PsiReference { } private static String prependNamespacePrefix(String newElementName, String namespacePrefix) { - newElementName = (namespacePrefix.length() > 0 ? namespacePrefix + ":":namespacePrefix) + newElementName; + newElementName = (!namespacePrefix.isEmpty() ? namespacePrefix + ":":namespacePrefix) + newElementName; return newElementName; } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/TagNameVariantCollector.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/TagNameVariantCollector.java index cb80e547c0e5..9ff2f8aeb175 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/TagNameVariantCollector.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/TagNameVariantCollector.java @@ -131,7 +131,7 @@ public class TagNameVariantCollector { // If there are tags from default namespace they will be handled via // their element descriptors (prev if section) if (namespace == null) return; - if(namespace.length() == 0 && !visited.isEmpty()) return; + if(namespace.isEmpty() && !visited.isEmpty()) return; XmlNSDescriptor nsDescriptor = getDescriptor(element, namespace, true, extension); if (nsDescriptor == null) { diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java index c3afa3f6d1c5..e48926c9513b 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeImpl.java @@ -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. @@ -117,7 +117,7 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute { final String name = getName(); final String prefixByQualifiedName = XmlUtil.findPrefixByQualifiedName(name); // The namespace name for an unprefixed attribute name always has no value. Namespace recommendation section 6.2, third paragraph - if (prefixByQualifiedName.length() == 0) return XmlUtil.EMPTY_URI; + if (prefixByQualifiedName.isEmpty()) return XmlUtil.EMPTY_URI; return getParent().getNamespaceByPrefix(prefixByQualifiedName); } @@ -325,12 +325,12 @@ public class XmlAttributeImpl extends XmlElementImpl implements XmlAttribute { final String localName = getLocalName(); final String prefix = XmlUtil.findPrefixByQualifiedName(getName()); final TextRange range = - prefix.length() == 0 ? TextRange.from(getName().length(), 0) : TextRange.from(prefix.length() + 1, localName.length()); + prefix.isEmpty() ? TextRange.from(getName().length(), 0) : TextRange.from(prefix.length() + 1, localName.length()); refs[0] = new SchemaPrefixReference(this, range, localName, null); } else { final String prefix = getNamespacePrefix(); - if (prefix.length() > 0 && getLocalName().length() > 0) { + if (!prefix.isEmpty() && !getLocalName().isEmpty()) { refs = new PsiReference[referencesFromProviders.length + 2]; refs[0] = new SchemaPrefixReference(this, TextRange.from(0, prefix.length()), prefix, null); refs[1] = new XmlAttributeReference(this); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeReference.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeReference.java index b8681745976e..6ca97dd5acd4 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeReference.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeReference.java @@ -55,7 +55,7 @@ public class XmlAttributeReference implements PsiReference { public TextRange getRangeInElement() { final int parentOffset = myAttribute.getNameElement().getStartOffsetInParent(); int nsLen = myAttribute.getNamespacePrefix().length(); - nsLen += nsLen > 0 && myAttribute.getRealLocalName().length() > 0 ? 1 : -nsLen; + nsLen += nsLen > 0 && !myAttribute.getRealLocalName().isEmpty() ? 1 : -nsLen; return new TextRange(parentOffset + nsLen, parentOffset + myAttribute.getNameElement().getTextLength()); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeValueImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeValueImpl.java index eb278803f697..dbb7834f4b89 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeValueImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlAttributeValueImpl.java @@ -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. @@ -76,7 +76,7 @@ public class XmlAttributeValueImpl extends XmlElementImpl implements XmlAttribut public TextRange getValueTextRange() { final TextRange range = getTextRange(); final String value = getValue(); - if (value.length() == 0) { + if (value.isEmpty()) { return range; } final int start = range.getStartOffset() + getText().indexOf(value); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java index fea20095bc75..29d212496148 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlDocumentImpl.java @@ -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. @@ -217,7 +217,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { if (nsDescriptor == null) { String htmlns = ExternalResourceManagerEx.getInstanceEx().getDefaultHtmlDoctype(getProject()); - if (htmlns.length() == 0) { + if (htmlns.isEmpty()) { htmlns = Html5SchemaProvider.getHtml5SchemaLocation(); } nsDescriptor = getDefaultNSDescriptor(htmlns, false); @@ -226,7 +226,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { } else if (XmlUtil.XHTML_URI.equals(namespace)) { String xhtmlNamespace = XmlUtil.getDefaultXhtmlNamespace(getProject()); - if (xhtmlNamespace == null || xhtmlNamespace.length() == 0) { + if (xhtmlNamespace == null || xhtmlNamespace.isEmpty()) { xhtmlNamespace = Html5SchemaProvider.getXhtml5SchemaLocation(); } return getDefaultNSDescriptor(xhtmlNamespace, false); @@ -301,7 +301,7 @@ public class XmlDocumentImpl extends XmlElementImpl implements XmlDocument { final String dtdUri = XmlUtil.getDtdUri(doctype); LOG.debug("DTD url for doctype " + doctype.getText() + " in file " + filePath + " is " + dtdUri); - if (dtdUri != null && dtdUri.length() > 0){ + if (dtdUri != null && !dtdUri.isEmpty()){ XmlFile xmlFile = XmlUtil.findNamespace(containingFile, dtdUri); if (xmlFile == null) { // try to auto-detect it diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementContentGroupImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementContentGroupImpl.java index 06be625c8381..13b4a9f3e978 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementContentGroupImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlElementContentGroupImpl.java @@ -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. @@ -34,7 +34,7 @@ import org.jetbrains.annotations.NotNull; public class XmlElementContentGroupImpl extends XmlElementImpl implements XmlElementContentGroup, XmlElementType { - private NotNullLazyValue myParticles = new NotNullLazyValue() { + private final NotNullLazyValue myParticles = new NotNullLazyValue() { @NotNull @Override protected XmlContentParticle[] compute() { diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java index 7cbc00cc4587..c0c22c63c6e8 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTagImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 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. @@ -155,7 +155,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { if (startTagRef != null) { refs.add(startTagRef); } - if (prefix.length() > 0) { + if (!prefix.isEmpty()) { refs.add(createPrefixReference(startTagName, prefix, startTagRef)); } if (endTagName != null) { @@ -334,7 +334,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { return null; } - private Map> initializeSchema(final @NotNull String namespace, + private Map> initializeSchema(@NotNull final String namespace, @Nullable final String version, final String fileLocation, Map> map) { @@ -422,7 +422,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { } @Nullable - private PsiMetaOwner retrieveOwner(final XmlFile file, final @NotNull String namespace) { + private PsiMetaOwner retrieveOwner(final XmlFile file, @NotNull final String namespace) { if (file == null) { return namespace.equals(XmlUtil.getTargetSchemaNsFromTag(this)) ? this : null; } @@ -634,7 +634,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { if (keysByValue != null && !keysByValue.isEmpty()) { for (String prefix : keysByValue) { - if (prefix != null && prefix.length() > 0) { + if (prefix != null && !prefix.isEmpty()) { final String value = getAttributeValue(prefix + ":" + _name); if (value != null) return value; } @@ -646,7 +646,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { parent = parent.getParent(); } - if (namespace.length() == 0 || getNamespace().equals(namespace)) { + if (namespace.isEmpty() || getNamespace().equals(namespace)) { return getAttributeValue(_name); } return null; @@ -710,7 +710,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { } final String prefix = getPrefixByNamespace(namespace); - if (prefix == null || prefix.length() == 0) return null; + if (prefix == null || prefix.isEmpty()) return null; return getAttribute(prefix + ":" + name); } @@ -778,7 +778,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { //The prefix 'xml' is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but need not, be declared if (XML_NS_PREFIX.equals(prefix)) return XmlUtil.XML_NAMESPACE_URI; - if (prefix.length() > 0 && + if (!prefix.isEmpty() && !hasNamespaceDeclarations() && getNamespacePrefix().equals(prefix)) { // When there is no namespace declarations then qualified names should be just used in dtds @@ -973,7 +973,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag { public XmlAttribute setAttribute(String name, String namespace, String value) throws IncorrectOperationException { if (!Comparing.equal(namespace, "")) { final String prefix = getPrefixByNamespace(namespace); - if (prefix != null && prefix.length() > 0) name = prefix + ":" + name; + if (prefix != null && !prefix.isEmpty()) name = prefix + ":" + name; } return setAttribute(name, value); } diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTextImpl.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTextImpl.java index 7db38dfc37a2..d177362c719b 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTextImpl.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/XmlTextImpl.java @@ -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. @@ -227,7 +227,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI } public void insertText(String text, int displayOffset) throws IncorrectOperationException { - if (text == null || text.length() == 0) return; + if (text == null || text.isEmpty()) return; final int physicalOffset = displayToPhysical(displayOffset); final PsiElement psiElement = findElementAt(physicalOffset); @@ -296,7 +296,7 @@ public class XmlTextImpl extends XmlElementImpl implements XmlText, PsiLanguageI public PomModelEvent runInner() throws IncorrectOperationException { final String oldText = getText(); - if (newElementText.length() > 0) { + if (!newElementText.isEmpty()) { final ASTNode e = getPolicy().encodeXmlTextContents(newElementText, XmlTextImpl.this); replaceChild(psiElement.getNode(), e); diff --git a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/CDATAOnAnyEncodedPolicy.java b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/CDATAOnAnyEncodedPolicy.java index c22c6d9c0bcc..69f8c40c3ff5 100644 --- a/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/CDATAOnAnyEncodedPolicy.java +++ b/xml/xml-psi-impl/src/com/intellij/psi/impl/source/xml/behavior/CDATAOnAnyEncodedPolicy.java @@ -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. @@ -33,7 +33,7 @@ public class CDATAOnAnyEncodedPolicy extends DefaultXmlPsiPolicy{ public ASTNode encodeXmlTextContents(String displayText, PsiElement text) { final ASTNode firstChild = text.getNode().getFirstChildNode(); boolean textAlreadyHasCDATA = firstChild != null && firstChild.getElementType() == XmlElementType.XML_CDATA; - if ((textAlreadyHasCDATA || XmlUtil.toCode(displayText)) && displayText.length() > 0) { + if ((textAlreadyHasCDATA || XmlUtil.toCode(displayText)) && !displayText.isEmpty()) { final FileElement dummyParent = createCDATAElement(text.getManager(), SharedImplUtil.findCharTableByTree(text.getNode()), displayText); return dummyParent.getFirstChildNode(); }