From 93a03e25ba7c490e4f76ab34e9524aca4f207f76 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Wed, 1 May 2013 17:40:36 +0400 Subject: [PATCH] notnull/nullable --- .../groovy/formatter/AlignmentProvider.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/AlignmentProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/AlignmentProvider.java index 72c4f2ee18f0..900f7acfd1a3 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/AlignmentProvider.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/AlignmentProvider.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,11 +36,11 @@ class AlignmentProvider { private final Map, Boolean> myAllowBackwardShift = new HashMap, Boolean>(); private final Map, Alignment.Anchor> myAnchor = new HashMap, Alignment.Anchor>(); - public void addPair(PsiElement e1, PsiElement e2, Boolean allowBackwardShift) { + public void addPair(@NotNull PsiElement e1, @NotNull PsiElement e2, @Nullable Boolean allowBackwardShift) { addPair(e1, e2, allowBackwardShift, null); } - public void addPair(PsiElement e1, PsiElement e2, @Nullable Boolean allowBackwardShift, @Nullable Alignment.Anchor anchor) { + public void addPair(@NotNull PsiElement e1, @NotNull PsiElement e2, @Nullable Boolean allowBackwardShift, @Nullable Alignment.Anchor anchor) { assert e1 != e2; final Set set1 = myTree.get(e1); @@ -102,11 +102,12 @@ class AlignmentProvider { } } - private void addInternal(Set set, PsiElement element) { + private void addInternal(@NotNull Set set, @NotNull PsiElement element) { myTree.put(element, set); set.add(element); } + @NotNull private static HashSet createHashSet() { return new HashSet() { private final int myhash = new Object().hashCode(); @@ -118,15 +119,15 @@ class AlignmentProvider { }; } - public void addPair(ASTNode node1, ASTNode node2, boolean allowBackwardShift) { + public void addPair(@NotNull ASTNode node1, @NotNull ASTNode node2, boolean allowBackwardShift) { addPair(node1.getPsi(), node2.getPsi(), allowBackwardShift); } - private void add(PsiElement element, boolean allowBackwardShift) { + private void add(@NotNull PsiElement element, boolean allowBackwardShift) { add(element, allowBackwardShift, Alignment.Anchor.LEFT); } - private void add(PsiElement element, boolean allowBackwardShift, @NotNull Alignment.Anchor anchor) { + private void add(@NotNull PsiElement element, boolean allowBackwardShift, @NotNull Alignment.Anchor anchor) { if (myTree.get(element) != null) return; final HashSet set = createHashSet(); @@ -137,7 +138,7 @@ class AlignmentProvider { } @Nullable - public Alignment getAlignment(PsiElement e) { + public Alignment getAlignment(@NotNull PsiElement e) { final Set set = myTree.get(e); if (set == null) { return null; @@ -156,10 +157,12 @@ class AlignmentProvider { return alignment; } + @NotNull public Aligner createAligner(boolean allowBackwardShift) { return new Aligner(allowBackwardShift, Alignment.Anchor.LEFT); } + @NotNull public Aligner createAligner(PsiElement element, boolean allowBackwardShift, Alignment.Anchor anchor) { final Aligner aligner = new Aligner(allowBackwardShift, anchor); aligner.append(element);