-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #182 from nette-intellij/mn-patch-02
Small improvements
- Loading branch information
Showing
154 changed files
with
3,627 additions
and
1,807 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
ideaVersion = 2021.1 | ||
phpPluginVersion = 211.6693.111 | ||
ideaVersion = 2021.2.3 | ||
phpPluginVersion = 212.5457.49 | ||
#toolboxPluginVersion = 0.4.6 | ||
#annotationPluginVersion = 5.3 |
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
85 changes: 85 additions & 0 deletions
85
src/main/java/com/jantvrdik/intellij/latte/config/LatteReparseUtil.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,85 @@ | ||
package com.jantvrdik.intellij.latte.config; | ||
|
||
import com.intellij.openapi.project.DumbService; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.util.FileContentUtil; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.*; | ||
|
||
public class LatteReparseUtil { | ||
final private static int WAIT_MILIS_BETWEEN_REPARSE = 5000; | ||
|
||
private static final Map<Project, LatteReparseUtil> instances = new HashMap<>(); | ||
|
||
private long lastCall = 0; | ||
|
||
private final @NotNull Project project; | ||
|
||
public LatteReparseUtil(@NotNull Project project) { | ||
this.project = project; | ||
} | ||
|
||
public static LatteReparseUtil getInstance(@NotNull Project project) { | ||
if (!instances.containsKey(project)) { | ||
instances.put(project, new LatteReparseUtil(project)); | ||
} | ||
return instances.get(project); | ||
} | ||
|
||
public static void reinitialize(List<Project> projects) { | ||
for (Project project : projects) { | ||
LatteReparseUtil.getInstance(project).reinitialize(); | ||
} | ||
} | ||
|
||
public void reinitialize() { | ||
//LatteFileConfiguration.getInstance(project).reinitialize(); | ||
reparseOpenedFiles(project, null, false); | ||
} | ||
|
||
public void reinitialize(Runnable runnable) { | ||
//if (LatteFileConfiguration.getInstance(project).reinitialize()) { | ||
reparseOpenedFiles(project, runnable, false); | ||
//} | ||
} | ||
|
||
public void reinitializeDefault() { | ||
//if (LatteDefaultConfiguration.getInstance(project).reinitialize()) { | ||
reparseOpenedFiles(project, null, true); | ||
//} | ||
} | ||
|
||
private void reparseOpenedFiles(@NotNull Project project, @Nullable Runnable runnable, boolean def) { | ||
/*if ((lastCall + WAIT_MILIS_BETWEEN_REPARSE) > System.currentTimeMillis()) { | ||
run(runnable); | ||
return; | ||
}*/ | ||
|
||
DumbService.getInstance(project).runWhenSmart(() -> { | ||
if (def && !LatteDefaultConfiguration.getInstance(project).reinitialize()) { | ||
return; | ||
} | ||
|
||
if (!def && !LatteFileConfiguration.getInstance(project).reinitialize()) { | ||
return; | ||
} | ||
|
||
if ((lastCall + WAIT_MILIS_BETWEEN_REPARSE) > System.currentTimeMillis()) { | ||
run(runnable); | ||
return; | ||
} | ||
|
||
FileContentUtil.reparseOpenedFiles(); | ||
lastCall = System.currentTimeMillis(); | ||
run(runnable); | ||
}); | ||
} | ||
|
||
private void run(@Nullable Runnable runnable) { | ||
if (runnable != null) { | ||
runnable.run(); | ||
} | ||
} | ||
} |
Oops, something went wrong.