forked from ligasgr/intellij-xquery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding visibility filter - structure view is able to filter non-publi…
…c functions/variables Closes ligasgr#72
- Loading branch information
Showing
5 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
Arnost Valicek <arnost.valicek@gmail.com> - Issue #47 - Structure view should display visibility modifier | ||
Slawomir Wachowski <slawwach@gmail.com> - Issue #51 - Highlighting unused imports | ||
Michal Jedynak <m.jedynak@gmail.com> - Issue #22 - Duplicate declarations code insight | ||
Arnost Valicek <arnost.valicek@gmail.com> - Issue #72 - Structure view should be able to filter-out non-public functions and variables |
54 changes: 54 additions & 0 deletions
54
src/main/java/org/intellij/xquery/structure/VisibilityFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2013 Grzegorz Ligas <ligasgr@gmail.com> and other contributors (see the CONTRIBUTORS file). | ||
* | ||
* 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 org.intellij.xquery.structure; | ||
|
||
import com.intellij.ide.util.treeView.smartTree.ActionPresentation; | ||
import com.intellij.ide.util.treeView.smartTree.ActionPresentationData; | ||
import com.intellij.ide.util.treeView.smartTree.Filter; | ||
import com.intellij.ide.util.treeView.smartTree.TreeElement; | ||
import com.intellij.util.PlatformIcons; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class VisibilityFilter implements Filter { | ||
|
||
@NotNull | ||
@Override | ||
public ActionPresentation getPresentation() { | ||
return new ActionPresentationData("Show non-public", null, PlatformIcons.PRIVATE_ICON); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public String getName() { | ||
return "SHOW_NON_PUBLIC_FILTER"; | ||
} | ||
|
||
@Override | ||
public boolean isVisible(TreeElement element) { | ||
if (element instanceof XQueryStructureViewElement) { | ||
return ((XQueryStructureViewElement) element).isPublic(); | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean isReverted() { | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/test/java/org/intellij/xquery/structure/VisibilityFilterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2013 Grzegorz Ligas <ligasgr@gmail.com> and other contributors (see the CONTRIBUTORS file). | ||
* | ||
* 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 org.intellij.xquery.structure; | ||
|
||
import com.intellij.ide.util.treeView.smartTree.Filter; | ||
import org.junit.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
import static org.mockito.BDDMockito.given; | ||
import static org.mockito.Mockito.mock; | ||
|
||
public class VisibilityFilterTest { | ||
Filter filter = new VisibilityFilter(); | ||
|
||
@Test | ||
public void nonPublicElemensShouldBeDisplaydWhenButtonIsPressed() { | ||
assertThat(filter.isReverted(), is(true)); | ||
} | ||
|
||
@Test | ||
public void privateStructureViewElemensIsNotVisible() { | ||
XQueryStructureViewElement element = mock(XQueryStructureViewElement.class); | ||
given(element.isPublic()).willReturn(false); | ||
|
||
final boolean visible = filter.isVisible(element); | ||
assertThat(visible, is(false)); | ||
} | ||
|
||
@Test | ||
public void publicStructureViewElemensIsVisible() { | ||
XQueryStructureViewElement element = mock(XQueryStructureViewElement.class); | ||
given(element.isPublic()).willReturn(true); | ||
|
||
final boolean visible = filter.isVisible(element); | ||
assertThat(visible, is(true)); | ||
} | ||
|
||
|
||
} |