diff options
author | Tor Norbye <tnorbye@google.com> | 2014-07-16 18:07:37 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2014-07-16 18:09:03 -0700 |
commit | 65f60eb9011bb2c549a6d83ae31257480368ddc5 (patch) | |
tree | de0dca03bec460e8797332e5f460400f5cf6485f /java/java-impl/src/com/intellij/psi/impl | |
parent | 9ea67227e8fdcf8ed37e65bb96e32767291d0f4f (diff) | |
download | idea-65f60eb9011bb2c549a6d83ae31257480368ddc5.tar.gz |
Snapshot idea/138.1029 from git://git.jetbrains.org/idea/community.git
Update from idea/138.538 to idea/138.1029
Change-Id: I828f829a968439a99ec67640990c18ff7c9b58ce
Diffstat (limited to 'java/java-impl/src/com/intellij/psi/impl')
7 files changed, 82 insertions, 33 deletions
diff --git a/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java b/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java index 053a534e0c98..a53bd1c9d187 100644 --- a/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java +++ b/java/java-impl/src/com/intellij/psi/impl/beanProperties/CreateBeanPropertyFix.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,8 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import static com.intellij.psi.CommonClassNames.JAVA_LANG_STRING; + /** * @author Dmitry Avdeev */ @@ -59,7 +61,7 @@ public abstract class CreateBeanPropertyFix implements LocalQuickFix, IntentionA if (type == null) { final Project project = psiClass.getProject(); final JavaPsiFacade facade = JavaPsiFacade.getInstance(project); - final PsiClass aClass = facade.findClass("java.lang.String", GlobalSearchScope.allScope(project)); + final PsiClass aClass = facade.findClass(JAVA_LANG_STRING, GlobalSearchScope.allScope(project)); if (aClass == null) { return NO_FIXES; } diff --git a/java/java-impl/src/com/intellij/psi/impl/search/ThrowSearchUtil.java b/java/java-impl/src/com/intellij/psi/impl/search/ThrowSearchUtil.java index f3adf354de41..9375561d92e1 100644 --- a/java/java-impl/src/com/intellij/psi/impl/search/ThrowSearchUtil.java +++ b/java/java-impl/src/com/intellij/psi/impl/search/ThrowSearchUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package com.intellij.psi.impl.search; import com.intellij.find.findUsages.FindUsagesOptions; import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.Key; import com.intellij.psi.*; import com.intellij.psi.search.searches.MethodReferencesSearch; import com.intellij.psi.util.PsiFormatUtil; @@ -34,34 +33,29 @@ import java.util.Set; * Author: msk */ public class ThrowSearchUtil { - private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.search.ThrowSearchUtil"); private ThrowSearchUtil() { } public static class Root { - final PsiElement myElement; - final PsiType myType; - final boolean isExact; + @NotNull private final PsiElement myElement; + @NotNull private final PsiType myType; + private final boolean isExact; - public Root(final PsiElement root, final PsiType type, final boolean exact) { + public Root(@NotNull PsiElement root, @NotNull PsiType type, final boolean exact) { myElement = root; myType = type; isExact = exact; } + @Override public String toString() { return PsiFormatUtil.formatType(myType, PsiFormatUtilBase.SHOW_FQ_CLASS_NAMES, PsiSubstitutor.EMPTY); } } - public static Key<Root> THROW_SEARCH_ROOT_KEY = Key.create("ThrowSearchUtil.root"); - /** - * @param aCatch - * @param processor - * @param root * @return true, if we should continue processing */ private static boolean processExn(@NotNull PsiParameter aCatch, @NotNull Processor<UsageInfo> processor, @NotNull Root root) { @@ -123,7 +117,6 @@ public class ThrowSearchUtil { } /** - * @param exn * @return is type of exn exactly known */ diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaCharsetReferenceContributor.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaCharsetReferenceContributor.java new file mode 100644 index 000000000000..db1a385d5137 --- /dev/null +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaCharsetReferenceContributor.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.psi.impl.source.resolve.reference.impl; + +import com.intellij.codeInsight.daemon.impl.analysis.encoding.EncodingReference; +import com.intellij.psi.*; +import com.intellij.psi.impl.source.resolve.reference.impl.manipulators.StringLiteralManipulator; +import com.intellij.util.ProcessingContext; +import org.jetbrains.annotations.NotNull; + +import java.nio.charset.Charset; + +import static com.intellij.patterns.PsiJavaPatterns.literalExpression; +import static com.intellij.patterns.PsiJavaPatterns.psiMethod; +import static com.intellij.patterns.StandardPatterns.string; + +/** + * @author peter + */ +public class JavaCharsetReferenceContributor extends PsiReferenceContributor { + @Override + public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { + registrar.registerReferenceProvider( + literalExpression().methodCallParameter( + 0, psiMethod().withName(string().oneOf("forName", "isSupported")).inClass(Charset.class.getName())), + new PsiReferenceProvider() { + @NotNull + @Override + public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { + PsiLiteralExpression literal = (PsiLiteralExpression)element; + Object value = literal.getValue(); + if (value instanceof String) { + return new PsiReference[]{new EncodingReference(element, (String)value, StringLiteralManipulator.getValueRange(literal))}; + } + return PsiReference.EMPTY_ARRAY; + } + }); + } +} diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceContributor.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceContributor.java index 06e5d4a672f4..dbcc03041c6f 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceContributor.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/JavaReflectionReferenceContributor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ import com.intellij.patterns.PsiJavaElementPattern; import com.intellij.psi.PsiLiteral; import com.intellij.psi.PsiReferenceContributor; import com.intellij.psi.PsiReferenceRegistrar; +import org.jetbrains.annotations.NotNull; import static com.intellij.patterns.PsiJavaPatterns.psiExpression; import static com.intellij.patterns.PsiJavaPatterns.psiLiteral; @@ -38,7 +39,7 @@ public class JavaReflectionReferenceContributor extends PsiReferenceContributor .definedInClass(JAVA_LANG_CLASS))); @Override - public void registerReferenceProviders(PsiReferenceRegistrar registrar) { + public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider(PATTERN, new JavaReflectionReferenceProvider()); } } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackagePrefixFileSystemItemImpl.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackagePrefixFileSystemItemImpl.java index 7b85d17470ed..ce56ac3a36ad 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackagePrefixFileSystemItemImpl.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PackagePrefixFileSystemItemImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,11 +37,11 @@ import java.util.ArrayList; * @author Gregory.Shrago */ class PackagePrefixFileSystemItemImpl extends PsiElementBase implements PsiFileSystemItem, PackagePrefixFileSystemItem { - private final PsiDirectory myDirectory; + @NotNull private final PsiDirectory myDirectory; private final int myIndex; private final PsiPackage[] myPackages; - public static PackagePrefixFileSystemItemImpl create(final PsiDirectory directory) { + public static PackagePrefixFileSystemItemImpl create(@NotNull PsiDirectory directory) { final ArrayList<PsiPackage> packages = new ArrayList<PsiPackage>(); for (PsiPackage cur = JavaDirectoryService.getInstance().getPackage(directory); cur != null; cur = cur.getParentPackage()) { packages.add(0, cur); @@ -49,7 +49,7 @@ class PackagePrefixFileSystemItemImpl extends PsiElementBase implements PsiFileS return new PackagePrefixFileSystemItemImpl(directory, 0, packages.toArray(new PsiPackage[packages.size()])); } - private PackagePrefixFileSystemItemImpl(final PsiDirectory directory, int index, final PsiPackage[] packages) { + private PackagePrefixFileSystemItemImpl(@NotNull PsiDirectory directory, int index, final PsiPackage[] packages) { myDirectory = directory; myIndex = index; myPackages = packages; @@ -249,6 +249,7 @@ class PackagePrefixFileSystemItemImpl extends PsiElementBase implements PsiFileS return myDirectory.getIcon(flags); } + @NotNull @Override public PsiDirectory getDirectory() { return myDirectory; diff --git a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java index 5ffbaec2217d..195f06fb9cd3 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/JavaConcatenationInjectorManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +22,8 @@ import com.intellij.openapi.components.ServiceManager; import com.intellij.openapi.extensions.*; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.ModificationTracker; import com.intellij.openapi.util.Pair; +import com.intellij.openapi.util.SimpleModificationTracker; import com.intellij.psi.*; import com.intellij.psi.impl.PsiManagerEx; import com.intellij.psi.impl.PsiParameterizedCachedValue; @@ -38,9 +38,8 @@ import java.util.List; /** * @author cdr */ -public class JavaConcatenationInjectorManager implements ModificationTracker { +public class JavaConcatenationInjectorManager extends SimpleModificationTracker { public static final ExtensionPointName<ConcatenationAwareInjector> CONCATENATION_INJECTOR_EP_NAME = ExtensionPointName.create("com.intellij.concatenationAwareInjector"); - private volatile long myModificationCounter; public JavaConcatenationInjectorManager(Project project, PsiManagerEx psiManagerEx) { final ExtensionPoint<ConcatenationAwareInjector> concatPoint = Extensions.getArea(project).getExtensionPoint(CONCATENATION_INJECTOR_EP_NAME); @@ -58,7 +57,7 @@ public class JavaConcatenationInjectorManager implements ModificationTracker { psiManagerEx.registerRunnableToRunOnAnyChange(new Runnable() { @Override public void run() { - myModificationCounter++; // clear caches even on non-physical changes + incModificationCount(); // clear caches even on non-physical changes } }); } @@ -67,11 +66,6 @@ public class JavaConcatenationInjectorManager implements ModificationTracker { return ServiceManager.getService(project, JavaConcatenationInjectorManager.class); } - @Override - public long getModificationCount() { - return myModificationCounter; - } - private static Pair<PsiElement,PsiElement[]> computeAnchorAndOperandsImpl(@NotNull PsiElement context) { PsiElement element = context; PsiElement parent = context.getParent(); @@ -228,6 +222,6 @@ public class JavaConcatenationInjectorManager implements ModificationTracker { } private void concatenationInjectorsChanged() { - myModificationCounter++; + incModificationCount(); } } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java index 271eb0ca87b6..e9b8da7f7d20 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/tree/injected/MyTestInjector.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -160,6 +160,7 @@ public class MyTestInjector { private static void injectVariousStuffEverywhere(Disposable parent, final PsiManager psiManager) { final Language ql = Language.findLanguageByID("JPAQL"); final Language js = Language.findLanguageByID("JavaScript"); + final Language html = Language.findLanguageByID("HTML"); if (ql == null || js == null) return; final Language ecma4 = Language.findLanguageByID("ECMA Script Level 4"); @@ -216,6 +217,7 @@ public class MyTestInjector { inject(host, placesToInject, js); return; } + if ("jsprefix".equals(attrName)) { inject(host, placesToInject, js, "function foo(doc, window){", "}"); return; @@ -235,6 +237,10 @@ public class MyTestInjector { inject(host, placesToInject, js); return; } + if ("htmlInject".equals(tag.getLocalName())) { + inject(host, placesToInject, html); + return; + } if (ecma4 != null && "ecma4".equals(tag.getLocalName())) { inject(host, placesToInject, ecma4); return; |