mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
javascript-psi-impl shouldn't depend on lang-impl
This commit is contained in:
@@ -86,7 +86,7 @@ public class JavaLanguageLevelPusher implements FilePropertyPusher<LanguageLevel
|
||||
private static final FileAttribute PERSISTENCE = new FileAttribute("language_level_persistence", 3, true);
|
||||
|
||||
@Override
|
||||
public void persistAttribute(@NotNull VirtualFile fileOrDir, @NotNull LanguageLevel level) throws IOException {
|
||||
public void persistAttribute(@NotNull Project project, @NotNull VirtualFile fileOrDir, @NotNull LanguageLevel level) throws IOException {
|
||||
final DataInputStream iStream = PERSISTENCE.readAttribute(fileOrDir);
|
||||
if (iStream != null) {
|
||||
try {
|
||||
@@ -104,7 +104,7 @@ public class JavaLanguageLevelPusher implements FilePropertyPusher<LanguageLevel
|
||||
|
||||
for (VirtualFile child : fileOrDir.getChildren()) {
|
||||
if (!child.isDirectory() && StdFileTypes.JAVA.equals(child.getFileType())) {
|
||||
PushedFilePropertiesUpdater.filePropertiesChanged(child);
|
||||
PushedFilePropertiesUpdater.getInstance(project).filePropertiesChanged(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-16
@@ -53,7 +53,7 @@ import java.io.IOException;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class PushedFilePropertiesUpdater {
|
||||
public class PushedFilePropertiesUpdaterImpl extends PushedFilePropertiesUpdater {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.PushedFilePropertiesUpdater");
|
||||
|
||||
private final Project myProject;
|
||||
@@ -62,12 +62,7 @@ public class PushedFilePropertiesUpdater {
|
||||
private final Queue<Runnable> myTasks = new ConcurrentLinkedQueue<Runnable>();
|
||||
private final MessageBusConnection myConnection;
|
||||
|
||||
@NotNull
|
||||
public static PushedFilePropertiesUpdater getInstance(Project project) {
|
||||
return project.getComponent(PushedFilePropertiesUpdater.class);
|
||||
}
|
||||
|
||||
public PushedFilePropertiesUpdater(final Project project) {
|
||||
public PushedFilePropertiesUpdaterImpl(final Project project) {
|
||||
myProject = project;
|
||||
myPushers = Extensions.getExtensions(FilePropertyPusher.EP_NAME);
|
||||
myFilePushers = ContainerUtil.findAllAsArray(myPushers, new Condition<FilePropertyPusher>() {
|
||||
@@ -122,22 +117,24 @@ public class PushedFilePropertiesUpdater {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeProperties() {
|
||||
for (final FilePropertyPusher pusher : myPushers) {
|
||||
pusher.initExtra(myProject, myProject.getMessageBus(), new FilePropertyPusher.Engine() {
|
||||
@Override
|
||||
public void pushAll() {
|
||||
PushedFilePropertiesUpdater.this.pushAll(pusher);
|
||||
PushedFilePropertiesUpdaterImpl.this.pushAll(pusher);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushRecursively(VirtualFile file, Project project) {
|
||||
PushedFilePropertiesUpdater.this.schedulePushRecursively(file, pusher);
|
||||
PushedFilePropertiesUpdaterImpl.this.schedulePushRecursively(file, pusher);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushAllPropertiesNow() {
|
||||
performPushTasks();
|
||||
doPushAll(myPushers);
|
||||
@@ -222,6 +219,7 @@ public class PushedFilePropertiesUpdater {
|
||||
return projectValue != null ? projectValue : pusher.getDefaultValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushAll(final FilePropertyPusher... pushers) {
|
||||
queueTask(new Runnable() {
|
||||
@Override
|
||||
@@ -289,7 +287,7 @@ public class PushedFilePropertiesUpdater {
|
||||
pusher = pushers[i];
|
||||
if (!isDir && (pusher.pushDirectoriesOnly() || !pusher.acceptsFile(fileOrDir))) continue;
|
||||
else if (isDir && !pusher.acceptsDirectory(fileOrDir, myProject)) continue;
|
||||
findAndUpdateValue(myProject, fileOrDir, pusher, moduleValues != null ? moduleValues[i]:null);
|
||||
findAndUpdateValue(fileOrDir, pusher, moduleValues != null ? moduleValues[i]:null);
|
||||
}
|
||||
}
|
||||
catch (AbstractMethodError ame) { // acceptsDirectory is missed
|
||||
@@ -298,17 +296,18 @@ public class PushedFilePropertiesUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
public static <T> void findAndUpdateValue(final Project project, final VirtualFile fileOrDir, final FilePropertyPusher<T> pusher, final T moduleValue) {
|
||||
final T value = findPusherValuesUpwards(project, fileOrDir, pusher, moduleValue);
|
||||
updateValue(fileOrDir, value, pusher);
|
||||
@Override
|
||||
public <T> void findAndUpdateValue(final VirtualFile fileOrDir, final FilePropertyPusher<T> pusher, final T moduleValue) {
|
||||
final T value = findPusherValuesUpwards(myProject, fileOrDir, pusher, moduleValue);
|
||||
updateValue(myProject, fileOrDir, value, pusher);
|
||||
}
|
||||
|
||||
private static <T> void updateValue(final VirtualFile fileOrDir, final T value, final FilePropertyPusher<T> pusher) {
|
||||
private static <T> void updateValue(final Project project, final VirtualFile fileOrDir, final T value, final FilePropertyPusher<T> pusher) {
|
||||
final T oldValue = fileOrDir.getUserData(pusher.getFileDataKey());
|
||||
if (value != oldValue) {
|
||||
fileOrDir.putUserData(pusher.getFileDataKey(), value);
|
||||
try {
|
||||
pusher.persistAttribute(fileOrDir, value);
|
||||
pusher.persistAttribute(project, fileOrDir, value);
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.error(e);
|
||||
@@ -316,7 +315,8 @@ public class PushedFilePropertiesUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
public static void filePropertiesChanged(@NotNull final VirtualFile file) {
|
||||
@Override
|
||||
public void filePropertiesChanged(@NotNull final VirtualFile file) {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
FileBasedIndex.getInstance().requestReindex(file);
|
||||
for (final Project project : ProjectManager.getInstance().getOpenProjects()) {
|
||||
@@ -344,6 +344,7 @@ public class PushedFilePropertiesUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processPendingEvents() {
|
||||
myConnection.deliverImmediately();
|
||||
}
|
||||
@@ -208,6 +208,7 @@
|
||||
|
||||
<component>
|
||||
<implementation-class>com.intellij.openapi.roots.impl.PushedFilePropertiesUpdater</implementation-class>
|
||||
<implementation-class>com.intellij.openapi.roots.impl.PushedFilePropertiesUpdaterImpl</implementation-class>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ public interface FilePropertyPusher<T> {
|
||||
boolean acceptsFile(@NotNull VirtualFile file);
|
||||
boolean acceptsDirectory(@NotNull VirtualFile file, @NotNull Project project);
|
||||
|
||||
void persistAttribute(@NotNull VirtualFile fileOrDir, @NotNull T value) throws IOException;
|
||||
void persistAttribute(@NotNull Project project, @NotNull VirtualFile fileOrDir, @NotNull T value) throws IOException;
|
||||
|
||||
interface Engine {
|
||||
void pushAll();
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.roots.impl;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class PushedFilePropertiesUpdater {
|
||||
@NotNull
|
||||
public static PushedFilePropertiesUpdater getInstance(Project project) {
|
||||
return project.getComponent(PushedFilePropertiesUpdater.class);
|
||||
}
|
||||
|
||||
public abstract void initializeProperties();
|
||||
public abstract void pushAll(final FilePropertyPusher... pushers);
|
||||
public abstract void filePropertiesChanged(@NotNull final VirtualFile file);
|
||||
public abstract void processPendingEvents();
|
||||
public abstract void pushAllPropertiesNow();
|
||||
public abstract <T> void findAndUpdateValue(final VirtualFile fileOrDir, final FilePropertyPusher<T> pusher, final T moduleValue);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class PythonLanguageLevelPusher implements FilePropertyPusher<LanguageLev
|
||||
|
||||
private static final FileAttribute PERSISTENCE = new FileAttribute("python_language_level_persistence", 2, true);
|
||||
|
||||
public void persistAttribute(@NotNull VirtualFile fileOrDir, @NotNull LanguageLevel level) throws IOException {
|
||||
public void persistAttribute(@NotNull Project project, @NotNull VirtualFile fileOrDir, @NotNull LanguageLevel level) throws IOException {
|
||||
final DataInputStream iStream = PERSISTENCE.readAttribute(fileOrDir);
|
||||
if (iStream != null) {
|
||||
try {
|
||||
@@ -164,7 +164,7 @@ public class PythonLanguageLevelPusher implements FilePropertyPusher<LanguageLev
|
||||
|
||||
for (VirtualFile child : fileOrDir.getChildren()) {
|
||||
if (!child.isDirectory() && PythonFileType.INSTANCE.equals(child.getFileType())) {
|
||||
PushedFilePropertiesUpdater.filePropertiesChanged(child);
|
||||
PushedFilePropertiesUpdater.getInstance(project).filePropertiesChanged(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -247,7 +247,7 @@ public class PythonLanguageLevelPusher implements FilePropertyPusher<LanguageLev
|
||||
return false;
|
||||
}
|
||||
if (file.isDirectory()) {
|
||||
PushedFilePropertiesUpdater.findAndUpdateValue(project, file, PythonLanguageLevelPusher.this, languageLevel);
|
||||
PushedFilePropertiesUpdater.getInstance(project).findAndUpdateValue(file, PythonLanguageLevelPusher.this, languageLevel);
|
||||
}
|
||||
if (suppressSizeLimit) {
|
||||
SingleRootFileViewProvider.doNotCheckFileSizeLimit(file);
|
||||
|
||||
Reference in New Issue
Block a user