Skip to content

Commit

Permalink
fixed more reports
Browse files Browse the repository at this point in the history
  • Loading branch information
yasamprom committed Jul 4, 2022
1 parent 23bd13a commit db18081
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 35 deletions.
36 changes: 18 additions & 18 deletions src/main/java/org/eolang/jetbrains/EOColorSettingsPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@

/**
* Class drawing settings page in IDE
* @since 0.0.0
* @see <a href="https://plugins.jetbrains.com/docs/intellij/syntax-highlighter-and-color-settings-page.html">
* documentation</a>
* documentation</a>
*/

public class EOColorSettingsPage implements ColorSettingsPage {
private static final AttributesDescriptor[] DESCRIPTORS =
new AttributesDescriptor[] {
Expand All @@ -49,7 +49,7 @@ public class EOColorSettingsPage implements ColorSettingsPage {
new AttributesDescriptor("Strings", EOSyntaxHighlighter.STRING),
new AttributesDescriptor("Metas", EOSyntaxHighlighter.META),
new AttributesDescriptor("Constants", EOSyntaxHighlighter.NUMBERS),
new AttributesDescriptor("Braces", EOSyntaxHighlighter.BRACES)
new AttributesDescriptor("Braces", EOSyntaxHighlighter.BRACES),
};

@Nullable
Expand All @@ -73,21 +73,21 @@ public SyntaxHighlighter getHighlighter() {
@NotNull
@Override
public String getDemoText() {
return "+alias org.eolang.io.stdout\n" +
"+alias org.eolang.txt.sprintf\n\n" +
"# is year leap?\n\n" +
"[args...] > main\n" +
" [y] > leap\n" +
" or. > @\n" +
" and.\n" +
" eq. (mod. y 4) 0\n" +
" not. (eq. (mod. y 100) 0)\n" +
" eq. (mod. y 400) 0\n" +
" stdout > @\n" +
" sprintf\n" +
" \"%d is %sa leap year!\"\n" +
" (args.get 0).as-int > year!\n" +
" if. (leap year:y) \"\" \"not \"\n";
return "+alias org.eolang.io.stdout\n"
+ "+alias org.eolang.txt.sprintf\n\n"
+ "# is year leap?\n\n"
+ "[args...] > main\n"
+ " [y] > leap\n"
+ " or. > @\n"
+ " and.\n"
+ " eq. (mod. y 4) 0\n"
+ " not. (eq. (mod. y 100) 0)\n"
+ " eq. (mod. y 400) 0\n"
+ " stdout > @\n"
+ " sprintf\n"
+ " \"%d is %sa leap year!\"\n"
+ " (args.get 0).as-int > year!\n"
+ " if. (leap year:y) \"\" \"not \"\n";
}

@NotNull
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/eolang/jetbrains/EOFileType.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,24 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
* Description of *.eo files.
* @since 0.0.0
*/
public class EOFileType extends LanguageFileType {
/**
* EO language file extension.
*/
public static final String FILE_EXTENSION = "eo";

/**
* Creating instance.
*/
public static final EOFileType INSTANCE = new EOFileType();

/**
* Call constructor of super class.
*/
protected EOFileType() {
super(EOLanguage.INSTANCE);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/eolang/jetbrains/EOFileTypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
import com.intellij.openapi.fileTypes.FileTypeFactory;
import org.jetbrains.annotations.NotNull;

/**
* Class for definition of FileType.
* @since 0.0.0
*/
public class EOFileTypeFactory extends FileTypeFactory {
@Override
public void createFileTypes(@NotNull final FileTypeConsumer fileTypeConsumer) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/eolang/jetbrains/EOLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
* Language Definition.
* @since 0.0.0
*/

public final class EOLanguage extends Language {
/**
* Creating instance.
*/
public static final EOLanguage INSTANCE = new EOLanguage();

/**
Expand Down
24 changes: 15 additions & 9 deletions src/main/java/org/eolang/jetbrains/EOParserDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@
import org.eolang.jetbrains.psi.EOPSIFileRoot;
import org.jetbrains.annotations.NotNull;

/**
* Let's define a parser for EO language
*/
public class EOParserDefinition implements ParserDefinition {
public static final IFileElementType FILE = new IFileElementType(EOLanguage.INSTANCE);

public static TokenIElementType ID;

static {
PSIElementTypeFactory.defineLanguageIElementTypes(
EOLanguage.INSTANCE, EOParser.tokenNames, EOParser.ruleNames);
EOLanguage.INSTANCE, EOParser.tokenNames, EOParser.ruleNames
);
final List<TokenIElementType> tokenIElementTypes =
PSIElementTypeFactory.getTokenIElementTypes(EOLanguage.INSTANCE);
PSIElementTypeFactory.getTokenIElementTypes(EOLanguage.INSTANCE);
EOParserDefinition.ID = tokenIElementTypes.get(EOLexer.AT);
}

Expand Down Expand Up @@ -120,15 +124,17 @@ public PsiFile createFile(final FileViewProvider viewProvider) {
}

/**
* Convert from *NON-LEAF* parse node (AST they call it) to PSI node. Leaves are created in the
* AST factory. Rename re-factoring can cause this to be called on a TokenIElementType since we
* want to rename ID nodes. In that case, this method is called to create the root node but with
* ID type. Kind of strange, but we can simply create a ASTWrapperPsiElement to make everything
* Convert from *NON-LEAF* parse node (AST they call it) to PSI node. Leaves are
* created in the AST factory. Rename re-factoring can cause this to be called
* on a TokenIElementType since we want to rename ID nodes. In that case, this
* method is called to create the root node but with ID type. Kind of strange,
* but we can simply create a ASTWrapperPsiElement to make everything
* work correctly.
*
* <p>RuleIElementType. Ah! It's that ID is the root IElementType requested to parse, which means
* that the root node returned from parsetree->PSI conversion. But, it must be a CompositeElement!
* The adaptor calls rootMarker.done(root) to finish off the PSI conversion.
* <p>RuleIElementType. Ah! It's that ID is the root IElementType requested to parse,
* which means that the root node returned from parsetree->PSI conversion. But, it
* must be a CompositeElement! The adaptor calls rootMarker.done(root) to finish off
* the PSI conversion.
*
* <p>If you don't care to distinguish PSI nodes by type, it is sufficient to create a {@link
* ANTLRPsiNode} around the parse tree node
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/org/eolang/jetbrains/EOPluginController.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@ public void projectOpened() {
@Override
public void initComponent() {
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
final Runnable r1 = ()->fileTypeManager.removeAssociatedExtension(FileTypes.PLAIN_TEXT, "eo");
final Runnable r2 = ()->fileTypeManager.associateExtension(EOFileType.INSTANCE, "eo");
WriteCommandAction.runWriteCommandAction(project, r1);
WriteCommandAction.runWriteCommandAction(project, r2);
final Runnable runnableRemove = () -> fileTypeManager.removeAssociatedExtension(
FileTypes.PLAIN_TEXT, "eo"
);
final Runnable runnableAssociate = () -> fileTypeManager.associateExtension(
EOFileType.INSTANCE, "eo"
);
WriteCommandAction.runWriteCommandAction(project, runnableRemove);
WriteCommandAction.runWriteCommandAction(project, runnableAssociate);
}

@Override
Expand Down
42 changes: 41 additions & 1 deletion src/main/java/org/eolang/jetbrains/EOSyntaxHighlighter.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,46 +39,86 @@

/**
* Class for declaration groups of tokens and highlighting colors.
* We will highlight all tokens with one of colors below. One group - one color.
* @since 0.0.0
*/

public class EOSyntaxHighlighter extends SyntaxHighlighterBase {
/**
* Code below is description of token groups.
*/
public static final TextAttributesKey NUMBERS =
createTextAttributesKey("EO_INT", DefaultLanguageHighlighterColors.CONSTANT);

/**
* Define comments.
*/
public static final TextAttributesKey COMMENT =
createTextAttributesKey("EO_COMMENT", DefaultLanguageHighlighterColors.LINE_COMMENT);

/**
* Define metas.
*/
public static final TextAttributesKey META =
createTextAttributesKey("EO_META", DefaultLanguageHighlighterColors.METADATA);

/**
* Define keyword.
*/
public static final TextAttributesKey KEYWORD =
createTextAttributesKey("EO_STAR", DefaultLanguageHighlighterColors.KEYWORD);

/**
* Define space.
*/
public static final TextAttributesKey SPACE =
createTextAttributesKey("EO_SPACE", DefaultLanguageHighlighterColors.TEMPLATE_LANGUAGE_COLOR);

/**
* Define dot.
*/
public static final TextAttributesKey DOT =
createTextAttributesKey("EO_DOT", DefaultLanguageHighlighterColors.DOT);

/**
* Define braces.
*/
public static final TextAttributesKey BRACES =
createTextAttributesKey("EO_LSQ", DefaultLanguageHighlighterColors.BRACES);

/**
* Define hash.
*/
public static final TextAttributesKey HASH =
createTextAttributesKey("EO_HASH", DefaultLanguageHighlighterColors.LINE_COMMENT);

/**
* Define EOL.
*/
public static final TextAttributesKey EOL =
createTextAttributesKey("EO_EOL", DefaultLanguageHighlighterColors.TEMPLATE_LANGUAGE_COLOR);

/**
* Define string.
*/
public static final TextAttributesKey STRING =
createTextAttributesKey("EO_STRING", DefaultLanguageHighlighterColors.STRING);

/**
* Define name.
*/
public static final TextAttributesKey NAME =
createTextAttributesKey("EO_NAME", DefaultLanguageHighlighterColors.IDENTIFIER);

/**
* Define bad symbol.
*/
public static final TextAttributesKey BAD_CHARACTER =
createTextAttributesKey("EO_BAD_CHARACTER", HighlighterColors.BAD_CHARACTER);

/**
* Define empty key.
*/
private static final TextAttributesKey[] EMPTY_KEYS = new TextAttributesKey[0];

@NotNull
Expand All @@ -96,7 +136,7 @@ public TextAttributesKey[] getTokenHighlights(final IElementType tokenType) {
}
final TokenIElementType myType = (TokenIElementType) tokenType;
final int ttype = myType.getANTLRTokenType();
TextAttributesKey attrKey;
final TextAttributesKey attrKey;
switch (ttype) {
case EOLexer.LSQ:
case EOLexer.RSQ:
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/eolang/jetbrains/psi/EOPSIFileRoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@
import org.jetbrains.annotations.Nullable;

/**
* Describing PSIFileRoot
* Describing PSIFileRoot.
* @since 0.0.0
*/
public class EOPSIFileRoot extends PsiFileBase implements ScopeNode {
/**
* Definition of PsiFileRoot
* @param viewProvider FileViewProvider
*/
public EOPSIFileRoot(@NotNull final FileViewProvider viewProvider) {
super(viewProvider, EOLanguage.INSTANCE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ public void testParsingTestData() {

@Override
protected final String getTestDataPath() {
System.out.println("TEST1\n");
return "src/test/testData_1";
}

Expand Down

1 comment on commit db18081

@0pdd
Copy link

@0pdd 0pdd commented on db18081 Jul 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to retrieve PDD puzzles from the code base and submit them to GitHub. If you think that it's a bug on our side, please submit it to yegor256/0pdd:

set -x && set -e && set -o pipefail && cd /tmp/0pdd20220612-12-q4n2xj/objectionary/eo-intellij-plugin && master=master && git config --local core.autocrlf false && git fetch --force --all --quiet && git reset --hard --quiet origin/${master} && git clean --force -d && git checkout origin/${master}...

Please, copy and paste this stack trace to GitHub:

Exec::Error
set -x && set -e && set -o pipefail && cd /tmp/0pdd20220612-12-q4n2xj/objectionary/eo-intellij-plugin && master=master && git config --local core.autocrlf false && git fetch --force --all --quiet && git reset --hard --quiet origin/${master} && git clean --force -d && git checkout origin/${master} && git rebase --abort || true && git rebase --autostash --strategy-option=theirs origin/${master} [1]:
+ set -e
+ set -o pipefail
+ cd /tmp/0pdd20220612-12-q4n2xj/objectionary/eo-intellij-plugin
+ master=master
+ git config --local core.autocrlf false
+ git fetch --force --all --quiet
fatal: Couldn't find remote ref refs/heads/main
error: Could not fetch origin
+ true
+ git rebase --autostash --strategy-option=theirs origin/master
fatal: Needed a single revision
invalid upstream 'origin/master'


/app/objects/exec.rb:60:in `block (2 levels) in run'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/open3.rb:219:in `popen_run'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/open3.rb:101:in `popen3'
/app/objects/exec.rb:54:in `block in run'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/timeout.rb:33:in `block in catch'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/timeout.rb:108:in `timeout'
/app/objects/exec.rb:53:in `run'
/app/objects/git_repo.rb:110:in `pull'
/app/objects/git_repo.rb:75:in `push'
/app/objects/job.rb:36:in `proceed'
/app/objects/job_starred.rb:33:in `proceed'
/app/objects/job_recorded.rb:32:in `proceed'
/app/objects/job_emailed.rb:35:in `proceed'
/app/objects/job_commiterrors.rb:36:in `proceed'
/app/objects/job_detached.rb:48:in `exclusive'
/app/objects/job_detached.rb:36:in `block in proceed'
/app/objects/job_detached.rb:36:in `fork'
/app/objects/job_detached.rb:36:in `proceed'
/app/0pdd.rb:366:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1675:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1675:in `block in compile!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1013:in `block (3 levels) in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1032:in `route_eval'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1013:in `block (2 levels) in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1061:in `block in process_route'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1059:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1059:in `process_route'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1011:in `block in route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1008:in `each'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1008:in `route!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1129:in `block in dispatch!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `block in invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1124:in `dispatch!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:939:in `block in call!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `block in invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `catch'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `invoke'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:939:in `call!'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:929:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/xss_header.rb:18:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/path_traversal.rb:16:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/json_csrf.rb:26:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/base.rb:50:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-protection-2.1.0/lib/rack/protection/frame_options.rb:31:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/logger.rb:17:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/common_logger.rb:38:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:253:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:246:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:216:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1991:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1542:in `block in call'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1769:in `synchronize'
/app/vendor/bundle/ruby/2.6.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1542:in `call'
/app/vendor/bundle/ruby/2.6.0/gems/rack-2.2.3/lib/rack/handler/webrick.rb:95:in `service'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/httpserver.rb:140:in `service'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/httpserver.rb:96:in `run'
/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/webrick/server.rb:307:in `block in start_thread'

Please sign in to comment.