Skip to content

Commit

Permalink
Merge pull request #68 from RabotaRu/v3.13.0
Browse files Browse the repository at this point in the history
v3.13.0
  • Loading branch information
rpiontik authored Feb 16, 2024
2 parents 1d6ed57 + 74bfadd commit 816bd37
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 123 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project Properties
group=org.dochub.idea
version=3.12.1
version=3.13.0

# Supported build number ranges and IntelliJ Platform versions
pluginSinceBuild=231
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ScrollType;
import com.intellij.util.text.CharArrayUtil;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

import static org.apache.commons.lang3.StringUtils.repeat;

public class FormattingInsertHandler implements InsertHandler {
private final CompletionKey key;

Expand Down Expand Up @@ -44,19 +47,19 @@ public void handleInsert(@NotNull final InsertionContext context, @NotNull final
TabOutScopesTracker.getInstance().registerEmptyScopeAtCaret(context.getEditor());
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
editor.getSelectionModel().removeSelection();
AutoPopupController.getInstance(editor.getProject()).scheduleAutoPopup(editor);
AutoPopupController.getInstance(Objects.requireNonNull(editor.getProject())).scheduleAutoPopup(editor);
}

private String getCharsToInsert() {
StringBuilder result = new StringBuilder(":");
switch (key.getValueType()) {
case MAP:
result.append("\n")
.append(StringUtils.repeat(" ", (documentLevel + 1) * 2));
.append(repeat(" ", (documentLevel + 1) * 2));
break;
case LIST:
result.append("\n")
.append(StringUtils.repeat(" ", (documentLevel + 1) * 2))
.append(repeat(" ", (documentLevel + 1) * 2))
.append("- ");
break;
default:
Expand Down
38 changes: 27 additions & 11 deletions src/main/java/org/dochub/idea/arch/indexing/DocHubIndexData.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,27 @@
import com.intellij.psi.PsiFile;
import org.yaml.snakeyaml.Yaml;

import java.io.*;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;

public final class DocHubIndexData extends HashMap<String, DocHubIndexData.Section> {

public class Section {
public ArrayList<String> locations = new ArrayList();
public ArrayList<String> ids = new ArrayList();
public List<String> locations = new ArrayList<>();
public List<String> ids = new ArrayList<>();
public List<String> imports = new ArrayList<>();

public boolean isEmpty() {
return (locations.size() + ids.size() + imports.size()) == 0;
}
Expand Down Expand Up @@ -110,8 +117,15 @@ public void parse(DataInput in) throws ClassNotFoundException, IOException {
}

public void makeCacheDataImports(Map<String, Object> yaml) {
ArrayList<String> result = (ArrayList<String>) yaml.get("imports");
if ((result != null) && (result.size() > 0)) {
List<String> imports = (List<String>) yaml.get("imports");

List<String> result = Optional.ofNullable(imports)
.stream()
.flatMap(Collection::stream)
.filter(e -> e != null && !e.isEmpty())
.toList();

if (!result.isEmpty()) {
Section section = new Section();
section.imports = result;
this.put("imports", section);
Expand All @@ -123,27 +137,28 @@ public void makeCacheDataSection(Map<String, Object> yaml, String section) {
try {
Map<String, Object> keys = (Map<String, Object>) yaml.get(section);
if (keys != null) {
for ( String id : keys.keySet()) {
for (String id : keys.keySet()) {
secData.ids.add(id);
Object object = yaml.get(id);
if (object instanceof Map) {
Object location = ((Map) object).get("location");
if (location instanceof String) {
if (location != null) secData.locations.add((String) location);
secData.locations.add((String) location);
}
}
}
}
if ((secData.locations.size()) > 0 || (secData.ids.size() > 0) )
if ((secData.locations.size()) > 0 || (secData.ids.size() > 0))
this.put(section, secData);
} catch (ClassCastException e) {}
} catch (ClassCastException e) {
}
}

public void makeCacheDataManifest(PsiFile file) {
VirtualFile vFile = file.getVirtualFile();
if (vFile != null) {
String path = vFile.getPath();
try(InputStream inputStream = new FileInputStream(path)) {
try (InputStream inputStream = new FileInputStream(path)) {
Yaml yaml = new Yaml();
Map<String, Object> sections = yaml.load(inputStream);
if (sections != null) {
Expand All @@ -154,7 +169,8 @@ public void makeCacheDataManifest(PsiFile file) {
makeCacheDataSection(sections, "docs");
makeCacheDataSection(sections, "datasets");
}
} catch (Exception e) {}
} catch (Exception e) {
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ public static VirtualFile applySchema(Project project, String schema) {
LocalFileSystem fs = LocalFileSystem.getInstance();
currentSchema = fs.findFileByPath(file.getAbsolutePath());

VirtualFileManager.getInstance().refreshAndFindFileByNioPath(file.toPath());


schemas.put(projectHash, currentSchema);

Runnable dropCaches = () -> {
Expand Down
198 changes: 99 additions & 99 deletions src/main/resources/html/plugin.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ entities:
schema:
type: object
patternProperties:
"^[a-zA-Z][a-zA-Z0-9_-]*(\\.[a-zA-Z][a-zA-Z0-9_-]*)*$":
"^[a-zA-Z][a-zA-Z0-9_-]*(\\.[a-zA-Z0-9][a-zA-Z0-9_-]*)*$":
type: object
properties:
title:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ entities:
items:
type: string
title: Идентификатор компонента или маска
pattern: "^[0-9a-zA-Z][a-zA-Z0-9\\_]*(\\.([a-zA-Z][a-zA-Z0-9\\_]*|\\*))*$"
pattern: "^[0-9a-zA-Z][a-zA-Z0-9\\_]*(\\.([a-zA-Z0-9][a-zA-Z0-9\\_]*|\\*))*$"
extra-links:
title: Отображать компоненты ближайших связей
type: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ entities:
properties:
"dh-context-id":
title: Идентификатор контекста
type: string
pattern: ^[0-9a-zA-Z][a-zA-Z0-9_-]*(\.[a-zA-Z][a-zA-Z0-9_-]*)*$
type: string
pattern: ^[0-9a-zA-Z][a-zA-Z0-9_-]*(\.[0-9a-zA-Z][a-zA-Z0-9_-]*)*$
"dh-focus-id":
title: Идентификатор требующий подсветку
type: string
pattern: ^[0-9a-zA-Z][a-zA-Z0-9_-]*(\.[a-zA-Z][a-zA-Z0-9_-]*)*$
pattern: ^[0-9a-zA-Z][a-zA-Z0-9_-]*(\.[a-zA-Z0-9][a-zA-Z0-9_-]*)*$
required:
- dh-context-id
type: plantuml
Expand Down

0 comments on commit 816bd37

Please sign in to comment.