mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -24,7 +24,6 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.CompilerModuleExtension;
|
||||
import com.intellij.openapi.roots.CompilerProjectExtension;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -228,15 +227,12 @@ public class CompilerPaths {
|
||||
return StringUtil.isEmpty(sourceDirName)? VirtualFileManager.extractPath(roots[0]): VirtualFileManager.extractPath(roots[0]) + "/" + sourceDirName;
|
||||
}
|
||||
|
||||
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(module.getProject());
|
||||
if (extension == null) {
|
||||
|
||||
final String path = getModuleOutputPath(module, false);
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
final String url = extension.getCompilerOutputUrl();
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
return StringUtil.isEmpty(sourceDirName)? VirtualFileManager.extractPath(url) : VirtualFileManager.extractPath(url) + "/" + sourceDirName;
|
||||
return StringUtil.isEmpty(sourceDirName)? path : path + "/" + sourceDirName;
|
||||
}
|
||||
|
||||
@NonNls
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.util.xmlb.annotations.Tag;
|
||||
import com.intellij.util.xmlb.annotations.Transient;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
@@ -31,7 +31,9 @@ import org.jetbrains.annotations.Nullable;
|
||||
@State(name = "SelectProjectTemplateSettings", storages = {@Storage( file = StoragePathMacros.APP_CONFIG + "/other.xml")})
|
||||
public class SelectTemplateSettings implements PersistentStateComponent<SelectTemplateSettings> {
|
||||
|
||||
static SelectTemplateSettings getInstance() {
|
||||
private static final String STATE_ELEMENT_NAME = "treeState";
|
||||
|
||||
public static SelectTemplateSettings getInstance() {
|
||||
return ServiceManager.getService(SelectTemplateSettings.class);
|
||||
}
|
||||
|
||||
@@ -45,11 +47,11 @@ public class SelectTemplateSettings implements PersistentStateComponent<SelectTe
|
||||
myTreeState = state;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
@Override
|
||||
public SelectTemplateSettings getState() {
|
||||
try {
|
||||
myTreeState.writeExternal(treeState);
|
||||
myTreeState.writeExternal(myElement = new Element(STATE_ELEMENT_NAME));
|
||||
}
|
||||
catch (WriteExternalException ignore) {
|
||||
}
|
||||
@@ -59,14 +61,14 @@ public class SelectTemplateSettings implements PersistentStateComponent<SelectTe
|
||||
@Override
|
||||
public void loadState(SelectTemplateSettings state) {
|
||||
try {
|
||||
myTreeState.readExternal(state.treeState);
|
||||
myTreeState.readExternal(state.myElement);
|
||||
}
|
||||
catch (InvalidDataException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@Tag("treeState")
|
||||
public Element treeState = new Element("treeState");
|
||||
public Element myElement = new Element(STATE_ELEMENT_NAME);
|
||||
|
||||
private TreeState myTreeState = new TreeState();
|
||||
}
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class CreateFromTemplateMode extends WizardMode {
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(WizardContext context) {
|
||||
return true;
|
||||
return context.isCreatingNewProject();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+1
-6
@@ -60,12 +60,7 @@ public class JavaClassNameCompletionContributor extends CompletionContributor {
|
||||
|
||||
static void addAllClasses(CompletionParameters parameters, final CompletionResultSet _result) {
|
||||
CompletionResultSet result = _result.withPrefixMatcher(CompletionUtil.findReferenceOrAlphanumericPrefix(parameters));
|
||||
addAllClasses(parameters, parameters.getInvocationCount() <= 1, result.getPrefixMatcher(), new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(LookupElement element) {
|
||||
_result.addElement(element);
|
||||
}
|
||||
});
|
||||
addAllClasses(parameters, parameters.getInvocationCount() <= 1, result.getPrefixMatcher(), _result);
|
||||
}
|
||||
|
||||
private static boolean mayContainClassName(CompletionParameters parameters) {
|
||||
|
||||
+4
@@ -62,6 +62,10 @@ public class JavaClassReferenceCompletionContributor extends CompletionContribut
|
||||
StringUtil.join(extendClassNames, ", "));
|
||||
}
|
||||
|
||||
if (parameters.getCompletionType() == CompletionType.SMART) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parameters.getCompletionType() == CompletionType.CLASS_NAME) {
|
||||
JavaClassNameCompletionContributor.addAllClasses(parameters, result);
|
||||
}
|
||||
|
||||
+1
-6
@@ -237,12 +237,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
!((PsiReferenceExpression)parent).isQualified() &&
|
||||
parameters.isExtendedCompletion() &&
|
||||
StringUtil.isNotEmpty(matcher.getPrefix())) {
|
||||
new JavaStaticMemberProcessor(parameters).processStaticMethodsGlobally(matcher, new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(LookupElement element) {
|
||||
result.addElement(element);
|
||||
}
|
||||
});
|
||||
new JavaStaticMemberProcessor(parameters).processStaticMethodsGlobally(matcher, result);
|
||||
}
|
||||
result.stopHere();
|
||||
}
|
||||
|
||||
@@ -554,12 +554,7 @@ public class JavaCompletionData extends JavaAwareCompletionData {
|
||||
|
||||
static void addExpectedTypeMembers(CompletionParameters parameters, final CompletionResultSet result, PsiElement position) {
|
||||
for (final ExpectedTypeInfo info : JavaSmartCompletionContributor.getExpectedTypes(parameters)) {
|
||||
new JavaMembersGetter(info.getDefaultType(), parameters).addMembers(parameters.getInvocationCount() > 1, new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(LookupElement element) {
|
||||
result.addElement(element);
|
||||
}
|
||||
});
|
||||
new JavaMembersGetter(info.getDefaultType(), parameters).addMembers(parameters.getInvocationCount() > 1, result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,12 +90,7 @@ public class JavaNoVariantsDelegator extends CompletionContributor {
|
||||
private static void suggestCollectionUtilities(CompletionParameters parameters, final CompletionResultSet result, PsiElement position) {
|
||||
if (StringUtil.isNotEmpty(result.getPrefixMatcher().getPrefix())) {
|
||||
for (ExpectedTypeInfo info : JavaSmartCompletionContributor.getExpectedTypes(parameters)) {
|
||||
new CollectionsUtilityMethodsProvider(position, info.getType(), info.getDefaultType(), new Consumer<LookupElement>() {
|
||||
@Override
|
||||
public void consume(LookupElement element) {
|
||||
result.addElement(element);
|
||||
}
|
||||
}).addCompletions(true);
|
||||
new CollectionsUtilityMethodsProvider(position, info.getType(), info.getDefaultType(), result).addCompletions(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.intellij.psi.impl.source.resolve.reference.impl.providers;
|
||||
|
||||
import com.intellij.codeInsight.completion.CompletionResultSet;
|
||||
import com.intellij.codeInsight.completion.JavaLookupElementBuilder;
|
||||
import com.intellij.codeInsight.completion.scope.JavaCompletionProcessor;
|
||||
import com.intellij.codeInsight.daemon.QuickFixProvider;
|
||||
@@ -24,6 +23,7 @@ import com.intellij.codeInsight.daemon.impl.quickfix.OrderEntryFix;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixActionRegistrarImpl;
|
||||
import com.intellij.codeInsight.daemon.quickFix.CreateClassOrPackageFix;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementBuilder;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.LocalQuickFixProvider;
|
||||
@@ -51,6 +51,7 @@ import com.intellij.psi.util.ClassKind;
|
||||
import com.intellij.psi.util.ClassUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
@@ -512,7 +513,7 @@ public class JavaClassReference extends GenericReference implements PsiJavaRefer
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public void processSubclassVariants(@NotNull PsiPackage context, @NotNull String[] extendClasses, CompletionResultSet result) {
|
||||
public void processSubclassVariants(@NotNull PsiPackage context, @NotNull String[] extendClasses, Consumer<LookupElement> result) {
|
||||
GlobalSearchScope packageScope = PackageScope.packageScope(context, true);
|
||||
GlobalSearchScope scope = myJavaClassReferenceSet.getProvider().getScope(getElement().getProject());
|
||||
if (scope != null) {
|
||||
@@ -532,13 +533,13 @@ public class JavaClassReference extends GenericReference implements PsiJavaRefer
|
||||
// add itself
|
||||
if (packageScope.contains(extendClass.getContainingFile().getVirtualFile())) {
|
||||
if (isClassAccepted(extendClass, classKind, instantiatable, concrete, notInterface, notEnum)) {
|
||||
result.addElement(createSubclassLookupValue(extendClass, extendClassName));
|
||||
result.consume(createSubclassLookupValue(extendClass, extendClassName));
|
||||
}
|
||||
}
|
||||
for (final PsiClass clazz : ClassInheritorsSearch.search(extendClass, packageScope, true)) {
|
||||
String qname = clazz.getQualifiedName();
|
||||
if (qname != null && isClassAccepted(clazz, classKind, instantiatable, concrete, notInterface, notEnum)) {
|
||||
result.addElement(createSubclassLookupValue(clazz, qname));
|
||||
result.consume(createSubclassLookupValue(clazz, qname));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,7 @@ public class MethodUsagesSearcher extends QueryExecutorBase<PsiReference, Method
|
||||
|
||||
final String textToSearch = method.getName();
|
||||
if (StringUtil.isEmpty(textToSearch)) {
|
||||
PsiFile file = aClass.getContainingFile();
|
||||
LOG.error("Cannot search for the method with empty name: "+method+"; class:"+aClass+"; file: "+ file+"; "+(file == null ? null : file.getVirtualFile()));
|
||||
return;
|
||||
}
|
||||
final PsiMethod[] methods = strictSignatureSearch ? new PsiMethod[]{method} : aClass.findMethodsByName(textToSearch, false);
|
||||
|
||||
|
||||
@@ -89,4 +89,5 @@ public interface CommonClassNames {
|
||||
String TARGET_ANNOTATION_FQ_NAME = "java.lang.annotation.Target";
|
||||
@NonNls String JAVA_LANG_RUNNABLE = "java.lang.Runnable";
|
||||
@NonNls String JAVA_IO_FILE = "java.io.File";
|
||||
String JAVA_LANG_ASSERTION_ERROR = "java.lang.AssertionError";
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public interface BuildRootIndex {
|
||||
<R extends BuildRootDescriptor> Collection<R> findAllParentDescriptors(@NotNull File file, @Nullable CompileContext context);
|
||||
|
||||
@Nullable
|
||||
JavaSourceRootDescriptor getModuleAndRoot(@Nullable CompileContext context, File file);
|
||||
JavaSourceRootDescriptor findJavaRootDescriptor(@Nullable CompileContext context, File file);
|
||||
|
||||
@NotNull
|
||||
FileFilter getRootFilter(@NotNull BuildRootDescriptor descriptor);
|
||||
|
||||
@@ -8,15 +8,22 @@ import com.intellij.util.containers.ConcurrentHashMap;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.builders.*;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.builders.java.ResourcesOnlyRootDescriptor;
|
||||
import org.jetbrains.jps.builders.storage.BuildDataPaths;
|
||||
import org.jetbrains.jps.incremental.BuilderRegistry;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget;
|
||||
import org.jetbrains.jps.indices.IgnoredFileIndex;
|
||||
import org.jetbrains.jps.indices.ModuleExcludeIndex;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration;
|
||||
import org.jetbrains.jps.model.java.compiler.ProcessorConfigProfile;
|
||||
import org.jetbrains.jps.service.JpsServiceManager;
|
||||
|
||||
import java.io.File;
|
||||
@@ -31,30 +38,65 @@ public class BuildRootIndexImpl implements BuildRootIndex {
|
||||
private static final Key<Map<File, BuildRootDescriptor>> ROOT_DESCRIPTOR_MAP = Key.create("_root_to_descriptor_map");
|
||||
private static final Key<Map<BuildTarget<?>, List<? extends BuildRootDescriptor>>> TEMP_TARGET_ROOTS_MAP = Key.create("_module_to_root_map");
|
||||
private HashMap<BuildTarget<?>, List<? extends BuildRootDescriptor>> myRootsByTarget;
|
||||
private THashMap<File,List<BuildRootDescriptor>> myRootToDescriptor;
|
||||
private THashMap<File,List<BuildRootDescriptor>> myRootToDescriptors;
|
||||
private ConcurrentMap<BuildRootDescriptor, FileFilter> myFileFilters;
|
||||
|
||||
public BuildRootIndexImpl(BuildTargetIndex targetIndex, JpsModel model, ModuleExcludeIndex index,
|
||||
BuildDataPaths dataPaths, final IgnoredFileIndex ignoredFileIndex) {
|
||||
myRootsByTarget = new HashMap<BuildTarget<?>, List<? extends BuildRootDescriptor>>();
|
||||
myRootToDescriptor = new THashMap<File, List<BuildRootDescriptor>>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
myRootToDescriptors = new THashMap<File, List<BuildRootDescriptor>>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
myFileFilters = new ConcurrentHashMap<BuildRootDescriptor, FileFilter>();
|
||||
final Iterable<AdditionalRootsProviderService> rootsProviders = JpsServiceManager.getInstance().getExtensions(AdditionalRootsProviderService.class);
|
||||
for (BuildTargetType<?> targetType : BuilderRegistry.getInstance().getTargetTypes()) {
|
||||
for (BuildTarget<?> target : targetIndex.getAllTargets(targetType)) {
|
||||
addRoots(dataPaths, rootsProviders, targetType, target, model, index, ignoredFileIndex);
|
||||
addRoots(dataPaths, rootsProviders, target, model, index, ignoredFileIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// registering resource-only roots for annotation processor's generated classes
|
||||
Map<String, List<ModuleBuildTarget>> moduleNameToTargetsMap = null;
|
||||
|
||||
final JpsProject project = model.getProject();
|
||||
final ProjectPaths paths = new ProjectPaths(project);
|
||||
final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
|
||||
for (ProcessorConfigProfile profile : compilerConfig.getAnnotationProcessingConfigurations()) {
|
||||
if (!profile.isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
for (String moduleName : profile.getModuleNames()) {
|
||||
if (moduleNameToTargetsMap == null) {
|
||||
moduleNameToTargetsMap = buildModuleNameToTargetsMap(targetIndex); // lazy init
|
||||
}
|
||||
final List<ModuleBuildTarget> targets = moduleNameToTargetsMap.get(moduleName);
|
||||
if (targets != null) {
|
||||
for (ModuleBuildTarget target : targets) {
|
||||
final File annotationOut = paths.getAnnotationProcessorGeneratedSourcesOutputDir(target.getModule(), target.isTests(), profile);
|
||||
if (annotationOut != null) {
|
||||
if (findJavaRootDescriptor(null, annotationOut) == null) {
|
||||
// register only if the root is not under already existing roots
|
||||
final ResourcesOnlyRootDescriptor descriptor = new ResourcesOnlyRootDescriptor(annotationOut, target, true, false, "");
|
||||
registerDescriptor(descriptor);
|
||||
//noinspection unchecked
|
||||
final List<BuildRootDescriptor> descriptors = (List<BuildRootDescriptor>)myRootsByTarget.get(target);
|
||||
assert descriptors != null;
|
||||
descriptors.add(descriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private <R extends BuildRootDescriptor> void addRoots(BuildDataPaths dataPaths, Iterable<AdditionalRootsProviderService> rootsProviders,
|
||||
BuildTargetType<?> targetType, BuildTarget<R> target,
|
||||
BuildTarget<R> target,
|
||||
JpsModel model,
|
||||
ModuleExcludeIndex index,
|
||||
IgnoredFileIndex ignoredFileIndex) {
|
||||
List<R> descriptors = target.computeRootDescriptors(model, index, ignoredFileIndex, dataPaths);
|
||||
for (AdditionalRootsProviderService<?> provider : rootsProviders) {
|
||||
if (provider.getTargetTypes().contains(targetType)) {
|
||||
if (provider.getTargetTypes().contains(target.getTargetType())) {
|
||||
//noinspection unchecked
|
||||
AdditionalRootsProviderService<R> providerService = (AdditionalRootsProviderService<R>)provider;
|
||||
final List<R> additionalRoots = providerService.getAdditionalRoots(target, dataPaths);
|
||||
@@ -65,22 +107,42 @@ public class BuildRootIndexImpl implements BuildRootIndex {
|
||||
}
|
||||
}
|
||||
for (BuildRootDescriptor descriptor : descriptors) {
|
||||
List<BuildRootDescriptor> list = myRootToDescriptor.get(descriptor.getRootFile());
|
||||
if (list == null) {
|
||||
list = new SmartList<BuildRootDescriptor>();
|
||||
myRootToDescriptor.put(descriptor.getRootFile(), list);
|
||||
}
|
||||
list.add(descriptor);
|
||||
registerDescriptor(descriptor);
|
||||
}
|
||||
myRootsByTarget.put(target, descriptors);
|
||||
}
|
||||
|
||||
private void registerDescriptor(BuildRootDescriptor descriptor) {
|
||||
List<BuildRootDescriptor> list = myRootToDescriptors.get(descriptor.getRootFile());
|
||||
if (list == null) {
|
||||
list = new SmartList<BuildRootDescriptor>();
|
||||
myRootToDescriptors.put(descriptor.getRootFile(), list);
|
||||
}
|
||||
list.add(descriptor);
|
||||
}
|
||||
|
||||
private static Map<String, List<ModuleBuildTarget>> buildModuleNameToTargetsMap(BuildTargetIndex targetIndex) {
|
||||
final Map<String, List<ModuleBuildTarget>> moduleNameToTargetsMap = new HashMap<String, List<ModuleBuildTarget>>();
|
||||
for (JavaModuleBuildTargetType type : JavaModuleBuildTargetType.ALL_TYPES) {
|
||||
for (ModuleBuildTarget target : targetIndex.getAllTargets(type)) {
|
||||
final String moduleName = target.getModule().getName();
|
||||
List<ModuleBuildTarget> targets = moduleNameToTargetsMap.get(moduleName);
|
||||
if (targets == null) {
|
||||
targets = new ArrayList<ModuleBuildTarget>();
|
||||
moduleNameToTargetsMap.put(moduleName, targets);
|
||||
}
|
||||
targets.add(target);
|
||||
}
|
||||
}
|
||||
return moduleNameToTargetsMap;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <R extends BuildRootDescriptor> List<R> getRootDescriptors(@NotNull File root,
|
||||
@Nullable Collection<? extends BuildTargetType<? extends BuildTarget<R>>> types,
|
||||
@Nullable CompileContext context) {
|
||||
List<BuildRootDescriptor> descriptors = myRootToDescriptor.get(root);
|
||||
List<BuildRootDescriptor> descriptors = myRootToDescriptors.get(root);
|
||||
List<R> result = new SmartList<R>();
|
||||
if (descriptors != null) {
|
||||
for (BuildRootDescriptor descriptor : descriptors) {
|
||||
@@ -132,9 +194,7 @@ public class BuildRootIndexImpl implements BuildRootIndex {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R extends BuildRootDescriptor> void associateTempRoot(@NotNull CompileContext context,
|
||||
@NotNull BuildTarget<R> target,
|
||||
@NotNull R root) {
|
||||
public <R extends BuildRootDescriptor> void associateTempRoot(@NotNull CompileContext context, @NotNull BuildTarget<R> target, @NotNull R root) {
|
||||
Map<File, BuildRootDescriptor> rootToDescriptorMap = ROOT_DESCRIPTOR_MAP.get(context);
|
||||
if (rootToDescriptorMap == null) {
|
||||
rootToDescriptorMap = new THashMap<File, BuildRootDescriptor>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
@@ -223,7 +283,7 @@ public class BuildRootIndexImpl implements BuildRootIndex {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JavaSourceRootDescriptor getModuleAndRoot(@Nullable CompileContext context, File file) {
|
||||
public JavaSourceRootDescriptor findJavaRootDescriptor(@Nullable CompileContext context, File file) {
|
||||
return findParentDescriptor(file, JavaModuleBuildTargetType.ALL_TYPES, context);
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,8 @@ public class JavaBuilderUtil {
|
||||
final List<Pair<File, JpsModule>> result = new ArrayList<Pair<File, JpsModule>>();
|
||||
for (File file : affected) {
|
||||
if (!moduleBasedFilter.accept(file)) {
|
||||
final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context,
|
||||
file);
|
||||
result.add(Pair.create(file, moduleAndRoot != null ? moduleAndRoot.target.getModule() : null));
|
||||
}
|
||||
}
|
||||
@@ -176,7 +177,8 @@ public class JavaBuilderUtil {
|
||||
final Set<JpsModule> chunkModules = chunk.getModules();
|
||||
if (!chunkModules.isEmpty()) {
|
||||
for (File file : affected) {
|
||||
final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context,
|
||||
file);
|
||||
if (moduleAndRoot != null && chunkModules.contains(moduleAndRoot.target.getModule())) {
|
||||
return true;
|
||||
}
|
||||
@@ -250,7 +252,7 @@ public class JavaBuilderUtil {
|
||||
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
final JavaSourceRootDescriptor rd = myContext.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(myContext, file);
|
||||
final JavaSourceRootDescriptor rd = myContext.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(myContext, file);
|
||||
if (rd == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.jetbrains.jps.builders.java;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.BuildRootDescriptor;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
import org.jetbrains.jps.model.java.compiler.JpsCompilerExcludes;
|
||||
@@ -15,7 +14,7 @@ import java.io.FileFilter;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 1/3/12
|
||||
*/
|
||||
public final class JavaSourceRootDescriptor extends BuildRootDescriptor {
|
||||
public class JavaSourceRootDescriptor extends BuildRootDescriptor {
|
||||
@NotNull
|
||||
public final File root;
|
||||
@NotNull
|
||||
@@ -57,7 +56,7 @@ public final class JavaSourceRootDescriptor extends BuildRootDescriptor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuildTarget<?> getTarget() {
|
||||
public ModuleBuildTarget getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.jetbrains.jps.builders.java;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 1/3/12
|
||||
*/
|
||||
public final class ResourcesOnlyRootDescriptor extends JavaSourceRootDescriptor {
|
||||
|
||||
public ResourcesOnlyRootDescriptor(@NotNull File root,
|
||||
@NotNull ModuleBuildTarget target,
|
||||
boolean isGenerated,
|
||||
boolean isTemp,
|
||||
@NotNull String packagePrefix) {
|
||||
super(root, target, isGenerated, isTemp, packagePrefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ResourceRootDescriptor{" +
|
||||
"target='" + target + '\'' +
|
||||
", root=" + root +
|
||||
", generated=" + isGeneratedSources +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -282,7 +282,9 @@ final class BuildSession implements Runnable, CanceledStatus {
|
||||
LOG.info("Applying dirty path from fs event: " + file.getPath());
|
||||
}
|
||||
for (BuildRootDescriptor descriptor : descriptors) {
|
||||
pd.fsState.markDirty(null, file, descriptor, timestamps);
|
||||
if (!descriptor.isGenerated()) { // ignore generates sources as they are processed at the time of generation
|
||||
pd.fsState.markDirty(null, file, descriptor, timestamps);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Utils.IS_TEST_MODE) {
|
||||
|
||||
+2
-2
@@ -6,7 +6,6 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.util.JpsPathUtil;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.builders.BuildRootIndex;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
@@ -14,6 +13,7 @@ import org.jetbrains.jps.model.JpsEncodingConfigurationService;
|
||||
import org.jetbrains.jps.model.JpsEncodingProjectConfiguration;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.util.JpsPathUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@@ -50,7 +50,7 @@ public class CompilerEncodingConfiguration {
|
||||
File file = JpsPathUtil.urlToFile(fileUrl);
|
||||
if (charset == null || (!file.isDirectory() && !shouldHonorEncodingForCompilation(builders, file))) continue;
|
||||
|
||||
final JavaSourceRootDescriptor rootDescriptor = myRootsIndex.getModuleAndRoot(null, file);
|
||||
final JavaSourceRootDescriptor rootDescriptor = myRootsIndex.findJavaRootDescriptor(null, file);
|
||||
if (rootDescriptor == null) continue;
|
||||
|
||||
final JpsModule module = rootDescriptor.target.getModule();
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.Set;
|
||||
*/
|
||||
public class FSOperations {
|
||||
public static void markDirty(CompileContext context, final File file) throws IOException {
|
||||
final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, file);
|
||||
if (rd != null) {
|
||||
final ProjectDescriptor pd = context.getProjectDescriptor();
|
||||
pd.fsState.markDirty(context, file, rd, pd.timestamps.getStorage());
|
||||
@@ -39,7 +39,7 @@ public class FSOperations {
|
||||
}
|
||||
|
||||
public static void markDirtyIfNotDeleted(CompileContext context, final File file) throws IOException {
|
||||
final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, file);
|
||||
if (rd != null) {
|
||||
final ProjectDescriptor pd = context.getProjectDescriptor();
|
||||
pd.fsState.markDirtyIfNotDeleted(context, file, rd, pd.timestamps.getStorage());
|
||||
@@ -47,7 +47,7 @@ public class FSOperations {
|
||||
}
|
||||
|
||||
public static void markDeleted(CompileContext context, File file) throws IOException {
|
||||
final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, file);
|
||||
if (rd != null) {
|
||||
final ProjectDescriptor pd = context.getProjectDescriptor();
|
||||
pd.fsState.registerDeleted(rd.target, file, pd.timestamps.getStorage());
|
||||
|
||||
@@ -93,19 +93,16 @@ public class ModuleBuildTarget extends BuildTarget<JavaSourceRootDescriptor> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<JavaSourceRootDescriptor> computeRootDescriptors(JpsModel model,
|
||||
ModuleExcludeIndex index,
|
||||
IgnoredFileIndex ignoredFileIndex,
|
||||
BuildDataPaths dataPaths) {
|
||||
public List<JavaSourceRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
|
||||
List<JavaSourceRootDescriptor> roots = new ArrayList<JavaSourceRootDescriptor>();
|
||||
JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
|
||||
Iterable<ExcludedJavaSourceRootProvider> excludedRootProviders = JpsServiceManager.getInstance().getExtensions(ExcludedJavaSourceRootProvider.class);
|
||||
|
||||
roots:
|
||||
roots_loop:
|
||||
for (JpsTypedModuleSourceRoot<JpsSimpleElement<JavaSourceRootProperties>> sourceRoot : myModule.getSourceRoots(type)) {
|
||||
for (ExcludedJavaSourceRootProvider provider : excludedRootProviders) {
|
||||
if (provider.isExcludedFromCompilation(myModule, sourceRoot)) {
|
||||
continue roots;
|
||||
continue roots_loop;
|
||||
}
|
||||
}
|
||||
String packagePrefix = sourceRoot.getProperties().getData().getPackagePrefix();
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.FileProcessor;
|
||||
import org.jetbrains.jps.builders.java.JavaBuilderUtil;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.builders.java.ResourcesOnlyRootDescriptor;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Mappings;
|
||||
import org.jetbrains.jps.builders.logging.ProjectBuilderLogger;
|
||||
@@ -122,12 +123,13 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
public void process(CompileContext context, OutputFileObject out) {
|
||||
final OutputFileObject.Content content = out.getContent();
|
||||
final File srcFile = out.getSourceFile();
|
||||
boolean isTemp = false;
|
||||
final JavaFileObject.Kind outKind = out.getKind();
|
||||
if (srcFile != null && content != null) {
|
||||
final String outputPath = FileUtil.toSystemIndependentName(out.getFile().getPath());
|
||||
final String sourcePath = FileUtil.toSystemIndependentName(srcFile.getPath());
|
||||
final JavaSourceRootDescriptor rootDescriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, srcFile);
|
||||
final JavaSourceRootDescriptor rootDescriptor = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, srcFile);
|
||||
final BuildDataManager dataManager = context.getProjectDescriptor().dataManager;
|
||||
boolean isTemp = false;
|
||||
if (rootDescriptor != null) {
|
||||
isTemp = rootDescriptor.isTemp;
|
||||
if (!isTemp) {
|
||||
@@ -140,7 +142,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
}
|
||||
out.setTemp(isTemp);
|
||||
if (!isTemp && out.getKind() == JavaFileObject.Kind.CLASS && !Utils.errorsDetected(context)) {
|
||||
if (!isTemp && outKind == JavaFileObject.Kind.CLASS && !Utils.errorsDetected(context)) {
|
||||
final Callbacks.Backend callback = DELTA_MAPPINGS_CALLBACK_KEY.get(context);
|
||||
if (callback != null) {
|
||||
final ClassReader reader = new ClassReader(content.getBuffer(), content.getOffset(), content.getLength());
|
||||
@@ -148,6 +150,14 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isTemp && outKind != JavaFileObject.Kind.CLASS && outKind != JavaFileObject.Kind.SOURCE) { // this should be a generated resource
|
||||
try {
|
||||
FSOperations.markDirty(context, out.getFile());
|
||||
}
|
||||
catch (IOException e) {
|
||||
LOG.info(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -179,7 +189,10 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
final Set<File> formsToCompile = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
|
||||
dirtyFilesHolder.processDirtyFiles(new FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget>() {
|
||||
public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor sourceRoot) throws IOException {
|
||||
public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor descriptor) throws IOException {
|
||||
if (descriptor instanceof ResourcesOnlyRootDescriptor) {
|
||||
return true;
|
||||
}
|
||||
if (JAVA_SOURCES_FILTER.accept(file)) {
|
||||
filesToCompile.add(file);
|
||||
}
|
||||
@@ -196,7 +209,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
if (!context.isProjectRebuild()) {
|
||||
for (Iterator<File> formsIterator = formsToCompile.iterator(); formsIterator.hasNext(); ) {
|
||||
final File form = formsIterator.next();
|
||||
final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, form);
|
||||
final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, form);
|
||||
if (descriptor == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -315,11 +328,11 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
try {
|
||||
if (hasSourcesToCompile) {
|
||||
exitCode = ExitCode.OK;
|
||||
final Set<File> tempRootsSourcePath = new HashSet<File>();
|
||||
final Set<File> srcPath = new HashSet<File>();
|
||||
final BuildRootIndex index = pd.getBuildRootIndex();
|
||||
for (ModuleBuildTarget target : chunk.getTargets()) {
|
||||
for (JavaSourceRootDescriptor rd : index.getTempTargetRoots(target, context)) {
|
||||
tempRootsSourcePath.add(rd.root);
|
||||
srcPath.add(rd.root);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +353,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
LOG.debug(" " + file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
compiledOk = compileJava(context, chunk, files, classpath, platformCp, tempRootsSourcePath, diagnosticSink, outputSink);
|
||||
compiledOk = compileJava(context, chunk, files, classpath, platformCp, srcPath, diagnosticSink, outputSink);
|
||||
}
|
||||
|
||||
context.checkCanceled();
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.LinkedHashSet;
|
||||
*
|
||||
* @author peter
|
||||
*/
|
||||
public abstract class CompletionResultSet {
|
||||
public abstract class CompletionResultSet implements Consumer<LookupElement> {
|
||||
private final PrefixMatcher myPrefixMatcher;
|
||||
private final Consumer<CompletionResult> myConsumer;
|
||||
protected final CompletionService myCompletionService = CompletionService.getCompletionService();
|
||||
@@ -39,6 +39,11 @@ public abstract class CompletionResultSet {
|
||||
return myConsumer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consume(LookupElement element) {
|
||||
addElement(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* If a given element matches the prefix, give it for further processing (which may eventually result in its appearing in the completion list)
|
||||
* @param element
|
||||
|
||||
@@ -22,10 +22,9 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Interface that should be implemented by the language in order to provide inline functionality and possibly
|
||||
* participate in inline of elements in other languages this language may reference.
|
||||
@@ -60,19 +59,19 @@ public interface InlineHandler {
|
||||
* @return <code>Settings</code> object in case refactoring should be performed or null otherwise
|
||||
|
||||
*/
|
||||
@Nullable Settings prepareInlineElement(PsiElement element, Editor editor, boolean invokedOnReference);
|
||||
@Nullable Settings prepareInlineElement(@NotNull PsiElement element, @Nullable Editor editor, boolean invokedOnReference);
|
||||
|
||||
/**
|
||||
* @param element inlined element
|
||||
*/
|
||||
void removeDefinition(PsiElement element, Settings settings);
|
||||
void removeDefinition(@NotNull PsiElement element, @NotNull Settings settings);
|
||||
|
||||
/**
|
||||
* @param element inlined element
|
||||
* @param settings
|
||||
* @return Inliner instance to be used for inlining references in this language
|
||||
*/
|
||||
@Nullable Inliner createInliner(PsiElement element, Settings settings);
|
||||
@Nullable Inliner createInliner(@NotNull PsiElement element, @NotNull Settings settings);
|
||||
|
||||
interface Inliner {
|
||||
/**
|
||||
@@ -82,13 +81,13 @@ public interface InlineHandler {
|
||||
* or null if no conflicts detected.
|
||||
*/
|
||||
@Nullable
|
||||
MultiMap<PsiElement, String> getConflicts(PsiReference reference, PsiElement referenced);
|
||||
MultiMap<PsiElement, String> getConflicts(@NotNull PsiReference reference, @NotNull PsiElement referenced);
|
||||
|
||||
/**
|
||||
* Perform actual inline of element to the point where it is referenced
|
||||
* @param usage usage of inlined element
|
||||
* @param referenced inlined element
|
||||
*/
|
||||
void inlineUsage(UsageInfo usage, PsiElement referenced);
|
||||
void inlineUsage(@NotNull UsageInfo usage, @NotNull PsiElement referenced);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,12 @@ import com.intellij.lang.refactoring.InlineHandler;
|
||||
import com.intellij.lang.refactoring.InlineHandlers;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNamedElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
@@ -48,6 +50,8 @@ import java.util.*;
|
||||
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
|
||||
public class GenericInlineHandler {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(GenericInlineHandler.class);
|
||||
|
||||
public static boolean invoke(final PsiElement element, @Nullable Editor editor, final InlineHandler languageSpecific) {
|
||||
final PsiReference invocationReference = editor != null ? TargetElementUtilBase.findReference(editor) : null;
|
||||
final InlineHandler.Settings settings = languageSpecific.prepareInlineElement(element, editor, invocationReference != null);
|
||||
@@ -128,7 +132,7 @@ public class GenericInlineHandler {
|
||||
languageSpecific.removeDefinition(element, settings);
|
||||
}
|
||||
}
|
||||
}, RefactoringBundle.message("inline.command", subj), null);
|
||||
}, RefactoringBundle.message("inline.command", StringUtil.notNullize(subj, "<nameless>")), null);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
@@ -139,7 +143,10 @@ public class GenericInlineHandler {
|
||||
Collection<? extends PsiReference> allReferences) {
|
||||
final Map<Language, InlineHandler.Inliner> inliners = new HashMap<Language, InlineHandler.Inliner>();
|
||||
for (PsiReference ref : allReferences) {
|
||||
final Language language = ref.getElement().getLanguage();
|
||||
PsiElement refElement = ref.getElement();
|
||||
LOG.assertTrue(refElement != null, ref.getClass().getName());
|
||||
|
||||
final Language language = refElement.getLanguage();
|
||||
if (inliners.containsKey(language)) continue;
|
||||
|
||||
final List<InlineHandler> handlers = InlineHandlers.getInlineHandlers(language);
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public abstract class PresentableNodeDescriptor<E> extends NodeDescriptor<E> {
|
||||
private PresentationData myTemplatePresentation;
|
||||
private PresentationData myUpdatedPresentation;
|
||||
|
||||
protected PresentableNodeDescriptor(Project project, NodeDescriptor parentDescriptor) {
|
||||
protected PresentableNodeDescriptor(Project project, @Nullable NodeDescriptor parentDescriptor) {
|
||||
super(project, parentDescriptor);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ public abstract class CachingSimpleNode extends SimpleNode {
|
||||
super(aParent);
|
||||
}
|
||||
|
||||
protected CachingSimpleNode(Project aProject, NodeDescriptor aParentDescriptor) {
|
||||
protected CachingSimpleNode(Project aProject, @Nullable NodeDescriptor aParentDescriptor) {
|
||||
super(aProject, aParentDescriptor);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public abstract class SimpleNode extends PresentableNodeDescriptor implements Co
|
||||
this(project, null);
|
||||
}
|
||||
|
||||
protected SimpleNode(Project project, NodeDescriptor parentDescriptor) {
|
||||
protected SimpleNode(Project project, @Nullable NodeDescriptor parentDescriptor) {
|
||||
super(project, parentDescriptor);
|
||||
myName = "";
|
||||
}
|
||||
|
||||
@@ -931,7 +931,7 @@ add.scope.popup.title=Add scope
|
||||
add.scope.name.label=Name
|
||||
add.scope.dialog.title=Add New Scope
|
||||
scope.banner.text=Scope ''{0}''
|
||||
prompt.please.select.module.jdk=Please select {0} to be set for this module
|
||||
prompt.please.select.module.jdk=Please select the {0} to be set for this module
|
||||
scopes.save.dialog.title.shared=Save as shared scope
|
||||
scopes.save.dialog.title.local=Save as local scope
|
||||
plugin.version.label=Version
|
||||
|
||||
@@ -922,6 +922,7 @@
|
||||
<action id="Console.TableResult.PreviousPage"><keyboard-shortcut first-keystroke="control alt UP"/></action>
|
||||
<action id="Console.TableResult.NextPage"><keyboard-shortcut first-keystroke="control alt DOWN"/></action>
|
||||
<action id="Console.TableResult.Reload"><keyboard-shortcut first-keystroke="control R"/></action>
|
||||
<action id="Console.TableResult.EditValue"><keyboard-shortcut first-keystroke="F2"/><keyboard-shortcut first-keystroke="alt ENTER"/></action>
|
||||
|
||||
<action id="Console.History.Next"><keyboard-shortcut first-keystroke="control UP"/></action>
|
||||
<action id="Console.History.Previous"><keyboard-shortcut first-keystroke="control DOWN"/></action>
|
||||
|
||||
@@ -53,7 +53,7 @@ message.text.stop.searching.for.frameworks={0} is currently searching for framew
|
||||
label.text.the.following.frameworks.are.detected=<html><body>Several frameworks are detected in the project. Please review the following items and exclude mistakenly detected.</body></html>
|
||||
label.text.no.frameworks.detected=No frameworks detected.
|
||||
|
||||
sdk.java.name=JSDK
|
||||
sdk.java.name=JDK
|
||||
sdk.java.unknown.name=Unknown
|
||||
sdk.java.corrupt.error=Probably SDK installed in ''{0}'' is corrupt
|
||||
sdk.java.corrupt.title=Cannot Detect SDK Version
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.vcs.versionBrowser.ChangesBrowserSettingsEditor;
|
||||
import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.AsynchConsumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
@@ -34,6 +35,7 @@ import java.util.List;
|
||||
* @author yole
|
||||
*/
|
||||
public interface CommittedChangesProvider<T extends CommittedChangeList, U extends ChangeBrowserSettings> extends VcsProviderMarker {
|
||||
@NotNull
|
||||
U createDefaultSettings();
|
||||
ChangesBrowserSettingsEditor<U> createFilterUI(final boolean showDateFilter);
|
||||
|
||||
|
||||
@@ -60,11 +60,11 @@ public class Change {
|
||||
// if null, vcs's is used. intended: for property conflict case
|
||||
private Getter<MergeTexts> myMergeProvider;
|
||||
|
||||
public Change(final ContentRevision beforeRevision, final ContentRevision afterRevision) {
|
||||
public Change(@Nullable final ContentRevision beforeRevision, @Nullable final ContentRevision afterRevision) {
|
||||
this(beforeRevision, afterRevision, convertStatus(beforeRevision, afterRevision));
|
||||
}
|
||||
|
||||
public Change(final ContentRevision beforeRevision, final ContentRevision afterRevision, FileStatus fileStatus) {
|
||||
public Change(@Nullable final ContentRevision beforeRevision, @Nullable final ContentRevision afterRevision, @Nullable FileStatus fileStatus) {
|
||||
assert beforeRevision != null || afterRevision != null;
|
||||
myBeforeRevision = beforeRevision;
|
||||
myAfterRevision = afterRevision;
|
||||
@@ -73,7 +73,7 @@ public class Change {
|
||||
myOtherLayers = new HashMap<String, Change>(0);
|
||||
}
|
||||
|
||||
private static FileStatus convertStatus(ContentRevision beforeRevision, ContentRevision afterRevision) {
|
||||
private static FileStatus convertStatus(@Nullable ContentRevision beforeRevision, @Nullable ContentRevision afterRevision) {
|
||||
if (beforeRevision == null) return FileStatus.ADDED;
|
||||
if (afterRevision == null) return FileStatus.DELETED;
|
||||
return FileStatus.MODIFIED;
|
||||
|
||||
@@ -292,6 +292,10 @@ public class FilePathImpl implements FilePath {
|
||||
return myVirtualFile != null ? myVirtualFile.getFileType() : FileTypeManager.getInstance().getFileTypeByFileName(myFile.getName());
|
||||
}
|
||||
|
||||
public static FilePathImpl create(VirtualFile file) {
|
||||
return create(VfsUtilCore.virtualToIoFile(file), file.isDirectory());
|
||||
}
|
||||
|
||||
public static FilePathImpl create(File selectedFile) {
|
||||
return create(selectedFile, false);
|
||||
}
|
||||
|
||||
+2
@@ -31,6 +31,7 @@ import com.intellij.ui.components.JBTabbedPane;
|
||||
import com.intellij.util.AsynchConsumer;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -53,6 +54,7 @@ public class CompositeCommittedChangesProvider implements CommittedChangesProvid
|
||||
Collections.addAll(myBaseVcss, baseVcss);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public CompositeCommittedChangesProvider.CompositeChangeBrowserSettings createDefaultSettings() {
|
||||
Map<AbstractVcs, ChangeBrowserSettings> map = new HashMap<AbstractVcs, ChangeBrowserSettings>();
|
||||
for(AbstractVcs vcs: myBaseVcss) {
|
||||
|
||||
@@ -61,7 +61,7 @@ class IfStatementPredicate implements PsiElementPredicate {
|
||||
}
|
||||
final PsiClass aClass = (PsiClass)target;
|
||||
final String qualifiedName = aClass.getQualifiedName();
|
||||
return "java.lang.AssertionError".equals(qualifiedName);
|
||||
return CommonClassNames.JAVA_LANG_ASSERTION_ERROR.equals(qualifiedName);
|
||||
}
|
||||
else if (element instanceof PsiBlockStatement) {
|
||||
final PsiBlockStatement blockStatement =
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<idea-plugin version="2">
|
||||
<name>Android Designer</name>
|
||||
<id>com.intellij.android-designer</id>
|
||||
<description>
|
||||
Provides visual editing support for Android layout files.
|
||||
</description>
|
||||
<vendor>JetBrains</vendor>
|
||||
|
||||
<resource-bundle>messages.AndroidDesignerBundle</resource-bundle>
|
||||
|
||||
+2
-2
@@ -113,7 +113,7 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
|
||||
}
|
||||
});
|
||||
|
||||
showProgress("Load configuration");
|
||||
showProgress("Loading configuration...");
|
||||
myProfileAction = new ProfileAction(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -253,7 +253,7 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mySession == null) {
|
||||
showProgress("Create RenderLib");
|
||||
showProgress("Creating RenderLib...");
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
|
||||
+3
-2
@@ -906,7 +906,8 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder {
|
||||
|
||||
@Nullable
|
||||
private static String getDependencyFolder(@NotNull CompileContext context, @NotNull File sourceFile, @NotNull File genFolder) {
|
||||
final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, sourceFile);
|
||||
final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context,
|
||||
sourceFile);
|
||||
if (descriptor == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -976,7 +977,7 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder {
|
||||
|
||||
@Nullable
|
||||
private static String computePackageForFile(@NotNull CompileContext context, @NotNull File file) throws IOException {
|
||||
final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context, file);
|
||||
if (descriptor == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+1
@@ -63,6 +63,7 @@ public class CvsCommittedChangesProvider implements CachingCommittedChangesProvi
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ChangeBrowserSettings createDefaultSettings() {
|
||||
return new ChangeBrowserSettings();
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ public class GitCommittedChangeListProvider implements CommittedChangesProvider<
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ChangeBrowserSettings createDefaultSettings() {
|
||||
return new ChangeBrowserSettings();
|
||||
}
|
||||
|
||||
@@ -165,9 +165,6 @@ public class GitBranchUiUtil {
|
||||
return null;
|
||||
}
|
||||
GitRepositoryManager manager = GitUtil.getRepositoryManager(project);
|
||||
if (manager == null) {
|
||||
return null;
|
||||
}
|
||||
VirtualFile file = getSelectedFile(project);
|
||||
if (file != null) {
|
||||
return manager.getRepositoryForRoot(getVcsRootFor(project, file));
|
||||
|
||||
+4
-2
@@ -220,7 +220,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
GroovycOSProcessHandler.OutputItem item, Map<ModuleBuildTarget, String> generationOutputs, String compilerOutput) throws IOException {
|
||||
if (chunk.getModules().size() > 1) {
|
||||
final BuildRootIndex rootsIndex = context.getProjectDescriptor().getBuildRootIndex();
|
||||
JavaSourceRootDescriptor descriptor = rootsIndex.getModuleAndRoot(context, new File(item.sourcePath));
|
||||
JavaSourceRootDescriptor descriptor = rootsIndex.findJavaRootDescriptor(context, new File(item.sourcePath));
|
||||
if (descriptor != null) {
|
||||
ModuleBuildTarget srcTarget = descriptor.target;
|
||||
if (!srcTarget.equals(chunk.representativeTarget())) {
|
||||
@@ -283,7 +283,9 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
for (GroovycOSProcessHandler.OutputItem item : successfullyCompiled) {
|
||||
final String sourcePath = FileUtil.toSystemIndependentName(item.sourcePath);
|
||||
final String outputPath = FileUtil.toSystemIndependentName(item.outputPath);
|
||||
final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, new File(sourcePath));
|
||||
final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().findJavaRootDescriptor(context,
|
||||
new File(
|
||||
sourcePath));
|
||||
if (moduleAndRoot != null) {
|
||||
final ModuleBuildTarget target = moduleAndRoot.target;
|
||||
context.getProjectDescriptor().dataManager.getSourceToOutputMap(target).appendOutput(sourcePath, outputPath);
|
||||
|
||||
@@ -333,4 +333,5 @@ top.level.class.maynot.have.private.modifier=Top level class may not have 'priva
|
||||
top.level.class.maynot.have.protected.modifier=Top level class may not have 'protected' modifier
|
||||
property.missing=propertyMissing
|
||||
attribute.name.expected=Attribute name expected
|
||||
java.style.for.each.statement.requires.a.type.declaration=Java-style for-each statement requires a type declaration
|
||||
java.style.for.each.statement.requires.a.type.declaration=Java-style for-each statement requires a type declaration
|
||||
enums.may.not.have.extends.clause=Enums may not have 'extends' clause
|
||||
@@ -1341,6 +1341,9 @@ public class GroovyAnnotator extends GroovyElementVisitor implements Annotator {
|
||||
if (typeDefinition.isInterface()) {
|
||||
checkReferenceList(myHolder, extendsClause, true, GroovyBundle.message("no.class.expected.here"), null);
|
||||
}
|
||||
else if (typeDefinition.isEnum()) {
|
||||
myHolder.createErrorAnnotation(extendsClause, GroovyBundle.message("enums.may.not.have.extends.clause"));
|
||||
}
|
||||
else {
|
||||
checkReferenceList(myHolder, extendsClause, false, GroovyBundle.message("no.interface.expected.here"), new ChangeExtendsImplementsQuickFix(typeDefinition));
|
||||
}
|
||||
|
||||
+2
-5
@@ -37,10 +37,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrOpenBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrBreakStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrContinueStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrThrowStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
@@ -662,7 +659,7 @@ public class ControlFlowUtils {
|
||||
}
|
||||
else if (last instanceof ThrowingInstruction) {
|
||||
PsiElement element = last.getElement();
|
||||
if (!(element instanceof GrThrowStatement)) return true;
|
||||
if (!(element instanceof GrThrowStatement || element instanceof GrAssertStatement)) return true;
|
||||
}
|
||||
|
||||
PsiElement element = last.getElement();
|
||||
|
||||
+2
@@ -19,6 +19,7 @@ package org.jetbrains.plugins.groovy.findUsages;
|
||||
import com.intellij.openapi.application.QueryExecutorBase;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -72,6 +73,7 @@ public class MethodLateBoundReferencesSearcher extends QueryExecutorBase<PsiRefe
|
||||
|
||||
|
||||
private static void orderSearching(SearchScope searchScope, final String name, @NotNull SearchRequestCollector collector, final int paramCount) {
|
||||
if (StringUtil.isEmpty(name)) return;
|
||||
collector.searchWord(name, searchScope, UsageSearchContext.IN_CODE, true, new RequestResultProcessor("groovy.lateBound") {
|
||||
@Override
|
||||
public boolean processTextOccurrence(PsiElement element, int offsetInElement, Processor<PsiReference> consumer) {
|
||||
|
||||
+74
-39
@@ -33,6 +33,8 @@ import com.intellij.psi.impl.source.tree.LeafPsiElement;
|
||||
import com.intellij.psi.templateLanguages.OuterLanguageElement;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
@@ -215,53 +217,27 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
|
||||
|
||||
|
||||
private void calculateAlignments(List<ASTNode> children, boolean classLevel) {
|
||||
List<AlignmentProvider.Aligner> currentGroup = null;
|
||||
List<GrStatement> currentGroup = null;
|
||||
boolean spock = true;
|
||||
for (ASTNode child : children) {
|
||||
PsiElement psi = child.getPsi();
|
||||
if (psi instanceof GrLabeledStatement) {
|
||||
List<LeafPsiElement> table = getSpockTable(((GrLabeledStatement)psi).getStatement());
|
||||
if (table.isEmpty()) {
|
||||
currentGroup = null;
|
||||
}
|
||||
else {
|
||||
currentGroup = new ArrayList<AlignmentProvider.Aligner>();
|
||||
for (LeafPsiElement expression : table) {
|
||||
currentGroup.add(myAlignmentProvider.createAligner(expression, true, Alignment.Anchor.RIGHT));
|
||||
}
|
||||
}
|
||||
alignGroup(currentGroup, spock, classLevel);
|
||||
currentGroup = ContainerUtil.newArrayList((GrStatement)psi);
|
||||
spock = true;
|
||||
}
|
||||
else if (currentGroup != null && isTablePart(psi)) {
|
||||
List<LeafPsiElement> table = getSpockTable((GrStatement)psi);
|
||||
for (int i = 0; i < Math.min(table.size(), currentGroup.size()); i++) {
|
||||
currentGroup.get(i).append(table.get(i));
|
||||
}
|
||||
else if (currentGroup != null && spock && isTablePart(psi)) {
|
||||
currentGroup.add((GrStatement)psi);
|
||||
}
|
||||
else if (psi instanceof GrVariableDeclaration) {
|
||||
final GrVariableDeclaration varDeclaration = (GrVariableDeclaration)psi;
|
||||
GrVariable[] variables = varDeclaration.getVariables();
|
||||
GrVariable[] variables = ((GrVariableDeclaration)psi).getVariables();
|
||||
if (variables.length > 0) {
|
||||
if (!classLevel || currentGroup == null || fieldGroupEnded(psi)) {
|
||||
currentGroup = new ArrayList<AlignmentProvider.Aligner>();
|
||||
currentGroup.add(myAlignmentProvider.createAligner(true));
|
||||
currentGroup.add(myAlignmentProvider.createAligner(true));
|
||||
currentGroup.add(myAlignmentProvider.createAligner(true));
|
||||
}
|
||||
|
||||
AlignmentProvider.Aligner varName = currentGroup.get(1);
|
||||
for (GrVariable variable : variables) {
|
||||
varName.append(variable.getNameIdentifierGroovy());
|
||||
}
|
||||
|
||||
if (classLevel && mySettings.ALIGN_GROUP_FIELD_DECLARATIONS) {
|
||||
final AlignmentProvider.Aligner typeElement = currentGroup.get(0);
|
||||
typeElement.append(varDeclaration.getTypeElementGroovy());
|
||||
|
||||
ASTNode current_eq = variables[variables.length - 1].getNode().findChildByType(GroovyTokenTypes.mASSIGN);
|
||||
final AlignmentProvider.Aligner eq = currentGroup.get(2);
|
||||
if (current_eq != null) {
|
||||
eq.append(current_eq.getPsi());
|
||||
}
|
||||
if (!classLevel || currentGroup == null || fieldGroupEnded(psi) || spock) {
|
||||
alignGroup(currentGroup, spock, classLevel);
|
||||
currentGroup = ContainerUtil.newArrayList();
|
||||
spock = false;
|
||||
}
|
||||
currentGroup.add((GrStatement)psi);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -271,11 +247,70 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
alignGroup(currentGroup, spock, classLevel);
|
||||
currentGroup = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void alignGroup(@Nullable List<GrStatement> group, boolean spock, boolean classLevel) {
|
||||
if (group == null) {
|
||||
return;
|
||||
}
|
||||
if (spock) {
|
||||
alignSpockTable(group);
|
||||
} else {
|
||||
alignVariableDeclarations(group, classLevel);
|
||||
}
|
||||
}
|
||||
|
||||
private void alignVariableDeclarations(List<GrStatement> group, boolean classLevel) {
|
||||
AlignmentProvider.Aligner typeElement = myAlignmentProvider.createAligner(true);
|
||||
AlignmentProvider.Aligner varName = myAlignmentProvider.createAligner(true);
|
||||
AlignmentProvider.Aligner eq = myAlignmentProvider.createAligner(true);
|
||||
for (GrStatement statement : group) {
|
||||
GrVariableDeclaration varDeclaration = (GrVariableDeclaration) statement;
|
||||
GrVariable[] variables = varDeclaration.getVariables();
|
||||
for (GrVariable variable : variables) {
|
||||
varName.append(variable.getNameIdentifierGroovy());
|
||||
}
|
||||
|
||||
if (classLevel && mySettings.ALIGN_GROUP_FIELD_DECLARATIONS) {
|
||||
typeElement.append(varDeclaration.getTypeElementGroovy());
|
||||
|
||||
ASTNode current_eq = variables[variables.length - 1].getNode().findChildByType(GroovyTokenTypes.mASSIGN);
|
||||
if (current_eq != null) {
|
||||
eq.append(current_eq.getPsi());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void alignSpockTable(List<GrStatement> group) {
|
||||
if (group.size() < 2) {
|
||||
return;
|
||||
}
|
||||
GrStatement inner = ((GrLabeledStatement)group.get(0)).getStatement();
|
||||
boolean embedded = inner != null && isTablePart(inner);
|
||||
|
||||
GrStatement first = embedded ? inner : group.get(1);
|
||||
List<AlignmentProvider.Aligner> alignments = ContainerUtil
|
||||
.map2List(getSpockTable(first), new Function<LeafPsiElement, AlignmentProvider.Aligner>() {
|
||||
@Override
|
||||
public AlignmentProvider.Aligner fun(LeafPsiElement leaf) {
|
||||
return myAlignmentProvider.createAligner(leaf, true, Alignment.Anchor.RIGHT);
|
||||
}
|
||||
});
|
||||
|
||||
int second = embedded ? 1 : 2;
|
||||
for (int i = second; i < group.size(); i++) {
|
||||
List<LeafPsiElement> table = getSpockTable(group.get(i));
|
||||
for (int j = 0; j < Math.min(table.size(), alignments.size()); j++) {
|
||||
alignments.get(j).append(table.get(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean fieldGroupEnded(PsiElement psi) {
|
||||
if (!mySettings.ALIGN_GROUP_FIELD_DECLARATIONS) return true;
|
||||
PsiElement prevSibling = psi.getPrevSibling();
|
||||
|
||||
+47
-53
@@ -66,6 +66,7 @@ import org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil;
|
||||
|
||||
import static com.intellij.patterns.PsiJavaPatterns.psiElement;
|
||||
import static com.intellij.patterns.StandardPatterns.or;
|
||||
import static org.jetbrains.plugins.groovy.lang.completion.GroovyCompletionUtil.*;
|
||||
|
||||
/**
|
||||
* @author ilyas
|
||||
@@ -148,11 +149,10 @@ public class GroovyCompletionData {
|
||||
addModifiers(position, result);
|
||||
}
|
||||
if (psiElement().afterLeaf(MODIFIERS).accepts(position) ||
|
||||
GroovyCompletionUtil.isInTypeDefinitionBody(position) && GroovyCompletionUtil.isNewStatement(position, true)) {
|
||||
isInTypeDefinitionBody(position) && isNewStatement(position, true)) {
|
||||
addKeywords(result, true, PsiKeyword.SYNCHRONIZED);
|
||||
}
|
||||
if (suggestFinalDef(position) || psiElement().afterLeaf(
|
||||
psiElement().withText("(").withParent(GrForStatement.class)).accepts(position)) {
|
||||
if (suggestFinalDef(position) || psiElement().afterLeaf(psiElement().withText("(").withParent(GrForStatement.class)).accepts(position)) {
|
||||
addKeywords(result, true, PsiKeyword.FINAL, "def");
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class GroovyCompletionData {
|
||||
}
|
||||
|
||||
private static void addExtendsForTypeParams(PsiElement position, CompletionResultSet result) {
|
||||
if (GroovyCompletionUtil.isWildcardCompletion(position)) {
|
||||
if (isWildcardCompletion(position)) {
|
||||
addKeywords(result, true, PsiKeyword.EXTENDS, PsiKeyword.SUPER);
|
||||
}
|
||||
}
|
||||
@@ -314,13 +314,13 @@ public class GroovyCompletionData {
|
||||
return true;
|
||||
}
|
||||
|
||||
final PsiElement leaf = GroovyCompletionUtil.getLeafByOffset(context.getTextRange().getStartOffset() - 1, context);
|
||||
final PsiElement leaf = getLeafByOffset(context.getTextRange().getStartOffset() - 1, context);
|
||||
if (leaf != null) {
|
||||
PsiElement parent = leaf.getParent();
|
||||
if (parent instanceof GroovyFile) {
|
||||
GroovyFile groovyFile = (GroovyFile) parent;
|
||||
if (groovyFile.getPackageDefinition() == null) {
|
||||
return GroovyCompletionUtil.isNewStatement(context, false);
|
||||
return isNewStatement(context, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,15 +331,15 @@ public class GroovyCompletionData {
|
||||
private static boolean suggestImport(PsiElement context) {
|
||||
if (context.getParent() != null &&
|
||||
!(context.getParent() instanceof PsiErrorElement) &&
|
||||
GroovyCompletionUtil.isNewStatement(context, false) &&
|
||||
isNewStatement(context, false) &&
|
||||
context.getParent().getParent() instanceof GroovyFile) {
|
||||
return true;
|
||||
}
|
||||
final PsiElement leaf = GroovyCompletionUtil.getLeafByOffset(context.getTextRange().getStartOffset() - 1, context);
|
||||
final PsiElement leaf = getLeafByOffset(context.getTextRange().getStartOffset() - 1, context);
|
||||
if (leaf != null) {
|
||||
PsiElement parent = leaf.getParent();
|
||||
if (parent instanceof GroovyFile) {
|
||||
return GroovyCompletionUtil.isNewStatement(context, false);
|
||||
return isNewStatement(context, false);
|
||||
}
|
||||
}
|
||||
return context.getTextRange().getStartOffset() == 0 && !(context instanceof OuterLanguageElement);
|
||||
@@ -367,7 +367,7 @@ public class GroovyCompletionData {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
final PsiElement leaf = GroovyCompletionUtil.getLeafByOffset(context.getTextRange().getStartOffset() - 1, context);
|
||||
final PsiElement leaf = getLeafByOffset(context.getTextRange().getStartOffset() - 1, context);
|
||||
if (leaf != null) {
|
||||
PsiElement prev = leaf;
|
||||
prev = PsiImplUtil.realPrevious(prev);
|
||||
@@ -378,7 +378,7 @@ public class GroovyCompletionData {
|
||||
}
|
||||
|
||||
if (leaf.getParent() instanceof GroovyFile) {
|
||||
return GroovyCompletionUtil.isNewStatement(context, false);
|
||||
return isNewStatement(context, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,8 +403,8 @@ public class GroovyCompletionData {
|
||||
ASTNode node = prevSibling.getNode();
|
||||
return !TokenSets.DOTS.contains(node.getElementType());
|
||||
}
|
||||
if (GroovyCompletionUtil.isNewStatement(context, true)) {
|
||||
final PsiElement leaf = GroovyCompletionUtil.getLeafByOffset(offset - 1, context);
|
||||
if (isNewStatement(context, true)) {
|
||||
final PsiElement leaf = getLeafByOffset(offset - 1, context);
|
||||
if (leaf != null && (leaf.getParent() instanceof GrStatementOwner || leaf.getParent() instanceof GrLabeledStatement)) {
|
||||
return true;
|
||||
}
|
||||
@@ -458,17 +458,17 @@ public class GroovyCompletionData {
|
||||
|
||||
private static boolean afterTry(PsiElement context) {
|
||||
if (context != null &&
|
||||
GroovyCompletionUtil.nearestLeftSibling(context) instanceof GrTryCatchStatement) {
|
||||
GrTryCatchStatement tryStatement = (GrTryCatchStatement) GroovyCompletionUtil.nearestLeftSibling(context);
|
||||
nearestLeftSibling(context) instanceof GrTryCatchStatement) {
|
||||
GrTryCatchStatement tryStatement = (GrTryCatchStatement) nearestLeftSibling(context);
|
||||
if (tryStatement == null) return false;
|
||||
if (tryStatement.getFinallyClause() == null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (context != null &&
|
||||
GroovyCompletionUtil.nearestLeftSibling(context) instanceof PsiErrorElement &&
|
||||
GroovyCompletionUtil.nearestLeftSibling(context).getPrevSibling() instanceof GrTryCatchStatement) {
|
||||
GrTryCatchStatement tryStatement = (GrTryCatchStatement) GroovyCompletionUtil.nearestLeftSibling(context).getPrevSibling();
|
||||
nearestLeftSibling(context) instanceof PsiErrorElement &&
|
||||
nearestLeftSibling(context).getPrevSibling() instanceof GrTryCatchStatement) {
|
||||
GrTryCatchStatement tryStatement = (GrTryCatchStatement) nearestLeftSibling(context).getPrevSibling();
|
||||
if (tryStatement == null) return false;
|
||||
if (tryStatement.getFinallyClause() == null) {
|
||||
return true;
|
||||
@@ -476,8 +476,8 @@ public class GroovyCompletionData {
|
||||
}
|
||||
if (context != null &&
|
||||
(context.getParent() instanceof GrReferenceExpression || context.getParent() instanceof PsiErrorElement) &&
|
||||
GroovyCompletionUtil.nearestLeftSibling(context.getParent()) instanceof GrTryCatchStatement) {
|
||||
GrTryCatchStatement tryStatement = (GrTryCatchStatement) GroovyCompletionUtil.nearestLeftSibling(context.getParent());
|
||||
nearestLeftSibling(context.getParent()) instanceof GrTryCatchStatement) {
|
||||
GrTryCatchStatement tryStatement = (GrTryCatchStatement) nearestLeftSibling(context.getParent());
|
||||
if (tryStatement == null) return false;
|
||||
if (tryStatement.getFinallyClause() == null) {
|
||||
return true;
|
||||
@@ -488,13 +488,13 @@ public class GroovyCompletionData {
|
||||
|
||||
private static boolean afterIfOrElse(PsiElement context) {
|
||||
if (context.getParent() != null &&
|
||||
GroovyCompletionUtil.nearestLeftSibling(context.getParent()) instanceof GrIfStatement) {
|
||||
nearestLeftSibling(context.getParent()) instanceof GrIfStatement) {
|
||||
return true;
|
||||
}
|
||||
if (context.getParent() != null &&
|
||||
GroovyCompletionUtil.nearestLeftSibling(context) != null &&
|
||||
GroovyCompletionUtil.nearestLeftSibling(context).getPrevSibling() instanceof GrIfStatement) {
|
||||
GrIfStatement statement = (GrIfStatement) GroovyCompletionUtil.nearestLeftSibling(context).getPrevSibling();
|
||||
nearestLeftSibling(context) != null &&
|
||||
nearestLeftSibling(context).getPrevSibling() instanceof GrIfStatement) {
|
||||
GrIfStatement statement = (GrIfStatement) nearestLeftSibling(context).getPrevSibling();
|
||||
if (statement.getElseBranch() == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -512,7 +512,7 @@ public class GroovyCompletionData {
|
||||
|
||||
private static boolean afterAbstractMethod(PsiElement context) {
|
||||
PsiElement candidate = null;
|
||||
if (GroovyCompletionUtil.isInTypeDefinitionBody(context)) {
|
||||
if (isInTypeDefinitionBody(context)) {
|
||||
PsiElement run = context;
|
||||
while(!(run.getParent() instanceof GrTypeDefinitionBody)) {
|
||||
run = run.getParent();
|
||||
@@ -551,9 +551,9 @@ public class GroovyCompletionData {
|
||||
if (previous != null && GroovyTokenTypes.mAT.equals(previous.getNode().getElementType())) {
|
||||
return false;
|
||||
}
|
||||
if (GroovyCompletionUtil.asSimpleVariable(context) ||
|
||||
GroovyCompletionUtil.asTypedMethod(context) ||
|
||||
GroovyCompletionUtil.asVariableInBlock(context)) {
|
||||
if (asSimpleVariable(context) ||
|
||||
asTypedMethod(context) ||
|
||||
asVariableInBlock(context)) {
|
||||
return true;
|
||||
}
|
||||
if ((parent instanceof GrParameter &&
|
||||
@@ -578,7 +578,7 @@ public class GroovyCompletionData {
|
||||
}
|
||||
return parent instanceof GrExpression &&
|
||||
parent.getParent() instanceof GroovyFile &&
|
||||
GroovyCompletionUtil.isNewStatement(context, false);
|
||||
isNewStatement(context, false);
|
||||
}
|
||||
|
||||
private static boolean isInfixOperatorPosition(PsiElement context) {
|
||||
@@ -588,17 +588,17 @@ public class GroovyCompletionData {
|
||||
context.getParent().getParent() instanceof GrCommandArgumentList) {
|
||||
return true;
|
||||
}
|
||||
if (GroovyCompletionUtil.nearestLeftSibling(context) instanceof PsiErrorElement &&
|
||||
GroovyCompletionUtil.endsWithExpression(GroovyCompletionUtil.nearestLeftSibling(context).getPrevSibling())) {
|
||||
if (nearestLeftSibling(context) instanceof PsiErrorElement &&
|
||||
endsWithExpression(nearestLeftSibling(context).getPrevSibling())) {
|
||||
return true;
|
||||
}
|
||||
if (context.getParent() instanceof GrReferenceExpression &&
|
||||
GroovyCompletionUtil.nearestLeftLeaf(context) instanceof PsiErrorElement &&
|
||||
GroovyCompletionUtil.endsWithExpression(GroovyCompletionUtil.nearestLeftLeaf(context).getPrevSibling())) {
|
||||
nearestLeftLeaf(context) instanceof PsiErrorElement &&
|
||||
endsWithExpression(nearestLeftLeaf(context).getPrevSibling())) {
|
||||
return true;
|
||||
}
|
||||
if (context.getParent() instanceof PsiErrorElement &&
|
||||
GroovyCompletionUtil.endsWithExpression(GroovyCompletionUtil.nearestLeftSibling(context.getParent()))) {
|
||||
endsWithExpression(nearestLeftSibling(context.getParent()))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -606,12 +606,12 @@ public class GroovyCompletionData {
|
||||
}
|
||||
|
||||
private static boolean suggestModifiers(PsiElement context) {
|
||||
if (GroovyCompletionUtil.asSimpleVariable(context) ||
|
||||
GroovyCompletionUtil.asTypedMethod(context) ||
|
||||
GroovyCompletionUtil.isNewStatementInScript(context)) {
|
||||
if (asSimpleVariable(context) ||
|
||||
asTypedMethod(context) ||
|
||||
isNewStatementInScript(context)) {
|
||||
return true;
|
||||
}
|
||||
if (GroovyCompletionUtil.isFirstElementAfterPossibleModifiersInVariableDeclaration(context, false) &&
|
||||
if (isFirstElementAfterPossibleModifiersInVariableDeclaration(context, false) &&
|
||||
!psiElement().afterLeaf("def").accepts(context)) {
|
||||
return true;
|
||||
}
|
||||
@@ -636,7 +636,7 @@ public class GroovyCompletionData {
|
||||
}
|
||||
if (contextParent instanceof GrExpression &&
|
||||
contextParent.getParent() instanceof GroovyFile &&
|
||||
GroovyCompletionUtil.isNewStatement(context, false)) {
|
||||
isNewStatement(context, false)) {
|
||||
return true;
|
||||
}
|
||||
if (context.getTextRange().getStartOffset() == 0 && !(context instanceof OuterLanguageElement)) {
|
||||
@@ -645,22 +645,16 @@ public class GroovyCompletionData {
|
||||
return contextParent instanceof GrExpression &&
|
||||
contextParent.getParent() instanceof GrApplicationStatement &&
|
||||
contextParent.getParent().getParent() instanceof GroovyFile &&
|
||||
GroovyCompletionUtil.isNewStatement(context, false);
|
||||
isNewStatement(context, false);
|
||||
}
|
||||
|
||||
public static boolean suggestFinalDef(PsiElement context) {
|
||||
if (GroovyCompletionUtil.asSimpleVariable(context) ||
|
||||
GroovyCompletionUtil.asTypedMethod(context) ||
|
||||
GroovyCompletionUtil.asVariableInBlock(context) ||
|
||||
GroovyCompletionUtil.isNewStatementInScript(context)) {
|
||||
return true;
|
||||
}
|
||||
if ((context.getParent() instanceof GrParameter &&
|
||||
((GrParameter) context.getParent()).getTypeElementGroovy() == null) ||
|
||||
context.getParent() instanceof GrReferenceElement &&
|
||||
!(context.getParent() instanceof GrReferenceExpression) &&
|
||||
!(context.getParent().getParent() instanceof GrImportStatement) &&
|
||||
!(context.getParent().getParent() instanceof GrPackageDefinition)) {
|
||||
if (asSimpleVariable(context) ||
|
||||
asTypedMethod(context) ||
|
||||
asVariableInBlock(context) ||
|
||||
isNewStatementInScript(context) && !isReferenceElementInNewExpr(context) ||
|
||||
isTypelessParameter(context) ||
|
||||
isCodeReferenceElementApplicableToModifierCompletion(context)) {
|
||||
return true;
|
||||
}
|
||||
if (PsiImplUtil.realPrevious(context.getParent().getPrevSibling()) instanceof GrModifierList) {
|
||||
@@ -671,6 +665,6 @@ public class GroovyCompletionData {
|
||||
}
|
||||
return context.getParent() instanceof GrExpression &&
|
||||
context.getParent().getParent() instanceof GroovyFile &&
|
||||
GroovyCompletionUtil.isNewStatement(context, false);
|
||||
isNewStatement(context, false);
|
||||
}
|
||||
}
|
||||
|
||||
+22
@@ -62,12 +62,14 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrApplicationStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrClassTypeElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement;
|
||||
@@ -577,4 +579,24 @@ public class GroovyCompletionUtil {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isReferenceElementInNewExpr(PsiElement context) {
|
||||
if (context.getParent() instanceof GrCodeReferenceElement) {
|
||||
PsiElement pparent = context.getParent().getParent();
|
||||
if (pparent instanceof GrNewExpression) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean isCodeReferenceElementApplicableToModifierCompletion(PsiElement context) {
|
||||
return context.getParent() instanceof GrCodeReferenceElement &&
|
||||
!(context.getParent().getParent() instanceof GrImportStatement) &&
|
||||
!(context.getParent().getParent() instanceof GrPackageDefinition) &&
|
||||
!(context.getParent().getParent() instanceof GrNewExpression);
|
||||
}
|
||||
|
||||
static boolean isTypelessParameter(PsiElement context) {
|
||||
return (context.getParent() instanceof GrParameter && ((GrParameter)context.getParent()).getTypeElementGroovy() == null);
|
||||
}
|
||||
}
|
||||
|
||||
+29
-26
@@ -23,8 +23,8 @@ import org.jetbrains.plugins.groovy.GroovyBundle;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.Separators;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.declaration.Declaration;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.auxiliary.modifiers.Modifiers;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.declaration.Declaration;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.members.ClassMember;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.members.EnumConstant;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.members.InterfaceMember;
|
||||
@@ -83,15 +83,14 @@ public class TypeDefinition implements GroovyElementTypes {
|
||||
return false;
|
||||
}
|
||||
|
||||
String name;
|
||||
if (!mIDENT.equals(builder.getTokenType())) {
|
||||
if (builder.getTokenType() != mIDENT) {
|
||||
builder.error(GroovyBundle.message("identifier.expected"));
|
||||
return false;
|
||||
} else {
|
||||
name = builder.getTokenText();
|
||||
builder.advanceLexer();
|
||||
}
|
||||
|
||||
String name = builder.getTokenText();
|
||||
builder.advanceLexer();
|
||||
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
TypeParameters.parse(builder);
|
||||
@@ -114,39 +113,38 @@ public class TypeDefinition implements GroovyElementTypes {
|
||||
return false;
|
||||
}
|
||||
|
||||
String name;
|
||||
if (!mIDENT.equals(builder.getTokenType())) {
|
||||
if (builder.getTokenType() != mIDENT) {
|
||||
builder.error(GroovyBundle.message("identifier.expected"));
|
||||
return false;
|
||||
} else {
|
||||
name = builder.getTokenText();
|
||||
builder.advanceLexer();
|
||||
}
|
||||
|
||||
String name = builder.getTokenText();
|
||||
builder.advanceLexer();
|
||||
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
TypeParameters.parse(builder);
|
||||
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
if (kEXTENDS.equals(builder.getTokenType())) {
|
||||
if (builder.getTokenType() == kEXTENDS) {
|
||||
ReferenceElement.parseReferenceList(builder, kEXTENDS, EXTENDS_CLAUSE);
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
}
|
||||
|
||||
if (kIMPLEMENTS.equals(builder.getTokenType())) {
|
||||
if (builder.getTokenType() == kIMPLEMENTS) {
|
||||
ReferenceElement.parseReferenceList(builder, kIMPLEMENTS, IMPLEMENTS_CLAUSE);
|
||||
}
|
||||
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
|
||||
if (mLCURLY.equals(builder.getTokenType())) {
|
||||
parseClassBody(builder, name, parser);
|
||||
} else {
|
||||
if (builder.getTokenType() != mLCURLY) {
|
||||
builder.error(GroovyBundle.message("lcurly.expected"));
|
||||
return true;
|
||||
}
|
||||
|
||||
parseClassBody(builder, name, parser);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -155,17 +153,21 @@ public class TypeDefinition implements GroovyElementTypes {
|
||||
return false;
|
||||
}
|
||||
|
||||
String name;
|
||||
if (!mIDENT.equals(builder.getTokenType())) {
|
||||
if (builder.getTokenType() != mIDENT) {
|
||||
builder.error(GroovyBundle.message("identifier.expected"));
|
||||
return false;
|
||||
} else {
|
||||
name = builder.getTokenText();
|
||||
builder.advanceLexer();
|
||||
}
|
||||
|
||||
if (WRONGWAY.equals(ReferenceElement.parseReferenceList(builder, kIMPLEMENTS, IMPLEMENTS_CLAUSE))) {
|
||||
return true;
|
||||
String name = builder.getTokenText();
|
||||
builder.advanceLexer();
|
||||
|
||||
if (builder.getTokenType() == kEXTENDS) {
|
||||
ReferenceElement.parseReferenceList(builder, kEXTENDS, EXTENDS_CLAUSE);
|
||||
ParserUtils.getToken(builder, mNLS);
|
||||
}
|
||||
|
||||
if (builder.getTokenType() == kIMPLEMENTS) {
|
||||
ReferenceElement.parseReferenceList(builder, kIMPLEMENTS, IMPLEMENTS_CLAUSE);
|
||||
}
|
||||
|
||||
Separators.parse(builder);
|
||||
@@ -265,7 +267,7 @@ public class TypeDefinition implements GroovyElementTypes {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean parseEnumBlock(PsiBuilder builder, String enumName, GroovyParser parser) {
|
||||
private static boolean parseEnumBlock(PsiBuilder builder, @Nullable String enumName, GroovyParser parser) {
|
||||
//see also InterfaceBlock, EnumBlock, AnnotationBlock
|
||||
PsiBuilder.Marker ebMarker = builder.mark();
|
||||
|
||||
@@ -278,7 +280,8 @@ public class TypeDefinition implements GroovyElementTypes {
|
||||
|
||||
if (parseEnumConstantStart(builder, parser)) {
|
||||
EnumConstant.parseConstantList(builder, parser);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ClassMember.parse(builder, enumName, parser);
|
||||
}
|
||||
|
||||
@@ -305,7 +308,7 @@ public class TypeDefinition implements GroovyElementTypes {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean parseInterfaceBlock(PsiBuilder builder, String interfaceName, GroovyParser parser) {
|
||||
private static boolean parseInterfaceBlock(PsiBuilder builder, @Nullable String interfaceName, GroovyParser parser) {
|
||||
//see also InterfaceBlock, EnumBlock, AnnotationBlock
|
||||
PsiBuilder.Marker ibMarker = builder.mark();
|
||||
|
||||
|
||||
+2
-1
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.plugins.groovy.lang.parser.parsing.statements.typeDefinitions.members;
|
||||
|
||||
import com.intellij.lang.PsiBuilder;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.GroovyBundle;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
|
||||
import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
|
||||
@@ -31,7 +32,7 @@ import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
|
||||
* @date: 20.03.2007
|
||||
*/
|
||||
public class InterfaceMember implements GroovyElementTypes {
|
||||
public static boolean parse(PsiBuilder builder, String interfaceName, GroovyParser parser) {
|
||||
public static boolean parse(PsiBuilder builder, @Nullable String interfaceName, GroovyParser parser) {
|
||||
//constructor
|
||||
if (ConstructorDefinition.parse(builder, interfaceName, parser)) return true;
|
||||
|
||||
|
||||
+22
-7
@@ -378,25 +378,38 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor {
|
||||
}
|
||||
|
||||
public void visitAssertStatement(GrAssertStatement assertStatement) {
|
||||
final InstructionImpl assertInstruction = startNode(assertStatement);
|
||||
|
||||
final GrExpression assertion = assertStatement.getAssertion();
|
||||
if (assertion != null) {
|
||||
myConditions.push(addNodeAndCheckPending(new ConditionInstruction(assertion)));
|
||||
assertion.accept(this);
|
||||
final InstructionImpl assertInstruction = startNode(assertStatement);
|
||||
|
||||
InstructionImpl positiveHead = myHead;
|
||||
|
||||
List<GotoInstruction> negations = collectAndRemoveAllPendingNegations(assertStatement);
|
||||
if (!negations.isEmpty()) {
|
||||
interruptFlow();
|
||||
reduceAllNegationsIntoInstruction(assertStatement, negations);
|
||||
}
|
||||
|
||||
GrExpression errorMessage = assertStatement.getErrorMessage();
|
||||
if (errorMessage != null) {
|
||||
errorMessage.accept(this);
|
||||
}
|
||||
final PsiType type = TypesUtil.createTypeByFQClassName("java.lang.AssertionError", assertStatement);
|
||||
addNode(new ThrowingInstruction(assertStatement));
|
||||
|
||||
final PsiType type = TypesUtil.createTypeByFQClassName(CommonClassNames.JAVA_LANG_ASSERTION_ERROR, assertStatement);
|
||||
ExceptionInfo info = findCatch(type);
|
||||
if (info != null) {
|
||||
info.myThrowers.add(assertInstruction);
|
||||
info.myThrowers.add(myHead);
|
||||
}
|
||||
else {
|
||||
addPendingEdge(null, assertInstruction);
|
||||
addPendingEdge(null, myHead);
|
||||
}
|
||||
finishNode(assertInstruction);
|
||||
|
||||
myHead = positiveHead;
|
||||
}
|
||||
finishNode(assertInstruction);
|
||||
}
|
||||
|
||||
public void visitThrowStatement(GrThrowStatement throwStatement) {
|
||||
@@ -525,7 +538,9 @@ public class ControlFlowBuilder extends GroovyRecursiveElementVisitor {
|
||||
return instruction;
|
||||
}
|
||||
else if (negations.size() == 1) {
|
||||
return negations.get(0);
|
||||
GotoInstruction instruction = negations.get(0);
|
||||
myHead = instruction;
|
||||
return instruction;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+1
-2
@@ -34,8 +34,7 @@ import org.jetbrains.plugins.groovy.lang.psi.stubs.GrTypeDefinitionStub;
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class GrEnumConstantInitializerImpl extends GrAnonymousClassDefinitionImpl implements GrEnumConstantInitializer {
|
||||
private static final Logger LOG =
|
||||
Logger.getInstance("#org.jetbrains.plugins.groovy.lang.psi.impl.statements.typedef.GrEnumConstantInitializerImpl");
|
||||
private static final Logger LOG = Logger.getInstance(GrEnumConstantInitializerImpl.class);
|
||||
|
||||
public GrEnumConstantInitializerImpl(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.plugins.groovy.GroovyFileType;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumConstantInitializer;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
|
||||
@@ -391,12 +392,16 @@ public class GrClassImplUtil {
|
||||
|
||||
public static boolean isSameDeclaration(PsiElement place, PsiElement element) {
|
||||
if (element instanceof GrAccessorMethod) element = ((GrAccessorMethod)element).getProperty();
|
||||
|
||||
if (!(element instanceof GrField)) return false;
|
||||
if (element instanceof GrScriptField) element = ((GrScriptField)element).getOriginalVariable();
|
||||
if (element == null) return false;
|
||||
|
||||
while (place != null) {
|
||||
if (place == element) return true;
|
||||
place = place.getParent();
|
||||
if (place instanceof GrClosableBlock) return false;
|
||||
if (place instanceof GrEnumConstantInitializer) return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+1
-1
@@ -201,7 +201,7 @@ public abstract class GroovyRefactoringUtil {
|
||||
}
|
||||
|
||||
|
||||
public static void highlightOccurrences(Project project, Editor editor, PsiElement[] elements) {
|
||||
public static void highlightOccurrences(Project project, @Nullable Editor editor, PsiElement[] elements) {
|
||||
if (editor == null) return;
|
||||
ArrayList<RangeHighlighter> highlighters = new ArrayList<RangeHighlighter>();
|
||||
HighlightManager highlightManager = HighlightManager.getInstance(project);
|
||||
|
||||
+3
-2
@@ -28,6 +28,7 @@ import com.intellij.psi.util.PsiFormatUtilBase;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
@@ -62,7 +63,7 @@ public class GrVariableInliner implements InlineHandler.Inliner {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public MultiMap<PsiElement, String> getConflicts(PsiReference reference, PsiElement referenced) {
|
||||
public MultiMap<PsiElement, String> getConflicts(@NotNull PsiReference reference, @NotNull PsiElement referenced) {
|
||||
MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
|
||||
GrExpression expr = (GrExpression)reference.getElement();
|
||||
if (expr.getParent() instanceof GrAssignmentExpression) {
|
||||
@@ -86,7 +87,7 @@ public class GrVariableInliner implements InlineHandler.Inliner {
|
||||
return conflicts;
|
||||
}
|
||||
|
||||
public void inlineUsage(final UsageInfo usage, final PsiElement referenced) {
|
||||
public void inlineUsage(@NotNull final UsageInfo usage, @NotNull final PsiElement referenced) {
|
||||
inlineReference(usage, referenced, myTempExpr);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiMember;
|
||||
import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.util.CommonRefactoringUtil;
|
||||
import com.intellij.usageView.UsageViewUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.GrClassSubstitution;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
|
||||
@@ -38,7 +39,7 @@ import org.jetbrains.plugins.groovy.refactoring.GroovyRefactoringBundle;
|
||||
public class GroovyInlineHandler implements InlineHandler {
|
||||
|
||||
@Nullable
|
||||
public Settings prepareInlineElement(final PsiElement element, Editor editor, boolean invokedOnReference) {
|
||||
public Settings prepareInlineElement(@NotNull final PsiElement element, @Nullable Editor editor, boolean invokedOnReference) {
|
||||
if (element instanceof GrField) {
|
||||
return GrInlineFieldUtil.inlineFieldSettings((GrField)element, editor, invokedOnReference);
|
||||
}
|
||||
|
||||
+14
-14
@@ -35,7 +35,7 @@ public class GroovyCompletionTest extends GroovyCompletionTestBase {
|
||||
@Override
|
||||
protected void setUp() {
|
||||
super.setUp()
|
||||
CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
|
||||
CamelHumpMatcher.forceStartMatching(testRootDisposable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,27 +135,27 @@ public class GroovyCompletionTest extends GroovyCompletionTestBase {
|
||||
|
||||
public void testFieldSuggestedOnce1() {
|
||||
myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + ".groovy");
|
||||
assertNull(myFixture.getLookupElements());
|
||||
assertNull(myFixture.lookupElements);
|
||||
}
|
||||
|
||||
public void testFieldSuggestedOnce2() {
|
||||
myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + ".groovy");
|
||||
assertNull(myFixture.getLookupElements());
|
||||
assertNull(myFixture.lookupElements);
|
||||
}
|
||||
|
||||
public void testFieldSuggestedOnce3() {
|
||||
myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + ".groovy");
|
||||
assertNull(myFixture.getLookupElements());
|
||||
assertNull(myFixture.lookupElements);
|
||||
}
|
||||
|
||||
public void testFieldSuggestedOnce4() {
|
||||
myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + ".groovy");
|
||||
assertNull(myFixture.getLookupElements());
|
||||
assertNull(myFixture.lookupElements);
|
||||
}
|
||||
|
||||
public void testFieldSuggestedOnce5() {
|
||||
myFixture.testCompletion(getTestName(false) + ".groovy", getTestName(false) + ".groovy");
|
||||
assertNull(myFixture.getLookupElements());
|
||||
assertNull(myFixture.lookupElements);
|
||||
}
|
||||
|
||||
public void testFieldSuggestedInMethodCall() {
|
||||
@@ -300,7 +300,7 @@ public class GroovyCompletionTest extends GroovyCompletionTestBase {
|
||||
}
|
||||
|
||||
public void testCompletionNamedArgumentWithoutSpace() {
|
||||
def settings = CodeStyleSettingsManager.getSettings(getProject()).getCustomSettings(GroovyCodeStyleSettings.class)
|
||||
def settings = CodeStyleSettingsManager.getSettings(project).getCustomSettings(GroovyCodeStyleSettings.class)
|
||||
settings.SPACE_IN_NAMED_ARGUMENT = false
|
||||
|
||||
try {
|
||||
@@ -937,12 +937,12 @@ class Fopppp {
|
||||
|
||||
public void testExcludeStringBuffer() {
|
||||
assert doContainsTest('StringBuffer', 'StringBuff<caret>f')
|
||||
CodeInsightSettings.getInstance().EXCLUDED_PACKAGES = [StringBuffer.name] as String[]
|
||||
CodeInsightSettings.instance.EXCLUDED_PACKAGES = [StringBuffer.name] as String[]
|
||||
try {
|
||||
assert !doContainsTest('StringBuffer', 'StringBuff<caret>f')
|
||||
}
|
||||
finally {
|
||||
CodeInsightSettings.getInstance().EXCLUDED_PACKAGES = new String[0]
|
||||
CodeInsightSettings.instance.EXCLUDED_PACKAGES = new String[0]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1022,10 +1022,6 @@ while(true) {
|
||||
assertEquals 'stryng', myFixture.lookupElementStrings[0]
|
||||
}
|
||||
|
||||
private def caseSensitiveNone() {
|
||||
CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE
|
||||
}
|
||||
|
||||
public void testFieldVsPackage() {
|
||||
myFixture.addFileToProject 'aaa/bbb/Foo.groovy', 'package aaa.bbb; class Foo{}'
|
||||
def file = myFixture.addFileToProject('aaa/bar.groovy', '''
|
||||
@@ -1340,7 +1336,7 @@ def map = [1:2]
|
||||
print map.metc<caret>
|
||||
''');
|
||||
myFixture.complete(CompletionType.BASIC);
|
||||
assertEmpty myFixture.getLookupElements()
|
||||
assertEmpty myFixture.lookupElements
|
||||
}
|
||||
|
||||
void testAnnotationCompletion0() {
|
||||
@@ -1572,4 +1568,8 @@ setBarrr(<caret>)
|
||||
void testParenthesesAfterDot() {
|
||||
myFixture.testCompletionTyping(getTestName(false) + '.groovy', '\t', getTestName(false) + '_after.groovy')
|
||||
}
|
||||
|
||||
void testNewExprDoesntCompleteDef() {
|
||||
doNoVariantsTest('def a = \new <caret>', 'def', 'final')
|
||||
}
|
||||
}
|
||||
+17
-3
@@ -13,12 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.plugins.groovy.completion;
|
||||
|
||||
package org.jetbrains.plugins.groovy.completion
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightSettings
|
||||
import com.intellij.codeInsight.completion.CompletionType
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import org.jetbrains.plugins.groovy.GroovyFileType
|
||||
/**
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
@@ -96,4 +97,17 @@ abstract public class GroovyCompletionTestBase extends LightCodeInsightFixtureTe
|
||||
myFixture.checkResult(after);
|
||||
}
|
||||
|
||||
public void doNoVariantsTest(String before, String... excludedVariants) {
|
||||
myFixture.configureByText(GroovyFileType.GROOVY_FILE_TYPE, before)
|
||||
myFixture.completeBasic()
|
||||
final excluded = ContainerUtil.newHashSet(excludedVariants)
|
||||
for (String lookup : myFixture.lookupElementStrings) {
|
||||
assertFalse(lookup, excluded.contains(lookup))
|
||||
}
|
||||
}
|
||||
|
||||
protected static def caseSensitiveNone() {
|
||||
CodeInsightSettings.instance.COMPLETION_CASE_SENSITIVE = CodeInsightSettings.NONE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+36
-31
@@ -17,37 +17,37 @@ import org.jetbrains.plugins.groovy.util.TestUtils
|
||||
public class ControlFlowTest extends LightCodeInsightFixtureTestCase {
|
||||
final String basePath = TestUtils.testDataPath + "groovy/controlFlow/"
|
||||
|
||||
public void testAssignment() throws Throwable { doTest(); }
|
||||
public void testClosure1() throws Throwable { doTest(); }
|
||||
public void testComplexAssign() throws Throwable { doTest(); }
|
||||
public void testFor1() throws Throwable { doTest(); }
|
||||
public void testForeach1() throws Throwable { doTest(); }
|
||||
public void testGrvy1497() throws Throwable { doTest(); }
|
||||
public void testIf1() throws Throwable { doTest(); }
|
||||
public void testMultipleAssignment() throws Throwable { doTest(); }
|
||||
public void testNested() throws Throwable { doTest(); }
|
||||
public void testReturn() throws Throwable { doTest(); }
|
||||
public void testSwitch1() throws Throwable { doTest(); }
|
||||
public void testSwitch2() throws Throwable { doTest(); }
|
||||
public void testSwitch3() throws Throwable { doTest(); }
|
||||
public void testSwitch4() throws Throwable { doTest(); }
|
||||
public void testSwitch5() throws Throwable { doTest(); }
|
||||
public void testThrow1() throws Throwable { doTest(); }
|
||||
public void testThrowInCatch() throws Throwable { doTest(); }
|
||||
public void testTry1() throws Throwable { doTest(); }
|
||||
public void testTry2() throws Throwable { doTest(); }
|
||||
public void testTry3() throws Throwable { doTest(); }
|
||||
public void testTry4() throws Throwable { doTest(); }
|
||||
public void testTry5() throws Throwable { doTest(); }
|
||||
public void testTry6() throws Throwable { doTest(); }
|
||||
public void testTry7() throws Throwable { doTest(); }
|
||||
public void testTry8() throws Throwable { doTest(); }
|
||||
public void testTry9() throws Throwable { doTest(); }
|
||||
public void testTry10() throws Throwable { doTest(); }
|
||||
public void testWhile1() throws Throwable { doTest(); }
|
||||
public void testWhile2() throws Throwable { doTest(); }
|
||||
public void testWhileNonConstant() throws Throwable { doTest(); }
|
||||
public void testIfInstanceofElse() throws Throwable { doTest(); }
|
||||
public void testAssignment() { doTest(); }
|
||||
public void testClosure1() { doTest(); }
|
||||
public void testComplexAssign() { doTest(); }
|
||||
public void testFor1() { doTest(); }
|
||||
public void testForeach1() { doTest(); }
|
||||
public void testGrvy1497() { doTest(); }
|
||||
public void testIf1() { doTest(); }
|
||||
public void testMultipleAssignment() { doTest(); }
|
||||
public void testNested() { doTest(); }
|
||||
public void testReturn() { doTest(); }
|
||||
public void testSwitch1() { doTest(); }
|
||||
public void testSwitch2() { doTest(); }
|
||||
public void testSwitch3() { doTest(); }
|
||||
public void testSwitch4() { doTest(); }
|
||||
public void testSwitch5() { doTest(); }
|
||||
public void testThrow1() { doTest(); }
|
||||
public void testThrowInCatch() { doTest(); }
|
||||
public void testTry1() { doTest(); }
|
||||
public void testTry2() { doTest(); }
|
||||
public void testTry3() { doTest(); }
|
||||
public void testTry4() { doTest(); }
|
||||
public void testTry5() { doTest(); }
|
||||
public void testTry6() { doTest(); }
|
||||
public void testTry7() { doTest(); }
|
||||
public void testTry8() { doTest(); }
|
||||
public void testTry9() { doTest(); }
|
||||
public void testTry10() { doTest(); }
|
||||
public void testWhile1() { doTest(); }
|
||||
public void testWhile2() { doTest(); }
|
||||
public void testWhileNonConstant() { doTest(); }
|
||||
public void testIfInstanceofElse() { doTest(); }
|
||||
public void testReturnMapFromClosure() {doTest();}
|
||||
public void testSwitchInTryWithThrows() {doTest();}
|
||||
public void testClosure() {doTest();}
|
||||
@@ -56,6 +56,11 @@ public class ControlFlowTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testOrInReturn() {doTest();}
|
||||
public void testVarInString() {doTest();}
|
||||
public void testMayBeStaticWithCondition() {doTest()}
|
||||
public void testAssert0() { doTest() }
|
||||
public void testAssert1() { doTest() }
|
||||
public void testAssert2() { doTest() }
|
||||
public void testAssert3() { doTest() }
|
||||
public void testAssert4() { doTest() }
|
||||
|
||||
public void doTest() {
|
||||
final List<String> input = TestUtils.readInput(testDataPath + getTestName(true) + ".test");
|
||||
|
||||
@@ -120,6 +120,7 @@ public class FormatterTest extends GroovyFormatterTestCase {
|
||||
|
||||
public void testSpockTable() throws Throwable { doTest(); }
|
||||
public void testSpockTableComments() throws Throwable { doTest(); }
|
||||
public void testSpockTableWithStringComment() throws Throwable { doTest(); }
|
||||
|
||||
public void testElseIfs() throws Throwable {
|
||||
getGroovySettings().SPECIAL_ELSE_IF_TREATMENT = false;
|
||||
|
||||
+7
@@ -896,6 +896,13 @@ def methodMissing(String methodName, args) {
|
||||
this.metaClass."$methodName" = closure
|
||||
<error descr="Invalid value to assign to">closure()</error> = 2
|
||||
}
|
||||
''')
|
||||
}
|
||||
|
||||
void testEnumExtendsList() {
|
||||
testHighlighting('''\
|
||||
enum Ee <error descr="Enums may not have 'extends' clause">extends Enum</error> {
|
||||
}
|
||||
''')
|
||||
}
|
||||
}
|
||||
+34
-19
@@ -21,6 +21,7 @@ import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstant
|
||||
@@ -47,7 +48,7 @@ public class ResolvePropertyTest extends GroovyResolveTestCase {
|
||||
PsiReference ref = configureByFile("closureOwner/A.groovy");
|
||||
PsiElement resolved = ref.resolve();
|
||||
assertInstanceOf(resolved, PsiVariable);
|
||||
assertEquals(((PsiVariable) resolved).getType().getCanonicalText(), "W");
|
||||
assertEquals((resolved as PsiVariable).type.canonicalText, "W");
|
||||
}
|
||||
|
||||
public void testLocal1() throws Exception {
|
||||
@@ -117,21 +118,21 @@ public class ResolvePropertyTest extends GroovyResolveTestCase {
|
||||
}
|
||||
|
||||
public void testField3() throws Exception {
|
||||
GrReferenceElement ref = (GrReferenceElement) configureByFile("field3/A.groovy").getElement();
|
||||
GrReferenceElement ref = (GrReferenceElement)configureByFile("field3/A.groovy").element;
|
||||
GroovyResolveResult resolveResult = ref.advancedResolve();
|
||||
assertTrue(resolveResult.getElement() instanceof GrField);
|
||||
assertFalse(resolveResult.isValidResult());
|
||||
assertTrue(resolveResult.element instanceof GrField);
|
||||
assertFalse(resolveResult.validResult);
|
||||
}
|
||||
|
||||
public void testToGetter() throws Exception {
|
||||
GrReferenceElement ref = (GrReferenceElement) configureByFile("toGetter/A.groovy").getElement();
|
||||
GrReferenceElement ref = (GrReferenceElement)configureByFile("toGetter/A.groovy").element;
|
||||
PsiElement resolved = ref.resolve();
|
||||
assertTrue(resolved instanceof GrMethod);
|
||||
assertTrue(PropertyUtil.isSimplePropertyGetter((PsiMethod) resolved));
|
||||
}
|
||||
|
||||
public void testToSetter() throws Exception {
|
||||
GrReferenceElement ref = (GrReferenceElement) configureByFile("toSetter/A.groovy").getElement();
|
||||
GrReferenceElement ref = (GrReferenceElement)configureByFile("toSetter/A.groovy").element;
|
||||
PsiElement resolved = ref.resolve();
|
||||
assertTrue(resolved instanceof GrMethod);
|
||||
assertTrue(PropertyUtil.isSimplePropertySetter((PsiMethod) resolved));
|
||||
@@ -209,7 +210,7 @@ public class ResolvePropertyTest extends GroovyResolveTestCase {
|
||||
public void testUnderscoredField() throws Exception {
|
||||
PsiReference ref = configureByFile("underscoredField/UnderscoredField.groovy");
|
||||
final GrField field = assertInstanceOf(ref.resolve(), GrField.class);
|
||||
assertFalse(ref.isReferenceTo(field.getGetters()[0]));
|
||||
assertFalse(ref.isReferenceTo(field.getters[0]));
|
||||
assertTrue(ref.isReferenceTo(field));
|
||||
}
|
||||
|
||||
@@ -298,7 +299,7 @@ print ba<caret>r
|
||||
"""
|
||||
def ref = findReference()
|
||||
def target = assertInstanceOf(ref.resolve(), PsiField)
|
||||
assertEquals target.getName(), "foo"
|
||||
assertEquals target.name, "foo"
|
||||
}
|
||||
|
||||
private void doTest(String fileName) throws Exception {
|
||||
@@ -322,7 +323,7 @@ print ba<caret>r
|
||||
def ref = findReference()
|
||||
def resolved = ref.resolve();
|
||||
assertNotNull resolved
|
||||
assert ((PsiMethod) resolved).getName() == "isFoo"
|
||||
assert ((PsiMethod)resolved).name == "isFoo"
|
||||
}
|
||||
|
||||
public void testExplicitBooleanProperty() throws Exception {
|
||||
@@ -332,7 +333,7 @@ print ba<caret>r
|
||||
print new A().f<caret>oo""");
|
||||
def ref = findReference()
|
||||
def resolved = ref.resolve();
|
||||
assert ((PsiMethod) resolved).getName() == "isFoo"
|
||||
assert ((PsiMethod)resolved).name == "isFoo"
|
||||
}
|
||||
|
||||
public void testStaticFieldAndNonStaticGetter() {
|
||||
@@ -353,8 +354,8 @@ print ba<caret>r
|
||||
}""")
|
||||
def ref = findReference()
|
||||
def resolved = ref.resolve();
|
||||
assertInstanceOf resolved, GrField.class
|
||||
assertTrue resolved.getModifierList().hasExplicitVisibilityModifiers()
|
||||
assertInstanceOf resolved, GrField
|
||||
assertTrue ((resolved as GrField).modifierList.hasExplicitVisibilityModifiers())
|
||||
}
|
||||
|
||||
public void testPropertyAndFieldDeclarationOutsideClass() {
|
||||
@@ -405,8 +406,8 @@ class Foo extends Bar {
|
||||
print new Foo().foo""")
|
||||
def ref = findReference()
|
||||
def resolved = ref.resolve();
|
||||
assertInstanceOf resolved, GrField.class
|
||||
assertTrue resolved.getModifierList().hasExplicitVisibilityModifiers()
|
||||
assertInstanceOf resolved, GrField
|
||||
assertTrue ((resolved as GrField).modifierList.hasExplicitVisibilityModifiers())
|
||||
}
|
||||
|
||||
public void testPropertyAndFieldDeclarationWithSuperClass3() {
|
||||
@@ -442,8 +443,8 @@ class Foo extends Bar {
|
||||
print new Foo().foo""")
|
||||
def ref = findReference()
|
||||
def resolved = ref.resolve();
|
||||
assertInstanceOf resolved, GrField.class
|
||||
assertTrue !resolved.getModifierList().hasExplicitVisibilityModifiers()
|
||||
assertInstanceOf resolved, GrField
|
||||
assertTrue (!(resolved as GrField).modifierList.hasExplicitVisibilityModifiers())
|
||||
}
|
||||
|
||||
public void testReadAccessToStaticallyImportedProperty() {
|
||||
@@ -568,13 +569,13 @@ set<caret>Foo(2)
|
||||
|
||||
public void testFieldAccessInStaticContext() {
|
||||
def ref = configureByFile("fieldAccessInStaticContext/A.groovy")
|
||||
def resolveResult = ref.advancedResolve()
|
||||
assertTrue !resolveResult.staticsOK
|
||||
def resolveResult = (ref as GrReferenceExpression).advancedResolve()
|
||||
assertFalse resolveResult.staticsOK
|
||||
}
|
||||
|
||||
public void testFieldAccessInClosureVsStaticContext() {
|
||||
def ref = configureByFile("fieldAccessInClosureVsStaticContext/A.groovy")
|
||||
def resolveResult = ref.advancedResolve()
|
||||
def resolveResult = (ref as GrReferenceExpression).advancedResolve()
|
||||
assertTrue resolveResult.staticsOK
|
||||
}
|
||||
|
||||
@@ -895,4 +896,18 @@ class User {
|
||||
|
||||
assertInstanceOf(ref.resolve(), GrField)
|
||||
}
|
||||
|
||||
void testResolveEnumConstantInsideItsInitializer() {
|
||||
def ref = configureByText('''\
|
||||
enum MyEnum {
|
||||
CONST {
|
||||
void get() {
|
||||
C<caret>ONST
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
''')
|
||||
assertNotNull(ref)
|
||||
}
|
||||
}
|
||||
|
||||
+53
-44
@@ -37,111 +37,111 @@ public class TypeInferenceTest extends GroovyResolveTestCase {
|
||||
final String basePath = TestUtils.testDataPath + "resolve/inference/"
|
||||
|
||||
public void testTryFinallyFlow() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow/A.groovy").getElement();
|
||||
final PsiType type = ref.getType();
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow/A.groovy").element;
|
||||
final PsiType type = ref.type;
|
||||
assertTrue(type instanceof PsiIntersectionType);
|
||||
final PsiType[] conjuncts = ((PsiIntersectionType)type).getConjuncts();
|
||||
final PsiType[] conjuncts = ((PsiIntersectionType)type).conjuncts;
|
||||
assertEquals(conjuncts.length, 2);
|
||||
}
|
||||
|
||||
public void testTryFinallyFlow1() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow1/A.groovy").getElement();
|
||||
final PsiType type = ref.getType();
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow1/A.groovy").element;
|
||||
final PsiType type = ref.type;
|
||||
assertNotNull(type);
|
||||
assertTrue(type.equalsToText("java.lang.Integer"));
|
||||
}
|
||||
|
||||
public void testTryFinallyFlow2() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow2/A.groovy").getElement();
|
||||
final PsiType type = ref.getType();
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("tryFinallyFlow2/A.groovy").element;
|
||||
final PsiType type = ref.type;
|
||||
assertNotNull(type);
|
||||
assertTrue(type.equalsToText("java.lang.Integer"));
|
||||
}
|
||||
|
||||
public void testThrowVariable() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("throwVariable/A.groovy").getElement();
|
||||
final PsiType type = ref.getType();
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("throwVariable/A.groovy").element;
|
||||
final PsiType type = ref.type;
|
||||
assertNotNull(type);
|
||||
assertEquals("java.lang.Exception", type.getCanonicalText());
|
||||
assertEquals("java.lang.Exception", type.canonicalText);
|
||||
}
|
||||
|
||||
public void testGrvy852() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("grvy852/A.groovy").getElement();
|
||||
final PsiType type = ref.getType();
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("grvy852/A.groovy").element;
|
||||
final PsiType type = ref.type;
|
||||
assertNotNull(type);
|
||||
assertEquals("java.lang.Object", type.getCanonicalText());
|
||||
assertEquals("java.lang.Object", type.canonicalText);
|
||||
}
|
||||
|
||||
public void testGenericMethod() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("genericMethod/A.groovy").getElement();
|
||||
final PsiType type = ref.getType();
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("genericMethod/A.groovy").element;
|
||||
final PsiType type = ref.type;
|
||||
assertNotNull(type);
|
||||
assertEquals("java.util.List<java.lang.String>", type.getCanonicalText());
|
||||
assertEquals("java.util.List<java.lang.String>", type.canonicalText);
|
||||
}
|
||||
|
||||
public void testCircular() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("circular/A.groovy").getElement();
|
||||
assertNull(ref.getType());
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("circular/A.groovy").element;
|
||||
assertNull(ref.type);
|
||||
}
|
||||
|
||||
public void testCircular1() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("circular1/A.groovy").getElement();
|
||||
assertNull(ref.getType());
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("circular1/A.groovy").element;
|
||||
assertNull(ref.type);
|
||||
}
|
||||
|
||||
public void testClosure() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("closure/A.groovy").getElement();
|
||||
assertNotNull(ref.getType());
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("closure/A.groovy").element;
|
||||
assertNotNull(ref.type);
|
||||
}
|
||||
|
||||
public void testClosure1() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("closure1/A.groovy").getElement();
|
||||
assertTrue(ref.getType().equalsToText("java.lang.Integer"));
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("closure1/A.groovy").element;
|
||||
assertTrue(ref.type.equalsToText("java.lang.Integer"));
|
||||
}
|
||||
|
||||
public void testClosure2() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("closure2/A.groovy").getElement();
|
||||
assertTrue(ref.getType().equalsToText("java.lang.Integer"));
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("closure2/A.groovy").element;
|
||||
assertTrue(ref.type.equalsToText("java.lang.Integer"));
|
||||
}
|
||||
|
||||
public void testGrvy1209() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("grvy1209/A.groovy").getElement();
|
||||
assertTrue(ref.getType().equalsToText("java.lang.String"));
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("grvy1209/A.groovy").element;
|
||||
assertTrue(ref.type.equalsToText("java.lang.String"));
|
||||
}
|
||||
|
||||
public void testLeastUpperBoundClosureType() {
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("leastUpperBoundClosureType/A.groovy").getElement();
|
||||
assertInstanceOf(ref.getType(), GrClosureType.class);
|
||||
GrReferenceExpression ref = (GrReferenceExpression)configureByFile("leastUpperBoundClosureType/A.groovy").element;
|
||||
assertInstanceOf(ref.type, GrClosureType.class);
|
||||
}
|
||||
|
||||
public void testJavaLangClassType() {
|
||||
final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("javaLangClassType/A.groovy").getElement();
|
||||
assertEquals("java.lang.String", ref.getType().getCanonicalText());
|
||||
final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("javaLangClassType/A.groovy").element;
|
||||
assertEquals("java.lang.String", ref.type.canonicalText);
|
||||
}
|
||||
|
||||
public void testGenericWildcard() {
|
||||
final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("genericWildcard/A.groovy").getElement();
|
||||
assertEquals("A<Base>", ref.getType().getCanonicalText());
|
||||
final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("genericWildcard/A.groovy").element;
|
||||
assertEquals("A<Base>", ref.type.canonicalText);
|
||||
}
|
||||
|
||||
public void testArrayLikeAccessWithIntSequence() {
|
||||
final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("arrayLikeAccessWithIntSequence/A.groovy").getElement();
|
||||
assertEquals("java.util.List<java.lang.Integer>", ref.getType().getCanonicalText());
|
||||
final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("arrayLikeAccessWithIntSequence/A.groovy").element;
|
||||
assertEquals("java.util.List<java.lang.Integer>", ref.type.canonicalText);
|
||||
}
|
||||
|
||||
public void testArrayAccess() {
|
||||
final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("arrayAccess/A.groovy");
|
||||
assertEquals(JAVA_LANG_STRING, ref.getType().getCanonicalText());
|
||||
assertEquals(JAVA_LANG_STRING, ref.type.canonicalText);
|
||||
}
|
||||
|
||||
public void testReturnTypeByTailExpression() {
|
||||
final GrReferenceExpression ref = (GrReferenceExpression)configureByFile("returnTypeByTailExpression/A.groovy");
|
||||
assertEquals(JAVA_LANG_STRING, ref.getType().getCanonicalText());
|
||||
assertEquals(JAVA_LANG_STRING, ref.type.canonicalText);
|
||||
}
|
||||
|
||||
public void testParameterWithBuiltinType() {
|
||||
GrReferenceExpression refExpr = (GrReferenceExpression)configureByFile("parameterWithBuiltinType/A.groovy");
|
||||
assertEquals("java.lang.Integer", refExpr.getType().getCanonicalText());
|
||||
assertEquals("java.lang.Integer", refExpr.type.canonicalText);
|
||||
}
|
||||
|
||||
public void testRawTypeInReturnExpression() {
|
||||
@@ -150,15 +150,15 @@ public class TypeInferenceTest extends GroovyResolveTestCase {
|
||||
|
||||
public void testMethodCallInvokedOnArrayAccess() {
|
||||
final GrReferenceExpression reference = (GrReferenceExpression)configureByFile("A.groovy");
|
||||
assertEquals("java.lang.Integer", reference.getType().getCanonicalText());
|
||||
assertEquals("java.lang.Integer", reference.type.canonicalText);
|
||||
}
|
||||
|
||||
private void assertTypeEquals(String expected, String fileName) {
|
||||
final PsiReference ref = configureByFile(getTestName(true) + "/" + fileName);
|
||||
assertInstanceOf(ref, GrReferenceExpression.class);
|
||||
final PsiType type = ((GrReferenceExpression)ref).getType();
|
||||
final PsiType type = ((GrReferenceExpression)ref).type;
|
||||
assertNotNull(type);
|
||||
assertEquals(expected, type.getCanonicalText());
|
||||
assertEquals(expected, type.canonicalText);
|
||||
}
|
||||
|
||||
public void testTypeOfGroupBy() {
|
||||
@@ -170,7 +170,7 @@ public class TypeInferenceTest extends GroovyResolveTestCase {
|
||||
}
|
||||
|
||||
public void testImplicitCallMethod() {
|
||||
assertEquals("java.lang.String", ((GrExpression)configureByFile("A.groovy")).getType().getCanonicalText());
|
||||
assertEquals("java.lang.String", ((GrExpression)configureByFile("A.groovy")).type.canonicalText);
|
||||
}
|
||||
|
||||
public void testTupleWithNullInIt() {
|
||||
@@ -220,7 +220,7 @@ public class TypeInferenceTest extends GroovyResolveTestCase {
|
||||
public void testNoSOF() {
|
||||
final PsiReference ref = configureByFile(getTestName(true) + "/A.groovy");
|
||||
assertInstanceOf(ref, GrReferenceExpression.class);
|
||||
final PsiType type = ((GrReferenceExpression)ref).getType();
|
||||
final PsiType type = ((GrReferenceExpression)ref).type;
|
||||
assertNull(type);
|
||||
}
|
||||
|
||||
@@ -568,6 +568,15 @@ def method(List<? extends Tx> t) {
|
||||
''', 'Tx')
|
||||
}
|
||||
|
||||
void testAssert() {
|
||||
doTest('''\
|
||||
def foo(def var) {
|
||||
assert var instanceof String
|
||||
va<caret>r.isEmpty()
|
||||
}
|
||||
''', 'java.lang.String')
|
||||
}
|
||||
|
||||
private void doTest(String text, String type) {
|
||||
def file = myFixture.configureByText('_.groovy', text)
|
||||
def ref = file.findReferenceAt(myFixture.editor.caretModel.offset) as GrReferenceExpression
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
assert x instanceof String : bar()
|
||||
return x.isEmpty()
|
||||
-----
|
||||
0(1) element: null
|
||||
1(2) element: ASSERT statement
|
||||
2(3) READ x
|
||||
3(4,6) Condition Instanceof expression
|
||||
4(5) instanceof: x instanceof String
|
||||
5(7) Negating goto instruction, condition=3Instanceof expression
|
||||
6(9) instanceof: x instanceof String
|
||||
7(8) READ bar
|
||||
8(11) THROW. element: ASSERT statement
|
||||
9(10) READ x
|
||||
10(11) element: RETURN statement
|
||||
11() element: null
|
||||
@@ -0,0 +1,26 @@
|
||||
try {
|
||||
assert x instanceof String : bar()
|
||||
}
|
||||
catch (java.lang.AssertionError e) {
|
||||
return true
|
||||
}
|
||||
|
||||
return x.isEmpty()
|
||||
-----
|
||||
0(1) element: null
|
||||
1(2) element: Open block
|
||||
2(3) element: ASSERT statement
|
||||
3(4) READ x
|
||||
4(5,7) Condition Instanceof expression
|
||||
5(6) instanceof: x instanceof String
|
||||
6(8) Negating goto instruction, condition=4Instanceof expression
|
||||
7(14) instanceof: x instanceof String
|
||||
8(9) READ bar
|
||||
9(10,11) THROW. element: Method call
|
||||
10(11) THROW. element: ASSERT statement
|
||||
11(12) element: Catch clause
|
||||
12(13) WRITE e
|
||||
13(16) element: RETURN statement
|
||||
14(15) READ x
|
||||
15(16) element: RETURN statement
|
||||
16() element: null
|
||||
@@ -0,0 +1,10 @@
|
||||
assert cond() : 'abc'
|
||||
print 2
|
||||
-----
|
||||
0(1) element: null
|
||||
1(2) element: ASSERT statement
|
||||
2(3,4) READ cond
|
||||
3(6) THROW. element: ASSERT statement
|
||||
4(5) READ print
|
||||
5(6) element: Call expression MAYBE_RETURN
|
||||
6() element: null
|
||||
@@ -0,0 +1,9 @@
|
||||
assert false
|
||||
print 2
|
||||
-----
|
||||
0(1) element: null
|
||||
1(2,3) element: ASSERT statement
|
||||
2(5) THROW. element: ASSERT statement
|
||||
3(4) READ print
|
||||
4(5) element: Call expression MAYBE_RETURN
|
||||
5() element: null
|
||||
@@ -0,0 +1,9 @@
|
||||
assert true
|
||||
print 2
|
||||
-----
|
||||
0(1) element: null
|
||||
1(2,3) element: ASSERT statement
|
||||
2(5) THROW. element: ASSERT statement
|
||||
3(4) READ print
|
||||
4(5) element: Call expression MAYBE_RETURN
|
||||
5() element: null
|
||||
@@ -0,0 +1,23 @@
|
||||
class HelloSpock extends spock.lang.Specification {
|
||||
def "length of Spock's and his friends' names"() {
|
||||
expect:
|
||||
name.size() == length
|
||||
|
||||
where: "something"
|
||||
name || length
|
||||
"Kirk" || 4
|
||||
"Scotty" || 6
|
||||
}
|
||||
}
|
||||
-----
|
||||
class HelloSpock extends spock.lang.Specification {
|
||||
def "length of Spock's and his friends' names"() {
|
||||
expect:
|
||||
name.size() == length
|
||||
|
||||
where: "something"
|
||||
name || length
|
||||
"Kirk" || 4
|
||||
"Scotty" || 6
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,3 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
*/
|
||||
def x = new Date()
|
||||
def y = new Date()
|
||||
def <warning descr="Assignment is not used">z</warning> = new Date()
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.AsynchConsumer;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.zmlx.hg4idea.*;
|
||||
import org.zmlx.hg4idea.command.HgLogCommand;
|
||||
@@ -151,6 +152,7 @@ public class HgCachingCommitedChangesProvider implements CachingCommittedChanges
|
||||
throw new UnsupportedOperationException(); //TODO implement method
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ChangeBrowserSettings createDefaultSettings() {
|
||||
return new ChangeBrowserSettings();
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ public class SvnCommittedChangesProvider implements CachingCommittedChangesProvi
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ChangeBrowserSettings createDefaultSettings() {
|
||||
return new ChangeBrowserSettings();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<idea-plugin version="2">
|
||||
<name>UI Designer (Core)</name>
|
||||
<id>com.intellij.ui-designer-new</id>
|
||||
<description>
|
||||
Provides shared functionality for visual editing plugins.
|
||||
</description>
|
||||
<vendor>JetBrains</vendor>
|
||||
|
||||
<resource-bundle>messages.DesignerBundle</resource-bundle>
|
||||
|
||||
+10
-5
@@ -58,12 +58,22 @@ public class XsltValidator {
|
||||
if (templateTag == null) {
|
||||
return;
|
||||
}
|
||||
final XmlAttribute attribute = tag.getAttribute("name");
|
||||
if (attribute == null) {
|
||||
return;
|
||||
}
|
||||
final PsiElement token = XsltSupport.getAttValueToken(attribute);
|
||||
if (token == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final SearchScope scope = new LocalSearchScope(templateTag);
|
||||
final Query<PsiReference> refs = ReferencesSearch.search(variable, scope, false);
|
||||
|
||||
if (isUnused(variable, refs)) {
|
||||
final String name = variable.getName();
|
||||
assert name != null;
|
||||
|
||||
final LocalQuickFix[] fixes;
|
||||
if (variable instanceof XsltParameter) {
|
||||
fixes = new LocalQuickFix[]{ new DeleteUnusedParameterFix(name, (XsltParameter)variable) };
|
||||
@@ -71,11 +81,6 @@ public class XsltValidator {
|
||||
fixes = new LocalQuickFix[]{ new DeleteUnusedVariableFix(name, variable) };
|
||||
}
|
||||
|
||||
final XmlAttribute attribute = tag.getAttribute("name");
|
||||
assert attribute != null;
|
||||
|
||||
final PsiElement token = XsltSupport.getAttValueToken(attribute);
|
||||
assert token != null;
|
||||
holder.registerProblem(token, ((DeleteUnusedElementBase)fixes[0]).getType() +
|
||||
" '" + name + "' is never used", ProblemHighlightType.LIKE_UNUSED_SYMBOL, fixes);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user