mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-229821 [groovy] add separate file type for gdsl; remove gdsl file index
GitOrigin-RevId: b6fb16cbfaaa039a8490d1debf46cfb0827aac2c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5536fa6b2e
commit
e367472e0a
@@ -0,0 +1,17 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy
|
||||
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType
|
||||
import javax.swing.Icon
|
||||
|
||||
object GdslFileType : LanguageFileType(GroovyLanguage, true) {
|
||||
|
||||
init {
|
||||
GroovyFileType.GROOVY_FILE_TYPES.add(this)
|
||||
}
|
||||
|
||||
override fun getIcon(): Icon? = GroovyFileType.GROOVY_FILE_TYPE.icon
|
||||
override fun getName(): String = "gdsl"
|
||||
override fun getDescription(): String = "IntelliJ Groovy DSL configuration"
|
||||
override fun getDefaultExtension(): String = "gdsl"
|
||||
}
|
||||
@@ -1,30 +1,16 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.plugins.groovy.dsl;
|
||||
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.plugins.groovy.GdslFileType;
|
||||
|
||||
public class GdslUtil {
|
||||
public static final Key<GroovyClassDescriptor> INITIAL_CONTEXT = Key.create("gdsl.initialContext");
|
||||
|
||||
public static final Condition<VirtualFile> GDSL_FILTER =
|
||||
file -> file != null && !file.isDirectory() && StringUtil.endsWith(file.getNameSequence(), ".gdsl");
|
||||
public static final Condition<VirtualFile> GDSL_FILTER = file -> file.getFileType() == GdslFileType.INSTANCE;
|
||||
|
||||
static volatile boolean ourGdslStopped = false;
|
||||
|
||||
static void stopGdsl() {
|
||||
|
||||
+5
-68
@@ -20,6 +20,7 @@ import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.search.FileTypeIndex;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.CachedValue;
|
||||
import com.intellij.psi.util.CachedValueProvider;
|
||||
@@ -31,14 +32,10 @@ import com.intellij.util.concurrency.AppExecutorUtil;
|
||||
import com.intellij.util.containers.ConcurrentMultiMap;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.indexing.*;
|
||||
import com.intellij.util.io.EnumeratorStringDescriptor;
|
||||
import com.intellij.util.io.KeyDescriptor;
|
||||
import com.intellij.util.io.URLUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.GdslFileType;
|
||||
import org.jetbrains.plugins.groovy.dsl.DslActivationStatus.Status;
|
||||
import org.jetbrains.plugins.groovy.dsl.holders.CustomMembersHolder;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
@@ -56,53 +53,17 @@ import java.util.regex.Pattern;
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public final class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
public class GroovyDslFileIndex {
|
||||
private static final Key<Pair<GroovyDslExecutor, Long>> CACHED_EXECUTOR = Key.create("CachedGdslExecutor");
|
||||
private static final Key<CachedValue<List<GroovyDslScript>>> SCRIPTS_CACHE = Key.create("GdslScriptCache");
|
||||
private static final Logger LOG = Logger.getInstance(GroovyDslFileIndex.class);
|
||||
private static final @NonNls String OUR_KEY = "ourKey";
|
||||
public static final @NonNls ID<String, Void> NAME = ID.create("GroovyDslFileIndex");
|
||||
|
||||
private static final MultiMap<String, LinkedBlockingQueue<Pair<VirtualFile, GroovyDslExecutor>>> filesInProcessing =
|
||||
new ConcurrentMultiMap<>();
|
||||
|
||||
private static final ExecutorService ourPool = AppExecutorUtil.createBoundedApplicationPoolExecutor("GroovyDSLIndex Pool", 4);
|
||||
|
||||
private final MyDataIndexer myDataIndexer = new MyDataIndexer();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ID<String, Void> getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public DataIndexer<String, Void, FileContent> getIndexer() {
|
||||
return myDataIndexer;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public KeyDescriptor<String> getKeyDescriptor() {
|
||||
return EnumeratorStringDescriptor.INSTANCE;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FileBasedIndex.InputFilter getInputFilter() {
|
||||
return new MyInputFilter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dependsOnFileContent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVersion() {
|
||||
return 0;
|
||||
}
|
||||
private GroovyDslFileIndex() {}
|
||||
|
||||
@Nullable
|
||||
public static String getError(VirtualFile file) {
|
||||
@@ -288,14 +249,10 @@ public final class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
|
||||
final GlobalSearchScope scope = GlobalSearchScope.allScope(project);
|
||||
|
||||
for (VirtualFile vfile : FileBasedIndex.getInstance().getContainingFiles(NAME, OUR_KEY, scope)) {
|
||||
for (VirtualFile vfile : FileTypeIndex.getFiles(GdslFileType.INSTANCE, scope)) {
|
||||
if (!vfile.isValid()) {
|
||||
continue;
|
||||
}
|
||||
if (!GdslUtil.GDSL_FILTER.value(vfile)) {
|
||||
LOG.error("Index returned non-gdsl file: " + vfile);
|
||||
continue;
|
||||
}
|
||||
if (fileIndex.isInLibrarySource(vfile)) {
|
||||
continue;
|
||||
}
|
||||
@@ -380,26 +337,6 @@ public final class GroovyDslFileIndex extends ScalarIndexExtension<String> {
|
||||
}, false);
|
||||
}
|
||||
|
||||
private static class MyDataIndexer implements DataIndexer<String, Void, FileContent> {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<String, Void> map(@NotNull final FileContent inputData) {
|
||||
return Collections.singletonMap(OUR_KEY, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyInputFilter extends DefaultFileTypeSpecificInputFilter {
|
||||
MyInputFilter() {
|
||||
super(GroovyFileType.GROOVY_FILE_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptInput(@NotNull final VirtualFile file) {
|
||||
return GdslUtil.GDSL_FILTER.value(file);
|
||||
}
|
||||
}
|
||||
|
||||
private static void scheduleParsing(final LinkedBlockingQueue<Pair<VirtualFile, GroovyDslExecutor>> queue,
|
||||
final Project project,
|
||||
final VirtualFile vfile,
|
||||
|
||||
@@ -298,8 +298,10 @@
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<fileType name="Groovy" language="Groovy" extensions="groovy;gy;gdsl"
|
||||
<fileType name="Groovy" language="Groovy" extensions="groovy;gy"
|
||||
implementationClass="org.jetbrains.plugins.groovy.GroovyFileType" fieldName="GROOVY_FILE_TYPE"/>
|
||||
<fileType name="gdsl" extensions="gdsl"
|
||||
implementationClass="org.jetbrains.plugins.groovy.GdslFileType" fieldName="INSTANCE"/>
|
||||
|
||||
<highlightingPassFactory implementation="org.jetbrains.plugins.groovy.annotator.GrReferenceHighlighterFactory"/>
|
||||
<highlightingPassFactory implementation="org.jetbrains.plugins.groovy.highlighter.GroovyDeclarationHighlightingPassFactory"/>
|
||||
@@ -681,7 +683,6 @@
|
||||
<renameInputValidator implementation="org.jetbrains.plugins.groovy.GroovyRenameInputValidator"/>
|
||||
<lang.namesValidator implementationClass="org.jetbrains.plugins.groovy.lang.GroovyNamesValidator" language="Groovy"/>
|
||||
|
||||
<fileBasedIndex implementation="org.jetbrains.plugins.groovy.dsl.GroovyDslFileIndex"/>
|
||||
<fileBasedIndex implementation="org.jetbrains.plugins.groovy.lang.resolve.GroovyTraitFieldsFileIndex"/>
|
||||
<fileBasedIndex implementation="org.jetbrains.plugins.groovy.lang.resolve.GroovyTraitMethodsFileIndex"/>
|
||||
|
||||
|
||||
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 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.
|
||||
*/
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
package org.jetbrains.plugins.groovy.actions;
|
||||
|
||||
@@ -28,6 +14,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import icons.JetgroovyIcons;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.plugins.groovy.GdslFileType;
|
||||
import org.jetbrains.plugins.groovy.GroovyBundle;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
|
||||
@@ -75,7 +62,7 @@ public class NewScriptAction extends JavaCreateTemplateInPackageAction<GroovyFil
|
||||
|
||||
private static String extractExtension(String templateName) {
|
||||
if (GroovyTemplates.GROOVY_DSL_SCRIPT.equals(templateName)) {
|
||||
return "gdsl";
|
||||
return GdslFileType.INSTANCE.getDefaultExtension();
|
||||
}
|
||||
return GroovyFileType.DEFAULT_EXTENSION;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user