Skip to content

Commit b53618e

Browse files
authored
Merge pull request #114 from cedricziel/index-after-update
Re-Index after update
2 parents 96e9f40 + 5b476e4 commit b53618e

File tree

5 files changed

+113
-3
lines changed

5 files changed

+113
-3
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ cache:
1717
matrix:
1818
include:
1919
- env: IDEA_VERSION="IU-2017.2.5" PHP_PLUGIN_VERSION="172.4155.41"
20-
- env: IDEA_VERSION="IU-2017.3" PHP_PLUGIN_VERSION="173.3942.13"
20+
- env: IDEA_VERSION="IU-173.3942.15" PHP_PLUGIN_VERSION="173.3942.13"
2121
allow_failures:
22-
- env: IDEA_VERSION="IU-2017.3" PHP_PLUGIN_VERSION="173.3942.13"
22+
- env: IDEA_VERSION="IU-173.3942.15" PHP_PLUGIN_VERSION="173.3942.13"
2323

2424
before_install:
2525
- "export ORG_GRADLE_PROJECT_ideaVersion=${IDEA_VERSION}"

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ideaVersion = IU-2017.3
1+
ideaVersion = IU-173.3942.15
22
phpPluginVersion = 173.3942.13
33
#ideaVersion = IU-2017.2.5
44
#phpPluginVersion = 172.4155.41

src/main/java/com/cedricziel/idea/typo3/TYPO3CMSProjectComponent.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
package com.cedricziel.idea.typo3;
22

3+
import com.cedricziel.idea.typo3.index.*;
4+
import com.cedricziel.idea.typo3.index.php.LegacyClassesForIDEIndex;
5+
import com.intellij.ide.plugins.IdeaPluginDescriptor;
6+
import com.intellij.ide.plugins.PluginManager;
37
import com.intellij.openapi.components.ProjectComponent;
48
import com.intellij.openapi.diagnostic.Logger;
9+
import com.intellij.openapi.extensions.PluginId;
510
import com.intellij.openapi.project.Project;
11+
import com.intellij.util.indexing.FileBasedIndex;
612
import org.jetbrains.annotations.NotNull;
713

814
public class TYPO3CMSProjectComponent implements ProjectComponent {
@@ -35,6 +41,25 @@ public String getComponentName() {
3541

3642
@Override
3743
public void projectOpened() {
44+
TYPO3CMSSettings instance = TYPO3CMSSettings.getInstance(project);
45+
IdeaPluginDescriptor plugin = PluginManager.getPlugin(PluginId.getId("com.cedricziel.idea.typo3"));
46+
if (plugin == null) {
47+
return;
48+
}
49+
50+
String version = instance.getVersion();
51+
if (version == null || !plugin.getVersion().equals(version)) {
52+
instance.setVersion(plugin.getVersion());
53+
54+
FileBasedIndex index = FileBasedIndex.getInstance();
55+
index.scheduleRebuild(CoreServiceMapStubIndex.KEY, new Throwable());
56+
index.scheduleRebuild(ExtensionNameStubIndex.KEY, new Throwable());
57+
index.scheduleRebuild(IconIndex.KEY, new Throwable());
58+
index.scheduleRebuild(ResourcePathIndex.KEY, new Throwable());
59+
index.scheduleRebuild(RouteIndex.KEY, new Throwable());
60+
index.scheduleRebuild(TablenameFileIndex.KEY, new Throwable());
61+
index.scheduleRebuild(LegacyClassesForIDEIndex.KEY, new Throwable());
62+
}
3863
}
3964

4065
@Override
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package com.cedricziel.idea.typo3;
2+
3+
import com.intellij.openapi.components.PersistentStateComponent;
4+
import com.intellij.openapi.components.ServiceManager;
5+
import com.intellij.openapi.components.State;
6+
import com.intellij.openapi.components.Storage;
7+
import com.intellij.openapi.project.Project;
8+
import org.jdom.Element;
9+
import org.jetbrains.annotations.NotNull;
10+
import org.jetbrains.annotations.Nullable;
11+
12+
@State(
13+
name = "TYPO3Settings",
14+
storages = {@Storage("$WORKSPACE_FILE$")}
15+
)
16+
public class TYPO3CMSSettings implements PersistentStateComponent<Element> {
17+
/**
18+
* Plugin version.
19+
*/
20+
private String version;
21+
22+
public static TYPO3CMSSettings getInstance(Project project) {
23+
return ServiceManager.getService(project, TYPO3CMSSettings.class);
24+
}
25+
26+
@Nullable
27+
@Override
28+
public Element getState() {
29+
final Element element = new Element(KEY.ROOT.toString());
30+
element.setAttribute(KEY.VERSION.toString(), version);
31+
32+
return element;
33+
}
34+
35+
@Override
36+
public void loadState(Element state) {
37+
38+
String value = state.getAttributeValue(KEY.VERSION.toString());
39+
if (value != null) {
40+
version = value;
41+
}
42+
43+
}
44+
45+
/**
46+
* Returns plugin version.
47+
*
48+
* @return version
49+
*/
50+
public String getVersion() {
51+
return version;
52+
}
53+
54+
/**
55+
* Sets plugin version.
56+
*
57+
* @param version of the plugin
58+
*/
59+
public void setVersion(@NotNull String version) {
60+
this.version = version;
61+
}
62+
63+
/**
64+
* Settings keys.
65+
*/
66+
public enum KEY {
67+
ROOT("TYPO3CMSSettings"),
68+
VERSION("version");
69+
70+
private final String key;
71+
72+
KEY(@NotNull String key) {
73+
this.key = key;
74+
}
75+
76+
@Override
77+
public String toString() {
78+
return this.key;
79+
}
80+
}
81+
82+
}

src/main/resources/META-INF/plugin.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ It is a great inspiration for possible solutions and parts of the code.</p>
295295
</extensions>
296296

297297
<extensions defaultExtensionNs="com.intellij">
298+
299+
<projectService serviceImplementation="com.cedricziel.idea.typo3.TYPO3CMSSettings"/>
300+
298301
<!-- indexes -->
299302
<fileBasedIndex implementation="com.cedricziel.idea.typo3.index.CoreServiceMapStubIndex"/>
300303
<fileBasedIndex implementation="com.cedricziel.idea.typo3.index.ExtensionNameStubIndex"/>

0 commit comments

Comments
 (0)