Skip to content

Commit

Permalink
Merge pull request #163 from ZenUml/fixing-preview-static-server-cast…
Browse files Browse the repository at this point in the history
…ing-error

Fixing preview static server casting error
  • Loading branch information
MrCoder authored Mar 9, 2021
2 parents 7585cbe + cbd8428 commit 82daf26
Show file tree
Hide file tree
Showing 47 changed files with 133 additions and 740 deletions.
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'java'
id 'idea'
id 'org.jetbrains.intellij' version '0.4.21'
id 'org.jetbrains.kotlin.jvm' version '1.3.21'
id 'org.jetbrains.kotlin.jvm' version '1.4.21'
}

repositories {
Expand All @@ -15,8 +15,8 @@ dependencies {
// https://mvnrepository.com/artifact/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer
compile group: 'com.googlecode.owasp-java-html-sanitizer', name: 'owasp-java-html-sanitizer'
compile "org.jetbrains:markdown:${markdownParserVersion}"
compile "org.jetbrains.kotlin:kotlin-reflect:1.3.21"
compile "org.jetbrains.kotlin:kotlin-stdlib:1.3.21"
compile "org.jetbrains.kotlin:kotlin-reflect:1.4.21"
compile "org.jetbrains.kotlin:kotlin-stdlib:1.4.21"
compile "io.reactivex.rxjava2:rxjava:2.2.9"

testCompile group: 'junit', name: 'junit', version: '4.12'
Expand All @@ -27,7 +27,7 @@ targetCompatibility = javaVersion

compileKotlin {
kotlinOptions.jvmTarget = javaVersion
kotlinOptions.apiVersion = "1.3"
kotlinOptions.apiVersion = "1.4"
}
compileTestKotlin {
kotlinOptions.jvmTarget = javaVersion
Expand All @@ -54,11 +54,11 @@ sourceSets {
}

intellij {
version 'IC-2020.2'
version 'IC-2020.3.2'
pluginName 'zenuml'
downloadSources false
updateSinceUntilBuild false
plugins = ['IntelliLang', 'java', 'com.intellij.javafx:1.0.2']
plugins = ['IntelliLang', 'java']
}

//buildSearchableOptions {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
23 changes: 13 additions & 10 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

##############################################################################
##
Expand Down Expand Up @@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

warn ( ) {
warn () {
echo "$*"
}

die ( ) {
die () {
echo
echo "$*"
echo
Expand Down Expand Up @@ -154,16 +154,19 @@ if $cygwin ; then
esac
fi

# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
APP_ARGS=$(save "$@")

# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"

# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi

exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
exec "$JAVACMD" "$@"
8 changes: 4 additions & 4 deletions resource/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<idea-plugin>
<id>com.zenuml.jetbrains</id>
<name>ZenUML support</name>
<version>2020.2</version>
<version>2021.3</version>
<idea-version since-build="202.6397.94"/>
<vendor url="http://www.zenuml.com">ZenUML</vendor>

<depends>com.intellij.modules.lang</depends>
<depends>com.intellij.modules.java</depends>
<depends>com.intellij.javafx</depends>
<depends optional="true" config-file="plugin-intelliLang.xml">org.intellij.intelliLang</depends>

<description><![CDATA[
Expand Down Expand Up @@ -66,7 +65,8 @@ Includes the following features:</p>
</extensionPoints>

<extensions defaultExtensionNs="com.intellij">
<fileTypeFactory implementation="org.intellij.plugins.markdown.lang.MarkdownFileTypeFactory"/>
<fileType name="ZenUML" extensions="z;zen;zenuml" language="ZenUML"
implementationClass="org.intellij.plugins.markdown.lang.ZenUmlFileType" fieldName="INSTANCE"/>
<lang.parserDefinition language="ZenUML" implementationClass="org.intellij.plugins.markdown.lang.parser.MarkdownParserDefinition"/>
<lang.ast.factory language="ZenUML" implementationClass="org.intellij.plugins.markdown.lang.psi.MarkdownASTFactory"/>

Expand Down Expand Up @@ -111,7 +111,7 @@ Includes the following features:</p>
implementationClass="org.intellij.plugins.markdown.structureView.MarkdownStructureViewFactory"/>
<psi.referenceContributor implementation="org.intellij.plugins.markdown.lang.references.MarkdownReferenceProvider"/>
<stripTrailingSpacesFilterFactory implementation="org.intellij.plugins.markdown.editor.MarkdownStripTrailingSpacesFilterFactory"/>
<httpRequestHandler implementation="org.intellij.plugins.markdown.ui.preview.PreviewStaticServer"/>
<httpRequestHandler implementation="org.intellij.plugins.markdown.ui.preview.PreviewStaticServer2"/>

<localInspection shortName="ZenUmlUnresolvedFileReference" bundle="org.intellij.plugins.markdown.bundle.MarkdownBundle"
key="zenuml.placeholder.inspection.name" groupKey="zenuml.inspection.group.ruby.name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
import com.intellij.lang.PairedBraceMatcher;
import com.intellij.psi.PsiFile;
import com.intellij.psi.tree.IElementType;
import org.intellij.plugins.markdown.lang.MarkdownLanguage;
import org.intellij.plugins.markdown.lang.ZenUmlLanguage;
import org.intellij.plugins.markdown.lang.MarkdownTokenTypes;
import org.jetbrains.annotations.NotNull;

public class MarkdownBraceMatcher extends PairedBraceMatcherAdapter {

public MarkdownBraceMatcher() {
super(new MyPairedBraceMatcher(), MarkdownLanguage.INSTANCE);
super(new MyPairedBraceMatcher(), ZenUmlLanguage.INSTANCE);
}

private static class MyPairedBraceMatcher implements PairedBraceMatcher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.intellij.openapi.editor.StripTrailingSpacesFilterFactory;
import com.intellij.openapi.editor.impl.PsiBasedStripTrailingSpacesFilter;
import com.intellij.openapi.project.Project;
import org.intellij.plugins.markdown.lang.MarkdownLanguage;
import org.intellij.plugins.markdown.lang.ZenUmlLanguage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -31,7 +31,7 @@ public class MarkdownStripTrailingSpacesFilterFactory extends StripTrailingSpace
@Override
public StripTrailingSpacesFilter createFilter(@Nullable Project project, @NotNull Document document) {
Language documentLanguage = PsiBasedStripTrailingSpacesFilter.getDocumentLanguage(document);
if (documentLanguage != null && documentLanguage.is(MarkdownLanguage.INSTANCE)) {
if (documentLanguage != null && documentLanguage.is(ZenUmlLanguage.INSTANCE)) {
return StripTrailingSpacesFilter.NOT_ALLOWED;
}
return StripTrailingSpacesFilter.ALL_LINES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class MarkdownElementType extends IElementType {
new HashMap<>();

public MarkdownElementType(@NotNull @NonNls String debugName) {
super(debugName, MarkdownLanguage.INSTANCE);
super(debugName, ZenUmlLanguage.INSTANCE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import static org.intellij.plugins.markdown.lang.MarkdownElementType.platformType;

public interface MarkdownElementTypes {
IFileElementType MARKDOWN_FILE_ELEMENT_TYPE = new IStubFileElementType("Markdown file", MarkdownLanguage.INSTANCE);
IFileElementType MARKDOWN_FILE_ELEMENT_TYPE = new IStubFileElementType("ZenUML file", ZenUmlLanguage.INSTANCE);

IElementType MARKDOWN_FILE = platformType(org.intellij.markdown.MarkdownElementTypes.MARKDOWN_FILE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
public class MarkdownFileTypeFactory extends FileTypeFactory {
@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
consumer.consume(MarkdownFileType.INSTANCE, "z;zen;zenuml");
consumer.consume(ZenUmlFileType.INSTANCE, "z;zen;zenuml");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class MarkdownLazyElementType extends ILazyParseableElementType {
public MarkdownLazyElementType(@NotNull @NonNls String debugName) {
super(debugName, MarkdownLanguage.INSTANCE);
super(debugName, ZenUmlLanguage.INSTANCE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@

import javax.swing.*;

public class MarkdownFileType extends LanguageFileType {
public static final MarkdownFileType INSTANCE = new MarkdownFileType();
public class ZenUmlFileType extends LanguageFileType {
public static final ZenUmlFileType INSTANCE = new ZenUmlFileType();

private MarkdownFileType() {
super(MarkdownLanguage.INSTANCE);
private ZenUmlFileType() {
super(ZenUmlLanguage.INSTANCE);
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

import com.intellij.lang.Language;

public class MarkdownLanguage extends Language {
public class ZenUmlLanguage extends Language {

public static final MarkdownLanguage INSTANCE = new MarkdownLanguage();
public static final ZenUmlLanguage INSTANCE = new ZenUmlLanguage();

protected MarkdownLanguage() {
protected ZenUmlLanguage() {
super("ZenUML", "text/x-zenuml");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package org.intellij.plugins.markdown.lang.formatter

import com.intellij.application.options.TabbedLanguageCodeStylePanel
import com.intellij.psi.codeStyle.CodeStyleSettings
import org.intellij.plugins.markdown.lang.MarkdownLanguage
import org.intellij.plugins.markdown.lang.ZenUmlLanguage

class MarkdownCodeStyleSettingsPanel(currentSettings: CodeStyleSettings, settings: CodeStyleSettings)
: TabbedLanguageCodeStylePanel(MarkdownLanguage.INSTANCE, currentSettings, settings) {
: TabbedLanguageCodeStylePanel(ZenUmlLanguage.INSTANCE, currentSettings, settings) {

override fun initTabs(settings: CodeStyleSettings?) {
addWrappingAndBracesTab(settings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import com.intellij.psi.codeStyle.CodeStyleConfigurable
import com.intellij.psi.codeStyle.CodeStyleSettings
import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider
import org.intellij.plugins.markdown.lang.MarkdownLanguage
import org.intellij.plugins.markdown.lang.ZenUmlLanguage

class MarkdownLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvider() {
override fun getLanguage(): Language = MarkdownLanguage.INSTANCE
override fun getLanguage(): Language = ZenUmlLanguage.INSTANCE

private val STANDARD_WRAPPING_OPTIONS = arrayOf("RIGHT_MARGIN", "WRAP_ON_TYPING")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MarkdownHeadersIndex : StringStubIndexExtension<MarkdownHeaderImpl>() {
val KEY: StubIndexKey<String, MarkdownHeaderImpl> = StubIndexKey.createIndexKey<String, MarkdownHeaderImpl>("zenuml.header")

fun collectFileHeaders(suggestHeaderRef: String, project: Project, psiFile: PsiFile?): Collection<PsiElement> {
val list = ContainerUtil.newArrayList<PsiElement>()
val list = ArrayList<PsiElement>()
StubIndex.getInstance().processElements(MarkdownHeadersIndex.KEY, suggestHeaderRef, project,
psiFile?.let { GlobalSearchScope.fileScope(it) },
MarkdownHeaderImpl::class.java,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.intellij.psi.impl.PsiFileFactoryImpl;
import com.intellij.testFramework.LightVirtualFile;
import com.intellij.util.ObjectUtils;
import org.intellij.plugins.markdown.lang.MarkdownLanguage;
import org.intellij.plugins.markdown.lang.ZenUmlLanguage;
import org.intellij.plugins.markdown.lang.psi.impl.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -32,9 +32,9 @@ private MarkdownPsiElementFactory() { }

@NotNull
public static MarkdownFile createFile(@NotNull Project project, @NotNull String text) {
final LightVirtualFile virtualFile = new LightVirtualFile("temp.rb", MarkdownLanguage.INSTANCE, text);
final LightVirtualFile virtualFile = new LightVirtualFile("temp.rb", ZenUmlLanguage.INSTANCE, text);
PsiFile psiFile = ((PsiFileFactoryImpl)PsiFileFactory.getInstance(project))
.trySetupPsiForFile(virtualFile, MarkdownLanguage.INSTANCE, true, true);
.trySetupPsiForFile(virtualFile, ZenUmlLanguage.INSTANCE, true, true);

if (!(psiFile instanceof MarkdownFile)) {
throw new RuntimeException("Cannot create a new markdown file. Text: " + text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
import com.intellij.openapi.fileTypes.FileType;
import com.intellij.psi.FileViewProvider;
import com.intellij.psi.PsiElementVisitor;
import org.intellij.plugins.markdown.lang.MarkdownFileType;
import org.intellij.plugins.markdown.lang.MarkdownLanguage;
import org.intellij.plugins.markdown.lang.ZenUmlFileType;
import org.intellij.plugins.markdown.lang.ZenUmlLanguage;
import org.intellij.plugins.markdown.lang.psi.MarkdownElementVisitor;
import org.intellij.plugins.markdown.lang.psi.MarkdownPsiElement;
import org.jetbrains.annotations.NotNull;

public class MarkdownFile extends PsiFileBase implements MarkdownPsiElement {
public MarkdownFile(FileViewProvider viewProvider) {
super(viewProvider, MarkdownLanguage.INSTANCE);
super(viewProvider, ZenUmlLanguage.INSTANCE);
}

@Override
Expand All @@ -43,6 +43,6 @@ public void accept(@NotNull PsiElementVisitor visitor) {
@Override
@NotNull
public FileType getFileType() {
return MarkdownFileType.INSTANCE;
return ZenUmlFileType.INSTANCE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MarkdownAnchorReferenceImpl internal constructor(private val myAnchor: Str

override fun getVariants(): Array<Any> {
val project = myPsiElement.project
val list = ContainerUtil.newArrayList<String>()
val list = ArrayList<String>()

StubIndex.getInstance().getAllKeys(MarkdownHeadersIndex.KEY, project)
.forEach { key ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.stubs.IStubElementType;
import org.intellij.plugins.markdown.lang.MarkdownLanguage;
import org.intellij.plugins.markdown.lang.ZenUmlLanguage;
import org.intellij.plugins.markdown.lang.psi.MarkdownPsiElement;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

public abstract class MarkdownStubElementType<S extends MarkdownStubElement, T extends MarkdownPsiElement> extends IStubElementType<S, T> {
public abstract class MarkdownStubElementType<S extends MarkdownStubElement<?>, T extends MarkdownPsiElement> extends IStubElementType<S, T> {
public MarkdownStubElementType(@NotNull @NonNls String debugName) {
super(debugName, MarkdownLanguage.INSTANCE);
super(debugName, ZenUmlLanguage.INSTANCE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

public class MarkdownSettingsConfigurable implements SearchableConfigurable {
static final String PLANT_UML_DIRECTORY = "plantUML";
static final String PLANTUML_JAR_URL = Registry.stringValue("markdown.plantuml.download.link");
static final String PLANTUML_JAR = "plantuml.jar";

private static final String DOWNLOAD_CACHE_DIRECTORY = "download-cache";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import com.intellij.psi.util.PsiTreeUtil;
import org.intellij.plugins.markdown.lang.MarkdownLanguage;
import org.intellij.plugins.markdown.lang.ZenUmlLanguage;
import org.intellij.plugins.markdown.ui.split.SplitFileEditor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -45,7 +45,7 @@ public static Editor findMarkdownTextEditor(AnActionEvent e) {
// This fallback is used primarily for testing

final PsiFile psiFile = e.getData(CommonDataKeys.PSI_FILE);
if (psiFile != null && psiFile.getLanguage() == MarkdownLanguage.INSTANCE && ApplicationManager.getApplication().isUnitTestMode()) {
if (psiFile != null && psiFile.getLanguage() == ZenUmlLanguage.INSTANCE && ApplicationManager.getApplication().isUnitTestMode()) {
return e.getData(CommonDataKeys.EDITOR);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface MarkdownHtmlPanel extends Disposable {
"darcula.css",
"vue-sequence-ext.css",
"font-awesome.min.css",
PreviewStaticServer.INLINE_CSS_FILENAME
PreviewStaticServer2.INLINE_CSS_FILENAME
);

@NotNull
Expand Down Expand Up @@ -67,10 +67,10 @@ static String getCssLines(@Nullable String inlineCss, @NotNull String... fileUri

static String migrateUriToHttp(@NotNull String uri) {
if (uri.equals(MarkdownCssSettings.DEFAULT.getStylesheetUri())) {
return PreviewStaticServer.getStyleUrl("default.css");
return PreviewStaticServer2.getStyleUrl("default.css");
}
else if (uri.equals(MarkdownCssSettings.DARCULA.getStylesheetUri())) {
return PreviewStaticServer.getStyleUrl("darcula.css");
return PreviewStaticServer2.getStyleUrl("darcula.css");
}
else {
return uri;
Expand Down
Loading

0 comments on commit 82daf26

Please sign in to comment.