Merge remote-tracking branch 'origin/master'

This commit is contained in:
Vassiliy Kudryashov
2012-10-17 20:36:37 +04:00
115 changed files with 1013 additions and 614 deletions
+2 -1
View File
@@ -236,7 +236,8 @@ libraryLicense(name: "protobuf", version: "2.3.0", license: "New BSD", url: "htt
libraryLicense(name: "Netty", libraryName: "Netty", version: "3.5.8", license: "Apache 2.0", url: "http://netty.io", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0")
libraryLicense(name: "Kryo", libraryName: "Kryo", version: "1.04", license: "New BSD License", url: "http://code.google.com/p/kryo/", licenseUrl: "http://www.opensource.org/licenses/bsd-license.php")
libraryLicense(name: "Snappy-Java", libraryName: "Snappy-Java", version: "1.0.4.1", license: "Apache 2.0", url: "http://code.google.com/p/snappy-java/", licenseUrl: "http://www.apache.org/licenses/LICENSE-2.0")
libraryLicense(name: "Cucumber-JVM", libraryName: "cucumber-jvm", version: "1.0.11", license: "MIT License", url: "https://github.com/cucumber/cucumber-jvm/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html")
libraryLicense(name: "Cucumber-Java", libraryName: "cucumber-java", version: "1.0.14", license: "MIT License", url: "https://github.com/cucumber/cucumber-jvm/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html")
libraryLicense(name: "Cucumber-JVM", libraryName: "cucumber-jvm", version: "1.0.14", license: "MIT License", url: "https://github.com/cucumber/cucumber-jvm/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html")
libraryLicense(name: "Cucumber-Groovy", libraryName: "cucumber-groovy", version: "1.0.14", license: "MIT License", url: "https://github.com/cucumber/cucumber-jvm/", licenseUrl: "http://www.opensource.org/licenses/mit-license.html")
libraryLicense(name: "proxy-vole", libraryName: "proxy-vole", version: "20120920", license: "New BSD License", url: "http://code.google.com/p/proxy-vole/", licenseUrl: "http://opensource.org/licenses/BSD-3-Clause")
libraryLicense(name: "Rhino JavaScript Engine", libraryName: "rhino-js-1_7R4", version: "1.7R4", license: "MPL 1.1", url: "http://www.mozilla.org/rhino/", licenseUrl: "http://www.mozilla.org/MPL/MPL-1.1.html")
@@ -626,6 +626,8 @@ public class CompileDriver {
LOG.error(e); // todo
}
finally {
CompilerCacheManager.getInstance(myProject).flushCaches();
final long duration = notifyCompilationCompleted(compileContext, callback, COMPILE_SERVER_BUILD_STATUS.get(compileContext));
CompilerUtil.logDuration(
"\tCOMPILATION FINISHED (BUILD PROCESS); Errors: " +
@@ -635,8 +637,6 @@ public class CompileDriver {
duration
);
CompilerCacheManager.getInstance(myProject).flushCaches();
// refresh on output roots is required in order for the order enumerator to see all roots via VFS
final Set<File> outputs = new HashSet<File>();
for (final String path : CompilerPathsEx.getOutputPaths(ModuleManager.getInstance(myProject).getModules())) {
@@ -668,7 +668,6 @@ public class CompileDriver {
doCompile(compileContext, isRebuild, forceCompile, callback, checkCachesVersion);
}
finally {
CompilerCacheManager.getInstance(myProject).flushCaches();
FileUtil.delete(CompilerPaths.getRebuildMarkerFile(myProject));
}
}
@@ -737,6 +736,7 @@ public class CompileDriver {
}
finally {
dropDependencyCache(compileContext);
CompilerCacheManager.getInstance(myProject).flushCaches();
if (compileContext.isRebuildRequested()) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
@@ -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
@@ -79,7 +79,7 @@ public class AddModuleWizard extends AbstractWizard<ModuleWizardStep> {
initModuleWizard(project, null);
}
private void initModuleWizard(final Project project, @Nullable final String defaultPath) {
private void initModuleWizard(@Nullable final Project project, @Nullable final String defaultPath) {
myWizardContext = new WizardContext(project);
if (defaultPath != null) {
myWizardContext.setProjectFileDirectory(defaultPath);
@@ -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();
}
@@ -68,18 +68,19 @@ public class CreateFromScratchMode extends WizardMode {
StepSequence sequence, List<ModuleBuilder> builders) {
sequence.addCommonStep(new ProjectNameWithTypeStep(context, sequence, mode));
for (ModuleBuilder builder : builders) {
addModuleBuilder(builder, context, modulesProvider, sequence);
context.setTemplateMode(mode instanceof CreateFromTemplateMode);
addStepsForBuilder(builder, context, modulesProvider, sequence);
}
return sequence;
}
private static void addModuleBuilder(ModuleBuilder builder,
WizardContext context,
ModulesProvider modulesProvider,
StepSequence myStepSequence) {
private static void addStepsForBuilder(ModuleBuilder builder,
WizardContext context,
ModulesProvider modulesProvider,
StepSequence sequence) {
final String id = builder.getBuilderId();
for (ModuleWizardStep step : builder.createWizardSteps(context, modulesProvider)) {
myStepSequence.addSpecificStep(id, step);
sequence.addSpecificStep(id, step);
}
}
@@ -47,7 +47,7 @@ public class CreateFromTemplateMode extends WizardMode {
@Override
public boolean isAvailable(WizardContext context) {
return true;
return context.isCreatingNewProject();
}
@Nullable
@@ -82,6 +82,9 @@ public class ExpectedTypeInfoImpl implements ExpectedTypeInfo {
}
this.defaultType = defaultType;
assert type.isValid();
assert defaultType.isValid();
}
@Override
@@ -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) {
@@ -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);
}
@@ -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);
}
}
@@ -177,6 +177,9 @@ public class JavaCompletionSorting {
final PsiType defaultType = expectedInfo.getDefaultType();
final PsiType expectedType = expectedInfo.getType();
assert expectedType.isValid();
assert defaultType.isValid();
if (defaultType != expectedType && defaultType.isAssignableFrom(itemType)) {
return ExpectedTypeMatching.ofDefaultType;
}
@@ -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);
}
}
}
@@ -973,7 +973,7 @@ public class HighlightMethodUtil {
PsiClass[] interfaces = aClass.getInterfaces();
for (PsiClass aInterfaces : interfaces) {
superClass = aInterfaces;
superMethod = MethodSignatureUtil.findMethodBySignature(superClass, method, true);
superMethod = MethodSignatureUtil.findMethodInSuperClassBySignatureInDerived(aClass, superClass, method.getSignature(PsiSubstitutor.EMPTY), true);
highlightInfo = checkStaticMethodOverride(aClass, method, true, superClass, superMethod);
if (highlightInfo != null) return highlightInfo;
}
@@ -36,7 +36,6 @@ import com.intellij.openapi.vfs.VirtualFileVisitor;
import com.intellij.psi.JavaPsiFacade;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiPackage;
import com.intellij.util.PlatformIcons;
import com.intellij.util.ui.tree.TreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -104,8 +103,8 @@ public class TreeModelBuilder {
createMaps(ScopeType.TEST);
if (myGroupByScopeType) {
mySourceRoot = new GeneralGroupNode(PRODUCTION_NAME, PlatformIcons.PACKAGE_ICON, project);
myTestRoot = new GeneralGroupNode(TEST_NAME, AllIcons.Nodes.TestSourceFolder, project);
mySourceRoot = new GeneralGroupNode(PRODUCTION_NAME, AllIcons.Modules.SourceFolder, project);
myTestRoot = new GeneralGroupNode(TEST_NAME, AllIcons.Modules.TestSourceFolder, project);
myLibsRoot = new GeneralGroupNode(LIBRARY_NAME, AllIcons.Nodes.PpLibFolder, project);
myRoot.add(mySourceRoot);
myRoot.add(myTestRoot);
@@ -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;
@@ -255,7 +256,7 @@ public class JavaClassReference extends GenericReference implements PsiJavaRefer
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
@NotNull
@Nullable
public PsiElement getCompletionContext() {
PsiElement context = getContext();
return context == null ? JavaPsiFacade.getInstance(getElement().getProject()).findPackage("") : context;
@@ -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));
}
}
}
@@ -226,7 +226,7 @@ public class InvertBooleanProcessor extends BaseRefactoringProcessor {
for (final PsiElement element : myRenameProcessor.getElements()) {
try {
RenameUtil.doRename(element, myNewName, extractUsagesForElement(element, usages), myProject, new RefactoringElementListener() {
RenameUtil.doRename(element, myRenameProcessor.getNewName(element), extractUsagesForElement(element, usages), myProject, new RefactoringElementListener() {
public void elementMoved(@NotNull PsiElement newElement) {
}
@@ -84,7 +84,7 @@ public class ConstructorReferencesSearchHelper {
if (parent instanceof PsiMethodReferenceExpression &&
((PsiMethodReferenceExpression)parent).getReferenceNameElement() instanceof PsiKeyword) {
if (((PsiMethodReferenceExpression)parent).isReferenceTo(constructor)) {
processor.process(reference);
processor.process((PsiReference)parent);
}
}
}
@@ -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";
}
@@ -811,6 +811,7 @@ public class LambdaUtil {
@Nullable
private static PsiType getReturnType(int functionalTypeIdx, CandidateInfo method) {
final PsiParameter[] methodParameters = ((PsiMethod)method.getElement()).getParameterList().getParameters();
if (methodParameters.length == 0) return null;
final PsiParameter param = functionalTypeIdx < methodParameters.length ? methodParameters[functionalTypeIdx] : methodParameters[methodParameters.length - 1];
final PsiType functionalInterfaceType = method.getSubstitutor().substitute(param.getType());
return getFunctionalInterfaceReturnType(functionalInterfaceType);
@@ -104,6 +104,7 @@ public class PsiPrimitiveType extends PsiType {
@Nullable
public static PsiPrimitiveType getUnboxedType(PsiType type) {
if (!(type instanceof PsiClassType)) return null;
assert type.isValid();
if (!((PsiClassType)type).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) return null;
final PsiClass psiClass = ((PsiClassType)type).resolve();
if (psiClass == null) return null;
@@ -0,0 +1,8 @@
import java.util.*;
public class MyClass implements Comparator<String> {
<error descr="Static method 'compare(String, String)' in 'MyClass' cannot override instance method 'compare(T, T)' in 'java.util.Comparator'">public static int compare(String a, String b)</error> {
return 42;
}
}
@@ -150,6 +150,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testInconvertibleTypes() throws Exception { doTest(false); }
public void testIncompatibleReturnType() throws Exception { doTest(false); }
public void testContinueInferenceAfterFirstRawResult() throws Exception { doTest(false); }
public void testStaticOverride() throws Exception { doTest(false); }
public void testJavaUtilCollections_NoVerify() throws Exception {
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
@@ -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 && !FileUtil.filesEqual(annotationOut, target.getOutputDir())) {
// register only if the root is not under already existing roots and not is the same as target's output root
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) {
@@ -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
@@ -59,7 +59,7 @@ public class WizardContext {
void nextStepRequested();
}
public WizardContext(Project project) {
public WizardContext(@Nullable Project project) {
myProject = project;
if (myProject != null){
myProjectJdk = ProjectRootManager.getInstance(myProject).getProjectSdk();
@@ -172,4 +172,16 @@ public class WizardContext {
public StorageScheme getProjectStorageFormat() {
return myProjectStorageFormat;
}
private boolean myTemplateMode;
/** This will be removed shortly */
@Deprecated
public boolean isTemplateMode() {
return myTemplateMode;
}
public void setTemplateMode(boolean templateMode) {
myTemplateMode = templateMode;
}
}
@@ -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);
}
}
@@ -18,6 +18,7 @@ public class WebModuleType extends WebModuleTypeBase<ModuleBuilder> {
@Override
public ModuleWizardStep[] createWizardSteps(WizardContext wizardContext, ModuleBuilder moduleBuilder, ModulesProvider modulesProvider) {
if (wizardContext.isTemplateMode()) return ModuleWizardStep.EMPTY_ARRAY;
WebModuleGenerationStep generationStep = new WebModuleGenerationStep(
moduleBuilder,
wizardContext.getStepIcon(),
@@ -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);
@@ -100,6 +100,10 @@ public class RenameProcessor extends BaseRefactoringProcessor {
public Set<PsiElement> getElements() {
return Collections.unmodifiableSet(myAllRenames.keySet());
}
public String getNewName(PsiElement element) {
return myAllRenames.get(element);
}
public void addRenamerFactory(AutomaticRenamerFactory factory) {
if (!myRenamerFactories.contains(factory)) {
@@ -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);
}
@@ -71,7 +71,7 @@ public abstract class AbstractWizard<T extends Step> extends DialogWrapper {
initWizard(title);
}
public AbstractWizard(final String title, final Project project) {
public AbstractWizard(final String title, @Nullable final Project project) {
super(project, true);
mySteps = new ArrayList<T>();
initWizard(title);
@@ -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 = "";
}
@@ -298,15 +298,18 @@ public abstract class AppIcon {
Shape rect = new RoundRectangle2D.Double(xInset, y, width, progressHeight, progressHeight, progressHeight);
Shape border =
new RoundRectangle2D.Double(xInset - 1, y - 1, width + 2, progressHeight + 2, (progressHeight + 2), (progressHeight + 2));
Shape progress = new RoundRectangle2D.Double(xInset + 1, y + 1, (width - 2) * value, progressHeight - 2, (progressHeight - 2),
(progressHeight - 2));
Shape progress = new RoundRectangle2D.Double(xInset + 1, y + 1, (width - 2) * value, progressHeight - 1, (progressHeight - 2),
(progressHeight - 1));
AppImage appImg = createAppImage();
final Color brighter = Color.GRAY.brighter().brighter();
final Color backGround = new Color(brighter.getRed(), brighter.getGreen(), brighter.getBlue(), 85);
appImg.myG2d.setColor(backGround);
appImg.myG2d.fill(rect);
appImg.myG2d.setColor(isOk ? scheme.getOkColor() : scheme.getErrorColor());
final Color color = isOk ? scheme.getOkColor() : scheme.getErrorColor();
final GradientPaint paint = new GradientPaint(xInset + 1, y + 1, color.brighter(),
xInset + 1, y + progressHeight - 1, color.darker().darker());
appImg.myG2d.setPaint(paint);
appImg.myG2d.fill(progress);
appImg.myG2d.setColor(Color.GRAY.darker().darker());
appImg.myG2d.draw(rect);
@@ -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
@@ -943,7 +943,7 @@ scope.unable.to.save.scope.message=Do you want to save scope as shared?
scope.unable.to.save.scope.title=Unable to use local scope
predefined.scope.production.name=Production
plugin.manager.dependencies.detected.title=Plugin Dependencies Detected
plugin.manager.dependencies.detected.message=The plugin you want to install requires other plugin{0, choice, 1#|2#s} ({1}) which have to be installed as well.
plugin.manager.dependencies.detected.message=The plugin you want to install requires other plugin{0, choice, 1#|2#s} ({1}) which have to be installed as well. Proceed?
plugin.manager.optional.dependencies.detected.message=The plugin you want to install optionally requires other plugin{0, choice, 1#|2#s} ({1}). Should those be installed as well?
message.server.no.licenses=No suitable licenses left on the license server
title.server.no.licenses=No Licenses on Server
@@ -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>
@@ -931,15 +932,12 @@
<action id="Console.Jdbc.Properties"><keyboard-shortcut first-keystroke="control alt ENTER"/></action>
<action id="Console.Jdbc.Terminate"><keyboard-shortcut first-keystroke="control alt shift DELETE"/></action>
<action id="Console.Hibernate.Execute"><keyboard-shortcut first-keystroke="control ENTER"/></action>
<action id="Console.Hibernate.GenerateSql"><keyboard-shortcut first-keystroke="control shift ENTER"/></action>
<action id="Console.Hibernate.GenerateDDL"><keyboard-shortcut first-keystroke="control alt shift ENTER"/></action>
<action id="Console.Hibernate.Properties"><keyboard-shortcut first-keystroke="control alt ENTER"/></action>
<action id="Console.Hibernate.Terminate"><keyboard-shortcut first-keystroke="control alt shift DELETE"/></action>
<action id="Console.Jpa.Execute"><keyboard-shortcut first-keystroke="control ENTER"/></action>
<action id="Console.Jpa.Properties"><keyboard-shortcut first-keystroke="control alt ENTER"/></action>
<action id="Console.Jpa.Terminate"><keyboard-shortcut first-keystroke="control alt shift DELETE"/></action>
<action id="Console.Jpa.GenerateSql"><keyboard-shortcut first-keystroke="control shift ENTER"/></action>
<action id="Console.Jpa.GenerateDDL"><keyboard-shortcut first-keystroke="control alt shift ENTER"/></action>
<action id="Jdbc.RunSqlScript"><keyboard-shortcut first-keystroke="control shift F10"/></action>
@@ -61,10 +61,16 @@ public class CoreModule extends MockComponentManager implements ModuleEx {
}
});
ModuleRootManagerImpl moduleRootManager = new ModuleRootManagerImpl(this,
final ModuleRootManagerImpl moduleRootManager = new ModuleRootManagerImpl(this,
DirectoryIndex.getInstance(project),
ProjectRootManagerImpl.getInstanceImpl(project),
VirtualFilePointerManager.getInstance());
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
moduleRootManager.disposeComponent();
}
});
getPicoContainer().registerComponentInstance(ModuleRootManager.class, moduleRootManager);
getPicoContainer().registerComponentInstance(PathMacroManager.class, new ModulePathMacroManager(PathMacros.getInstance(), this));
myModuleScopeProvider = createModuleScopeProvider();
@@ -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
@@ -29,18 +29,14 @@ abstract class AbstractCollectionBinding implements Binding {
private final Class myElementType;
private final String myTagName;
@Nullable protected Accessor myAccessor;
private AbstractCollection myAnnotation = null;
private boolean myUsingOptionBinding = false;
@Nullable protected final Accessor myAccessor;
private final AbstractCollection myAnnotation;
public AbstractCollectionBinding(Class elementType, String tagName, @Nullable Accessor accessor) {
myElementType = elementType;
myTagName = tagName;
myAccessor = accessor;
if (accessor != null) {
myAnnotation = XmlSerializerImpl.findAnnotation(accessor.getAnnotations(), AbstractCollection.class);
}
myAnnotation = accessor == null ? null : XmlSerializerImpl.findAnnotation(accessor.getAnnotations(), AbstractCollection.class);
}
public void init() {
@@ -51,10 +47,10 @@ abstract class AbstractCollectionBinding implements Binding {
}
if (myAnnotation.elementTag().equals(Constants.OPTION)) {
getElementBindings();
if (myUsingOptionBinding) {
throw new XmlSerializationException("If surround with tag is turned off, element tag must be specified for: " + myAccessor);
for (Binding binding : getElementBindings().values()) {
if (binding instanceof TagBindingWrapper) {
throw new XmlSerializationException("If surround with tag is turned off, element tag must be specified for: " + myAccessor);
}
}
}
}
@@ -66,7 +62,7 @@ abstract class AbstractCollectionBinding implements Binding {
return binding == null ? XmlSerializerImpl.getBinding(elementClass) : binding;
}
private Map<Class, Binding> getElementBindings() {
private synchronized Map<Class, Binding> getElementBindings() {
if (myElementBindings == null) {
myElementBindings = new HashMap<Class, Binding>();
@@ -91,15 +87,8 @@ abstract class AbstractCollectionBinding implements Binding {
}
private Binding getBinding(final Class type) {
Binding binding;
binding = XmlSerializerImpl.getBinding(type);
if (!binding.getBoundNodeType().isAssignableFrom(Element.class)) {
binding = createElementTagWrapper(binding);
myUsingOptionBinding = true;
}
return binding;
Binding binding = XmlSerializerImpl.getBinding(type);
return binding.getBoundNodeType().isAssignableFrom(Element.class) ? binding : createElementTagWrapper(binding);
}
private Binding createElementTagWrapper(final Binding elementBinding) {
@@ -64,7 +64,7 @@ class BeanBinding implements Binding {
initPropertyBindings(myBeanClass);
}
private void initPropertyBindings(Class<?> beanClass) {
private synchronized void initPropertyBindings(Class<?> beanClass) {
for (Accessor accessor : getAccessors(beanClass)) {
final Binding binding = createBindingByAccessor(accessor);
myPropertyBindingsList.add(binding);
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable;
public class TextBinding implements Binding {
private final Accessor myAccessor;
private Binding myBinding;
private volatile Binding myBinding;
public TextBinding(final Accessor accessor) {
myAccessor = accessor;
@@ -44,6 +44,7 @@ import com.intellij.util.ThrowableRunnable;
import com.intellij.util.containers.Convertor;
import com.intellij.util.ui.VcsSynchronousProgressWrapper;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
@@ -559,6 +560,10 @@ public abstract class AbstractVcs<ComList extends CommittedChangeList> extends S
return true;
}
public boolean allowsRemoteCalls(@NotNull final VirtualFile file) {
return true;
}
public void setCheckinEnvironment(CheckinEnvironment checkinEnvironment) {
if (myCheckinEnvironment != null) throw new IllegalStateException("Attempt to redefine checkin environment");
myCheckinEnvironment = checkinEnvironment;
@@ -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);
}
@@ -74,7 +74,7 @@ public class BrowseChangesAction extends AnAction implements DumbAware {
VirtualFile vFile = e.getData(PlatformDataKeys.VIRTUAL_FILE);
if (vFile == null) return false;
AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(vFile);
if (vcs == null || vcs.getCommittedChangesProvider() == null) {
if (vcs == null || vcs.getCommittedChangesProvider() == null || !vcs.allowsRemoteCalls(vFile)) {
return false;
}
FilePath filePath = VcsContextFactory.SERVICE.getInstance().createFilePathOn(vFile);
@@ -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) {
@@ -60,10 +60,11 @@ import java.util.*;
* @author nik
*/
@State(
name = XDebuggerManagerImpl.COMPONENT_NAME,
storages = {@Storage(
file = StoragePathMacros.WORKSPACE_FILE)})
public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectComponent, PersistentStateComponent<XDebuggerManagerImpl.XDebuggerState> {
name = XDebuggerManagerImpl.COMPONENT_NAME,
storages = {@Storage(
file = StoragePathMacros.WORKSPACE_FILE)})
public class XDebuggerManagerImpl extends XDebuggerManager
implements ProjectComponent, PersistentStateComponent<XDebuggerManagerImpl.XDebuggerState> {
@NonNls public static final String COMPONENT_NAME = "XDebuggerManager";
private final Project myProject;
private final XBreakpointManagerImpl myBreakpointManager;
@@ -199,7 +200,7 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectCom
}
private XDebugSessionImpl startSession(final RunContentDescriptor contentToReuse, final XDebugProcessStarter processStarter,
final XDebugSessionImpl session) throws ExecutionException {
final XDebugSessionImpl session) throws ExecutionException {
XDebugProcess process = processStarter.start(session);
XDebugSessionData oldSessionData = contentToReuse != null ? mySessionData.get(contentToReuse) : null;
@@ -331,5 +332,4 @@ public class XDebuggerManagerImpl extends XDebuggerManager implements ProjectCom
myBreakpointManagerState = breakpointManagerState;
}
}
}
@@ -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>
@@ -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);
@@ -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;
}
@@ -63,6 +63,7 @@ public class CvsCommittedChangesProvider implements CachingCommittedChangesProvi
myProject = project;
}
@NotNull
public ChangeBrowserSettings createDefaultSettings() {
return new ChangeBrowserSettings();
}
@@ -25,7 +25,7 @@ import com.intellij.openapi.components.PathMacroManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.module.ModuleUtil;
import com.intellij.openapi.module.ModuleUtilCore;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.impl.ProjectRootManagerImpl;
@@ -170,14 +170,17 @@ public class EPathUtil {
@Nullable
public static String collapse2eclipseRelative2OtherModule(final @NotNull Project project, final @NotNull VirtualFile file) {
final Module module = ModuleUtil.findModuleForFile(file, project);
final Module module = ModuleUtilCore.findModuleForFile(file, project);
if (module != null) {
return collapse2eclipsePathRelative2Module(file, module);
} else if (ProjectRootManager.getInstance(project).getFileIndex().isIgnored(file)) { //should check all modules then
for (Module aModule : ModuleManager.getInstance(project).getModules()) {
final String path = collapse2eclipsePathRelative2Module(file, aModule);
if (path != null) {
return path;
} else { //should check all modules then
final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
if (fileIndex.isIgnored(file) || fileIndex.isInLibraryClasses(file)) {
for (Module aModule : ModuleManager.getInstance(project).getModules()) {
final String path = collapse2eclipsePathRelative2Module(file, aModule);
if (path != null) {
return path;
}
}
}
}
@@ -61,6 +61,7 @@ public class GitCommittedChangeListProvider implements CommittedChangesProvider<
myProject = project;
}
@NotNull
public ChangeBrowserSettings createDefaultSettings() {
return new ChangeBrowserSettings();
}
@@ -52,7 +52,7 @@ public class GitCrlfDialog extends DialogWrapper {
setOKButtonText("Fix and Commit");
setCancelButtonText("Cancel");
setTitle("Line separators warning");
setTitle("Line Separators Warning");
getCancelAction().putValue(DialogWrapper.FOCUSED_ACTION, true);
init();
@@ -60,7 +60,7 @@ public class GitCrlfDialog extends DialogWrapper {
@Override
protected Action[] createActions() {
return new Action[] { getOKAction(), getCancelAction(), new DialogWrapperExitAction("Commit as Is", DONT_SET) };
return new Action[] { getOKAction(), getCancelAction(), new DialogWrapperExitAction("Commit As Is", DONT_SET) };
}
@Override
@@ -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));
@@ -773,10 +773,10 @@ class GitBranchWorkerTest {
}
private static void assertContent(String expectedContent, String actual) {
expectedContent = StringUtil.convertLineSeparators(expectedContent, LineSeparator.getSystemLineSeparator().separatorString).trim()
actual = actual.trim()
assertEquals String.format("Content doesn't match.%nExpected:%n%s%nActual:%n%s%n",
substWhitespaces(expectedContent), substWhitespaces(actual)),
StringUtil.convertLineSeparators(expectedContent, LineSeparator.getSystemLineSeparator().separatorString).trim(),
actual.trim()
substWhitespaces(expectedContent), substWhitespaces(actual)), expectedContent, actual
}
private static String substWhitespaces(String s) {
@@ -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));
}
@@ -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();
@@ -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) {
@@ -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();
@@ -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);
}
}
@@ -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);
}
}
@@ -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();
@@ -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;
@@ -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;
}
@@ -73,42 +73,6 @@ public class TypeInferenceHelper {
return context != null ? context : InferenceContext.TOP_CONTEXT;
}
@Nullable
public static PsiType getInferredTypeOld(@NotNull final GrReferenceExpression refExpr) {
return RecursionManager.doPreventingRecursion(refExpr, true, new NullableComputable<PsiType>() {
@Override
public PsiType compute() {
final GrControlFlowOwner scope = ControlFlowUtils.findControlFlowOwner(refExpr);
if (scope == null) return null;
final Instruction[] flow = scope.getControlFlow();
ReadWriteVariableInstruction instruction = ControlFlowUtils.findRWInstruction(refExpr, flow);
if (instruction == null) return null;
if (instruction.isWrite()) {
return getInitializerType(refExpr);
}
final DFAType type = getInferredType(refExpr.getReferenceName(), instruction, flow, scope, new HashSet<MixinTypeInstruction>());
return type == null ? null : type.getResultType();
}
});
}
@Nullable
public static PsiType getInferredTypeOld(@NotNull PsiElement place, String variableName) {
final GrControlFlowOwner scope = ControlFlowUtils.findControlFlowOwner(place);
if (scope == null) return null;
final Instruction[] flow = scope.getControlFlow();
Instruction instruction = ControlFlowUtils.findNearestInstruction(place, flow);
if (instruction == null) return null;
final DFAType type = getInferredType(variableName, instruction, flow, scope, new HashSet<MixinTypeInstruction>());
return type != null ? type.getResultType() : null;
}
@Nullable
public static PsiType getInferredType(@NotNull final GrReferenceExpression refExpr) {
final GrControlFlowOwner scope = ControlFlowUtils.findControlFlowOwner(refExpr);
@@ -144,13 +108,10 @@ public class TypeInferenceHelper {
@Nullable
private static DFAType getInferredType(@NotNull String varName, @NotNull Instruction instruction, @NotNull Instruction[] flow, @NotNull GrControlFlowOwner scope, Set<MixinTypeInstruction> trace) {
final Pair<ReachingDefinitionsDfaInstance, List<DefinitionMap>> pair = getDefUseMaps(scope);
List<DefinitionMap> dfaResult = pair.second;
if (dfaResult == null) return null;
if (pair == null) return null;
final int varIndex = pair.first.getVarIndex(varName);
final DefinitionMap allDefs = dfaResult.get(instruction.num());
final DefinitionMap allDefs = pair.second.get(instruction.num());
final int[] varDefs = allDefs.getDefinitions(varIndex);
if (varDefs == null) return null;
@@ -169,6 +130,7 @@ public class TypeInferenceHelper {
return result;
}
@Nullable
private static Pair<ReachingDefinitionsDfaInstance, List<DefinitionMap>> getDefUseMaps(final GrControlFlowOwner scope) {
return CachedValuesManager.getManager(scope.getProject()).getCachedValue(scope, new CachedValueProvider<Pair<ReachingDefinitionsDfaInstance, List<DefinitionMap>>>() {
@Override
@@ -188,8 +150,10 @@ public class TypeInferenceHelper {
}
}
else if (instruction instanceof ArgumentInstruction) {
final int varIndex = getVarIndex(((ArgumentInstruction)instruction).getVariableName());
m.registerDef(instruction, varIndex);
String variableName = ((ArgumentInstruction)instruction).getVariableName();
if (variableName != null) {
m.registerDef(instruction, getVarIndex(variableName));
}
}
else {
super.fun(m, instruction);
@@ -199,7 +163,8 @@ public class TypeInferenceHelper {
final ReachingDefinitionsSemilattice lattice = new ReachingDefinitionsSemilattice();
final DFAEngine<DefinitionMap> engine = new DFAEngine<DefinitionMap>(flow, dfaInstance, lattice);
final List<DefinitionMap> dfaResult = engine.performDFAWithTimeout();
return Result.create(Pair.create(dfaInstance, dfaResult), PsiModificationTracker.MODIFICATION_COUNT);
Pair<ReachingDefinitionsDfaInstance, List<DefinitionMap>> result = dfaResult == null ? null : Pair.create(dfaInstance, dfaResult);
return Result.create(result, PsiModificationTracker.MODIFICATION_COUNT);
}
});
}
@@ -401,7 +366,13 @@ public class TypeInferenceHelper {
TypeDfaState cache = varTypes.get().get(instruction.num());
if (!cache.containsVariable(variableName)) {
Set<Instruction> interesting = collectRequiredInstructions(instruction, variableName);
Pair<ReachingDefinitionsDfaInstance, List<DefinitionMap>> defUse = getDefUseMaps(scope);
if (defUse == null) {
tooComplex.add(instruction);
return null;
}
Set<Instruction> interesting = collectRequiredInstructions(instruction, variableName, defUse);
List<TypeDfaState> dfaResult = performTypeDfa(scope, flow, interesting);
if (dfaResult == null) {
tooComplex.addAll(interesting);
@@ -426,9 +397,9 @@ public class TypeInferenceHelper {
return dfaType == null ? null : dfaType.negate(instruction);
}
private Set<Instruction> collectRequiredInstructions(Instruction instruction, String variableName) {
Pair<ReachingDefinitionsDfaInstance, List<DefinitionMap>> defUse = getDefUseMaps(scope);
private Set<Instruction> collectRequiredInstructions(@NotNull Instruction instruction,
@NotNull String variableName,
@NotNull Pair<ReachingDefinitionsDfaInstance, List<DefinitionMap>> defUse) {
Set<Instruction> interesting = ContainerUtil.newHashSet(instruction);
LinkedList<Pair<Instruction,String>> queue = ContainerUtil.newLinkedList();
queue.add(Pair.create(instruction, variableName));
@@ -445,22 +416,26 @@ public class TypeInferenceHelper {
}
private Set<Pair<Instruction,String>> findDependencies(Pair<ReachingDefinitionsDfaInstance, List<DefinitionMap>> defUse,
Instruction insn,
String varName) {
int[] definitions = defUse.second.get(insn.num()).getDefinitions(defUse.first.getVarIndex(varName));
@NotNull Instruction insn,
@NotNull String varName) {
DefinitionMap definitionMap = defUse.second.get(insn.num());
int varIndex = defUse.first.getVarIndex(varName);
int[] definitions = definitionMap.getDefinitions(varIndex);
if (definitions == null) return Collections.emptySet();
HashSet<Pair<Instruction, String>> pairs = ContainerUtil.newHashSet();
LinkedHashSet<Pair<Instruction, String>> pairs = ContainerUtil.newLinkedHashSet();
for (int defIndex : definitions) {
Instruction write = flow[defIndex];
pairs.add(Pair.create(write, varName));
PsiElement statement = findDependencyScope(write.getElement());
pairs.addAll(findAllInstructionsInside(statement));
if (statement != null) {
pairs.addAll(findAllInstructionsInside(statement));
}
}
return pairs;
}
private List<Pair<Instruction, String>> findAllInstructionsInside(PsiElement scope) {
private List<Pair<Instruction, String>> findAllInstructionsInside(@NotNull PsiElement scope) {
final List<Pair<Instruction, String>> result = ContainerUtil.newArrayList();
scope.accept(new PsiRecursiveElementWalkingVisitor() {
@Override
@@ -480,7 +455,7 @@ public class TypeInferenceHelper {
}
@Nullable
private static PsiElement findDependencyScope(PsiElement element) {
private static PsiElement findDependencyScope(@Nullable PsiElement element) {
return PsiTreeUtil.findFirstParent(element, new Condition<PsiElement>() {
@Override
public boolean value(PsiElement element) {
@@ -405,7 +405,7 @@ public class TypesUtil {
return type;
}
public static PsiType boxPrimitiveType(PsiType result, @NotNull PsiManager manager, @NotNull GlobalSearchScope resolveScope, boolean boxVoid) {
public static PsiType boxPrimitiveType(@Nullable PsiType result, @NotNull PsiManager manager, @NotNull GlobalSearchScope resolveScope, boolean boxVoid) {
if (result instanceof PsiPrimitiveType && (boxVoid || result != PsiType.VOID)) {
PsiPrimitiveType primitive = (PsiPrimitiveType)result;
String boxedTypeName = primitive.getBoxedTypeName();
@@ -417,7 +417,7 @@ public class TypesUtil {
return result;
}
public static PsiType boxPrimitiveType(PsiType result, @NotNull PsiManager manager, @NotNull GlobalSearchScope resolveScope) {
public static PsiType boxPrimitiveType(@Nullable PsiType result, @NotNull PsiManager manager, @NotNull GlobalSearchScope resolveScope) {
return boxPrimitiveType(result, manager, resolveScope, false);
}
@NotNull
@@ -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;
}
@@ -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);
@@ -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);
}
@@ -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);
}
@@ -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')
}
}
@@ -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
}
}
@@ -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;
@@ -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> {
}
''')
}
}
@@ -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)
}
}
@@ -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
+15
View File
@@ -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
+26
View File
@@ -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
+10
View File
@@ -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

Some files were not shown because too many files have changed in this diff Show More