-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom AsciiDoc search scopes (#1216)
- Loading branch information
Showing
10 changed files
with
174 additions
and
1 deletion.
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
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
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
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,22 @@ | ||
= Searching content | ||
:description: All AsciiDoc content is indexed, which allows fast searching. | ||
|
||
{description} | ||
|
||
== Overview | ||
|
||
There is standard functionality to search in IntelliJ: | ||
|
||
Users can search in a single file using kbd:[Ctrl+F]. | ||
Replacing is done via kbd:[Ctrl+R]. | ||
|
||
Users can search in all files using kbd:[Ctrl+Shift+F]. | ||
By default, the search is case-insensitive and searches for text snippets. | ||
It can be changed to search case-sensitive and with regexes. | ||
Replacing is available via kbd:[Ctrl+Shift+R]. | ||
|
||
When searching in the project, and also renaming entities, the plugin adds two new search scopes: _AsciiDoc files_ and _AsciiDoc files without Symlinks_. | ||
|
||
Using kbd:[Shift+Shift] (search everything), the user can search for all named elements. By default, the search returns file names. | ||
The plugin adds the capability to include section headings, attribute names, tags and IDs. | ||
|
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
28 changes: 28 additions & 0 deletions
28
src/main/java/org/asciidoc/intellij/searchScopes/AsciiDocSearchScopeProvider.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,28 @@ | ||
package org.asciidoc.intellij.searchScopes; | ||
|
||
import com.intellij.openapi.actionSystem.DataContext; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.psi.search.SearchScope; | ||
import com.intellij.psi.search.SearchScopeProvider; | ||
import org.asciidoc.intellij.psi.AsciiDocSearchScope; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class AsciiDocSearchScopeProvider implements SearchScopeProvider { | ||
@Override | ||
public @Nullable String getDisplayName() { | ||
return "AsciiDoc"; | ||
} | ||
|
||
@Override | ||
public @NotNull List<SearchScope> getSearchScopes(@NotNull Project project, @NotNull DataContext dataContext) { | ||
ArrayList<SearchScope> result = new ArrayList<>(); | ||
result.add(new AsciiDocSearchScopeWithName(new AsciiDocSearchScope(project).excludeSymlinks(), "All files without Symlinks")); | ||
result.add(new AsciiDocSearchScopeWithName(new AsciiDocSearchScope(project).restrictedByAsciiDocFileType(), "AsciiDoc files")); | ||
result.add(new AsciiDocSearchScopeWithName(new AsciiDocSearchScope(project).excludeSymlinks().restrictedByAsciiDocFileType(), "AsciiDoc files without Symlinks")); | ||
return result; | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/main/java/org/asciidoc/intellij/searchScopes/AsciiDocSearchScopeWithName.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,81 @@ | ||
package org.asciidoc.intellij.searchScopes; | ||
|
||
import com.intellij.openapi.module.Module; | ||
import com.intellij.openapi.vfs.VirtualFile; | ||
import com.intellij.psi.search.GlobalSearchScope; | ||
import com.intellij.psi.search.SearchScope; | ||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.Nls; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.*; | ||
import java.util.Objects; | ||
|
||
public class AsciiDocSearchScopeWithName extends GlobalSearchScope { | ||
|
||
private final GlobalSearchScope searchScope; | ||
private final String name; | ||
|
||
public AsciiDocSearchScopeWithName(GlobalSearchScope searchScope, String name) { | ||
this.searchScope = searchScope; | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
protected int calcHashCode() { | ||
return Objects.hash(name); | ||
} | ||
|
||
@SuppressWarnings("checkstyle:EqualsHashCode") | ||
@Override | ||
public boolean equals(Object obj) { | ||
if (!(obj instanceof AsciiDocSearchScopeWithName)) { | ||
return false; | ||
} | ||
return Objects.equals(name, ((AsciiDocSearchScopeWithName) obj).name); | ||
} | ||
|
||
@Override | ||
@Nls(capitalization = Nls.Capitalization.Sentence) | ||
@NotNull | ||
public String getDisplayName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public @Nullable Icon getIcon() { | ||
return searchScope.getIcon(); | ||
} | ||
|
||
@Override | ||
public boolean isSearchInModuleContent(@NotNull Module aModule) { | ||
return searchScope.isSearchInModuleContent(aModule); | ||
} | ||
|
||
@Override | ||
public boolean isSearchInLibraries() { | ||
return searchScope.isSearchInLibraries(); | ||
} | ||
|
||
@Override | ||
@Contract(pure = true) | ||
@NotNull | ||
public SearchScope intersectWith(@NotNull SearchScope scope2) { | ||
return searchScope.intersectWith(scope2); | ||
} | ||
|
||
@Override | ||
@Contract(pure = true) | ||
@NotNull | ||
public GlobalSearchScope union(@NotNull SearchScope scope) { | ||
return searchScope.union(scope); | ||
} | ||
|
||
@Override | ||
@Contract(pure = true) | ||
public boolean contains(@NotNull VirtualFile file) { | ||
return searchScope.contains(file); | ||
} | ||
|
||
} |
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