diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerIconLayerProvider.java b/java/compiler/impl/src/com/intellij/compiler/CompilerIconLayerProvider.java index c4eae8f1fee1..3f2b16d76562 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompilerIconLayerProvider.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompilerIconLayerProvider.java @@ -35,7 +35,7 @@ import javax.swing.*; */ public class CompilerIconLayerProvider implements IconLayerProvider { @Override - public Icon getLayerIcon(@NotNull Iconable element) { + public Icon getLayerIcon(@NotNull Iconable element, boolean isLocked) { VirtualFile vFile = null; Project project = null; if (element instanceof PsiModifierListOwner) { diff --git a/java/java-impl/src/com/intellij/openapi/vcs/contentAnnotation/VcsContentAnnotationExceptionFilter.java b/java/java-impl/src/com/intellij/openapi/vcs/contentAnnotation/VcsContentAnnotationExceptionFilter.java index a4a2eacef5bf..58d30f1bd1ea 100644 --- a/java/java-impl/src/com/intellij/openapi/vcs/contentAnnotation/VcsContentAnnotationExceptionFilter.java +++ b/java/java-impl/src/com/intellij/openapi/vcs/contentAnnotation/VcsContentAnnotationExceptionFilter.java @@ -55,11 +55,13 @@ public class VcsContentAnnotationExceptionFilter implements Filter, FilterMixin private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.contentAnnotation.VcsContentAnnotationExceptionFilter"); private final GlobalSearchScope myScope; private final VcsContentAnnotationSettings mySettings; + private Map myRevNumbersCache; public VcsContentAnnotationExceptionFilter(GlobalSearchScope scope) { myScope = scope; myProject = scope.getProject(); mySettings = VcsContentAnnotationSettings.getInstance(myProject); + myRevNumbersCache = new HashMap(); } private static class MyAdditionalHighlight extends AdditionalHighlight { @@ -111,7 +113,20 @@ public class VcsContentAnnotationExceptionFilter implements Filter, FilterMixin }); if (worker.getResult() != null) { VirtualFile vf = worker.getFile().getVirtualFile(); - final VcsRevisionNumber recentChangeRevision = vcsContentAnnotation.fileRecentlyChanged(vf); + if (vf.getFileSystem().isReadOnly()) continue; + + VcsRevisionNumber recentChangeRevision = myRevNumbersCache.get(vf); + if (recentChangeRevision == null) { + recentChangeRevision = vcsContentAnnotation.fileRecentlyChanged(vf); + if (recentChangeRevision == null) { + myRevNumbersCache.put(vf, VcsRevisionNumber.NULL); + } else { + myRevNumbersCache.put(vf, recentChangeRevision); + } + } + if (VcsRevisionNumber.NULL.equals(recentChangeRevision)) { + recentChangeRevision = null; + } if (localChangesCorrector.isFileAlreadyIdentifiedAsChanged(vf) || ChangeListManager.isFileChanged(myProject, vf) || recentChangeRevision != null) { final Document document = getDocumentForFile(worker); diff --git a/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java b/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java index c8da519c2617..68f600012f30 100644 --- a/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java +++ b/java/java-psi-impl/src/com/intellij/core/CoreJavaFileManager.java @@ -62,7 +62,7 @@ public class CoreJavaFileManager implements JavaFileManager { for (File file : myClasspath) { final PsiClass psiClass = findClassInClasspathEntry(qName, file); if (psiClass != null) { - return null; + return psiClass; } } return null; diff --git a/java/java-psi-impl/src/com/intellij/core/CoreJavaPsiImplementationHelper.java b/java/java-psi-impl/src/com/intellij/core/CoreJavaPsiImplementationHelper.java new file mode 100644 index 000000000000..0407bc285e35 --- /dev/null +++ b/java/java-psi-impl/src/com/intellij/core/CoreJavaPsiImplementationHelper.java @@ -0,0 +1,57 @@ +/* + * Copyright 2000-2011 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.core; + +import com.intellij.lang.ASTNode; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.pom.java.LanguageLevel; +import com.intellij.psi.*; +import com.intellij.psi.impl.JavaPsiImplementationHelper; + +/** + * @author yole + */ +public class CoreJavaPsiImplementationHelper extends JavaPsiImplementationHelper { + @Override + public PsiClass getOriginalClass(PsiClass psiClass) { + return psiClass; + } + + @Override + public PsiElement getClsFileNavigationElement(PsiJavaFile clsFile) { + return clsFile; + } + + @Override + public LanguageLevel getClassesLanguageLevel(VirtualFile virtualFile) { + return null; + } + + @Override + public ASTNode getDefaultImportAnchor(PsiImportList list, PsiImportStatementBase statement) { + throw new UnsupportedOperationException("TODO"); + } + + @Override + public PsiElement getDefaultMemberAnchor(PsiClass psiClass, PsiMember firstPsi) { + throw new UnsupportedOperationException("TODO"); + } + + @Override + public void setupCatchBlock(String exceptionName, PsiElement context, PsiCatchSection element) { + throw new UnsupportedOperationException("TODO"); + } +} diff --git a/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java b/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java index 285533fae0e4..a6a0dcc9db22 100644 --- a/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java +++ b/java/java-psi-impl/src/com/intellij/core/JavaCoreEnvironment.java @@ -22,6 +22,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; import com.intellij.psi.impl.EmptySubstitutorImpl; import com.intellij.psi.impl.JavaPsiFacadeImpl; +import com.intellij.psi.impl.JavaPsiImplementationHelper; import com.intellij.psi.impl.PsiElementFactoryImpl; import com.intellij.psi.impl.compiled.ClassFileStubBuilder; import com.intellij.psi.impl.compiled.ClsStubBuilderFactory; @@ -52,6 +53,7 @@ public class JavaCoreEnvironment extends CoreEnvironment { javaPsiFacade); myProject.registerService(JavaPsiFacade.class, javaPsiFacade); myProject.registerService(PsiElementFactory.class, new PsiElementFactoryImpl(myPsiManager)); + myProject.registerService(JavaPsiImplementationHelper.class, new CoreJavaPsiImplementationHelper()); myApplication.registerService(EmptySubstitutor.class, new EmptySubstitutorImpl()); } diff --git a/java/java-psi-impl/src/com/intellij/ide/highlighter/JavaClassFileType.java b/java/java-psi-impl/src/com/intellij/ide/highlighter/JavaClassFileType.java index 055dda576dcd..7efb0ee267b3 100644 --- a/java/java-psi-impl/src/com/intellij/ide/highlighter/JavaClassFileType.java +++ b/java/java-psi-impl/src/com/intellij/ide/highlighter/JavaClassFileType.java @@ -18,6 +18,7 @@ package com.intellij.ide.highlighter; import com.intellij.ide.IdeBundle; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.util.IconLoader; +import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; @@ -27,7 +28,13 @@ public class JavaClassFileType implements FileType { public static JavaClassFileType INSTANCE = new JavaClassFileType(); - private static final Icon ICON = IconLoader.getIcon("/fileTypes/javaClass.png"); + private static final NotNullLazyValue ICON = new NotNullLazyValue() { + @NotNull + @Override + protected Icon compute() { + return IconLoader.getIcon("/fileTypes/javaClass.png"); + } + }; private JavaClassFileType() { } @@ -48,7 +55,7 @@ public class JavaClassFileType implements FileType { } public Icon getIcon() { - return ICON; + return ICON.getValue(); } public boolean isBinary() { diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/ElementPresentationUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/ElementPresentationUtil.java index a77db3976060..056b2e044de9 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/ElementPresentationUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/ElementPresentationUtil.java @@ -211,7 +211,7 @@ public class ElementPresentationUtil implements PlatformIcons { int flags = getFlags(aClass, false); String adj = ""; for (IconLayerProvider provider : Extensions.getExtensions(IconLayerProvider.EP_NAME)) { - if (provider.getLayerIcon(aClass) != null) { + if (provider.getLayerIcon(aClass, false) != null) { adj += " " + provider.getLayerDescription(); } } diff --git a/java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java b/java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java index e3a57cd722bc..2640e2955592 100644 --- a/java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java +++ b/java/openapi/src/com/intellij/execution/filters/ExceptionWorker.java @@ -90,9 +90,9 @@ public class ExceptionWorker { myClass = psiFacade.findClass(className, mySearchScope); if (myClass == null) { myClass = psiFacade.findClass(className, GlobalSearchScope.allScope(myProject)); - if (myClass == null) {//try to find class according to all dollars in package name + /*if (myClass == null) {//try to find class according to all dollars in package name myClass = psiFacade.findClass(className, GlobalSearchScope.allScope(myProject)); - } + }*/ if (myClass == null) return; } myFile = (PsiFile) myClass.getContainingFile().getNavigationElement(); diff --git a/platform/core-api/src/com/intellij/ide/IconLayerProvider.java b/platform/core-api/src/com/intellij/ide/IconLayerProvider.java index 1f998d4aab8d..54139213cefc 100644 --- a/platform/core-api/src/com/intellij/ide/IconLayerProvider.java +++ b/platform/core-api/src/com/intellij/ide/IconLayerProvider.java @@ -29,7 +29,7 @@ public interface IconLayerProvider { ExtensionPointName EP_NAME = ExtensionPointName.create("com.intellij.iconLayerProvider"); @Nullable - Icon getLayerIcon(@NotNull Iconable element); + Icon getLayerIcon(@NotNull Iconable element, boolean isLocked); @Nullable String getLayerDescription(); diff --git a/platform/core-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java b/platform/core-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java index 8ded6faed7b1..768dc2606a3e 100644 --- a/platform/core-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java +++ b/platform/core-api/src/com/intellij/openapi/fileTypes/UnknownFileType.java @@ -16,13 +16,20 @@ package com.intellij.openapi.fileTypes; import com.intellij.openapi.util.IconLoader; +import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NotNull; import javax.swing.*; public class UnknownFileType implements FileType { - private static final Icon ICON = IconLoader.getIcon("/fileTypes/unknown.png"); + private static final NotNullLazyValue ICON = new NotNullLazyValue() { + @NotNull + @Override + protected Icon compute() { + return IconLoader.getIcon("/fileTypes/unknown.png"); + } + }; public static final FileType INSTANCE = new UnknownFileType(); private UnknownFileType() {} @@ -43,7 +50,7 @@ public class UnknownFileType implements FileType { } public Icon getIcon() { - return ICON; + return ICON.getValue(); } public boolean isBinary() { diff --git a/platform/core-api/src/com/intellij/psi/impl/ElementBase.java b/platform/core-api/src/com/intellij/psi/impl/ElementBase.java index 10f1c8f44f1d..e1e3ea13b156 100644 --- a/platform/core-api/src/com/intellij/psi/impl/ElementBase.java +++ b/platform/core-api/src/com/intellij/psi/impl/ElementBase.java @@ -25,10 +25,7 @@ import com.intellij.openapi.fileTypes.INativeFileType; import com.intellij.openapi.fileTypes.UnknownFileType; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.IndexNotReadyException; -import com.intellij.openapi.util.IconLoader; -import com.intellij.openapi.util.Iconable; -import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.UserDataHolderBase; +import com.intellij.openapi.util.*; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; @@ -42,6 +39,7 @@ import com.intellij.util.*; import com.intellij.util.ui.EmptyIcon; import com.intellij.util.ui.update.ComparableObject; import gnu.trove.TIntObjectHashMap; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import javax.swing.*; @@ -62,8 +60,21 @@ public abstract class ElementBase extends UserDataHolderBase implements Iconable }; private static final Key> BASE_ICONS = Key.create("BASE_ICONS"); - private static final Icon VISIBILITY_ICON_PLACEHOLDER = EmptyIcon.create(PlatformIcons.PUBLIC_ICON); - public static final Icon ICON_PLACEHOLDER = IconLoader.getIcon("/nodes/nodePlaceholder.png"); + private static final NotNullLazyValue VISIBILITY_ICON_PLACEHOLDER = new NotNullLazyValue() { + @NotNull + @Override + protected Icon compute() { + return EmptyIcon.create(PlatformIcons.PUBLIC_ICON); + } + }; + + public static final NotNullLazyValue ICON_PLACEHOLDER = new NotNullLazyValue() { + @NotNull + @Override + protected Icon compute() { + return IconLoader.getIcon("/nodes/nodePlaceholder.png"); + } + }; @Nullable public Icon getIcon(int flags) { @@ -133,7 +144,7 @@ public abstract class ElementBase extends UserDataHolderBase implements Iconable } } } - return ICON_PLACEHOLDER; + return ICON_PLACEHOLDER.getValue(); } public static boolean isNativeFileType(FileType fileType) { @@ -145,7 +156,7 @@ public abstract class ElementBase extends UserDataHolderBase implements Iconable if ((flags & ICON_FLAG_VISIBILITY) > 0) { RowIcon rowIcon = new RowIcon(2); rowIcon.setIcon(icon, 0); - rowIcon.setIcon(VISIBILITY_ICON_PLACEHOLDER, 1); + rowIcon.setIcon(VISIBILITY_ICON_PLACEHOLDER.getValue(), 1); result = rowIcon; } @@ -230,7 +241,7 @@ public abstract class ElementBase extends UserDataHolderBase implements Iconable public static RowIcon createLayeredIcon(Iconable instance, Icon icon, int flags) { List layersFromProviders = new SmartList(); for (IconLayerProvider provider : Extensions.getExtensions(IconLayerProvider.EP_NAME)) { - final Icon layerIcon = provider.getLayerIcon(instance); + final Icon layerIcon = provider.getLayerIcon(instance, (flags & FLAGS_LOCKED) != 0); if (layerIcon != null) { layersFromProviders.add(layerIcon); } @@ -281,8 +292,4 @@ public abstract class ElementBase extends UserDataHolderBase implements Iconable } ourIconLayers.add(new IconLayer(flagMask, icon)); } - - static { - registerIconLayer(FLAGS_LOCKED, PlatformIcons.LOCKED_ICON); - } } diff --git a/platform/core-impl/src/com/intellij/openapi/editor/impl/TextChangeImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/TextChangeImpl.java index a7a4bebab18a..5514c62b2db2 100644 --- a/platform/core-impl/src/com/intellij/openapi/editor/impl/TextChangeImpl.java +++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/TextChangeImpl.java @@ -36,7 +36,7 @@ public class TextChangeImpl implements TextChange { private int myEnd; /** - * Shorthand for creating {@link TextChangeImpl} with the given arguments where 'end index' has the same value as + * Shorthand for creating change object with the given arguments where 'end index' has the same value as * 'start index'. * * @param text text affected by the current change @@ -137,9 +137,7 @@ public class TextChangeImpl implements TextChange { /** * Applies given offset applied to the {@link #getStart() start} and {@link #getEnd() end} properties of current text change object. * - * @param offset offset to apply to the current change object - * @return text change that is built on the basis of the current object that with {@link #getStart() start} - * and {@link #getEnd() end} positions shifted to the given offset + * @param offset offset to apply to the current change object * @throws IllegalArgumentException if start index becomes zero after given offset appliance (it is not applied then) */ public void advance(int offset) throws IllegalArgumentException { diff --git a/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarVirtualFile.java b/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarVirtualFile.java index d6a9a7b4aa09..c62482117a0e 100644 --- a/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarVirtualFile.java +++ b/platform/core-impl/src/com/intellij/openapi/vfs/impl/jar/CoreJarVirtualFile.java @@ -22,6 +22,8 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; /** * @author yole @@ -87,7 +89,13 @@ public class CoreJarVirtualFile extends VirtualFile { @Override public VirtualFile[] getChildren() { - throw new UnsupportedOperationException("TODO"); + List result = new ArrayList(); + final String[] children = myHandler.list(this); + for (String child : children) { + final VirtualFile childFile = myHandler.findFileByPath(myPathInJar + "/" + child); + result.add(childFile); + } + return result.toArray(new VirtualFile[result.size()]); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java index 89bdba70f2d2..37e5b881a871 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/AutoHardWrapHandler.java @@ -175,7 +175,7 @@ public class AutoHardWrapHandler { caretOffsetDiff[0] += event.getNewLength() - event.getOldLength(); } - if (event.getNewLength() <= 0) { + if (event.getNewLength() <= event.getOldLength()) { // There is a possible case that document fragment is removed because of auto-formatting. We don't want to process such events. return; } diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java index 2b32d6d69cef..52cc66aef788 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java @@ -406,21 +406,6 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo myHyperlinks = new EditorHyperlinkSupport(myEditor, myProject); requestFlushImmediately(); myMainPanel.add(createCenterComponent(), BorderLayout.CENTER); - - - myEditor.getDocument().addDocumentListener(new DocumentAdapter() { - public void documentChanged(DocumentEvent e) { - if (e.getNewLength() == 0) { - // string has been removed, adjust token ranges - synchronized (LOCK) { - ConsoleUtil.updateTokensOnTextRemoval(myTokens, e.getOffset(), e.getOffset() + e.getOldLength()); - int toRemoveLen = e.getOldLength(); - myContentSize -= Math.min(myContentSize, toRemoveLen); - } - } - } - }); - myEditor.getScrollingModel().addVisibleAreaListener(new VisibleAreaListener() { @Override public void visibleAreaChanged(VisibleAreaEvent e) { @@ -732,6 +717,14 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo } public void documentChanged(DocumentEvent event) { + if (event.getNewLength() == 0) { + // string has been removed, adjust token ranges + synchronized (LOCK) { + ConsoleUtil.updateTokensOnTextRemoval(myTokens, event.getOffset(), event.getOffset() + event.getOldLength()); + int toRemoveLen = event.getOldLength(); + myContentSize -= Math.min(myContentSize, toRemoveLen); + } + } if (myFileType != null) { highlightUserTokens(); } diff --git a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarItem.java b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarItem.java index 5efe04b7e0c2..941431ec302c 100644 --- a/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarItem.java +++ b/platform/lang-impl/src/com/intellij/ide/navigationToolbar/NavBarItem.java @@ -78,6 +78,7 @@ class NavBarItem extends SimpleColoredComponent implements Disposable { setIpad(new Insets(0,0,0,0)); setMyBorder(null); setBorder(null); + setPaintFocusBorder(false); } update(); myPadding = new JBInsets(3, 3, 3, 3); @@ -144,7 +145,6 @@ class NavBarItem extends SimpleColoredComponent implements Disposable { } private void doPaintDecorated(Graphics2D g) { - setPaintFocusBorder(false); Icon icon = myIcon; final Color bg = getBackground(); g.setPaint(bg); diff --git a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java index 5eac40bb93e6..92d3cfa6a88b 100644 --- a/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java +++ b/platform/lang-impl/src/com/intellij/openapi/fileTypes/impl/NativeFileIconProvider.java @@ -68,7 +68,7 @@ public class NativeFileIconProvider implements FileIconProvider { if (icon != null) { return icon; } - return new DeferredIconImpl(ElementBase.ICON_PLACEHOLDER, file, false, new Function() { + return new DeferredIconImpl(ElementBase.ICON_PLACEHOLDER.getValue(), file, false, new Function() { public Icon fun(VirtualFile virtualFile) { final File f = new File(filePath); if (!f.exists()) { diff --git a/platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java b/platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java index b764b16fbb4d..061696be6b68 100644 --- a/platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java +++ b/platform/lang-impl/src/com/intellij/refactoring/rename/PsiElementRenameHandler.java @@ -16,7 +16,6 @@ package com.intellij.refactoring.rename; -import com.intellij.codeInsight.daemon.impl.CollectHighlightsUtil; import com.intellij.featureStatistics.FeatureUsageTracker; import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DataKey; @@ -108,8 +107,6 @@ public class PsiElementRenameHandler implements RenameHandler { static @Nullable String renameabilityStatus(Project project, PsiElement element) { if (element == null) return ""; - if (!(element instanceof PsiFile) && - CollectHighlightsUtil.isOutsideSourceRoot(element.getContainingFile())) return ""; boolean hasRenameProcessor = RenamePsiElementProcessor.forElement(element) != RenamePsiElementProcessor.DEFAULT; boolean hasWritableMetaData = element instanceof PsiMetaOwner && ((PsiMetaOwner)element).getMetaData() instanceof PsiWritableMetaData; diff --git a/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java b/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java index a8cf37d2efa6..9432d641d41d 100644 --- a/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/editor/EditorModificationUtil.java @@ -24,6 +24,7 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.LineTokenizer; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.psi.PsiDocumentManager; import org.jetbrains.annotations.Nullable; import java.awt.datatransfer.DataFlavor; @@ -292,6 +293,7 @@ public class EditorModificationUtil { boolean atLineStart = caretOffset >= doc.getTextLength() || doc.getLineStartOffset(doc.getLineNumber(caretOffset)) == caretOffset; if (atLineStart && project != null) { int offset = editor.getCaretModel().getOffset(); + PsiDocumentManager.getInstance(project).commitDocument(doc); // Sync document and PSI before formatting. String properIndent = offset >= doc.getTextLength() ? "" : CodeStyleFacade.getInstance(project).getLineIndent(doc, offset); if (properIndent != null) { int tabSize = editor.getSettings().getTabSize(project); diff --git a/platform/platform-impl/src/com/intellij/ide/LockedIconLayerProvider.java b/platform/platform-impl/src/com/intellij/ide/LockedIconLayerProvider.java new file mode 100644 index 000000000000..78b7f44e351d --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ide/LockedIconLayerProvider.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2011 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.ide; + +import com.intellij.openapi.util.Iconable; +import com.intellij.util.PlatformIcons; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; + +/** + * @author yole + */ +public class LockedIconLayerProvider implements IconLayerProvider { + @Override + public Icon getLayerIcon(@NotNull Iconable element, boolean isLocked) { + return isLocked ? PlatformIcons.LOCKED_ICON : null; + } + + @Override + public String getLayerDescription() { + return "Read-only"; + } +} diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java index f06f42e612da..8cca2185e03e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretModelImpl.java @@ -185,9 +185,19 @@ public class CaretModelImpl implements CaretModel, PrioritizedDocumentListener, validateCallContext(); moveToLogicalPosition(myEditor.offsetToLogicalPosition(offset), locateBeforeSoftWrap); if (!ignoreWrongMoves && !myEditor.offsetToLogicalPosition(myOffset).equals(myEditor.offsetToLogicalPosition(offset))) { + StringBuilder documentInfo = new StringBuilder(); + Document document = myEditor.getDocument(); + for (int line = 0; line < document.getLineCount(); line++) { + documentInfo.append(line).append(": ").append(document.getLineStartOffset(line)).append("-") + .append(document.getLineEndOffset(line)).append(", "); + } + if (documentInfo.length() > 0) { + documentInfo.setLength(documentInfo.length() - 1); + } LOG.error( "caret moved to wrong offset. Requested:" + offset + " but actual:" + myOffset - + ". Soft wraps data: " + myEditor.getSoftWrapModel() + ", folding data: " + myEditor.getFoldingModel()); + + ". Soft wraps data: " + myEditor.getSoftWrapModel() + ", folding data: " + myEditor.getFoldingModel() + ", " + + "document info: " + documentInfo); } } diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties index ff60e0f6ac3e..2e3b1ecee884 100644 --- a/platform/platform-resources-en/src/messages/IdeBundle.properties +++ b/platform/platform-resources-en/src/messages/IdeBundle.properties @@ -648,7 +648,7 @@ button.edit.action.icon=Edit Action &Icon button.add.separator=Add &Separator button.move.up.u=Move &Up button.move.down.d=Move &Down -button.add.action.after=Add a&fter... +button.add.action.after=Add A&fter... title.custom.actions.schemas=Custom Actions Schemes title.customizations=Menus and Toolbars label.choosebyname.no.matches.found=No matches found diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties index 4c05e3ce057d..34084f4bf19d 100644 --- a/platform/platform-resources-en/src/misc/registry.properties +++ b/platform/platform-resources-en/src/misc/registry.properties @@ -151,5 +151,5 @@ ide.enable.toolwindow.stack=false change.signature.awesome.mode=true change.signature.awesome.mode.description=Enables list view for change signature -navbar.is.decorated=false +navbar.is.decorated=true navbar.is.decorated.description=NavBar with decorations diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index 08e798f2a8e8..6f03e69ce002 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -254,4 +254,5 @@ + diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchForBaseRevisionTexts.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchForBaseRevisionTexts.java index d1c0e97a1ca3..3e7faf0fd7f5 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchForBaseRevisionTexts.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/ApplyPatchForBaseRevisionTexts.java @@ -44,7 +44,7 @@ public class ApplyPatchForBaseRevisionTexts { @NotNull public static ApplyPatchForBaseRevisionTexts create(final Project project, final VirtualFile file, final FilePath pathBeforeRename, final TextFilePatch patch, final Getter baseContents) { - assert ! patch.isNewFile(); // todo check + assert ! patch.isNewFile(); final String beforeVersionId = patch.getBeforeVersionId(); DefaultPatchBaseVersionProvider provider = null; if (beforeVersionId != null) { @@ -81,7 +81,7 @@ public class ApplyPatchForBaseRevisionTexts { return true; } myBase = text; - myPatched = applier.getAfter(); + setPatched(applier.getAfter()); return false; } }, myWarnings); @@ -102,7 +102,7 @@ public class ApplyPatchForBaseRevisionTexts { if (! applier.execute()) { applier.trySolveSomehow(); } - myPatched = applier.getAfter(); + setPatched(applier.getAfter()); return; } @@ -110,7 +110,7 @@ public class ApplyPatchForBaseRevisionTexts { if (! applier.execute()) { applier.trySolveSomehow(); } - myPatched = applier.getAfter(); + setPatched(applier.getAfter()); } public CharSequence getLocal() { @@ -120,6 +120,10 @@ public class ApplyPatchForBaseRevisionTexts { public CharSequence getBase() { return myBase; } + + private void setPatched(final String text) { + myPatched = StringUtil.convertLineSeparators(text); + } public String getPatched() { return myPatched; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/DefaultPatchBaseVersionProvider.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/DefaultPatchBaseVersionProvider.java index efea94a3a088..5685bcfc3123 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/DefaultPatchBaseVersionProvider.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/patch/DefaultPatchBaseVersionProvider.java @@ -27,6 +27,8 @@ import com.intellij.openapi.fileEditor.impl.LoadTextUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vcs.*; +import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vcs.diff.DiffProvider; import com.intellij.openapi.vcs.history.*; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.Processor; @@ -66,8 +68,8 @@ public class DefaultPatchBaseVersionProvider { } public void getBaseVersionContent(final FilePath filePath, - Processor processor, - List warnings) throws VcsException { + final Processor processor, + final List warnings) throws VcsException { if (myVcs == null) { return; } @@ -79,9 +81,33 @@ public class DefaultPatchBaseVersionProvider { final Matcher matcher = myRevisionPattern.matcher(myVersionId); if (matcher.find()) { revision = myVcs.parseRevisionNumber(matcher.group(1), filePath); + final VcsRevisionNumber finalRevision = revision; + final Boolean[] loadedExactRevision = new Boolean[1]; + if (historyProvider instanceof VcsBaseRevisionAdviser) { - if (((VcsBaseRevisionAdviser) historyProvider).getBaseVersionContent(filePath, processor, revision.asString(), warnings)) return; + final boolean success = VcsUtil.runVcsProcessWithProgress(new VcsRunnable() { + public void run() throws VcsException { + loadedExactRevision[0] = ((VcsBaseRevisionAdviser)historyProvider).getBaseVersionContent(filePath, processor, finalRevision.asString(), warnings); + } + }, VcsBundle.message("progress.text2.loading.revision", revision.asString()), true, myProject); + // was cancelled + if (! success) return; + } else { + // use diff provider + final DiffProvider diffProvider = myVcs.getDiffProvider(); + if (diffProvider != null && filePath.getVirtualFile() != null) { + final ContentRevision fileContent = diffProvider.createFileContent(finalRevision, filePath.getVirtualFile()); + + final boolean success = VcsUtil.runVcsProcessWithProgress(new VcsRunnable() { + public void run() throws VcsException { + loadedExactRevision[0] = ! processor.process(fileContent.getContent()); + } + }, VcsBundle.message("progress.text2.loading.revision", revision.asString()), true, myProject); + // was cancelled + if (! success) return; + } } + if (Boolean.TRUE.equals(loadedExactRevision[0])) return; } } diff --git a/plugins/android/src/org/jetbrains/android/AndroidIdIndex.java b/plugins/android/src/org/jetbrains/android/AndroidIdIndex.java index f5aaf2c5bad1..0344676ae229 100644 --- a/plugins/android/src/org/jetbrains/android/AndroidIdIndex.java +++ b/plugins/android/src/org/jetbrains/android/AndroidIdIndex.java @@ -30,6 +30,7 @@ import com.intellij.util.containers.HashMap; import com.intellij.util.indexing.*; import com.intellij.util.io.EnumeratorStringDescriptor; import com.intellij.util.io.KeyDescriptor; +import org.jetbrains.android.resourceManagers.ResourceManager; import org.jetbrains.android.util.AndroidResourceUtil; import org.jetbrains.annotations.NotNull; @@ -52,7 +53,8 @@ public class AndroidIdIndex extends ScalarIndexExtension { if (parent == null || !parent.isDirectory()) { return false; } - if (!canContainIdDeclaration(parent.getName())) { + final String resourceType = ResourceManager.getResourceTypeByDirName(parent.getName()); + if (resourceType == null || !canContainIdDeclaration(resourceType)) { return false; } parent = parent.getParent(); @@ -119,6 +121,6 @@ public class AndroidIdIndex extends ScalarIndexExtension { @Override public int getVersion() { - return 0; + return 1; } } diff --git a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager.java b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager.java index 0b591edf5f8c..c3419190969d 100644 --- a/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager.java +++ b/plugins/android/src/org/jetbrains/android/uipreview/AndroidLayoutPreviewToolWindowManager.java @@ -394,6 +394,8 @@ public class AndroidLayoutPreviewToolWindowManager implements ProjectComponent { final JPanel panel = new JPanel(new BorderLayout()); final JTextArea textArea = new JTextArea(stackTrace); textArea.setEditable(false); + textArea.setRows(40); + textArea.setColumns(70); panel.add(ScrollPaneFactory.createScrollPane(textArea)); return panel; } @@ -473,7 +475,17 @@ public class AndroidLayoutPreviewToolWindowManager implements ProjectComponent { final VirtualFile changedFile = event.getFile(); final VirtualFile parent = changedFile.getParent(); - if (parent != null && ResourceManager.isResourceDirectory(parent, myProject)) { + if (parent == null) { + return; + } + + if (ResourceManager.isResourceDirectory(parent, myProject)) { + myToolWindowForm.updateLocales(); + render(); + } + + final VirtualFile gp = parent.getParent(); + if (gp != null && ResourceManager.isResourceDirectory(gp, myProject)) { myToolWindowForm.updateLocales(); render(); } diff --git a/plugins/android/src/org/jetbrains/android/uipreview/RenderUtil.java b/plugins/android/src/org/jetbrains/android/uipreview/RenderUtil.java index 4d078b70bfbf..b125b0dc3e94 100644 --- a/plugins/android/src/org/jetbrains/android/uipreview/RenderUtil.java +++ b/plugins/android/src/org/jetbrains/android/uipreview/RenderUtil.java @@ -147,7 +147,7 @@ class RenderUtil { if (missingClasses.size() > 1) { warningBuilder.append("Missing classes:\n"); for (String missingClass : missingClasses) { - warningBuilder.append(" ").append(missingClass).append('\n'); + warningBuilder.append("       ").append(missingClass).append('\n'); } } else { diff --git a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java index 16a3a6ec0017..ab688c5a7ece 100644 --- a/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java +++ b/plugins/android/testSrc/org/jetbrains/android/dom/AndroidLayoutDomTest.java @@ -173,6 +173,12 @@ public class AndroidLayoutDomTest extends AndroidDomTest { doTestHighlighting("idh.xml"); } + public void testIdHighlighting1() throws Throwable { + VirtualFile virtualFile = copyFileToProject("idh.xml", "res/layout-large/idh.xml"); + myFixture.configureFromExistingVirtualFile(virtualFile); + myFixture.checkHighlighting(false, false, false); + } + public void testIdReferenceCompletion() throws Throwable { toTestCompletion("idref1.xml", "idref1_after.xml"); } diff --git a/plugins/git4idea/src/git4idea/commands/GitSimpleHandler.java b/plugins/git4idea/src/git4idea/commands/GitSimpleHandler.java index 988e1326ee09..d47304ad4397 100644 --- a/plugins/git4idea/src/git4idea/commands/GitSimpleHandler.java +++ b/plugins/git4idea/src/git4idea/commands/GitSimpleHandler.java @@ -218,8 +218,11 @@ public class GitSimpleHandler extends GitTextHandler { } public void startFailed(final Throwable exception) { - ex[0] = new VcsException("Process failed to start (" + myCommandLine.getCommandLineString() + "): " + exception.toString(), exception); - sem.release(); + try { + ex[0] = new VcsException("Process failed to start (" + myCommandLine.getCommandLineString() + "): " + exception.toString(), exception); + } finally { + sem.release(); + } } }); GitHandlerUtil.runInCurrentThread(this, null); diff --git a/plugins/git4idea/src/git4idea/commands/GitTextHandler.java b/plugins/git4idea/src/git4idea/commands/GitTextHandler.java index eccf539284b6..22838705a3e9 100644 --- a/plugins/git4idea/src/git4idea/commands/GitTextHandler.java +++ b/plugins/git4idea/src/git4idea/commands/GitTextHandler.java @@ -68,10 +68,13 @@ public abstract class GitTextHandler extends GitHandler { public void processTerminated(final ProcessEvent event) { final int exitCode = event.getExitCode(); - setExitCode(exitCode); - cleanupEnv(); - GitTextHandler.this.processTerminated(exitCode); - listeners().processTerminated(exitCode); + try { + setExitCode(exitCode); + cleanupEnv(); + GitTextHandler.this.processTerminated(exitCode); + } finally { + listeners().processTerminated(exitCode); + } } public void processWillTerminate(final ProcessEvent event, final boolean willBeDestroyed) { diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java b/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java index 6729dab96fd3..96a721a43b8c 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryProvider.java @@ -171,33 +171,12 @@ public class GitHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto throw new VcsException("Can not apply patch to " + filePath.getPath() + ".\nCan not find revision '" + beforeVersionId + "'."); } - /*final GitRevisionNumber mergeBase = GitHistoryUtils.getMergeBase(myProject, root, "HEAD", shaHash.getValue()); - if (mergeBase == null) { - throw new VcsException("Can not apply patch to " + filePath.getPath() + - ".\nBase revision '" + beforeVersionId + "', used in patch, is not on current branch (reachable from current HEAD)," + - "\nand there is no merge base between '" + beforeVersionId + "' and HEAD."); - }*/ final ContentRevision content = GitVcs.getInstance(myProject).getDiffProvider() .createFileContent(new GitRevisionNumber(shaHash.getValue()), filePath.getVirtualFile()); if (content == null) { throw new VcsException("Can not load content of '" + filePath.getPath() + "' for revision '" + shaHash.getValue() + "'"); } return ! processor.process(content.getContent()); - /*if (shaHash.getValue().startsWith(mergeBase.getRev())) { - // ok - return matched; - } else { - if (matched) { - warnings.add("Base revision '" + beforeVersionId + "', used in patch, is not on current branch (reachable from current HEAD)." + - "\nMerge base '" + mergeBase.getRev() +"' between '" + beforeVersionId + "' and HEAD was used."); - return true; - } else { - throw new VcsException("Can not apply patch to " + filePath.getPath() + - ".\nBase revision '" + beforeVersionId + "', used in patch, is not on current branch (reachable from current HEAD)," + - "\nand found merge base '" + mergeBase.getRev() + "' between '" + beforeVersionId + - "' and HEAD doesn't match the context."); - } - }*/ } public void reportAppendableHistory(final FilePath path, final VcsAppendableHistorySessionPartner partner) throws VcsException { diff --git a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java index d6bb88ff29f1..48506c06ef83 100644 --- a/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java +++ b/plugins/git4idea/src/git4idea/history/GitHistoryUtils.java @@ -223,6 +223,7 @@ public class GitHistoryUtils { } @Override public void startFailed(Throwable exception) { + semaphore.up(); } }); semaphore.down(); @@ -356,18 +357,24 @@ public class GitHistoryUtils { @Override public void startFailed(Throwable exception) { //noinspection ThrowableInstanceNeverThrown - exceptionConsumer.consume(new VcsException(exception)); - semaphore.up(); + try { + exceptionConsumer.consume(new VcsException(exception)); + } finally { + semaphore.up(); + } } @Override public void processTerminated(int exitCode) { - super.processTerminated(exitCode); - final GitLogRecord record = accumulator.processLast(); - if (record != null) { - resultAdapter.consume(record); + try { + super.processTerminated(exitCode); + final GitLogRecord record = accumulator.processLast(); + if (record != null) { + resultAdapter.consume(record); + } + } finally { + semaphore.up(); } - semaphore.up(); } }); semaphore.down(); @@ -607,6 +614,7 @@ public class GitHistoryUtils { } @Override public void startFailed(Throwable exception) { + semaphore.up(); } }); semaphore.down(); @@ -821,7 +829,7 @@ public class GitHistoryUtils { @Override public void startFailed(Throwable exception) { - // todo + semaphore.up(); } }); semaphore.down(); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/api/GrDocInlinedTag.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/api/GrDocInlinedTag.java index 56b82988a0d8..e623f2242df9 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/api/GrDocInlinedTag.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/groovydoc/psi/api/GrDocInlinedTag.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -16,8 +16,10 @@ package org.jetbrains.plugins.groovy.lang.groovydoc.psi.api; +import com.intellij.psi.javadoc.PsiInlineDocTag; + /** * @author ilyas */ -public interface GrDocInlinedTag extends GrDocTag { +public interface GrDocInlinedTag extends GrDocTag, PsiInlineDocTag { } diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java index d0f5c4e29125..08746f8de978 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/primary/PrimaryExpression.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -152,11 +152,16 @@ public class PrimaryExpression implements GroovyElementTypes { } else if (builder.getTokenType() == mLBRACK) { PsiBuilder.Marker forArray = builder.mark(); + ParserUtils.getToken(builder, mNLS); + ParserUtils.getToken(builder, mLBRACK); + if (!AssignmentExpression.parse(builder, parser)) { + builder.error(GroovyBundle.message("expression.expected")); + } + ParserUtils.getToken(builder, mNLS); + ParserUtils.getToken(builder, mRBRACK, GroovyBundle.message("rbrack.expected")); while (ParserUtils.getToken(builder, mLBRACK)) { ParserUtils.getToken(builder, mNLS); - if (!AssignmentExpression.parse(builder, parser)) { - builder.error(GroovyBundle.message("expression.expected")); - } + AssignmentExpression.parse(builder, parser); ParserUtils.getToken(builder, mNLS); ParserUtils.getToken(builder, mRBRACK, GroovyBundle.message("rbrack.expected")); } @@ -188,4 +193,4 @@ public class PrimaryExpression implements GroovyElementTypes { marker.done(ARGUMENTS); return true; } -} \ No newline at end of file +} diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/SubstitutorComputer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/SubstitutorComputer.java index 45b1992d35b1..5f4d43f9fde4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/SubstitutorComputer.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/resolve/processors/SubstitutorComputer.java @@ -192,6 +192,9 @@ public abstract class SubstitutorComputer { for (PsiTypeParameter typeParameter : typeParameters) { if (!substitutor.getSubstitutionMap().containsKey(typeParameter)) { substitutor = inferFromContext(typeParameter, PsiUtil.getSmartReturnType(method), substitutor, helper); + if (!substitutor.getSubstitutionMap().containsKey(typeParameter)) { + substitutor = substitutor.put(typeParameter, null); + } } } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy index bd101bfe4161..9c039b635085 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/GroovyHighlightingTest.groovy @@ -1,6 +1,17 @@ /* - * Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved. - * Use is subject to license terms. + * Copyright 2000-2011 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 org.jetbrains.plugins.groovy.lang; diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy index a346756b747e..c2f4fffd8bf5 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/parser/ExpressionsParsingTest.groovy @@ -1,5 +1,5 @@ /* - * Copyright 2000-2010 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -88,7 +88,7 @@ public class ExpressionsParsingTest extends GroovyParsingTestCase { public void testgstring$ugly_lexer() throws Throwable { doTest(); } public void testmapLiteral() throws Throwable { doTest(); } public void testnew$arr_decl() throws Throwable { doTest(); } -// public void testnew$new1() throws Throwable { doTest(); } +// public void testnew$new1() throws Throwable { doTest(); } public void testanonymous$anonymous() throws Throwable { doTest(); } public void testnumbers() throws Throwable { doTest(); } public void testparenthed$exprInParenth() throws Throwable { doTest(); } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTest.groovy index 6ef6b2415dfa..623bdede5df2 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/TypeInferenceTest.groovy @@ -1,17 +1,17 @@ /* - * Copyright 2000-2007 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 + * Copyright 2000-2011 JetBrains s.r.o. * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 * - * 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. + * 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 org.jetbrains.plugins.groovy.lang.resolve; @@ -266,4 +266,8 @@ map['i'] += 2 GrAssignmentExpression assignment = file.topStatements[2] assertTrue(assignment.getLValue().getType().equalsToText(CommonClassNames.JAVA_UTIL_DATE)) } + + void testAllTypeParamsAreSubstituted() { + assertTypeEquals('java.util.Map', 'a.groovy') + } } diff --git a/plugins/groovy/testdata/highlighting/RawTypeInAssignment.groovy b/plugins/groovy/testdata/highlighting/RawTypeInAssignment.groovy index 79434530df35..873dd9435982 100644 --- a/plugins/groovy/testdata/highlighting/RawTypeInAssignment.groovy +++ b/plugins/groovy/testdata/highlighting/RawTypeInAssignment.groovy @@ -1,3 +1,18 @@ +/* + * Copyright 2000-2011 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. + */ Map map3 map3 = [].collectEntries {} -int map4 = [].collectEntries {} +int map4 = [].collectEntries {} diff --git a/plugins/groovy/testdata/parsing/groovy/expressions/new/arr_decl.test b/plugins/groovy/testdata/parsing/groovy/expressions/new/arr_decl.test index 7eb5c0de753a..ef94ae7dfafc 100644 --- a/plugins/groovy/testdata/parsing/groovy/expressions/new/arr_decl.test +++ b/plugins/groovy/testdata/parsing/groovy/expressions/new/arr_decl.test @@ -1,4 +1,7 @@ j = new int[1][2] +j = new int[1][] +j = new int[] +j = new int[][2] ----- Groovy script Assignment expression @@ -18,6 +21,63 @@ Groovy script PsiElement(Integer)('1') PsiElement(])(']') PsiElement([)('[') + Literal + PsiElement(Integer)('2') + PsiElement(])(']') + PsiElement(new line)('\n') + Assignment expression + Reference expression + PsiElement(identifier)('j') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + NEW expression + PsiElement(new)('new') + PsiWhiteSpace(' ') + Built in type + PsiElement(int)('int') + Array declaration + PsiElement([)('[') + Literal + PsiElement(Integer)('1') + PsiElement(])(']') + PsiElement([)('[') + PsiElement(])(']') + PsiElement(new line)('\n') + Assignment expression + Reference expression + PsiElement(identifier)('j') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + NEW expression + PsiElement(new)('new') + PsiWhiteSpace(' ') + Built in type + PsiElement(int)('int') + Array declaration + PsiElement([)('[') + PsiErrorElement:Expression expected + + PsiElement(])(']') + PsiElement(new line)('\n') + Assignment expression + Reference expression + PsiElement(identifier)('j') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + NEW expression + PsiElement(new)('new') + PsiWhiteSpace(' ') + Built in type + PsiElement(int)('int') + Array declaration + PsiElement([)('[') + PsiErrorElement:Expression expected + + PsiElement(])(']') + PsiElement([)('[') Literal PsiElement(Integer)('2') PsiElement(])(']') \ No newline at end of file diff --git a/plugins/groovy/testdata/resolve/inference/allTypeParamsAreSubstituted/a.groovy b/plugins/groovy/testdata/resolve/inference/allTypeParamsAreSubstituted/a.groovy new file mode 100644 index 000000000000..176dd02f3dc8 --- /dev/null +++ b/plugins/groovy/testdata/resolve/inference/allTypeParamsAreSubstituted/a.groovy @@ -0,0 +1,19 @@ +/* + * Copyright 2000-2011 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. + */ +List l = ['a', 'b', 'c'] +def aa = l.collectEntries { [it, it]} + +print aa \ No newline at end of file diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenFilteredPropertiesCompletionAndResolutionTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenFilteredPropertiesCompletionAndResolutionTest.java index dd0c3f9e3e14..c013bf6ef819 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenFilteredPropertiesCompletionAndResolutionTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/dom/MavenFilteredPropertiesCompletionAndResolutionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -15,9 +15,12 @@ */ package org.jetbrains.idea.maven.dom; +import com.intellij.lang.properties.IProperty; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDirectory; +import com.intellij.psi.PsiElement; import com.intellij.psi.PsiManager; +import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.maven.dom.model.MavenDomProfilesModel; import org.jetbrains.idea.maven.dom.references.MavenPropertyPsiReference; @@ -201,7 +204,13 @@ public class MavenFilteredPropertiesCompletionAndResolutionTest extends MavenDom VirtualFile f = createProjectSubFile("res/foo.properties", "foo=abc${xxx}abc"); - assertResolved(f, MavenDomUtil.findProperty(myProject, filter, "xxx").getPsiElement()); + assertResolved(f, findPropertyPsiElement(filter, "xxx")); + } + + @Nullable + private PsiElement findPropertyPsiElement(final VirtualFile filter, final String propName) { + final IProperty property = MavenDomUtil.findProperty(myProject, filter, propName); + return property != null ? property.getPsiElement() : null; } public void testCompletionFromFilters() throws Exception { @@ -230,7 +239,7 @@ public class MavenFilteredPropertiesCompletionAndResolutionTest extends MavenDom } public void testSearchingFromFilters() throws Exception { - VirtualFile filter = createProjectSubFile("filters/filter.properties", "xxx=1"); + createProjectSubFile("filters/filter.properties", "xxx=1"); importProject("test" + "project" + @@ -250,7 +259,7 @@ public class MavenFilteredPropertiesCompletionAndResolutionTest extends MavenDom VirtualFile f = createProjectSubFile("res/foo.properties", "foo=${xxx}"); - filter = createProjectSubFile("filters/filter.properties", "xxx=1"); + VirtualFile filter = createProjectSubFile("filters/filter.properties", "xxx=1"); assertSearchResultsInclude(filter, MavenDomUtil.findPropertyValue(myProject, f, "foo")); } @@ -415,15 +424,11 @@ public class MavenFilteredPropertiesCompletionAndResolutionTest extends MavenDom VirtualFile f = createProjectSubFile("res/foo.properties", "foo=abc${xxx}abc"); - assertResolved(f, MavenDomUtil.findProperty(myProject, filter, "xxx").getPsiElement()); + assertResolved(f, findPropertyPsiElement(filter, "xxx")); doRename(f, "bar"); assertEquals("foo=abc${bar}abc", findPsiFile(f).getText()); assertEquals("bar=1", findPsiFile(filter).getText()); } - - public void testFilteredPropertiesUsages() throws Exception { - - } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java index ea81c3783bdc..1580c94c5eba 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnDiffProvider.java @@ -66,7 +66,7 @@ public class SvnDiffProvider implements DiffProvider, DiffMixin { private VcsRevisionDescription getCurrentRevisionDescription(File path) { final SVNWCClient client = myVcs.createWCClient(); try { - final SVNInfo svnInfo = client.doInfo(path, SVNRevision.COMMITTED); + final SVNInfo svnInfo = client.doInfo(path, SVNRevision.BASE); if (svnInfo.getCommittedRevision().equals(SVNRevision.UNDEFINED) && ! svnInfo.getCopyFromRevision().equals(SVNRevision.UNDEFINED) && svnInfo.getCopyFromURL() != null) { @@ -88,7 +88,7 @@ public class SvnDiffProvider implements DiffProvider, DiffMixin { private String getProperties(SVNWCClient client, File path) throws SVNException { final String[] message = new String[1]; - client.doGetRevisionProperty(path, null, SVNRevision.COMMITTED, new ISVNPropertyHandler() { + client.doGetRevisionProperty(path, null, SVNRevision.BASE, new ISVNPropertyHandler() { @Override public void handleProperty(File path, SVNPropertyData property) throws SVNException { handle(property);