Merge remote-tracking branch 'origin/master'

This commit is contained in:
anna
2013-02-25 12:31:22 +01:00
40 changed files with 192 additions and 94 deletions
@@ -60,7 +60,7 @@ public class BasePackageParameterFactory extends ProjectTemplateParameterFactory
@Override
public String getLabel() {
return "Base package:";
return "Base \u001Bpackage:";
}
@Override
@@ -26,7 +26,6 @@ import org.picocontainer.alternatives.AbstractDelegatingMutablePicoContainer;
/**
* @author Alexander Kireyev
*/
@SuppressWarnings({"unchecked"})
class AreaPicoContainerImpl extends AbstractDelegatingMutablePicoContainer implements AreaPicoContainer {
private final AreaInstance myAreaInstance;
@@ -30,6 +30,7 @@ public abstract class ProjectTemplateParameterFactory {
// standard ids
public static final String IJ_BASE_PACKAGE = "IJ_BASE_PACKAGE";
public static final String IJ_PROJECT_NAME = "IJ_PROJECT_NAME";
public static final String IJ_APPLICATION_SERVER = "IJ_APPLICATION_SERVER";
public abstract String getParameterId();
@@ -36,6 +36,7 @@ import com.intellij.openapi.fileTypes.impl.CustomSyntaxTableFileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiElement;
@@ -46,7 +47,6 @@ import com.intellij.psi.codeStyle.Indent;
import com.intellij.psi.util.PsiUtilBase;
import com.intellij.util.DocumentUtil;
import com.intellij.util.StringBuilderSpinAllocator;
import com.intellij.util.SystemProperties;
import com.intellij.util.containers.IntArrayList;
import com.intellij.util.text.CharArrayUtil;
import gnu.trove.THashMap;
@@ -57,9 +57,6 @@ import java.util.Map;
public class CommentByLineCommentHandler implements CodeInsightActionHandler {
private static final int MIN_LINES_TO_COMMENT_TO_USE_BULK_PROCESSING
= SystemProperties.getIntProperty("idea.bulk.comment.lines.trigger", 100);
private Project myProject;
private PsiFile myFile;
private Document myDocument;
@@ -424,7 +421,8 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
}
public void doDefaultCommenting(final Commenter commenter) {
DocumentUtil.executeInBulk(myDocument, myEndLine - myStartLine >= MIN_LINES_TO_COMMENT_TO_USE_BULK_PROCESSING, new Runnable() {
DocumentUtil.executeInBulk(
myDocument, myEndLine - myStartLine >= Registry.intValue("comment.by.line.bulk.lines.trigger"), new Runnable() {
@Override
public void run() {
for (int line = myEndLine; line >= myStartLine; line--) {
@@ -440,7 +438,8 @@ public class CommentByLineCommentHandler implements CodeInsightActionHandler {
final FileType fileType = myFile.getFileType();
final Indent minIndent = computeMinIndent(myStartLine, myEndLine, chars, myCodeStyleManager, fileType);
DocumentUtil.executeInBulk(myDocument, myEndLine - myStartLine > MIN_LINES_TO_COMMENT_TO_USE_BULK_PROCESSING, new Runnable() {
DocumentUtil.executeInBulk(
myDocument, myEndLine - myStartLine > Registry.intValue("comment.by.line.bulk.lines.trigger"), new Runnable() {
@Override
public void run() {
for (int line = myEndLine; line >= myStartLine; line--) {
@@ -84,7 +84,7 @@ public class GotoTypeDeclarationAction extends BaseCodeInsightAction implements
private static void navigate(@NotNull Project project, @NotNull PsiElement symbolType) {
PsiElement element = symbolType.getNavigationElement();
assert element != null;
assert element != null : "SymbolType :"+symbolType+"; file: "+symbolType.getContainingFile();
VirtualFile file = element.getContainingFile().getVirtualFile();
if (file != null) {
OpenFileDescriptor descriptor = new OpenFileDescriptor(project, file, element.getTextOffset());
@@ -261,7 +261,8 @@ public class InspectionProfileImpl extends ProfileEx implements ModifiableModel,
StringInterner interner = new StringInterner();
for (final Object o : element.getChildren(INSPECTION_TOOL_TAG)) {
Element toolElement = (Element)o;
// make clone to avoid retaining memory via o.parent pointers
Element toolElement = (Element)((Element)o).clone();
JDOMUtil.internElement(toolElement, interner);
String toolClassName = toolElement.getAttributeValue(CLASS_TAG);
@@ -19,6 +19,7 @@ package com.intellij.execution.impl;
import com.intellij.execution.*;
import com.intellij.execution.configurations.*;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.ide.util.projectWizard.ProjectTemplateComponent;
import com.intellij.openapi.components.ProjectComponent;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.project.Project;
@@ -39,7 +40,7 @@ import javax.swing.*;
import java.util.*;
public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, ProjectComponent {
public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable, ProjectComponent, ProjectTemplateComponent {
private final Project myProject;
private final Map<String, ConfigurationType> myTypesByName = new LinkedHashMap<String, ConfigurationType>();
@@ -1140,4 +1141,9 @@ public class RunManagerImpl extends RunManagerEx implements JDOMExternalizable,
myProviderKeysMap.put(id.toString(), id);
}
}
@Override
public String getStorageFile() {
return "workspace.xml";
}
}
@@ -139,7 +139,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
}
}
protected void dispatchPendingEvents() {
private void dispatchPendingEvents() {
myConnection.deliverImmediately();
}
@@ -414,7 +414,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
return myInitialized;
}
protected void doInitialize() {
private void doInitialize() {
IndexState newState = new IndexState();
newState.doInitialize(false);
myState = newState;
@@ -428,7 +428,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
}
@NotNull
protected static ContentEntry[] getContentEntries(@NotNull Module module) {
private static ContentEntry[] getContentEntries(@NotNull Module module) {
return ModuleRootManager.getInstance(module).getContentEntries();
}
@@ -478,12 +478,12 @@ public class DirectoryIndexImpl extends DirectoryIndex {
}
@Nullable
protected static String getPackageNameForSubdir(String parentPackageName, String subdirName) {
private static String getPackageNameForSubdir(String parentPackageName, String subdirName) {
if (parentPackageName == null) return null;
return parentPackageName.isEmpty() ? subdirName : parentPackageName + "." + subdirName;
}
class IndexState {
private class IndexState {
private final TIntObjectHashMap<Set<String>> myExcludeRootsMap = new TIntObjectHashMap<Set<String>>();
private final TIntHashSet myProjectExcludeRoots = new TIntHashSet();
private final TIntObjectHashMap<DirectoryInfo> myDirToInfoMap = new TIntObjectHashMap<DirectoryInfo>();
@@ -551,11 +551,10 @@ public class DirectoryIndexImpl extends DirectoryIndex {
}
@Nullable
DirectoryInfo getInfo(int fileId) {
private DirectoryInfo getInfo(int fileId) {
return myDirToInfoMap.get(fileId);
}
private void storeInfo(@NotNull DirectoryInfo info, int id) {
if (CHECK) {
VirtualFile file = findFileById(id);
@@ -567,7 +566,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
myDirToInfoMap.put(id, info);
}
void assertAncestorsConsistent() {
private void assertAncestorsConsistent() {
if (CHECK) {
myDirToInfoMap.forEachEntry(new TIntObjectProcedure<DirectoryInfo>() {
@Override
@@ -594,10 +593,10 @@ public class DirectoryIndexImpl extends DirectoryIndex {
}
}
void fillMapWithModuleContent(@NotNull NewVirtualFile root,
final Module module,
final NewVirtualFile contentRoot,
@Nullable final ProgressIndicator progress) {
private void fillMapWithModuleContent(@NotNull NewVirtualFile root,
final Module module,
final NewVirtualFile contentRoot,
@Nullable final ProgressIndicator progress) {
final int contentRootId = contentRoot == null ? 0 : contentRoot.getId();
if (contentRoot != null) {
assert VfsUtilCore.isAncestor(contentRoot, root, false) : "Root: "+root+"; contentRoot: "+contentRoot;
@@ -725,13 +724,13 @@ public class DirectoryIndexImpl extends DirectoryIndex {
}
}
protected void fillMapWithModuleSource(@NotNull final Module module,
@NotNull final NewVirtualFile contentRoot,
@NotNull final NewVirtualFile dir,
@NotNull final String packageName,
@NotNull final NewVirtualFile sourceRoot,
final boolean isTestSource,
@Nullable final ProgressIndicator progress) {
private void fillMapWithModuleSource(@NotNull final Module module,
@NotNull final NewVirtualFile contentRoot,
@NotNull final NewVirtualFile dir,
@NotNull final String packageName,
@NotNull final NewVirtualFile sourceRoot,
final boolean isTestSource,
@Nullable final ProgressIndicator progress) {
assert VfsUtilCore.isAncestor(sourceRoot, dir, false) : "SourceRoot: "+sourceRoot+" ("+sourceRoot.getFileSystem()+"); dir: "+dir+" ("+dir.getFileSystem()+")";
VfsUtilCore.visitChildrenRecursively(dir, new DirectoryVisitor() {
private final Stack<String> myPackages = new Stack<String>();
@@ -945,7 +944,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
}
}
protected void setPackageName(int dirId, @Nullable String newPackageName) {
private void setPackageName(int dirId, @Nullable String newPackageName) {
String oldPackageName = myDirToPackageName.get(dirId);
if (oldPackageName != null) {
removeDirFromPackage(oldPackageName, dirId);
@@ -962,13 +961,13 @@ public class DirectoryIndexImpl extends DirectoryIndex {
}
// orderEntries must be sorted BY_OWNER_MODULE
protected void fillMapWithOrderEntries(@NotNull NewVirtualFile root,
@NotNull final OrderEntry[] orderEntries,
@Nullable final Module module,
@Nullable final NewVirtualFile libraryClassRoot,
@Nullable final NewVirtualFile librarySourceRoot,
@Nullable final DirectoryInfo parentInfo,
@Nullable final ProgressIndicator progress) {
private void fillMapWithOrderEntries(@NotNull NewVirtualFile root,
@NotNull final OrderEntry[] orderEntries,
@Nullable final Module module,
@Nullable final NewVirtualFile libraryClassRoot,
@Nullable final NewVirtualFile librarySourceRoot,
@Nullable final DirectoryInfo parentInfo,
@Nullable final ProgressIndicator progress) {
VfsUtilCore.visitChildrenRecursively(root, new DirectoryVisitor() {
private final Stack<OrderEntry[]> myEntries = new Stack<OrderEntry[]>();
@@ -1014,7 +1013,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
});
}
protected void doInitialize(boolean reverseAllSets/* for testing order independence*/) {
private void doInitialize(boolean reverseAllSets/* for testing order independence*/) {
assertAncestorsConsistent();
ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator();
if (progress == null) progress = new EmptyProgressIndicator();
@@ -1148,7 +1147,7 @@ public class DirectoryIndexImpl extends DirectoryIndex {
}
@NotNull
IndexState copy(@Nullable final TIntProcedure idFilter) {
private IndexState copy(@Nullable final TIntProcedure idFilter) {
final IndexState copy = new IndexState();
myExcludeRootsMap.forEachEntry(new TIntObjectProcedure<Set<String>>() {
@@ -38,7 +38,7 @@ public abstract class RefreshQueue {
public abstract RefreshSession createSession(boolean async, boolean recursive, @Nullable Runnable finishRunnable, @NotNull ModalityState state);
public final void refresh(boolean async, boolean recursive, @Nullable Runnable finishRunnable, VirtualFile... files) {
public final void refresh(boolean async, boolean recursive, @Nullable Runnable finishRunnable, @NotNull VirtualFile... files) {
refresh(async, recursive, finishRunnable, getDefaultModalityState(), files);
}
@@ -50,7 +50,7 @@ public abstract class RefreshQueue {
boolean recursive,
@Nullable Runnable finishRunnable,
@NotNull ModalityState state,
VirtualFile... files) {
@NotNull VirtualFile... files) {
RefreshSession session = createSession(async, recursive, finishRunnable, state);
session.addAllFiles(files);
session.launch();
@@ -32,6 +32,10 @@ public class CollectionComboBoxModel extends AbstractCollectionComboBoxModel {
myItems = Collections.unmodifiableList(items);
}
public CollectionComboBoxModel(List items) {
super(items.isEmpty() ? null : items.get(0));
myItems = items;
}
@NotNull
final protected List getItems() {
@@ -405,6 +405,11 @@ public abstract class EditorComposite implements Disposable {
}
public void dispose() {
for (FileEditor editor : myEditors) {
if (!Disposer.isDisposed(editor)) {
Disposer.dispose(editor);
}
}
}
private static class TopBottomPanel extends JPanel {
@@ -719,6 +719,12 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Projec
providers = newSelectedComposite.getProviders();
}
else {
if (UISettings.getInstance().EDITOR_TAB_PLACEMENT == UISettings.TABS_NONE) {
for (EditorWithProviderComposite composite : window.getEditors()) {
Disposer.dispose(composite);
}
}
// File is not opened yet. In this case we have to create editors
// and select the created EditorComposite.
final FileEditorProviderManager editorProviderManager = FileEditorProviderManager.getInstance();
@@ -15,6 +15,7 @@
*/
package com.intellij.openapi.vfs.impl.win32;
import com.intellij.openapi.util.io.FileAttributes;
import com.intellij.openapi.util.io.win32.FileInfo;
import com.intellij.openapi.util.io.win32.IdeaWin32;
import com.intellij.openapi.vfs.VirtualFile;
@@ -34,19 +35,19 @@ import java.util.Map;
*/
class Win32FsCache {
private final IdeaWin32 myKernel = IdeaWin32.getInstance();
private Reference<Map<String, FileInfo>> myCache;
private Reference<Map<String, FileAttributes>> myCache;
void clearCache() {
myCache = null;
}
@NotNull
private Map<String, FileInfo> getMap() {
Reference<Map<String, FileInfo>> cache = myCache;
Map<String, FileInfo> map = cache == null ? null : cache.get();
private Map<String, FileAttributes> getMap() {
Reference<Map<String, FileAttributes>> cache = myCache;
Map<String, FileAttributes> map = cache == null ? null : cache.get();
if (map == null) {
map = new THashMap<String, FileInfo>();
myCache = new SoftReference<Map<String, FileInfo>>(map);
map = new THashMap<String, FileAttributes>();
myCache = new SoftReference<Map<String, FileAttributes>>(map);
}
return map;
}
@@ -60,10 +61,10 @@ class Win32FsCache {
if (!path.endsWith("/")) path += "/";
List<String> names = new ArrayList<String>(fileInfo.length);
Map<String, FileInfo> map = getMap();
Map<String, FileAttributes> map = getMap();
for (FileInfo info : fileInfo) {
String name = info.getName();
map.put(path + name, info);
map.put(path + name, info.toFileAttributes());
names.add(name);
}
@@ -71,17 +72,18 @@ class Win32FsCache {
}
@Nullable
FileInfo getInfo(@NotNull VirtualFile file) {
FileAttributes getAttributes(@NotNull VirtualFile file) {
String path = file.getPath();
Map<String, FileInfo> map = getMap();
FileInfo info = map.get(path);
if (info == null) {
info = myKernel.getInfo(path);
Map<String, FileAttributes> map = getMap();
FileAttributes attributes = map.get(path);
if (attributes == null) {
FileInfo info = myKernel.getInfo(path);
if (info == null) {
return null;
}
map.put(path, info);
attributes = info.toFileAttributes();
map.put(path, attributes);
}
return info;
return attributes;
}
}
@@ -16,7 +16,6 @@
package com.intellij.openapi.vfs.impl.win32;
import com.intellij.openapi.util.io.FileAttributes;
import com.intellij.openapi.util.io.win32.FileInfo;
import com.intellij.openapi.util.io.win32.IdeaWin32;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.impl.local.LocalFileSystemBase;
@@ -60,8 +59,7 @@ public class Win32LocalFileSystem extends LocalFileSystemBase {
@Override
public FileAttributes getAttributes(@NotNull VirtualFile file) {
final FileInfo fileInfo = myFsCache.getInfo(file);
return fileInfo != null ? fileInfo.toFileAttributes() : null;
return myFsCache.getAttributes(file);
}
@NotNull
@@ -36,7 +36,7 @@ import java.util.Collection;
import java.util.Collections;
public class VirtualFileImpl extends VirtualFileSystemEntry {
public VirtualFileImpl(String name, VirtualDirectoryImpl parent, int id, @PersistentFS.Attributes final int attributes) {
VirtualFileImpl(String name, VirtualDirectoryImpl parent, int id, @PersistentFS.Attributes final int attributes) {
super(name, parent, id, attributes);
}
@@ -271,3 +271,5 @@ diagrams.rendering.no.cache=true
wolf.the.problem.solver=true
ui.no.bangs.and.whistles=false
disable.graph.inference=false
comment.by.line.bulk.lines.trigger=100
@@ -371,7 +371,7 @@ public class VfsUtilTest extends PlatformLangTestCase {
}
}.execute().throwException();
}
final VirtualFile theChild = vDir.getChildren()[5111];
final VirtualFile theChild = vDir.findChild("5111.txt");
PlatformTestUtil.startPerformanceTest("find child is slow", 450, new ThrowableRunnable() {
@Override
@@ -273,6 +273,9 @@ public class VirtualFilePointerTest extends PlatformLangTestCase {
jarParent.mkdir();
FileUtil.copy(originalJar, jar);
assert jar.exists();
assert jarParent.exists();
assert jarParent.getParentFile().exists();
refreshVFS();
@@ -330,6 +333,7 @@ public class VirtualFilePointerTest extends PlatformLangTestCase {
jarParent.mkdir();
FileUtil.copy(originalJar, jar);
assert jar.exists();
refreshVFS();
@@ -26,6 +26,8 @@ import java.util.*;
* @author max
*/
public class Stack<T> extends ArrayList<T> {
public Stack() { }
public Stack(int initialCapacity) {
super(initialCapacity);
}
@@ -136,7 +136,7 @@ public class JDOMUtil {
@SuppressWarnings({"unchecked"})
@NotNull
public static Object[] getChildNodesWithAttrs(final Element e) {
public static Object[] getChildNodesWithAttrs(@NotNull Element e) {
ArrayList<Object> result = new ArrayList<Object>();
result.addAll(e.getContent());
result.addAll(e.getAttributes());
@@ -801,6 +801,22 @@ public class StringUtil extends StringUtilRt {
return testee.startsWith(firstPrefix) && testee.regionMatches(l1, secondPrefix, 0, l2);
}
/**
* Equivalent to testee.startsWith(firstPrefix + secondPrefix + thirdPrefix) but avoids creating an object for concatenation.
*/
public static boolean startsWithConcatenationOf(@NotNull String testee,
@NotNull String firstPrefix,
@NotNull String secondPrefix,
@NotNull String thirdPrefix) {
int l1 = firstPrefix.length();
int l2 = secondPrefix.length();
int l3 = thirdPrefix.length();
if (testee.length() < l1 + l2 + l3) return false;
return testee.startsWith(firstPrefix)
&& testee.regionMatches(l1, secondPrefix, 0, l2)
&& testee.regionMatches(l1 + l2, thirdPrefix, 0, l3);
}
@NotNull
public static String trimEnd(@NotNull String s, @NonNls @NotNull String suffix) {
if (s.endsWith(suffix)) {
@@ -114,6 +114,14 @@ public class ArrayUtil extends ArrayUtilRt {
array[array.length - 1] = value;
return array;
}
@NotNull
public static int[] insert(@NotNull int[] array, int index, int value) {
int[] result = new int[array.length + 1];
System.arraycopy(array, 0, result, 0, index);
result[index] = value;
System.arraycopy(array, index, result, index+1, array.length - index);
return result;
}
@NotNull
public static byte[] append(@NotNull byte[] array, byte value) {
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.JDOMUtil;
import com.intellij.util.xmlb.annotations.AbstractCollection;
import org.jdom.Content;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -130,7 +131,7 @@ abstract class AbstractCollectionBinding implements Binding {
}
}
public Object deserialize(Object o, Object... nodes) {
public Object deserialize(Object o, @NotNull Object... nodes) {
Collection result;
if (getTagName(o) != null) {
@@ -16,6 +16,7 @@
package com.intellij.util.xmlb;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class AccessorBindingWrapper implements Binding {
@@ -33,7 +34,7 @@ class AccessorBindingWrapper implements Binding {
}
@Nullable
public Object deserialize(Object context, Object... nodes) {
public Object deserialize(Object context, @NotNull Object... nodes) {
myAccessor.write(context, myBinding.deserialize(myAccessor.read(context), nodes));
return context;
}
@@ -19,6 +19,7 @@ package com.intellij.util.xmlb;
import com.intellij.util.xmlb.annotations.Attribute;
import org.jdom.Content;
import org.jdom.Text;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class AttributeBinding implements Binding {
@@ -39,7 +40,7 @@ public class AttributeBinding implements Binding {
}
@Nullable
public Object deserialize(Object context, Object... nodes) {
public Object deserialize(Object context, @NotNull Object... nodes) {
assert nodes.length == 1;
Object node = nodes[0];
assert isBoundTo(node);
@@ -60,6 +60,7 @@ class BeanBinding implements Binding {
assert !StringUtil.isEmptyOrSpaces(myTagName) : "Bean name is empty: " + beanClass;
}
@Override
public void init() {
initPropertyBindings(myBeanClass);
}
@@ -72,6 +73,7 @@ class BeanBinding implements Binding {
}
}
@Override
public Object serialize(Object o, Object context, SerializationFilter filter) {
Element element = new Element(myTagName);
@@ -112,15 +114,16 @@ class BeanBinding implements Binding {
}
}
public void deserializeInto(final Object bean, final Element element) {
public void deserializeInto(final Object bean, @NotNull Element element) {
_deserializeInto(bean, element);
}
public Object deserialize(Object o, Object... nodes) {
@Override
public Object deserialize(Object o, @NotNull Object... nodes) {
return _deserializeInto(instantiateBean(), nodes);
}
private Object _deserializeInto(final Object result, final Object... aNodes) {
private Object _deserializeInto(final Object result, @NotNull Object... aNodes) {
List<Object> nodes = new ArrayList<Object>();
for (Object aNode : aNodes) {
if (XmlSerializerImpl.isIgnoredNode(aNode)) continue;
@@ -181,10 +184,12 @@ class BeanBinding implements Binding {
return result;
}
@Override
public boolean isBoundTo(Object node) {
return node instanceof Element && ((Element)node).getName().equals(myTagName);
}
@Override
public Class getBoundNodeType() {
return Element.class;
}
@@ -15,13 +15,14 @@
*/
package com.intellij.util.xmlb;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
interface Binding {
Object serialize(Object o, @Nullable Object context, SerializationFilter filter);
@Nullable
Object deserialize(Object context, Object... nodes);
Object deserialize(Object context, @NotNull Object... nodes);
boolean isBoundTo(Object node);
@@ -18,6 +18,7 @@ package com.intellij.util.xmlb;
import com.intellij.util.xmlb.annotations.Tag;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -57,7 +58,7 @@ class JDOMElementBinding implements Binding {
}
@Nullable
public Object deserialize(Object context, Object... nodes) {
public Object deserialize(Object context, @NotNull Object... nodes) {
Element[] result = new Element[nodes.length];
System.arraycopy(nodes, 0, result, 0, nodes.length);
@@ -23,6 +23,7 @@ import org.jdom.Attribute;
import org.jdom.Content;
import org.jdom.Element;
import org.jdom.Text;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -134,7 +135,7 @@ class MapBinding implements Binding {
return myMapAnnotation == null ? KEY : myMapAnnotation.keyAttributeName();
}
public Object deserialize(Object o, Object... nodes) {
public Object deserialize(Object o, @NotNull Object... nodes) {
Map map = (Map)o;
map.clear();
@@ -25,6 +25,7 @@ import org.jdom.Content;
import org.jdom.Element;
import org.jdom.Text;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@@ -80,7 +81,7 @@ class OptionTagBinding implements Binding {
return targetElement;
}
public Object deserialize(Object o, Object... nodes) {
public Object deserialize(Object o, @NotNull Object... nodes) {
if (nodes.length > 1) {
LOG.info("Duplicate options for " + o + " will be ignored");
}
@@ -18,6 +18,7 @@ package com.intellij.util.xmlb;
import com.intellij.openapi.util.JDOMUtil;
import org.jdom.Text;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class PrimitiveValueBinding implements Binding {
@@ -33,7 +34,7 @@ class PrimitiveValueBinding implements Binding {
}
@Nullable
public Object deserialize(Object o, Object... nodes) {
public Object deserialize(Object o, @NotNull Object... nodes) {
assert nodes != null;
if (nodes.length == 0) {
@@ -22,6 +22,7 @@ import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.xmlb.annotations.Tag;
import org.jdom.Element;
import org.jdom.Text;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -53,7 +54,7 @@ class TagBinding implements Binding {
return v;
}
public Object deserialize(Object o, Object... nodes) {
public Object deserialize(Object o, @NotNull Object... nodes) {
assert nodes.length > 0;
Object[] children;
if (nodes.length == 1) {
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.JDOMUtil;
import org.jdom.Content;
import org.jdom.Element;
import org.jdom.Text;
import org.jetbrains.annotations.NotNull;
//todo: merge with option tag binding
class TagBindingWrapper implements Binding {
@@ -51,7 +52,7 @@ class TagBindingWrapper implements Binding {
return e;
}
public Object deserialize(Object context, Object... nodes) {
public Object deserialize(Object context, @NotNull Object... nodes) {
assert nodes.length == 1;
Element e = (Element)nodes[0];
@@ -18,6 +18,7 @@ package com.intellij.util.xmlb;
import org.jdom.Content;
import org.jdom.Text;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class TextBinding implements Binding {
@@ -36,7 +37,7 @@ public class TextBinding implements Binding {
}
@Nullable
public Object deserialize(Object context, Object... nodes) {
public Object deserialize(Object context, @NotNull Object... nodes) {
assert nodes.length == 1;
Object node = nodes[0];
assert isBoundTo(node);
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.JDOMUtil;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
@@ -28,6 +29,7 @@ import java.net.URL;
public class XmlSerializer {
private static final SerializationFilter TRUE_FILTER = new SerializationFilter() {
@Override
public boolean accepts(Accessor accessor, Object bean) {
return true;
}
@@ -54,8 +56,7 @@ public class XmlSerializer {
@SuppressWarnings({"unchecked"})
public static <T> T deserialize(Element element, Class<T> aClass) throws XmlSerializationException {
try {
XmlSerializerImpl serializer = new XmlSerializerImpl(TRUE_FILTER);
return (T)serializer.getBinding(aClass).deserialize(null, element);
return (T)XmlSerializerImpl.getBinding(aClass).deserialize(null, element);
}
catch (XmlSerializationException e) {
throw e;
@@ -91,10 +92,9 @@ public class XmlSerializer {
}
}
public static void deserializeInto(final Object bean, final Element element) {
public static void deserializeInto(@NotNull Object bean, @NotNull Element element) {
try {
XmlSerializerImpl serializer = new XmlSerializerImpl(TRUE_FILTER);
final Binding binding = serializer.getBinding(bean.getClass());
final Binding binding = XmlSerializerImpl.getBinding(bean.getClass());
assert binding instanceof BeanBinding;
((BeanBinding)binding).deserializeInto(bean, element);
@@ -116,8 +116,7 @@ public class XmlSerializer {
filter = TRUE_FILTER;
}
try {
XmlSerializerImpl serializer = new XmlSerializerImpl(filter);
final Binding binding = serializer.getBinding(bean.getClass());
final Binding binding = XmlSerializerImpl.getBinding(bean.getClass());
assert binding instanceof BeanBinding;
((BeanBinding)binding).serializeInto(bean, element, filter);
@@ -61,7 +61,7 @@ class XmlSerializerImpl {
if (type instanceof Class) {
return _getClassBinding((Class<?>)type, type, accessor);
}
else if (type instanceof ParameterizedType) {
if (type instanceof ParameterizedType) {
ParameterizedType parameterizedType = (ParameterizedType)type;
Type rawType = parameterizedType.getRawType();
assert rawType instanceof Class;
@@ -154,7 +154,7 @@ class XmlSerializerImpl {
}
public static boolean isIgnoredNode(final Object child) {
if (child instanceof Text && ((Text)child).getValue().trim().length() == 0) {
if (child instanceof Text && ((Text)child).getValue().trim().isEmpty()) {
return true;
}
if (child instanceof Comment) {
@@ -163,7 +163,7 @@ class XmlSerializerImpl {
if (child instanceof Attribute) {
Attribute attr = (Attribute)child;
final String namespaceURI = attr.getNamespaceURI();
if (namespaceURI != null && namespaceURI.length() > 0) return true;
if (namespaceURI != null && !namespaceURI.isEmpty()) return true;
}
return false;
@@ -140,9 +140,9 @@ public class MavenArtifact implements Serializable {
return getRelativePathForExtraArtifact(null, null);
}
public String getFileNameWithBaseVersion() {
public String getFileNameWithBaseVersion(@Nullable String extraArtifactClassifier, @Nullable String customExtension) {
StringBuilder res = new StringBuilder();
appendFileName(res, null, null);
appendFileName(res, extraArtifactClassifier, customExtension);
return res.toString();
}
@@ -166,7 +166,7 @@ public class MavenArtifact implements Serializable {
result.append('/');
result.append(myArtifactId);
result.append('/');
result.append(myVersion);
result.append(myBaseVersion);
result.append('/');
appendFileName(result, extraArtifactClassifier, customExtension);
@@ -334,8 +334,17 @@ public class MavenRootModelAdapter {
library.addRoot(newUrl, type);
}
private static boolean isRepositoryUrl(MavenArtifact artifact, String url, String classifier, String extension) {
return url.endsWith(artifact.getRelativePathForExtraArtifact(classifier, extension) + JarFileSystem.JAR_SEPARATOR);
private static boolean isRepositoryUrl(MavenArtifact artifact, String url, @Nullable String classifier, @Nullable String extension) {
if (!url.contains(artifact.getGroupId() + '/' + artifact.getArtifactId() + '/' + artifact.getBaseVersion() + '/' + artifact.getArtifactId() + '-')) {
return false;
}
String fileName = artifact.getFileNameWithBaseVersion(classifier, extension);
assert StringUtil.startsWithConcatenationOf(fileName, artifact.getArtifactId(), "-", artifact.getVersion());
String suffix = fileName.substring(artifact.getArtifactId().length() + 1 + artifact.getVersion().length());
return StringUtil.trimEnd(url, "!/").endsWith(suffix);
}
public static boolean isChangedByUser(Library library) {
@@ -94,9 +94,10 @@ public class MicrodataAttributeDescriptorsProvider implements XmlAttributeDescri
private static class MicrodataPropertyAttributeDescriptor extends AnyXmlAttributeDescriptor {
@NotNull
private final XmlTag myContext;
public MicrodataPropertyAttributeDescriptor(XmlTag context) {
public MicrodataPropertyAttributeDescriptor(@NotNull XmlTag context) {
super(ITEM_PROP);
myContext = context;
}
@@ -114,7 +115,7 @@ public class MicrodataAttributeDescriptorsProvider implements XmlAttributeDescri
@Override
public String[] getEnumeratedValues() {
final XmlTag scopeParent = findScopeTag(myContext);
final XmlTag scopeParent = findScopeTag(myContext.getParentTag());
return scopeParent != null ? findProperties(scopeParent) : super.getEnumeratedValues();
}
@@ -151,4 +151,25 @@ public class MicrodataCompletionTest extends CodeInsightFixtureTestCase {
"name", "nickname", "photo", "title", "role", "url", "affiliation", "friend", "acquaintance", "address"
);
}
public void testPropValueNestedScopes() throws Throwable {
final VirtualFile personFile = myFixture.copyFileToProject("Person.html");
final VirtualFile addressFile = myFixture.copyFileToProject("Address.html");
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
ExternalResourceManager.getInstance().addResource("http://data-vocabulary.org/Person", personFile.getPath());
ExternalResourceManager.getInstance().addResource("http://data-vocabulary.org/Address", addressFile.getPath());
}
});
doTestInHtml("<div itemscope itemtype=\"http://data-vocabulary.org/Person\">\n" +
" My name is <span itemprop=\"name\">Smith</span>\n" +
" <span itemprop=\"<caret>\" itemscope itemtype=\"http://data-vocabulary.org/Address\">\n" +
" <span itemprop=\"locality\">Albuquerque</span>\n" +
" <span itemprop=\"region\">NM</span>\n" +
" </span>\n" +
"</div>",
"name", "nickname", "photo", "title", "role", "url", "affiliation", "friend", "acquaintance", "address"
);
}
}