This commit is contained in:
Alexey Kudravtsev
2015-01-20 13:20:21 +03:00
parent 1d64a6e867
commit dd469ff7dc
6 changed files with 37 additions and 38 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2015 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,13 +34,13 @@ import org.jetbrains.annotations.Nullable;
* User: cdr
*/
class AnchorElementInfo extends SelfElementInfo {
private int stubId = -1;
private int stubId;
private IStubElementType myStubElementType;
AnchorElementInfo(@NotNull PsiElement anchor, @NotNull PsiFile containingFile) {
super(containingFile.getProject(), ProperTextRange.create(anchor.getTextRange()), anchor.getClass(), containingFile,
LanguageUtil.getRootLanguage(anchor));
super(containingFile.getProject(), ProperTextRange.create(anchor.getTextRange()), anchor.getClass(), containingFile, LanguageUtil.getRootLanguage(anchor));
assert !(anchor instanceof PsiFile) : "FileElementInfo must be used for file: "+anchor;
stubId = -1;
}
// will restore by stub index until file tree get loaded
AnchorElementInfo(@NotNull PsiElement anchor,
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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,7 +16,6 @@
package com.intellij.psi.impl.smartPointers;
import com.intellij.lang.Language;
import com.intellij.lang.LanguageUtil;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.RangeMarker;
@@ -47,15 +46,11 @@ public class SelfElementInfo implements SmartPointerElementInfo {
private volatile RangeMarker myRangeMarker; //maintains hard reference during modification
protected final Language myLanguage;
protected SelfElementInfo(@NotNull Project project, @NotNull PsiElement anchor) {
this(project, ProperTextRange.create(anchor.getTextRange()), anchor.getClass(), anchor.getContainingFile(),
LanguageUtil.getRootLanguage(anchor));
}
public SelfElementInfo(@NotNull Project project,
@NotNull ProperTextRange range,
@NotNull Class anchorClass,
@NotNull PsiFile containingFile,
@NotNull Language language) {
SelfElementInfo(@NotNull Project project,
@NotNull ProperTextRange range,
@NotNull Class anchorClass,
@NotNull PsiFile containingFile,
@NotNull Language language) {
myLanguage = language;
myVirtualFile = PsiUtilCore.getVirtualFile(containingFile);
myType = anchorClass;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -126,7 +126,9 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
}
@NotNull
static <E extends PsiElement> SmartPointerElementInfo createElementInfo(@NotNull Project project, @NotNull E element, PsiFile containingFile) {
private static <E extends PsiElement> SmartPointerElementInfo createElementInfo(@NotNull Project project,
@NotNull E element,
PsiFile containingFile) {
if (element instanceof PsiDirectory) {
return new DirElementInfo((PsiDirectory)element);
}
@@ -185,7 +187,7 @@ class SmartPsiElementPointerImpl<E extends PsiElement> implements SmartPointerEx
return myElementInfo;
}
protected static boolean pointsToTheSameElementAs(@NotNull SmartPsiElementPointer pointer1, @NotNull SmartPsiElementPointer pointer2) {
static boolean pointsToTheSameElementAs(@NotNull SmartPsiElementPointer pointer1, @NotNull SmartPsiElementPointer pointer2) {
if (pointer1 == pointer2) return true;
if (pointer1 instanceof SmartPsiElementPointerImpl && pointer2 instanceof SmartPsiElementPointerImpl) {
SmartPsiElementPointerImpl impl1 = (SmartPsiElementPointerImpl)pointer1;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -239,8 +239,8 @@ public class BlockSupportImpl extends BlockSupport {
}
@NotNull
private static DiffLog replaceElementWithEvents(final CompositeElement oldRoot,
final CompositeElement newRoot) {
private static DiffLog replaceElementWithEvents(@NotNull CompositeElement oldRoot,
@NotNull CompositeElement newRoot) {
DiffLog diffLog = new DiffLog();
diffLog.appendReplaceElementWithEvents(oldRoot, newRoot);
return diffLog;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -70,11 +70,11 @@ public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
}
}
public void appendReplaceElementWithEvents(CompositeElement oldRoot, CompositeElement newRoot) {
void appendReplaceElementWithEvents(@NotNull CompositeElement oldRoot, @NotNull CompositeElement newRoot) {
myEntries.add(new ReplaceElementWithEvents(oldRoot, newRoot));
}
public void appendReplaceFileElement(FileElement oldNode, FileElement newNode) {
void appendReplaceFileElement(@NotNull FileElement oldNode, @NotNull FileElement newNode) {
myEntries.add(new ReplaceFileElement(oldNode, newNode));
}
@@ -92,7 +92,7 @@ public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
private final ASTNode myOldChild;
private final ASTNode myNewChild;
public ReplaceEntry(@NotNull ASTNode oldNode, @NotNull ASTNode newNode) {
private ReplaceEntry(@NotNull ASTNode oldNode, @NotNull ASTNode newNode) {
myOldChild = oldNode;
myNewChild = newNode;
ASTNode parent = oldNode.getTreeParent();
@@ -133,10 +133,10 @@ public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
}
private static class DeleteEntry extends LogEntry {
private final ASTNode myOldParent;
private final ASTNode myOldNode;
@NotNull private final ASTNode myOldParent;
@NotNull private final ASTNode myOldNode;
public DeleteEntry(ASTNode oldParent, ASTNode oldNode) {
private DeleteEntry(@NotNull ASTNode oldParent, @NotNull ASTNode oldNode) {
myOldParent = oldParent;
myOldNode = oldNode;
}
@@ -167,11 +167,11 @@ public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
}
private static class InsertEntry extends LogEntry {
private final ASTNode myOldParent;
private final ASTNode myNewNode;
@NotNull private final ASTNode myOldParent;
@NotNull private final ASTNode myNewNode;
private final int myPos;
public InsertEntry(@NotNull ASTNode oldParent, @NotNull ASTNode newNode, int pos) {
private InsertEntry(@NotNull ASTNode oldParent, @NotNull ASTNode newNode, int pos) {
assert oldParent instanceof CompositeElement : oldParent;
myOldParent = oldParent;
myNewNode = newNode;
@@ -226,10 +226,10 @@ public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
}
private static class ReplaceFileElement extends LogEntry {
private final FileElement myOldNode;
private final FileElement myNewNode;
@NotNull private final FileElement myOldNode;
@NotNull private final FileElement myNewNode;
public ReplaceFileElement(FileElement oldNode, FileElement newNode) {
private ReplaceFileElement(@NotNull FileElement oldNode, @NotNull FileElement newNode) {
myOldNode = oldNode;
myNewNode = newNode;
}
@@ -250,10 +250,10 @@ public class DiffLog implements DiffTreeChangeBuilder<ASTNode,ASTNode> {
}
private static class ReplaceElementWithEvents extends LogEntry {
private final CompositeElement myOldRoot;
private final CompositeElement myNewRoot;
@NotNull private final CompositeElement myOldRoot;
@NotNull private final CompositeElement myNewRoot;
public ReplaceElementWithEvents(CompositeElement oldRoot, CompositeElement newRoot) {
private ReplaceElementWithEvents(@NotNull CompositeElement oldRoot, @NotNull CompositeElement newRoot) {
myOldRoot = oldRoot;
myNewRoot = newRoot;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -20,6 +20,7 @@ import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
import com.intellij.testFramework.PlatformTestUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.io.File;
@@ -85,6 +86,7 @@ public class XmlMoverTest extends LightPlatformCodeInsightTestCase {
return "/mover";
}
@NotNull
@Override
protected String getTestDataPath() {
return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + "/xml/tests/testData";