Skip to content

Commit ae91dc4

Browse files
authored
Merge branch 'master' into fix-2494
2 parents ea93252 + 22d228f commit ae91dc4

File tree

103 files changed

+916
-1117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+916
-1117
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ platformBranch=.2
2222
platformBuild=
2323
pluginVersion=
2424
pluginBranch=
25-
pluginBuild=
25+
pluginBuild=.1
2626
useInstaller=false
2727
pycharmVersion=192.4787.5-EAP-SNAPSHOT
2828
clionVersion=192.4787.12-EAP-SNAPSHOT

mason/htmlmason/core/src/main/java/com/perl5/lang/htmlmason/idea/hierarchy/HTMLMasonTypeHierarchyTreeStructure.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@ protected static List<PsiElement> getLinearParents(PsiElement element) {
6060
if (recursionMap.contains(run)) {
6161
break;
6262
}
63-
result.add(0, run);
63+
result.addFirst(run);
6464
recursionMap.add(run);
6565

6666
run = run.getParentComponent();

mason/htmlmason/core/src/main/java/com/perl5/lang/htmlmason/parser/psi/impl/HTMLMasonFileImpl.java

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -545,28 +545,18 @@ private Map<Class<? extends HTMLMasonCompositeElement>, List<HTMLMasonCompositeE
545545

546546
PsiTreeUtil.processElements(HTMLMasonFileImpl.this, element ->
547547
{
548-
if (element instanceof HTMLMasonOnceBlock) {
549-
onceResult.add((HTMLMasonCompositeElement)element);
550-
}
551-
else if (element instanceof HTMLMasonSharedBlock) {
552-
sharedResult.add((HTMLMasonCompositeElement)element);
553-
}
554-
else if (element instanceof HTMLMasonCleanupBlock) {
555-
cleanupResult.add((HTMLMasonCompositeElement)element);
556-
}
557-
else if (element instanceof HTMLMasonInitBlock &&
558-
HTMLMasonFileImpl.this.equals(PsiTreeUtil.getParentOfType(element, HTMLMasonArgsContainer.class))) {
559-
initResult.add((HTMLMasonCompositeElement)element);
560-
}
561-
else if (element instanceof HTMLMasonArgsBlock &&
562-
HTMLMasonFileImpl.this.equals(PsiTreeUtil.getParentOfType(element, HTMLMasonArgsContainer.class))) {
563-
argsResult.add((HTMLMasonCompositeElement)element);
564-
}
565-
else if (element instanceof HTMLMasonMethodDefinition) {
566-
methodsResult.add((HTMLMasonCompositeElement)element);
567-
}
568-
else if (element instanceof HTMLMasonSubcomponentDefitnition) {
569-
subComponentsResult.add((HTMLMasonCompositeElement)element);
548+
switch (element) {
549+
case HTMLMasonOnceBlock block -> onceResult.add(block);
550+
case HTMLMasonSharedBlock block -> sharedResult.add(block);
551+
case HTMLMasonCleanupBlock block -> cleanupResult.add(block);
552+
case HTMLMasonInitBlock block
553+
when HTMLMasonFileImpl.this.equals(PsiTreeUtil.getParentOfType(element, HTMLMasonArgsContainer.class)) -> initResult.add(block);
554+
case HTMLMasonArgsBlock block
555+
when HTMLMasonFileImpl.this.equals(PsiTreeUtil.getParentOfType(element, HTMLMasonArgsContainer.class)) -> argsResult.add(block);
556+
case HTMLMasonMethodDefinition definition -> methodsResult.add(definition);
557+
case HTMLMasonSubcomponentDefitnition defitnition -> subComponentsResult.add(defitnition);
558+
default -> {
559+
}
570560
}
571561

572562
return true;

mojo/src/test/java/run/MojoProjectTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,8 +51,8 @@ public void testGenerateAppAction() {
5151
if (projects.size() != 1) {
5252
fail("Expected an application, got: " + projects);
5353
}
54-
assertInstanceOf(projects.get(0), MojoApp.class);
55-
LOG.info("Got: " + projects.get(0));
54+
assertInstanceOf(projects.getFirst(), MojoApp.class);
55+
LOG.info("Got: " + projects.getFirst());
5656
}
5757

5858
private @NotNull List<MojoProject> runMojoGenerateActionAndGetProjects(@NotNull MojoGenerateAction action) {
@@ -86,8 +86,8 @@ public void testGeneratePluginAction() {
8686
if (projects.size() != 1) {
8787
fail("Expected a plugin, got: " + projects);
8888
}
89-
assertInstanceOf(projects.get(0), MojoPlugin.class);
90-
LOG.info("Got: " + projects.get(0));
89+
assertInstanceOf(projects.getFirst(), MojoPlugin.class);
90+
LOG.info("Got: " + projects.getFirst());
9191
}
9292

9393
private void assertMojoAvailable() {

plugin/core/src/main/java/com/perl5/lang/perl/documentation/PerlDocUtil.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -320,7 +320,7 @@ public void visitElement(@NotNull PsiElement element) {
320320
}
321321
});
322322

323-
return result.isEmpty() ? null : result.get(0);
323+
return result.isEmpty() ? null : result.getFirst();
324324
}
325325

326326
public static String renderPodFile(PodFileImpl file) {
@@ -375,17 +375,17 @@ else if (elementType != TokenType.WHITE_SPACE && elementType != COMMENT_LINE) {
375375
}
376376
PsiElement run = podSection;
377377

378-
// detecting first section
379378
while (true) {
380379
PsiElement prevSibling = run.getPrevSibling();
380+
//noinspection IfCanBeSwitch
381381
if (prevSibling == null) {
382382
break;
383383
}
384384
if (prevSibling instanceof PodSection && ((PodSection)prevSibling).hasContent()) {
385385
break;
386386
}
387-
if (prevSibling instanceof PodTitledSection) {
388-
podSection = (PodTitledSection)prevSibling;
387+
if (prevSibling instanceof PodTitledSection section) {
388+
podSection = section;
389389
}
390390
run = prevSibling;
391391
}
@@ -417,7 +417,7 @@ else if (elementType != TokenType.WHITE_SPACE && elementType != COMMENT_LINE) {
417417
if (run instanceof PodLinkTarget) {
418418
String bcLink = ((PodLinkTarget)run).getPodLink();
419419
if (StringUtil.isNotEmpty(bcLink)) {
420-
breadCrumbs.add(0, PodRenderUtil.getHTMLPsiLink(bcLink, ((PodLinkTarget)run).getPodLinkText()));
420+
breadCrumbs.addFirst(PodRenderUtil.getHTMLPsiLink(bcLink, ((PodLinkTarget)run).getPodLinkText()));
421421
}
422422
}
423423
if (run instanceof PsiFile) {

plugin/core/src/main/java/com/perl5/lang/perl/documentation/PerlDocumentationProvider.java

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -223,31 +223,23 @@ protected static boolean isOp(PsiElement element) {
223223
*/
224224
@Contract("null->null")
225225
public static @Nullable PsiElement findPodElement(@Nullable PsiElement element) {
226-
if (element == null) {
227-
return null;
228-
}
229-
else if (element instanceof PerlBuiltInSubDefinition) {
230-
String subName = StringUtil.notNullize(((PerlBuiltInSubDefinition)element).getName());
231-
if ("default".equals(subName)) {
232-
return PerlDocUtil.resolveDescriptor(SWITCH_DOC_LINK, element, false);
233-
}
234-
else {
235-
return PerlDocUtil.getPerlFuncDocFromText(element, subName);
226+
return switch (element) {
227+
case null -> null;
228+
case PerlBuiltInSubDefinition definition -> {
229+
String subName = StringUtil.notNullize(definition.getName());
230+
if ("default".equals(subName)) {
231+
yield PerlDocUtil.resolveDescriptor(SWITCH_DOC_LINK, element, false);
232+
}
233+
else {
234+
yield PerlDocUtil.getPerlFuncDocFromText(element, subName);
235+
}
236236
}
237-
}
238-
else if (element instanceof PerlSubElement) {
239-
return findPodElement((PerlSubElement)element);
240-
}
241-
else if (element instanceof PerlFileImpl) {
242-
return findPodElement((PerlFileImpl)element);
243-
}
244-
else if (element instanceof PerlNamespaceDefinitionElement) {
245-
return findPodElement((PerlNamespaceDefinitionElement)element);
246-
}
247-
else if (element instanceof PerlVariable) {
248-
return PerlDocUtil.getPerlVarDoc((PerlVariable)element);
249-
}
250-
return null;
237+
case PerlSubElement subElement -> findPodElement(subElement);
238+
case PerlFileImpl file -> findPodElement(file);
239+
case PerlNamespaceDefinitionElement definitionElement -> findPodElement(definitionElement);
240+
case PerlVariable variable -> PerlDocUtil.getPerlVarDoc(variable);
241+
default -> null;
242+
};
251243
}
252244

253245
/**

plugin/core/src/main/java/com/perl5/lang/perl/extensions/generation/PerlCodeGeneratorImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -144,13 +144,13 @@ public class PerlCodeGeneratorImpl implements PerlCodeGenerator {
144144
}
145145

146146
if (!superArgs.isEmpty()) {
147-
superArgs.remove(0);
147+
superArgs.removeFirst();
148148
}
149149

150-
if (!arguments.isEmpty() && !arguments.get(0).isEmpty()) {
150+
if (!arguments.isEmpty() && !arguments.getFirst().isEmpty()) {
151151
//noinspection StringConcatenationInsideStringBufferAppend
152152
code.append(
153-
arguments.get(0).toStringShort() + "->SUPER::" + perlSubBase.getSubName() + "(" + StringUtil.join(superArgs, ", ") + ");\n");
153+
arguments.getFirst().toStringShort() + "->SUPER::" + perlSubBase.getSubName() + "(" + StringUtil.join(superArgs, ", ") + ");\n");
154154
}
155155
code.append("}");
156156
return code.toString();

plugin/core/src/main/java/com/perl5/lang/perl/extensions/mojo/MojoBaseProcessor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,8 +54,8 @@ public PerlFeaturesTable getFeaturesTable(PerlUseStatementElement useStatement,
5454
if (allOptions != null) {
5555
allOptions.removeAll(getOptions().keySet());
5656

57-
if (!allOptions.isEmpty() && !MOJO_BASE.equals(allOptions.get(0))) {
58-
loadedPackages.add(allOptions.get(0));
57+
if (!allOptions.isEmpty() && !MOJO_BASE.equals(allOptions.getFirst())) {
58+
loadedPackages.add(allOptions.getFirst());
5959
}
6060
}
6161

@@ -83,7 +83,7 @@ public void changeParentsList(@NotNull PerlUseStatementElement useStatement, @No
8383
else {
8484
allOptions.removeAll(getOptions().keySet());
8585
if (!allOptions.isEmpty()) {
86-
currentList.add(allOptions.get(0));
86+
currentList.add(allOptions.getFirst());
8787
}
8888
}
8989
}

plugin/core/src/main/java/com/perl5/lang/perl/extensions/mojo/MojoLightDelegatingSubDefinition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ public MojoLightDelegatingSubDefinition(@NotNull PerlUseStatementElement useStat
5555
if (it instanceof PerlSubDefinition) {
5656
List<PerlSubArgument> list = new ArrayList<>(((PerlSubDefinition)it).getSubArgumentsList());
5757
if (!list.isEmpty()) {
58-
list.remove(0);
58+
list.removeFirst();
5959
}
6060
argumentsRef.set(list);
6161
return false;

plugin/core/src/main/java/com/perl5/lang/perl/extensions/packageprocessor/impl/MroProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2020 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ public class MroProcessor extends PerlPragmaProcessorBase implements PerlMroProv
3030
public @NotNull PerlMroType getMroType(PerlUseStatementElement useStatement) {
3131
List<String> parameters = useStatement.getImportParameters();
3232

33-
if (parameters != null && !parameters.isEmpty() && "c3".equals(parameters.get(0))) {
33+
if (parameters != null && !parameters.isEmpty() && "c3".equals(parameters.getFirst())) {
3434
return PerlMroType.C3;
3535
}
3636
return PerlMroType.DFS;

plugin/core/src/main/java/com/perl5/lang/perl/fileTypes/PerlFileTypeService.java

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,30 @@ public class PerlFileTypeService implements Disposable {
3636
private static final Logger LOG = Logger.getInstance(PerlFileTypeService.class);
3737

3838
private final NotNullLazyValue<LightDirectoryIndex<Function<VirtualFile, FileType>>> myDirectoryIndexProvider =
39-
NotNullLazyValue.createValue(() -> {
40-
return new LightDirectoryIndex<>(
41-
this,
42-
virtualFile -> null,
43-
directoryIndex -> ReadAction.run(() -> {
44-
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
45-
if (project.isDisposed()) {
46-
continue;
47-
}
48-
for (PerlFileTypeProvider fileTypeProvider : PerlFileTypeProvider.EP_NAME.getExtensionList()) {
49-
fileTypeProvider.addRoots(project, (root, function) -> {
50-
if (!root.isValid()) {
51-
LOG.warn("Attempt to create a descriptor for invalid file for " + root);
52-
return;
53-
}
54-
if (!root.isDirectory()) {
55-
LOG.warn("Attempt to create root for non-directory: " + root);
56-
return;
57-
}
58-
directoryIndex.putInfo(root, function);
59-
});
60-
}
39+
NotNullLazyValue.createValue(() -> new LightDirectoryIndex<>(
40+
this,
41+
virtualFile -> null,
42+
directoryIndex -> ReadAction.run(() -> {
43+
for (Project project : ProjectManager.getInstance().getOpenProjects()) {
44+
if (project.isDisposed()) {
45+
continue;
6146
}
62-
})
63-
);
64-
});
47+
for (PerlFileTypeProvider fileTypeProvider : PerlFileTypeProvider.EP_NAME.getExtensionList()) {
48+
fileTypeProvider.addRoots(project, (root, function) -> {
49+
if (!root.isValid()) {
50+
LOG.warn("Attempt to create a descriptor for invalid file for " + root);
51+
return;
52+
}
53+
if (!root.isDirectory()) {
54+
LOG.warn("Attempt to create root for non-directory: " + root);
55+
return;
56+
}
57+
directoryIndex.putInfo(root, function);
58+
});
59+
}
60+
}
61+
})
62+
));
6563

6664
public PerlFileTypeService() {
6765
PerlFileTypeProvider.EP_NAME.addChangeListener(this::reset, this);

plugin/core/src/main/java/com/perl5/lang/perl/idea/actions/PerlFileFromTemplateAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -87,7 +87,7 @@ else if (StringUtil.contains(name, "/")) {
8787
else {
8888
pathChunks.add(name);
8989
}
90-
name = pathChunks.remove(pathChunks.size() - 1);
90+
name = pathChunks.removeLast();
9191

9292
for (String pathChunk : pathChunks) {
9393
if (StringUtil.isNotEmpty(pathChunk)) {

plugin/core/src/main/java/com/perl5/lang/perl/idea/actions/PerlMarkSourceRootAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ protected boolean isEnabled(@NotNull List<VirtualFile> files, @NotNull Module mo
5757
if (files.isEmpty() || !PerlProjectManager.isPerlEnabled(module)) {
5858
return false;
5959
}
60-
return !myType.equals(PerlModuleExtension.getInstance(module).getRootType(files.get(0)));
60+
return !myType.equals(PerlModuleExtension.getInstance(module).getRootType(files.getFirst()));
6161
}
6262

6363
@Override

plugin/core/src/main/java/com/perl5/lang/perl/idea/actions/PerlUnmarkSourceRootAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2017 Alexandr Evstigneev
2+
* Copyright 2015-2024 Alexandr Evstigneev
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ public void update(@NotNull AnActionEvent e) {
5757
}
5858

5959
if (virtualFiles.size() == 1) {
60-
PerlSourceRootType type = perlModuleExtension.getRootType(virtualFiles.get(0));
60+
PerlSourceRootType type = perlModuleExtension.getRootType(virtualFiles.getFirst());
6161
if (type == null) {
6262
return;
6363
}

0 commit comments

Comments
 (0)