Merge remote-tracking branch 'origin/master'

This commit is contained in:
andrey.zaytsev
2013-02-03 18:48:07 +04:00
144 changed files with 2359 additions and 810 deletions
@@ -1,8 +1,7 @@
<templates>
<template>
<name>Java Hello World</name>
<description><![CDATA[ Simple Java "Hello World" application. ]]>
</description>
<description><![CDATA[ Simple Java "Hello World" application. ]]></description>
<path>HelloWorld.zip</path>
</template>
</templates>
@@ -0,0 +1,13 @@
<template-groups xmlns="http://www.jetbrains.com/projectTemplates">
<group>
<name>Spring</name>
<path>Spring</path>
<template>
<name>Spring Core</name>
<description><![CDATA[ A simple console application with Spring Framework 3.2. ]]></description>
<path>SpringApp</path>
<input-field>IJ_BASE_PACKAGE</input-field>
<input-field>IJ_APPLICATION_SERVER</input-field>
</template>
</group>
</template-groups>
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.jetbrains.com/projectTemplates">
<xs:element name="template-groups" type="template-groupsType"/>
<xs:complexType name="groupType">
<xs:sequence>
<xs:element type="xs:string" name="name"/>
<xs:element type="xs:string" name="path"/>
<xs:element type="templateType" name="template"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="templateType">
<xs:sequence>
<xs:element type="xs:string" name="name"/>
<xs:element type="xs:string" name="description"/>
<xs:element type="xs:string" name="path"/>
<xs:element name="input-field" maxOccurs="unbounded" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="IJ_BASE_PACKAGE"/>
<xs:enumeration value="IJ_APPLICATION_SERVER"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="template-groupsType">
<xs:sequence>
<xs:element type="groupType" name="group"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
@@ -22,21 +22,26 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.module.ModuleType;
import com.intellij.openapi.module.ModuleTypeManager;
import com.intellij.openapi.util.ClearableLazyValue;
import com.intellij.openapi.util.JDOMUtil;
import com.intellij.openapi.util.io.StreamUtil;
import com.intellij.platform.ProjectTemplate;
import com.intellij.platform.ProjectTemplatesFactory;
import com.intellij.util.ArrayUtil;
import com.intellij.util.NullableFunction;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.net.HttpConfigurable;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.Namespace;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.util.Collection;
import java.util.List;
import java.util.zip.ZipInputStream;
@@ -47,32 +52,47 @@ import java.util.zip.ZipInputStream;
public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
private static final String URL = "http://download.jetbrains.com/idea/project_templates/";
private static final String SAMPLES_GALLERY = "Samples Gallery";
private static final Namespace NAMESPACE = Namespace.getNamespace("http://www.jetbrains.com/projectTemplates");
private final ClearableLazyValue<MultiMap<String, ProjectTemplate>> myTemplates = new ClearableLazyValue<MultiMap<String, ProjectTemplate>>() {
@NotNull
@Override
protected MultiMap<String, ProjectTemplate> compute() {
return getTemplates();
}
};
@NotNull
@Override
public String[] getGroups() {
return new String[] { "Samples Gallery"};
myTemplates.drop();
return ArrayUtil.toStringArray(myTemplates.getValue().keySet());
}
@NotNull
@Override
public ProjectTemplate[] createTemplates(String group, WizardContext context) {
Collection<ProjectTemplate> templates = myTemplates.getValue().get(group);
return templates.toArray(new ProjectTemplate[templates.size()]);
}
private static MultiMap<String, ProjectTemplate> getTemplates() {
InputStream stream = null;
HttpURLConnection connection = null;
String code = ApplicationInfo.getInstance().getBuild().getProductCode();
try {
connection = getConnection(code + "_templates.xml");
stream = connection.getInputStream();
String text = StreamUtil.readText(stream);
String text = StreamUtil.readText(stream, TemplateModuleBuilder.UTF_8);
return createFromText(text);
}
catch (IOException ex) { // timeouts, lost connection etc
LOG.info(ex);
return ProjectTemplate.EMPTY_ARRAY;
return MultiMap.emptyInstance();
}
catch (Exception e) {
LOG.error(e);
return ProjectTemplate.EMPTY_ARRAY;
return MultiMap.emptyInstance();
}
finally {
StreamUtil.closeStream(stream);
@@ -83,15 +103,32 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
}
@SuppressWarnings("unchecked")
public static ProjectTemplate[] createFromText(String text) throws IOException, JDOMException {
public static MultiMap<String, ProjectTemplate> createFromText(String text) throws IOException, JDOMException {
List<Element> elements = JDOMUtil.loadDocument(text).getRootElement().getChildren("template");
Element rootElement = JDOMUtil.loadDocument(text).getRootElement();
List<Element> groups = rootElement.getChildren("group", NAMESPACE);
MultiMap<String, ProjectTemplate> map = new MultiMap<String, ProjectTemplate>();
if (groups.isEmpty()) { // sample gallery by default
map.put(SAMPLES_GALLERY, createGroupTemplates(rootElement, Namespace.NO_NAMESPACE));
}
else {
for (Element group : groups) {
map.put(group.getChildText("name", NAMESPACE), createGroupTemplates(group, NAMESPACE));
}
}
List<ProjectTemplate> templates = ContainerUtil.mapNotNull(elements, new NullableFunction<Element, ProjectTemplate>() {
return map;
}
@SuppressWarnings("unchecked")
private static List<ProjectTemplate> createGroupTemplates(Element groupElement, final Namespace ns) {
List<Element> elements = groupElement.getChildren("template", ns);
return ContainerUtil.mapNotNull(elements, new NullableFunction<Element, ProjectTemplate>() {
@Override
public ProjectTemplate fun(final Element element) {
List<Element> plugins = element.getChildren("requiredPlugin");
List<Element> plugins = element.getChildren("requiredPlugin", ns);
for (Element plugin : plugins) {
String id = plugin.getTextTrim();
if (!PluginManager.isPluginInstalled(PluginId.getId(id))) {
@@ -100,7 +137,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
}
String type = element.getChildText("moduleType");
final ModuleType moduleType = ModuleTypeManager.getInstance().findByID(type);
return new ArchivedProjectTemplate(element.getChildTextTrim("name")) {
return new ArchivedProjectTemplate(element.getChildTextTrim("name", ns)) {
@Override
protected ModuleType getModuleType() {
return moduleType;
@@ -108,7 +145,7 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
@Override
public ZipInputStream getStream() throws IOException {
String path = element.getChildText("path");
String path = element.getChildText("path", ns);
final HttpURLConnection connection = getConnection(path);
return new ZipInputStream(connection.getInputStream()) {
@Override
@@ -122,12 +159,11 @@ public class RemoteTemplatesFactory extends ProjectTemplatesFactory {
@Nullable
@Override
public String getDescription() {
return element.getChildTextTrim("description");
return element.getChildTextTrim("description", ns);
}
};
}
});
return templates.toArray(new ProjectTemplate[templates.size()]);
}
private static HttpURLConnection getConnection(String path) throws IOException {
@@ -59,10 +59,7 @@ public class JavaCompletionSorting {
final boolean afterNew = JavaSmartCompletionContributor.AFTER_NEW.accepts(position);
List<LookupElementWeigher> afterPriority = new ArrayList<LookupElementWeigher>();
if (!smart) {
ContainerUtil.addIfNotNull(afterPriority, preferStatics(position, expectedTypes));
}
else {
if (smart) {
afterPriority.add(new PreferDefaultTypeWeigher(expectedTypes, parameters));
}
ContainerUtil.addIfNotNull(afterPriority, recursion(parameters, expectedTypes));
@@ -83,13 +80,13 @@ public class JavaCompletionSorting {
}
List<LookupElementWeigher> afterPrefix = ContainerUtil.newArrayList();
if (smart) {
afterPriority.add(new PreferByKindWeigher(type, position, true));
if (!smart) {
ContainerUtil.addIfNotNull(afterPrefix, preferStatics(position, expectedTypes));
}
if (!smart && !afterNew) {
afterPrefix.add(new PreferExpected(false, expectedTypes));
}
afterPrefix.add(new PreferByKindWeigher(type, position, false));
afterPrefix.add(new PreferByKindWeigher(type, position));
Collections.addAll(afterPrefix, new PreferNonGeneric(), new PreferAccessible(position), new PreferSimple(),
new PreferEnumConstants(parameters));
@@ -132,7 +129,9 @@ public class JavaCompletionSorting {
public Comparable weigh(@NotNull LookupElement element) {
final Object o = element.getObject();
if (o instanceof PsiKeyword) return -3;
if (!(o instanceof PsiMember)) return 0;
if (!(o instanceof PsiMember) || element.getUserData(JavaOverrideCompletionContributor.OVERRIDE_ELEMENT) != null) {
return 0;
}
if (((PsiMember)o).hasModifierProperty(PsiModifier.STATIC) && !hasNonVoid(infos)) {
if (o instanceof PsiMethod) return -5;
@@ -405,7 +404,7 @@ public class JavaCompletionSorting {
public Comparable weigh(@NotNull LookupElement element) {
final PsiTypeLookupItem lookupItem = element.as(PsiTypeLookupItem.CLASS_CONDITION_KEY);
if (lookupItem != null) {
return lookupItem.getBracketsCount();
return lookupItem.getBracketsCount() * 10 + (lookupItem.isAddArrayInitializer() ? 1 : 0);
}
if (element.as(CastingLookupElementDecorator.CLASS_CONDITION_KEY) != null) {
return 239;
@@ -50,6 +50,14 @@ public class JavaInheritorsGetter extends CompletionProvider<CompletionParameter
myConstructorInsertHandler = constructorInsertHandler;
}
private static boolean shouldAddArrayInitializer(PsiElement position) {
if (!JavaCompletionContributor.isInJavaContext(position) || !JavaSmartCompletionContributor.AFTER_NEW.accepts(position)) {
return false;
}
PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(position, PsiNewExpression.class);
return newExpression != null && newExpression.getParent() instanceof PsiExpressionList;
}
@Override
public void addCompletions(@NotNull final CompletionParameters parameters, final ProcessingContext matchingContext, @NotNull final CompletionResultSet result) {
final ExpectedTypeInfo[] infos = JavaSmartCompletionContributor.getExpectedTypes(parameters);
@@ -88,16 +96,26 @@ public class JavaInheritorsGetter extends CompletionProvider<CompletionParameter
for (final PsiType type : ExpectedTypesGetter.extractTypes(infos, true)) {
if (type instanceof PsiArrayType) {
final LookupItem item = PsiTypeLookupItem.createLookupItem(TypeConversionUtil.erasure(type), identifierCopy);
if (item.getObject() instanceof PsiClass) {
JavaCompletionUtil.setShowFQN(item);
consumer.consume(createNewArrayItem(identifierCopy, type));
if (shouldAddArrayInitializer(identifierCopy)) {
PsiTypeLookupItem item = createNewArrayItem(identifierCopy, type);
item.setAddArrayInitializer();
consumer.consume(item);
}
item.setInsertHandler(new DefaultInsertHandler()); //braces & shortening
consumer.consume(item);
}
}
}
private static PsiTypeLookupItem createNewArrayItem(PsiElement identifierCopy, PsiType type) {
PsiTypeLookupItem item = PsiTypeLookupItem.createLookupItem(TypeConversionUtil.erasure(type), identifierCopy);
if (item.getObject() instanceof PsiClass) {
JavaCompletionUtil.setShowFQN(item);
}
item.setInsertHandler(new DefaultInsertHandler()); //braces & shortening
return item;
}
private static List<PsiClassType> extractClassTypes(ExpectedTypeInfo[] infos) {
final List<PsiClassType> expectedClassTypes = new SmartList<PsiClassType>();
for (PsiType type : ExpectedTypesGetter.extractTypes(infos, true)) {
@@ -0,0 +1,123 @@
/*
* Copyright 2000-2013 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.codeInsight.completion;
import com.intellij.codeInsight.generation.GenerateMembersUtil;
import com.intellij.codeInsight.generation.OverrideImplementExploreUtil;
import com.intellij.codeInsight.generation.OverrideImplementUtil;
import com.intellij.codeInsight.generation.PsiGenerationInfo;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementBuilder;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.util.Key;
import com.intellij.psi.*;
import com.intellij.psi.infos.CandidateInfo;
import com.intellij.psi.util.PsiFormatUtil;
import com.intellij.psi.util.PsiFormatUtilBase;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.ui.RowIcon;
import com.intellij.util.Consumer;
import java.util.List;
import static com.intellij.patterns.PlatformPatterns.psiElement;
/**
* @author peter
*/
public class JavaOverrideCompletionContributor extends CompletionContributor {
static final Key<Boolean> OVERRIDE_ELEMENT = Key.create("OVERRIDE_ELEMENT");
@Override
public void fillCompletionVariants(CompletionParameters parameters, CompletionResultSet _result) {
if (parameters.getCompletionType() != CompletionType.BASIC && parameters.getCompletionType() != CompletionType.SMART) {
return;
}
PsiElement position = parameters.getPosition();
if (psiElement(PsiIdentifier.class).withParents(PsiJavaCodeReferenceElement.class, PsiTypeElement.class, PsiClass.class).
andNot(JavaCompletionData.AFTER_DOT).
andNot(psiElement().afterLeaf(psiElement().inside(PsiModifierList.class))).accepts(position)) {
final PsiClass parent = CompletionUtil.getOriginalElement((PsiClass)position.getParent().getParent().getParent());
if (parent != null) {
CompletionResultSet result = JavaCompletionSorting.addJavaSorting(parameters, _result);
addSuperSignatureElements(parent, true, result);
addSuperSignatureElements(parent, false, result);
}
}
}
private static void addSuperSignatureElements(final PsiClass parent, boolean implemented, CompletionResultSet result) {
for (CandidateInfo candidate : OverrideImplementExploreUtil.getMethodsToOverrideImplement(parent, implemented)) {
PsiMethod baseMethod = (PsiMethod)candidate.getElement();
if (!baseMethod.isConstructor()) {
PsiClass baseClass = baseMethod.getContainingClass();
List<PsiMethod> prototypes = OverrideImplementUtil.overrideOrImplementMethod(parent, baseMethod, candidate.getSubstitutor(), new Consumer<PsiMethod>() {
@Override
public void consume(PsiMethod method) {
OverrideImplementUtil.deleteDocComment(method);
}
});
if (!prototypes.isEmpty() && baseClass != null) {
result.addElement(createOverridingLookupElement(parent, implemented, baseMethod, baseClass, prototypes.get(0)));
}
}
}
}
private static LookupElementBuilder createOverridingLookupElement(final PsiClass parent,
boolean implemented,
final PsiMethod baseMethod,
PsiClass baseClass, final PsiMethod prototype) {
PsiIdentifier nameIdentifier = prototype.getNameIdentifier();
assert nameIdentifier != null;
String signature = prototype.getModifierList().getText();
if (!signature.isEmpty()) {
signature += " ";
}
PsiType returnType = prototype.getReturnType();
signature += TypeConversionUtil.erasure(returnType).getPresentableText() + " " + prototype.getName();
String parameters = PsiFormatUtil.formatMethod(prototype, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_NAME);
InsertHandler<LookupElement> insertHandler = new InsertHandler<LookupElement>() {
@Override
public void handleInsert(InsertionContext context, LookupElement item) {
context.getDocument().deleteString(context.getStartOffset(), context.getTailOffset());
context.commitDocument();
List<PsiMethod> prototypes = OverrideImplementUtil.overrideOrImplementMethod(parent, baseMethod, false);
List<PsiGenerationInfo<PsiMethod>> infos = OverrideImplementUtil.convert2GenerationInfos(prototypes);
List<PsiGenerationInfo<PsiMethod>> newInfos = GenerateMembersUtil.insertMembersAtOffset(context.getFile(), context.getStartOffset(), infos);
if (!newInfos.isEmpty()) {
newInfos.get(0).positionCaret(context.getEditor(), true);
}
}
};
RowIcon icon = new RowIcon(2);
icon.setIcon(baseMethod.getIcon(0), 0);
icon.setIcon(implemented ? AllIcons.Gutter.ImplementingMethod : AllIcons.Gutter.OverridingMethod, 1);
LookupElementBuilder element = LookupElementBuilder.create(baseMethod, signature).withLookupString(prototype.getName()).
withLookupString(signature).withInsertHandler(insertHandler).
appendTailText(parameters, false).appendTailText(" {...}", true).withTypeText(baseClass.getName()).withIcon(icon);
element.putUserData(OVERRIDE_ELEMENT, true);
return element;
}
}
@@ -155,9 +155,12 @@ public class JavaPsiClassReferenceElement extends LookupItem<Object> {
String tailText = StringUtil.notNullize((String) item.getAttribute(LookupItem.TAIL_TEXT_ATTR));
PsiSubstitutor substitutor = (PsiSubstitutor)item.getAttribute(LookupItem.SUBSTITUTOR);
if (item instanceof PsiTypeLookupItem && ((PsiTypeLookupItem)item).isIndicateAnonymous() &&
(psiClass.isInterface() || psiClass.hasModifierProperty(PsiModifier.ABSTRACT))) {
tailText = "{...}" + tailText;
if (item instanceof PsiTypeLookupItem) {
if (((PsiTypeLookupItem)item).isIndicateAnonymous() &&
(psiClass.isInterface() || psiClass.hasModifierProperty(PsiModifier.ABSTRACT)) ||
((PsiTypeLookupItem)item).isAddArrayInitializer()) {
tailText = "{...}" + tailText;
}
}
if (substitutor == null && !diamond && psiClass.getTypeParameters().length > 0) {
tailText = "<" + StringUtil.join(psiClass.getTypeParameters(), new Function<PsiTypeParameter, String>() {
@@ -46,7 +46,8 @@ public class PreferByKindWeigher extends LookupElementWeigher {
psiElement(PsiVariable.class).withParent(PsiCatchSection.class)))));
static final ElementPattern<PsiElement> IN_MULTI_CATCH_TYPE =
or(psiElement().afterLeaf(psiElement().withText("|").withParent(PsiTypeElement.class).withSuperParent(2, PsiCatchSection.class)),
psiElement().afterLeaf(psiElement().withText("|").withParent(PsiTypeElement.class).withSuperParent(2, PsiParameter.class).withSuperParent(3, PsiCatchSection.class)));
psiElement().afterLeaf(psiElement().withText("|").withParent(PsiTypeElement.class).withSuperParent(2, PsiParameter.class)
.withSuperParent(3, PsiCatchSection.class)));
static final ElementPattern<PsiElement> INSIDE_METHOD_THROWS_CLAUSE =
psiElement().afterLeaf(PsiKeyword.THROWS, ",").inside(psiElement(JavaElementType.THROWS_LIST));
static final ElementPattern<PsiElement> IN_RESOURCE_TYPE =
@@ -55,15 +56,13 @@ public class PreferByKindWeigher extends LookupElementWeigher {
withParent(or(psiElement(PsiResourceVariable.class), psiElement(PsiResourceList.class)))));
private final CompletionType myCompletionType;
private final PsiElement myPosition;
private final boolean myLocal;
private final Set<PsiField> myNonInitializedFields;
@NotNull private final Condition<PsiClass> myRequiredSuper;
public PreferByKindWeigher(CompletionType completionType, final PsiElement position, boolean local) {
super("kind" + (local ? "Local" : "Global"));
public PreferByKindWeigher(CompletionType completionType, final PsiElement position) {
super("kind");
myCompletionType = completionType;
myPosition = position;
myLocal = local;
myNonInitializedFields = JavaCompletionProcessor.getNonInitializedFields(position);
myRequiredSuper = createSuitabilityCondition(position);
}
@@ -155,10 +154,6 @@ public class PreferByKindWeigher extends LookupElementWeigher {
}
}
if (myLocal) {
return MyResult.normal;
}
if (object instanceof String && item.getUserData(JavaCompletionUtil.SUPER_METHOD_PARAMETERS) == Boolean.TRUE) {
return MyResult.superMethodParameters;
}
@@ -282,10 +282,14 @@ public class HighlightClassUtil {
PsiElement file = aClass.getParent();
if (file instanceof PsiJavaFile && !((PsiJavaFile)file).getPackageName().isEmpty()) {
PsiElement directory = file.getParent();
if (directory instanceof PsiDirectory && ((PsiDirectory)directory).findSubdirectory(aClass.getName()) != null) {
String message = JavaErrorMessages.message("class.clashes.with.package", name);
TextRange range = HighlightNamesUtil.getClassDeclarationTextRange(aClass);
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, range, message);
if (directory instanceof PsiDirectory) {
String simpleName = aClass.getName();
PsiDirectory subDirectory = ((PsiDirectory)directory).findSubdirectory(simpleName);
if (subDirectory != null && simpleName.equals(subDirectory.getName())) {
String message = JavaErrorMessages.message("class.clashes.with.package", name);
TextRange range = HighlightNamesUtil.getClassDeclarationTextRange(aClass);
return HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR, range, message);
}
}
}
@@ -691,7 +695,7 @@ public class HighlightClassUtil {
IntentionAction fix = QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, false, false);
QuickFixAction.registerQuickFixAction(info, fix);
}
} else if (aClass instanceof PsiAnonymousClass) {
final PsiClass baseClass = PsiUtil.resolveClassInType(((PsiAnonymousClass)aClass).getBaseClassType());
if (baseClass != null && baseClass.isInterface()) {
@@ -982,7 +986,7 @@ public class HighlightClassUtil {
PsiNewExpression newExpression =
(PsiNewExpression)JavaPsiFacade.getElementFactory(project).createExpressionFromText(startElement.getText() + "{}", startElement);
newExpression = (PsiNewExpression)startElement.replace(newExpression);
final PsiClass psiClass = newExpression.getAnonymousClass();
final PsiClass psiClass = newExpression.getAnonymousClass();
if (psiClass == null) return;
PsiClassType baseClassType = ((PsiAnonymousClass)psiClass).getBaseClassType();
PsiClass resolve = baseClassType.resolve();
@@ -61,6 +61,7 @@ import com.intellij.psi.javadoc.PsiDocComment;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.*;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Consumer;
import com.intellij.util.Function;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.containers.ContainerUtil;
@@ -95,7 +96,7 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
* @return list of method prototypes
*/
@NotNull
public static Collection<PsiMethod> overrideOrImplementMethod(PsiClass aClass, PsiMethod method, boolean toCopyJavaDoc) throws IncorrectOperationException {
public static List<PsiMethod> overrideOrImplementMethod(PsiClass aClass, PsiMethod method, boolean toCopyJavaDoc) throws IncorrectOperationException {
final PsiClass containingClass = method.getContainingClass();
LOG.assertTrue(containingClass != null);
PsiSubstitutor substitutor = aClass.isInheritor(containingClass, true)
@@ -126,11 +127,18 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
}
@NotNull
private static Collection<PsiMethod> overrideOrImplementMethod(PsiClass aClass,
private static List<PsiMethod> overrideOrImplementMethod(PsiClass aClass,
PsiMethod method,
PsiSubstitutor substitutor,
boolean toCopyJavaDoc,
boolean insertOverrideIfPossible) throws IncorrectOperationException {
return overrideOrImplementMethod(aClass, method, substitutor, createDefaultDecorator(aClass, method, toCopyJavaDoc, insertOverrideIfPossible));
}
public static List<PsiMethod> overrideOrImplementMethod(PsiClass aClass,
PsiMethod method,
PsiSubstitutor substitutor,
Consumer<PsiMethod> decorator) throws IncorrectOperationException {
if (!method.isValid() || !substitutor.isValid()) return Collections.emptyList();
List<PsiMethod> results = new ArrayList<PsiMethod>();
@@ -141,13 +149,14 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
}
else {
for (PsiMethod prototype : prototypes) {
results.add(decorateMethod(aClass, method, toCopyJavaDoc, insertOverrideIfPossible, prototype));
decorator.consume(prototype);
results.add(prototype);
}
}
}
if (results.isEmpty()) {
PsiMethod method1 = GenerateMembersUtil.substituteGenericMethod(method, substitutor, aClass);
PsiElementFactory factory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory();
PsiMethod result = (PsiMethod)factory.createClass("Dummy").add(method1);
if (PsiUtil.isAnnotationMethod(result)) {
@@ -161,7 +170,8 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
defaultValue.getParent().deleteChildRange(defaultKeyword, defaultValue);
}
}
results.add(decorateMethod(aClass, method, toCopyJavaDoc, insertOverrideIfPossible, result));
decorator.consume(result);
results.add(result);
}
for (Iterator<PsiMethod> iterator = results.iterator(); iterator.hasNext();) {
@@ -173,6 +183,18 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
return results;
}
public static Consumer<PsiMethod> createDefaultDecorator(final PsiClass aClass,
final PsiMethod method,
final boolean toCopyJavaDoc,
final boolean insertOverrideIfPossible) {
return new Consumer<PsiMethod>() {
@Override
public void consume(PsiMethod result) {
decorateMethod(aClass, method, toCopyJavaDoc, insertOverrideIfPossible, result);
}
};
}
private static PsiMethod decorateMethod(PsiClass aClass,
PsiMethod method,
boolean toCopyJavaDoc,
@@ -182,10 +204,7 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
PsiUtil.setModifierProperty(result, PsiModifier.NATIVE, false);
if (!toCopyJavaDoc){
PsiDocComment comment = result.getDocComment();
if (comment != null){
comment.delete();
}
deleteDocComment(result);
}
//method type params are not allowed when overriding from raw type
@@ -231,6 +250,13 @@ public class OverrideImplementUtil extends OverrideImplementExploreUtil {
return result;
}
public static void deleteDocComment(PsiMethod result) {
PsiDocComment comment = result.getDocComment();
if (comment != null){
comment.delete();
}
}
public static void annotateOnOverrideImplement(PsiMethod method, PsiClass targetClass, PsiMethod overridden) {
annotateOnOverrideImplement(method, targetClass, overridden,
CodeStyleSettingsManager.getSettings(method.getProject()).INSERT_OVERRIDE_ANNOTATION);
@@ -27,7 +27,6 @@ import com.intellij.psi.*;
import com.intellij.psi.impl.DebugUtil;
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
import com.intellij.psi.impl.source.PsiClassReferenceType;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.PsiUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -55,6 +54,7 @@ public class PsiTypeLookupItem extends LookupItem {
private final int myBracketsCount;
private boolean myIndicateAnonymous;
private final InsertHandler<PsiTypeLookupItem> myImportFixer;
private boolean myAddArrayInitializer;
private PsiTypeLookupItem(Object o, @NotNull @NonNls String lookupString, boolean diamond, int bracketsCount, InsertHandler<PsiTypeLookupItem> fixer) {
super(o, lookupString);
@@ -84,7 +84,17 @@ public class PsiTypeLookupItem extends LookupItem {
@Override
public boolean equals(final Object o) {
return super.equals(o) && o instanceof PsiTypeLookupItem && getBracketsCount() == ((PsiTypeLookupItem) o).getBracketsCount();
return super.equals(o) && o instanceof PsiTypeLookupItem &&
getBracketsCount() == ((PsiTypeLookupItem) o).getBracketsCount() &&
myAddArrayInitializer == ((PsiTypeLookupItem) o).myAddArrayInitializer;
}
public boolean isAddArrayInitializer() {
return myAddArrayInitializer;
}
public void setAddArrayInitializer() {
myAddArrayInitializer = true;
}
@Override
@@ -93,7 +103,6 @@ public class PsiTypeLookupItem extends LookupItem {
PsiElement position = context.getFile().findElementAt(context.getStartOffset());
assert position != null;
boolean addBraces = shouldAddBraces(position);
int genericsStart = context.getTailOffset();
context.getDocument().insertString(genericsStart, JavaCompletionUtil.escapeXmlIfNeeded(context, calcGenerics(position, context)));
JavaCompletionUtil.shortenReference(context.getFile(), genericsStart - 1);
@@ -102,7 +111,7 @@ public class PsiTypeLookupItem extends LookupItem {
String braces = StringUtil.repeat("[]", getBracketsCount());
Editor editor = context.getEditor();
if (!braces.isEmpty()) {
if (LookupEvent.isSpecialCompletionChar(context.getCompletionChar()) && addBraces) {
if (myAddArrayInitializer) {
context.getDocument().insertString(tail, braces + "{}");
editor.getCaretModel().moveToOffset(tail + braces.length() + 1);
} else {
@@ -125,14 +134,6 @@ public class PsiTypeLookupItem extends LookupItem {
}
}
private static boolean shouldAddBraces(PsiElement position) {
if (!JavaCompletionContributor.isInJavaContext(position) || !JavaSmartCompletionContributor.AFTER_NEW.accepts(position)) {
return false;
}
PsiNewExpression newExpression = PsiTreeUtil.getParentOfType(position, PsiNewExpression.class);
return newExpression != null && newExpression.getParent() instanceof PsiExpressionList;
}
public String calcGenerics(@NotNull PsiElement context, InsertionContext insertionContext) {
if (insertionContext.getCompletionChar() == '<') {
return "";
@@ -467,7 +467,7 @@ public class JavaDocInfoGenerator {
}
// not a javadoc in fact..
private void generateVariableJavaDoc(@NonNls StringBuilder buffer, PsiVariable variable, boolean generatePrologueAndEpilogue) {
private static void generateVariableJavaDoc(@NonNls StringBuilder buffer, PsiVariable variable, boolean generatePrologueAndEpilogue) {
if (generatePrologueAndEpilogue)
generatePrologue(buffer);
@@ -604,7 +604,7 @@ public class JavaDocInfoGenerator {
}
}
private void generateAnnotations (@NonNls StringBuilder buffer, PsiModifierListOwner owner) {
private static void generateAnnotations(@NonNls StringBuilder buffer, PsiModifierListOwner owner) {
final PsiModifierList ownerModifierList = owner.getModifierList();
if (ownerModifierList == null) return;
PsiAnnotation[] annotations = ownerModifierList.getAnnotations();
@@ -1861,5 +1861,10 @@ public class JavaDocInfoGenerator {
public void visitLiteralExpression(PsiLiteralExpression expression) {
myBuffer.append(expression.getText());
}
@Override
public void visitReferenceExpression(PsiReferenceExpression expression) {
myBuffer.append(expression.getText());
}
}
}
@@ -0,0 +1,7 @@
interface Foo<T> {
void run(T t, int myInt);
}
public class A implements Foo<String> {
p<caret>
}
@@ -0,0 +1,10 @@
interface Foo<T> {
void run(T t, int myInt);
}
public class A implements Foo<String> {
@Override
public void run(String s, int myInt) {
<selection>//To change body of implemented methods use File | Settings | File Templates.</selection>
}
}
@@ -1,5 +1,5 @@
class Super {
void foo(String[] params, int... indices) {
foo(new String[]{<caret>}, 0);
foo(new String[<caret>], 0);
}
}
@@ -4,6 +4,6 @@ class MyException extends RuntimeException {
class XXX {
{
throw new MyException(new String[]{<caret>});
throw new MyException(new String[<caret>]);
}
}
@@ -0,0 +1,3 @@
package pkg;
public class Sub { }
@@ -0,0 +1,3 @@
package pkg.sub;
public class Test { }
@@ -0,0 +1 @@
<html><head> <style type="text/css"> #error { background-color: #eeeeee; margin-bottom: 10px; } p { margin: 5px 0; } </style></head><body><small><b><a href="psi_element://Test"><code>Test</code></a></b></small><PRE>public int <b>field = anotherField</b></PRE></body></html>
@@ -0,0 +1,4 @@
class Test {
public int field = anotherField;
public static int anotherField = 1;
}
@@ -1316,5 +1316,20 @@ class XInternalError {}
assert lookup.items.size() == 1
}
public void testImplementViaCompletion() {
configure()
myFixture.assertPreferredCompletionItems 0, 'private', 'protected', 'public', 'public void run'
def item = lookup.items[3]
def p = LookupElementPresentation.renderElement(item)
assert p.itemText == 'public void run'
assert p.tailText == '(s, myInt) {...}'
assert p.typeText == 'Foo'
lookup.currentItem = item
myFixture.type('\n')
checkResult()
}
}
@@ -348,6 +348,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
String path = "/generics";
configureByFile(path + "/before9.java");
selectItem(myItems[1]);
checkResultByFile(path + "/after9.java");
}
@@ -421,7 +422,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
public void testArrayAccessIndex() throws Throwable { doTest(); }
public void testThrowExceptionConstructor() throws Throwable { doTest(); }
public void testThrowExceptionConstructor() throws Throwable { doTest('\n'); }
public void testJavadocThrows() throws Throwable { doTest(); }
@@ -594,16 +595,18 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
public void testNewVararg() throws Throwable {
configureByTestName();
assertStringItems("Foo", "Foo");
assertStringItems("Foo", "Foo", "Foo");
assertEquals("{...} (default package)", LookupElementPresentation.renderElement(myItems[0]).getTailText());
assertEquals("[] (default package)", LookupElementPresentation.renderElement(myItems[1]).getTailText());
assertEquals("[]{...} (default package)", LookupElementPresentation.renderElement(myItems[2]).getTailText());
}
public void testNewVararg2() throws Throwable {
configureByTestName();
assertStringItems("String", "String");
assertStringItems("String", "String", "String");
assertEquals(" (java.lang)", LookupElementPresentation.renderElement(myItems[0]).getTailText());
assertEquals("[] (java.lang)", LookupElementPresentation.renderElement(myItems[1]).getTailText());
assertEquals("[]{...} (java.lang)", LookupElementPresentation.renderElement(myItems[2]).getTailText());
}
public void testNewByteArray() {
@@ -286,16 +286,24 @@ public class AdvHighlightingTest extends DaemonAnalyzerTestCase {
doTest(BASE_PATH + "/notAKeywords/Test.java", BASE_PATH + "/notAKeywords", false, false);
}
public void testPackageAndClassConflict1() throws Exception {
doTest(BASE_PATH + "/packageClassClash/pkg/sub/Test.java", BASE_PATH + "/packageClassClash", false, false);
public void testPackageAndClassConflict11() throws Exception {
doTest(BASE_PATH + "/packageClassClash1/pkg/sub/Test.java", BASE_PATH + "/packageClassClash1", false, false);
}
public void testPackageAndClassConflict2() throws Exception {
doTest(BASE_PATH + "/packageClassClash/pkg/sub.java", BASE_PATH + "/packageClassClash", false, false);
public void testPackageAndClassConflict12() throws Exception {
doTest(BASE_PATH + "/packageClassClash1/pkg/sub.java", BASE_PATH + "/packageClassClash1", false, false);
}
public void testPackageAndClassConflict3() throws Exception {
doTest(BASE_PATH + "/packageClassClash/java/lang.java", false, false);
public void testPackageAndClassConflict21() throws Exception {
doTest(BASE_PATH + "/packageClassClash2/pkg/sub/Test.java", BASE_PATH + "/packageClassClash2", false, false);
}
public void testPackageAndClassConflict22() throws Exception {
doTest(BASE_PATH + "/packageClassClash2/pkg/Sub.java", BASE_PATH + "/packageClassClash2", false, false);
}
public void testDefaultPackageAndClassConflict() throws Exception {
doTest(BASE_PATH + "/lang.java", false, false);
}
public void testPackageObscuring() throws Exception {
@@ -58,6 +58,10 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
public void testInitializerWithNew() throws Exception {
doTestField();
}
public void testInitializerWithReference() throws Exception {
doTestField();
}
private void doTestField() throws Exception {
PsiClass psiClass = getTestClass();
@@ -80,6 +84,7 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
final File htmlPath = new File(JavaTestUtil.getJavaTestDataPath() + "/codeInsight/javadocIG/" + getTestName(true) + ".html");
String htmlText = FileUtil.loadFile(htmlPath);
String docInfo = new JavaDocInfoGenerator(getProject(), field).generateDocInfo(null);
assertNotNull(docInfo);
assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), StringUtil.convertLineSeparators(docInfo.trim()));
}
@@ -90,6 +95,7 @@ public class JavaDocInfoGeneratorTest extends CodeInsightTestCase {
final String info =
new JavaDocInfoGenerator(getProject(), JavaPsiFacade.getInstance(getProject()).findPackage(getTestName(true))).generateDocInfo(null);
String htmlText = FileUtil.loadFile(new File(packageInfo + File.separator + "packageInfo.html"));
assertNotNull(info);
assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), StringUtil.convertLineSeparators(info.trim()));
}
@@ -31,6 +31,10 @@ public class IFileElementType extends ILazyParseableElementType {
super(debugName, language);
}
public IFileElementType(@NonNls @NotNull final String debugName, @Nullable final Language language, boolean register) {
super(debugName, language, register);
}
@Nullable
@Override
public ASTNode parseContents(final ASTNode chameleon) {
@@ -56,6 +56,7 @@ public abstract class PsiElementBaseIntentionAction extends BaseIntentionAction
@Override
public final boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
if (file == null) return false;
final PsiManager manager = file.getManager();
if (manager == null) return false;
if (!manager.isInProject(file)) return false;
@@ -109,9 +109,7 @@
<component id="28a18" class="javax.swing.JTextField" binding="myAutocompletionDelayField">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="50" height="-1"/>
<preferred-size width="144" height="28"/>
<maximum-size width="50" height="-1"/>
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
@@ -137,7 +135,9 @@
</component>
<component id="a1f3b" class="javax.swing.JTextField" binding="myAutopopupJavaDocField">
<constraints>
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="9" fill="0" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<columns value="4"/>
@@ -65,7 +65,10 @@ public class CodeCompletionPanel {
new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
myAutocompletionDelayField.setEnabled(myCbAutocompletion.isSelected());
boolean selected = myCbAutocompletion.isSelected();
myAutocompletionDelayField.setEnabled(selected);
myFocusLookup.setEnabled(selected);
myCbSelectByChars.setEnabled(selected);
}
}
);
@@ -15,7 +15,10 @@
*/
package com.intellij.codeInsight.lookup.impl;
import com.intellij.codeInsight.lookup.*;
import com.intellij.codeInsight.lookup.LookupElement;
import com.intellij.codeInsight.lookup.LookupElementPresentation;
import com.intellij.codeInsight.lookup.LookupEvent;
import com.intellij.codeInsight.lookup.LookupListener;
import com.intellij.ide.ui.UISettings;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
@@ -87,6 +90,11 @@ public class CompletionPreview implements Disposable {
return;
}
final EditorImpl editor = getEditorImpl();
if (editor.getSelectionModel().hasSelection() || editor.getSelectionModel().hasBlockSelection()) {
return;
}
String text = getPreviewText(item);
int prefixLength = myLookup.getPrefixLength(item);
@@ -103,7 +111,7 @@ public class CompletionPreview implements Disposable {
prefixLength = arrayList.get(arrayList.size() - 1).getEndOffset();
}
final EditorImpl editor = getEditorImpl();
editor.setCustomImage(null);
BufferedImage previewImage = createPreviewImage(text.substring(prefixLength));
editor.setCustomImage(Pair.create(getCaretPoint(), previewImage));
@@ -389,31 +389,24 @@ public class LanguageConsoleImpl implements Disposable, TypeSafeDataProvider {
final boolean scrollToEnd = shouldScrollHistoryToEnd();
final int[] offsets = new int[attributedText.size() + 1];
int i = 0;
offsets[i] = 0;
final StringBuilder sb = new StringBuilder();
final Document history = myHistoryViewer.getDocument();
offsets[i] = history.getTextLength();
for (final Pair<String, TextAttributes> pair : attributedText) {
final String str = StringUtil.convertLineSeparators(pair.getFirst());
final int lastOffset = offsets[i];
offsets[++i] = lastOffset + str.length();
sb.append(str);
appendToHistoryDocument(history, str);
offsets[++i] = history.getTextLength();
}
LOG.debug("printToHistory(): text processed");
final Document history = myHistoryViewer.getDocument();
final MarkupModel markupModel = DocumentMarkupModel.forDocument(history, myProject, true);
final int oldHistoryLength = history.getTextLength();
appendToHistoryDocument(history, sb.toString());
if ((oldHistoryLength + offsets[i]) != history.getTextLength()) {
assert false : "Last offset - " + offsets[i] + " history length: old " + oldHistoryLength + ", new - " + history.getTextLength()
+ ", history - " + history;
}
LOG.debug("printToHistory(): text added");
i = 0;
for (final Pair<String, TextAttributes> pair : attributedText) {
markupModel.addRangeHighlighter(oldHistoryLength + offsets[i],
oldHistoryLength + offsets[i+1],
HighlighterLayer.SYNTAX,
pair.getSecond(),
HighlighterTargetArea.EXACT_RANGE);
markupModel.addRangeHighlighter(
offsets[i],
offsets[i+1],
HighlighterLayer.SYNTAX,
pair.getSecond(),
HighlighterTargetArea.EXACT_RANGE
);
++i;
}
LOG.debug("printToHistory(): markup added");
@@ -109,6 +109,11 @@ public class CompositeWhiteSpaceFormattingStrategy implements WhiteSpaceFormatti
@Override
public boolean containsWhitespacesOnly(@NotNull ASTNode node) {
for (WhiteSpaceFormattingStrategy strategy : myStrategies) {
if (strategy.containsWhitespacesOnly(node)) {
return true;
}
}
return false;
}
@@ -19,6 +19,7 @@ import com.intellij.codeInsight.actions.ReformatAndOptimizeImportsProcessor;
import com.intellij.codeInsight.actions.ReformatCodeProcessor;
import com.intellij.lang.ASTFactory;
import com.intellij.lang.ASTNode;
import com.intellij.lang.Language;
import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
@@ -254,12 +255,12 @@ public class FormatterUtil {
if (node == null) return false;
if (isWhitespaceOrEmpty(node)) return true;
for (WhiteSpaceFormattingStrategy strategy : WhiteSpaceFormattingStrategyFactory.getAllStrategies()) {
if (strategy.containsWhitespacesOnly(node)) {
return true;
}
PsiElement psi = node.getPsi();
if (psi == null) {
return false;
}
return false;
Language language = psi.getLanguage();
return WhiteSpaceFormattingStrategyFactory.getStrategy(language).containsWhitespacesOnly(node);
}
/**
@@ -318,7 +318,8 @@ public class PsiVFSListener extends VirtualFileAdapter {
VirtualFile parent = vFile.getParent();
final PsiDirectory parentDir = getCachedDirectory(parent);
if (parentDir == null) {
// do not suppress reparse request for light files
if (parentDir == null && !FileContentUtil.FORCE_RELOAD_REQUESTOR.equals(event.getRequestor())) {
boolean fire = VirtualFile.PROP_NAME.equals(propertyName) && vFile.isDirectory();
if (fire) {
PsiDirectory psiDir = myFileManager.getCachedDirectory(vFile);
@@ -395,8 +396,10 @@ public class PsiVFSListener extends VirtualFileAdapter {
}
else if (newPsiFile != null) {
myFileManager.cacheViewProvider(vFile, fileViewProvider);
treeEvent.setChild(newPsiFile);
myManager.childAdded(treeEvent);
if (parentDir != null) {
treeEvent.setChild(newPsiFile);
myManager.childAdded(treeEvent);
}
}
}
}
@@ -23,6 +23,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.codeStyle.NameUtil;
import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -72,12 +73,18 @@ public class TestFinderHelper {
public static List<PsiElement> getSortedElements(final List<Pair<? extends PsiNamedElement, Integer>> elementsWithWeights,
final boolean weightsAscending) {
return getSortedElements(elementsWithWeights, weightsAscending, null);
}
public static List<PsiElement> getSortedElements(final List<Pair<? extends PsiNamedElement, Integer>> elementsWithWeights,
final boolean weightsAscending,
@Nullable final Comparator<PsiElement> sameNameComparator) {
Collections.sort(elementsWithWeights, new Comparator<Pair<? extends PsiNamedElement, Integer>>() {
public int compare(Pair<? extends PsiNamedElement, Integer> o1, Pair<? extends PsiNamedElement, Integer> o2) {
int result = weightsAscending ? o1.second.compareTo(o2.second) : o2.second.compareTo(o1.second);
if (result == 0) {
result = Comparing.compare(o1.first.getName(), o2.first.getName());
}
if (result == 0) result = Comparing.compare(o1.first.getName(), o2.first.getName());
if (result == 0 && sameNameComparator != null) result = sameNameComparator.compare(o1.first, o2.first);
return result;
}
});
@@ -22,6 +22,7 @@ import com.intellij.openapi.ui.popup.util.PopupUtil;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.util.net.HTTPProxySettingsPanel;
import org.jetbrains.annotations.NotNull;
@@ -283,15 +284,7 @@ public class CommonProxy extends ProxySelector {
}
private static URI createUri(final URL url) {
final URI uri;
try {
uri = new URI(url.toString());
}
catch (URISyntaxException e) {
LOG.info(e);
throw new RuntimeException(e);
}
return uri;
return VfsUtil.toUri(url.toString());
}
public static class HostInfo {
@@ -34,7 +34,7 @@ import org.jetbrains.io.Responses;
import java.util.Arrays;
@ChannelHandler.Sharable
public class XmlRpcServerImpl extends SimpleChannelUpstreamHandler implements XmlRpcServer, Consumer<ChannelPipeline> {
public class XmlRpcServerImpl extends SimpleChannelUpstreamHandler implements XmlRpcServer {
private static final Logger LOG = Logger.getInstance(XmlRpcServerImpl.class);
private final XmlRpcHandlerMappingImpl handlerMapping;
@@ -76,9 +76,12 @@ public class XmlRpcServerImpl extends SimpleChannelUpstreamHandler implements Xm
LOG.debug("XmlRpcServerImpl instantiated, handlers " + handlerMapping);
}
@Override
public void consume(ChannelPipeline pipeline) {
pipeline.addLast("pluggable_xmlRpc", this);
static final class XmlRpcPipelineConsumer implements Consumer<ChannelPipeline> {
@Override
public void consume(ChannelPipeline pipeline) {
XmlRpcServer xmlRpcServer = SERVICE.getInstance();
pipeline.addLast("pluggable_xmlRpc", (XmlRpcServerImpl)xmlRpcServer);
}
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -124,7 +124,8 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
show();
if (myChosenFiles.length > 0) {
callback.consume(Arrays.asList(myChosenFiles));
} else if (callback instanceof FileChooser.FileChooserConsumer){
}
else if (callback instanceof FileChooser.FileChooserConsumer) {
((FileChooser.FileChooserConsumer)callback).cancelled();
}
}
@@ -357,13 +358,21 @@ public class FileChooserDialogImpl extends DialogWrapper implements FileChooserD
myFileSystemTree.registerMouseListener(group);
}
@Nullable
private VirtualFile[] getSelectedFilesInt() {
if (myTreeIsUpdating || !myUiUpdater.isEmpty()) {
if (!isTextFieldActive() || StringUtil.isEmpty(myPathTextField.getTextFieldText()))
return VirtualFile.EMPTY_ARRAY;
final LocalFsFinder.VfsFile toFind = (LocalFsFinder.VfsFile)myPathTextField.getFile();
return toFind == null || !toFind.exists() ? VirtualFile.EMPTY_ARRAY : new VirtualFile[]{toFind.getFile()};
if (isTextFieldActive() && !StringUtil.isEmpty(myPathTextField.getTextFieldText())) {
LookupFile toFind = myPathTextField.getFile();
if (toFind instanceof LocalFsFinder.VfsFile && toFind.exists()) {
VirtualFile file = ((LocalFsFinder.VfsFile)toFind).getFile();
if (file != null) {
return new VirtualFile[]{file};
}
}
}
return VirtualFile.EMPTY_ARRAY;
}
final List<VirtualFile> selectedFiles = Arrays.asList(myFileSystemTree.getSelectedFiles());
return VfsUtilCore.toVirtualFileArray(FileChooserUtil.getChosenFiles(myChooserDescriptor, selectedFiles));
}
@@ -44,6 +44,7 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import static com.intellij.util.containers.ContainerUtil.*;
@@ -83,6 +84,7 @@ public class FileWatcher {
private final ManagingFS myManagingFS;
private final File myExecutable;
private final AtomicBoolean myInitialized = new AtomicBoolean(false);
private volatile MyProcessHandler myProcessHandler;
private volatile int myStartAttemptCount = 0;
private volatile boolean myIsShuttingDown = false;
@@ -101,12 +103,21 @@ public class FileWatcher {
myExecutable = getExecutable();
if (disabled) {
myInitialized.set(true);
LOG.info("Native file watcher is disabled");
}
else if (myExecutable == null) {
myInitialized.set(true);
LOG.info("Native file watcher is not supported on this platform");
}
else if (!myExecutable.exists()) {
}
private void init() {
if (!myInitialized.compareAndSet(false, true)) {
return;
}
if (!myExecutable.exists()) {
notifyOnFailure(ApplicationBundle.message("watcher.exe.not.found"), null);
}
else if (!myExecutable.canExecute()) {
@@ -244,7 +255,7 @@ public class FileWatcher {
}
public boolean isOperational() {
return myProcessHandler != null;
return !myInitialized.get() || myProcessHandler != null;
}
public boolean isSettingRoots() {
@@ -280,6 +291,7 @@ public class FileWatcher {
}
public void setWatchRoots(final List<String> recursive, final List<String> flat) {
init();
setWatchRoots(recursive, flat, false);
}
@@ -309,8 +321,7 @@ public class FileWatcher {
writeLine("#");
}
catch (IOException e) {
LOG.error(e);
shutdownProcess();
LOG.warn(e);
}
myRecursiveWatchRoots = recursive;
@@ -989,6 +989,14 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
}
}
}
//todo[kb] it's just a temporary solution due a number of focus issues in JDK 7
if (SystemInfo.isJavaVersionAtLeast("1.7")) {
if (hasOpenEditorFiles()) {
activateEditorComponentImpl(getSplittersFromFocus(), commandList, false);
} else {
focusToolWinowByDefault(id);
}
}
execute(commandList);
}
@@ -53,4 +53,8 @@ public interface RemoteSdkData extends RemoteCredentials {
boolean isHelpersVersionChecked();
void setHelpersVersionChecked(boolean helpersVersionChecked);
boolean isInitialized();
void setInitialized(boolean initialized);
}
@@ -30,6 +30,7 @@ public class RemoteSdkDataHolder implements RemoteSdkData {
private static final String HELPERS_PATH = "HELPERS_PATH";
private static final String REMOTE_ROOTS = "REMOTE_ROOTS";
private static final String REMOTE_PATH = "REMOTE_PATH";
private static final String INITIALIZED = "INITIALIZED";
private String myHost;
private int myPort;
@@ -52,6 +53,8 @@ public class RemoteSdkDataHolder implements RemoteSdkData {
private List<String> myRemoteRoots = new ArrayList<String>();
private boolean myInitialized;
public RemoteSdkDataHolder(@NotNull final String defaultDirName) {
myHelpersDefaultDirName = defaultDirName;
}
@@ -285,6 +288,16 @@ public class RemoteSdkDataHolder implements RemoteSdkData {
myHelpersVersionChecked = helpersVersionChecked;
}
@Override
public boolean isInitialized() {
return myInitialized;
}
@Override
public void setInitialized(boolean initialized) {
myInitialized = initialized;
}
public static boolean isRemoteSdk(@Nullable String path) {
if (path != null) {
return path.startsWith(SSH_PREFIX);
@@ -309,6 +322,8 @@ public class RemoteSdkDataHolder implements RemoteSdkData {
setHelpersPath(StringUtil.nullize(element.getAttributeValue(HELPERS_PATH)));
setRemoteRoots(loadStringsList(element, REMOTE_ROOTS, REMOTE_PATH));
setInitialized(StringUtil.parseBoolean(element.getAttributeValue(INITIALIZED), true));
}
protected static List<String> loadStringsList(Element element, String rootName, String attrName) {
@@ -336,6 +351,8 @@ public class RemoteSdkDataHolder implements RemoteSdkData {
rootElement.setAttribute(INTERPRETER_PATH, StringUtil.notNullize(getInterpreterPath()));
rootElement.setAttribute(HELPERS_PATH, StringUtil.notNullize(getHelpersPath()));
rootElement.setAttribute(INITIALIZED, Boolean.toString(isInitialized()));
for (String remoteRoot : getRemoteRoots()) {
final Element child = new Element(REMOTE_ROOTS);
child.setAttribute(REMOTE_PATH, remoteRoot);
@@ -1,14 +0,0 @@
package org.jetbrains.ide;
import com.intellij.ide.XmlRpcServer;
import com.intellij.ide.XmlRpcServerImpl;
import com.intellij.util.Consumer;
import org.jboss.netty.channel.ChannelPipeline;
class XmlRpcPipelineConsumer implements Consumer<ChannelPipeline> {
@Override
public void consume(ChannelPipeline pipeline) {
XmlRpcServer xmlRpcServer = XmlRpcServer.SERVICE.getInstance();
((XmlRpcServerImpl)xmlRpcServer).consume(pipeline);
}
}
@@ -248,3 +248,4 @@ zen.coding.incorrect.abbreviation.error=Incorrect abbreviation
title.cannot.create.html.file=Cannot create HTML file
new.html.file.action=HTML File
new.html.file.action.description=Creates new HTML file
html5.outline.mode=HTML5 Outline
@@ -289,7 +289,7 @@
<applicationService serviceInterface="org.jetbrains.ide.WebServerManager" serviceImplementation="org.jetbrains.ide.WebServerManagerImpl"/>
<applicationService serviceInterface="com.intellij.ide.XmlRpcServer" serviceImplementation="com.intellij.ide.XmlRpcServerImpl"/>
<serverPipelineConsumer implementation="org.jetbrains.ide.XmlRpcPipelineConsumer"/>
<serverPipelineConsumer implementation="com.intellij.ide.XmlRpcServerImpl$XmlRpcPipelineConsumer"/>
<postStartupActivity implementation="org.jetbrains.ide.WebServerManagerImpl$MyPostStartupActivity"/>
<editorNotificationProvider implementation="com.intellij.ide.FileChangedNotificationProvider"/>
@@ -438,8 +438,7 @@
<breadcrumbsPresentationProvider implementation="com.intellij.codeInsight.daemon.impl.tagTreeHighlighting.XmlTagTreeBreadcrumbsPresentationProvider"/>
<daemon.changeLocalityDetector implementation="com.intellij.xml.XmlChangeLocalityDetector"/>
<xmlStructureViewBuilderProvider implementation="com.intellij.lang.html.HtmlStructureViewBuilderProvider"/>
<xmlStructureViewElementProvider implementation="com.intellij.lang.html.HtmlStructureViewElementProvider"/>
<xmlStructureViewBuilderProvider implementation="com.intellij.lang.html.structureView.HtmlStructureViewBuilderProvider"/>
</extensions>
<extensions defaultExtensionNs="org.jetbrains">
<urlOpener implementation="com.intellij.ide.browsers.impl.DefaultUrlOpener" order="last"/>
@@ -271,15 +271,15 @@ public abstract class ParsingTestCase extends PlatformLiteFixture {
doCheckResult(myFullDataPath, targetDataName, text);
}
private static void doCheckResult(String myFullDataPath, String targetDataName, String text) throws IOException {
public static void doCheckResult(String fullPath, String targetDataName, String text) throws IOException {
text = text.trim();
String expectedFileName = myFullDataPath + File.separatorChar + targetDataName;
String expectedFileName = fullPath + File.separatorChar + targetDataName;
if (OVERWRITE_TESTDATA) {
VfsTestUtil.overwriteTestData(expectedFileName, text);
System.out.println("File " + expectedFileName + " created.");
}
try {
String expectedText = doLoadFile(myFullDataPath, targetDataName);
String expectedText = doLoadFile(fullPath, targetDataName);
if (!Comparing.equal(expectedText, text)) {
throw new FileComparisonFailure(targetDataName, expectedText, text, expectedFileName);
}
@@ -304,7 +304,7 @@ public abstract class ParsingTestCase extends PlatformLiteFixture {
return text;
}
private static void ensureParsed(PsiFile file) {
public static void ensureParsed(PsiFile file) {
file.accept(new PsiElementVisitor() {
@Override
public void visitElement(PsiElement element) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -159,7 +159,7 @@ public class BaseOSProcessHandler extends ProcessHandler {
myProcess.getOutputStream().close();
}
catch (IOException e) {
LOG.error(e);
LOG.warn(e);
}
}
@@ -45,7 +45,7 @@ class XmlSerializerImpl {
throw e;
}
catch (Exception e) {
throw new XmlSerializationException(e);
throw new XmlSerializationException("Can't serialize instance of " + object.getClass(), e);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2013 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.
@@ -94,7 +94,7 @@ abstract class ModifierIntention extends Intention implements LowPriorityAction
final String name = FileUtil.getNameWithoutExtension(javaFile.getName());
final String className = aClass.getName();
if (name.equals(className)) {
MultiMap.emptyInstance();
return MultiMap.emptyInstance();
}
final MultiMap<PsiElement, String> conflicts = new MultiMap();
conflicts.putValue(aClass, IntentionPowerPackBundle.message(
@@ -15,13 +15,12 @@
*/
package org.jetbrains.plugins.groovy.griffon;
import com.intellij.execution.configurations.ParametersList;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.mvc.MvcCommand;
import javax.swing.*;
@@ -50,20 +49,29 @@ public class GriffonCreateProjectDialog extends DialogWrapper {
return myComponent;
}
String getCommand() {
if (myCreateAddon.isSelected()) return "create-addon";
if (myCreateApp.isSelected()) return "create-app";
if (myCreateArchetype.isSelected()) return "create-archetype";
if (myCreatePlugin.isSelected()) return "create-plugin";
throw new AssertionError("No selection");
}
MvcCommand getCommand() {
String cmd;
String[] getArguments() {
String text = myOptionField.getText();
if (StringUtil.isEmptyOrSpaces(text)) {
return ArrayUtil.EMPTY_STRING_ARRAY;
if (myCreateAddon.isSelected()) {
cmd = "create-addon";
}
return text.split(" ");
else if (myCreateApp.isSelected()) {
cmd = "create-app";
}
else if (myCreateArchetype.isSelected()) {
cmd = "create-archetype";
}
else if (myCreatePlugin.isSelected()) {
cmd = "create-plugin";
}
else {
throw new AssertionError("No selection");
}
String text = myOptionField.getText();
if (text == null) text = "";
return new MvcCommand(cmd, ParametersList.parse(text));
}
}
@@ -19,6 +19,7 @@ package org.jetbrains.plugins.groovy.griffon;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.configurations.JavaParameters;
import com.intellij.execution.configurations.ParametersList;
import com.intellij.lang.properties.IProperty;
import com.intellij.lang.properties.psi.PropertiesFile;
import com.intellij.openapi.application.AccessToken;
@@ -41,17 +42,13 @@ import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.util.ArrayUtil;
import gnu.trove.TIntArrayList;
import icons.JetgroovyIcons;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.GroovyFileType;
import org.jetbrains.plugins.groovy.mvc.MvcFramework;
import org.jetbrains.plugins.groovy.mvc.MvcModuleStructureUtil;
import org.jetbrains.plugins.groovy.mvc.MvcPathMacros;
import org.jetbrains.plugins.groovy.mvc.MvcProjectStructure;
import org.jetbrains.plugins.groovy.mvc.*;
import javax.swing.*;
import java.io.File;
@@ -105,7 +102,7 @@ public class GriffonFramework extends MvcFramework {
return null;
}
return createCommandAndShowErrors(null, module, true, dialog.getCommand(), dialog.getArguments());
return createCommandAndShowErrors(null, module, true, dialog.getCommand());
}
@Override
@@ -231,8 +228,7 @@ public class GriffonFramework extends MvcFramework {
public JavaParameters createJavaParameters(@NotNull Module module, boolean forCreation, boolean forTests,
boolean classpathFromDependencies,
@Nullable String jvmParams,
@NotNull String command,
@NotNull String... args) throws ExecutionException {
@NotNull MvcCommand command) throws ExecutionException {
JavaParameters params = new JavaParameters();
Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
@@ -284,7 +280,8 @@ public class GriffonFramework extends MvcFramework {
throw new ExecutionException("Failed to initialize griffon module: module " + module.getName() + " contains more than one root");
}
args = ArrayUtil.mergeArrays(new String[]{roots[0].getName()}, args);
command.getArgs().add(0, roots[0].getName());
rootFile = roots[0].getParent();
}
else {
@@ -331,8 +328,9 @@ public class GriffonFramework extends MvcFramework {
params.setWorkingDirectory(workDir);
String argsString = args.length == 0 ? command : command + ' ' + StringUtil.join(args, " ");
params.getProgramParametersList().add(argsString);
ParametersList paramList = new ParametersList();
command.addToParametersList(paramList);
params.getProgramParametersList().add(paramList.getParametersString());
params.setDefaultCharset(module.getProject());
@@ -50,17 +50,17 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.formatter.GeeseUtil;
import org.jetbrains.plugins.groovy.lang.GrReferenceAdjuster;
import org.jetbrains.plugins.groovy.lang.psi.GrControlFlowOwner;
import org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
import org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariableDeclaration;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrApplicationStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrNewExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression;
@@ -214,11 +214,10 @@ public class GroovyCompletionUtil {
public static boolean asVariableInBlock(PsiElement context) {
if (context.getParent() instanceof GrReferenceExpression) {
PsiElement parent = context.getParent().getParent();
if (parent instanceof GrApplicationStatement) {
while (parent instanceof GrStatement) {
parent = parent.getParent();
}
if ((parent instanceof GrCodeBlock || parent instanceof GrCaseSection || parent instanceof GrLabeledStatement) &&
isNewStatement(context, true)) {
if ((parent instanceof GrControlFlowOwner || parent instanceof GrCaseSection) && isNewStatement(context, true)) {
return true;
}
}
@@ -0,0 +1,118 @@
package org.jetbrains.plugins.groovy.mvc;
import com.intellij.execution.configurations.ParametersList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.*;
/**
* @author Sergey Evdokimov
*/
public class MvcCommand {
public static final Collection<String> ourEnvironments = Arrays.asList("prod", "test", "dev");
private String myEnv;
private String myCommand;
private final ArrayList<String> myArgs = new ArrayList<String>();
private final ArrayList<String> myProperties = new ArrayList<String>();
public MvcCommand() {
}
public MvcCommand(String command, String ... args) {
myCommand = command;
Collections.addAll(myArgs, args);
}
@Nullable
public String getEnv() {
return myEnv;
}
public void setEnv(@Nullable String env) {
myEnv = env;
}
@Nullable
public String getCommand() {
return myCommand;
}
public void setCommand(@Nullable String command) {
myCommand = command;
}
/**
* Returns MODIFIABLE list of arguments
*/
public ArrayList<String> getArgs() {
return myArgs;
}
public void setArgs(List<String> args) {
if (args == myArgs) return;
myArgs.clear();
myArgs.addAll(args);
}
/**
* Returns MODIFIABLE list of system properties definition written before command (e.g. -Dgrails.port=9090 run-app)
*/
public ArrayList<String> getProperties() {
return myProperties;
}
public void setProperties(List<String> properties) {
if (myProperties == properties) return;
myProperties.clear();
myProperties.addAll(properties);
}
public void addToParametersList(@NotNull ParametersList list) {
if (myEnv != null) {
list.add(myEnv);
}
list.addAll(myProperties);
if (myCommand != null) {
list.add(myCommand);
}
list.addAll(myArgs);
}
@NotNull
public static MvcCommand parse(@NotNull String cmd) {
String[] args = ParametersList.parse(cmd);
MvcCommand res = new MvcCommand();
int i = 0;
while (res.myCommand == null && i < args.length) {
String s = args[i];
if (s.startsWith("-D")) {
res.myProperties.add(s);
}
else if (res.myEnv == null && ourEnvironments.contains(s)) {
res.myEnv = s;
}
else {
res.myCommand = s;
}
i++;
}
res.myArgs.addAll(Arrays.asList(args).subList(i, args.length));
return res;
}
}
@@ -166,7 +166,7 @@ public abstract class MvcFramework {
return null;
}
return createCommandAndShowErrors(null, module, true, result == 0 ? "create-app" : "create-plugin");
return createCommandAndShowErrors(null, module, true, new MvcCommand(result == 0 ? "create-app" : "create-plugin"));
}
public abstract void updateProjectStructure(@NotNull final Module module);
@@ -316,32 +316,12 @@ public abstract class MvcFramework {
from.remove(extension.getCompilerOutputPathForTests());
}
public static Pair<String, String[]> parsedCmd(String cmdLine) {
return parsedCmd(ParametersList.parse(cmdLine));
}
public static Pair<String, String[]> parsedCmd(String[] args) {
if (args.length == 0) {
return new Pair<String, String[]>("", ArrayUtil.EMPTY_STRING_ARRAY);
}
if (args.length == 1) {
return new Pair<String, String[]>(args[0], ArrayUtil.EMPTY_STRING_ARRAY);
}
String[] array = new String[args.length - 1];
System.arraycopy(args, 1, array, 0, array.length);
return new Pair<String, String[]>(args[0], array);
}
public abstract JavaParameters createJavaParameters(@NotNull Module module,
boolean forCreation,
boolean forTests,
boolean classpathFromDependencies,
@Nullable String jvmParams,
@NotNull String command,
@NotNull String... args) throws ExecutionException;
@NotNull MvcCommand command) throws ExecutionException;
protected static void ensureRunConfigurationExists(Module module, ConfigurationType configurationType, String name) {
final RunManagerEx runManager = RunManagerEx.getInstanceEx(module.getProject());
@@ -373,19 +353,24 @@ public abstract class MvcFramework {
public abstract String getSdkHomePropertyName();
@Nullable
public GeneralCommandLine createCommandAndShowErrors(@NotNull Module module, @NotNull String command, @NotNull String... args) {
return createCommandAndShowErrors(null, module, command, args);
public GeneralCommandLine createCommandAndShowErrors(@NotNull Module module, @NotNull String command, String... args) {
return createCommandAndShowErrors(null, module, new MvcCommand(command, args));
}
@Nullable
public GeneralCommandLine createCommandAndShowErrors(@Nullable String vmOptions, @NotNull Module module, @NotNull String command, @NotNull String... args) {
return createCommandAndShowErrors(vmOptions, module, false, command, args);
public GeneralCommandLine createCommandAndShowErrors(@NotNull Module module, @NotNull MvcCommand command) {
return createCommandAndShowErrors(null, module, command);
}
@Nullable
public GeneralCommandLine createCommandAndShowErrors(@Nullable String vmOptions, @NotNull Module module, final boolean forCreation, @NotNull String command, @NotNull String... args) {
public GeneralCommandLine createCommandAndShowErrors(@Nullable String vmOptions, @NotNull Module module, @NotNull MvcCommand command) {
return createCommandAndShowErrors(vmOptions, module, false, command);
}
@Nullable
public GeneralCommandLine createCommandAndShowErrors(@Nullable String vmOptions, @NotNull Module module, final boolean forCreation, @NotNull MvcCommand command) {
try {
return createCommand(module, vmOptions, forCreation, command, args);
return createCommand(module, vmOptions, forCreation, command);
}
catch (ExecutionException e) {
Messages.showErrorDialog(e.getMessage(), "Failed to run grails command: " + command);
@@ -397,9 +382,8 @@ public abstract class MvcFramework {
public GeneralCommandLine createCommand(@NotNull Module module,
@Nullable String jvmParams,
final boolean forCreation,
@NotNull String command,
@NotNull String... args) throws ExecutionException {
final JavaParameters params = createJavaParameters(module, forCreation, false, true, jvmParams, command, args);
@NotNull MvcCommand command) throws ExecutionException {
final JavaParameters params = createJavaParameters(module, forCreation, false, true, jvmParams, command);
addJavaHome(params, module);
final GeneralCommandLine commandLine = createCommandLine(params);
@@ -288,10 +288,9 @@ public abstract class MvcRunConfiguration extends ModuleBasedConfiguration<RunCo
}
protected JavaParameters createJavaParametersMVC() throws ExecutionException {
Pair<String, String[]> parsedCmd = MvcFramework.parsedCmd(myCmdLine);
MvcCommand cmd = MvcCommand.parse(myCmdLine);
final JavaParameters params = myFramework.createJavaParameters(myModule, false, myForTests, depsClasspath, vmParams, parsedCmd.first,
parsedCmd.second);
final JavaParameters params = myFramework.createJavaParameters(myModule, false, myForTests, depsClasspath, vmParams, cmd);
addEnvVars(params);
@@ -18,7 +18,6 @@ package org.jetbrains.plugins.groovy.mvc;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
/**
@@ -36,11 +35,9 @@ public class MvcRunTarget extends MvcActionBase {
Module selectedModule = dialog.getSelectedModule();
String[] targetArgs = dialog.getTargetArguments();
MvcCommand cmd = MvcCommand.parse(dialog.getTargetArguments());
Pair<String, String[]> parsedCmd = MvcFramework.parsedCmd(targetArgs);
final GeneralCommandLine commandLine = framework.createCommandAndShowErrors(dialog.getVmOptions(), selectedModule, parsedCmd.first, parsedCmd.second);
final GeneralCommandLine commandLine = framework.createCommandAndShowErrors(dialog.getVmOptions(), selectedModule, cmd);
if (commandLine == null) return;
MvcConsole.executeProcess(selectedModule, commandLine, null, false);
@@ -147,7 +147,8 @@ public class MvcRunTargetDialog extends DialogWrapper {
return (String)myTargetField.getEditor().getItem();
}
public String[] getTargetArguments() {
@NotNull
public String getTargetArguments() {
String text = getSelectedText();
text = text.trim();
@@ -155,12 +156,7 @@ public class MvcRunTargetDialog extends DialogWrapper {
text = text.substring(GRAILS_PREFIX.length());
}
Iterable<String> iterable = StringUtil.tokenize(text, " ");
ArrayList<String> args = new ArrayList<String>();
for (String s : iterable) {
args.add(s);
}
return ArrayUtil.toStringArray(args);
return text;
}
protected JComponent createCenterPanel() {
@@ -77,7 +77,7 @@ public class MvcTargetDialogCompletionUtils {
List<LookupElement> res = new ArrayList<LookupElement>();
if (text.substring(0, offset).matches("\\s*(grails\\s*)?(?:(:?-\\S+|dev|prod|test)\\s+)*\\S*")) {
if (text.substring(0, offset).matches("\\s*(grails\\s*)?(?:(:?-D\\S+|dev|prod|test)\\s+)*\\S*")) {
// Complete command name because command name is not typed.
for (String completionVariant : getAllTargetNames(module)) {
res.add(TailTypeDecorator.withTail(LookupElementBuilder.create(completionVariant), TailType.SPACE));
@@ -1663,4 +1663,11 @@ package bar
print new foo.Myclass()
''')
}
public void "test def before assignment"() {
assert doContainsTest("def", """
void foo() {
<caret> = baz
}""")
}
}
@@ -29,12 +29,4 @@ public interface HgPlatformFacade extends DvcsPlatformFacade {
@NotNull
HgVcs getVcs(@NotNull Project project);
@NotNull
HgRepositoryManager getRepositoryManager(@NotNull Project project);
//@NotNull
//HgProjectSettings getSettings(Project project);
//
//@NotNull
//HgCommandResultNotifier getNotificator(@NotNull Project project);
}
@@ -25,12 +25,6 @@ import org.jetbrains.annotations.NotNull;
*/
public class HgPlatformFacadeImpl extends DvcsPlatformFacadeImpl implements HgPlatformFacade {
@NotNull
@Override
public HgRepositoryManager getRepositoryManager(@NotNull Project project) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public HgVcs getVcs(@NotNull Project project) {
@@ -1,32 +0,0 @@
/*
* Copyright 2000-2013 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.zmlx.hg4idea;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import java.util.List;
/**
* @author Nadya Zabrodina
*/
public interface HgRepositoryManager {
/**
* @return all repositories tracked by the manager.
*/
@NotNull
List<VirtualFile> getRepositories();
}
@@ -202,7 +202,7 @@ public class HgCachingCommitedChangesProvider implements CachingCommittedChanges
if (changeBrowserSettings != null) {
args = new ArrayList<String>();
if (changeBrowserSettings.USE_CHANGE_AFTER_FILTER) {
args.add("-r " + changeBrowserSettings.getChangeAfterFilter());
args.add("-r " + changeBrowserSettings.getChangeAfterFilter() + ":");
}
}
List<HgFileRevision> localRevisions = hgLogCommand.execute(hgFile, maxCount == 0 ? -1 : maxCount, true, args);
@@ -17,7 +17,6 @@ package hg4idea.test;
import com.intellij.dvcs.test.Executor;
import com.intellij.openapi.util.text.StringUtil;
import org.zmlx.hg4idea.provider.HgRepositoryLocation;
import java.util.Arrays;
import java.util.List;
@@ -25,7 +24,7 @@ import java.util.List;
/**
* @author Nadya Zabrodina
*/
class HgExecutor extends Executor {
public class HgExecutor extends Executor {
private static final String HG_EXECUTABLE_ENV = "IDEA_TEST_HG_EXECUTABLE";
//private static final String TEAMCITY_HG_EXECUTABLE_ENV = "TEAMCITY_HG_PATH"; //todo var for server testing
@@ -37,31 +36,18 @@ class HgExecutor extends Executor {
return findExecutable("hg", "hg", "hg.exe", Arrays.asList(HG_EXECUTABLE_ENV));
}
public String hg(String command) {
public static String hg(String command) {
printVersionTheFirstTime();
List<String> split = StringUtil.split(command, " ");
split.add(0, HG_EXECUTABLE);
log("hg " + command);
for (int attempt = 0; attempt < 3; attempt++) {
String stdout = run(split);
return stdout;
for(int attempt = 0; attempt < 3; attempt++) {
return run(split);
}
throw new RuntimeException("fatal error during execution of Hg command: " + command);
}
public String hg(HgRepositoryLocation repository, String command) {
if (repository != null) {
cd(repository);
}
return hg(command);
}
public void cd(HgRepositoryLocation repository) {
cd(repository.getRoot().getPath());
}
private void printVersionTheFirstTime() {
private static void printVersionTheFirstTime() {
if (!myVersionPrinted) {
myVersionPrinted = true;
hg("version");
@@ -15,6 +15,7 @@
*/
package hg4idea.test;
import com.intellij.dvcs.test.Executor;
import com.intellij.dvcs.test.MockProject;
import com.intellij.dvcs.test.MockVirtualFile;
import com.intellij.openapi.application.PluginPathManager;
@@ -33,7 +34,7 @@ import static org.junit.Assume.assumeTrue;
/**
* @author Nadya Zabrodina
*/
public class HgLightTest extends HgExecutor {
public class HgLightTest {
//private static final String USER_NAME = "John Doe";
//private static final String USER_EMAIL = "John.Doe@example.com";
@@ -62,13 +63,14 @@ public class HgLightTest extends HgExecutor {
catch (IOException e) {
fail("Can not start test case!\n"); //todo change
}
cd(myTestRoot);
myProjectRoot = mkdir("project");
Executor.cd(myTestRoot);
myProjectRoot = Executor.mkdir("project");
myProject = new MockProject(myProjectRoot);
myPlatformFacade = new HgTestPlatformFacade();
cd(".hg");
Executor.cd(".hg");
File pluginRoot = new File(PluginPathManager.getPluginHomePath("hg4idea"));
File hgrcFile = new File(new File(pluginRoot, "testData\\repo\\dot_hg"), "hgrc");
String pathToHgrc = "testData\\repo\\dot_hg";
File hgrcFile = new File(new File(pluginRoot, FileUtil.toSystemIndependentName(pathToHgrc)), "hgrc");
File hgrc = new File(new File(myProjectRoot, ".hg"), "hgrc");
try {
FileUtil.copy(hgrcFile, hgrc);
@@ -96,11 +98,11 @@ public class HgLightTest extends HgExecutor {
return new MockVirtualFile(rootDir);
}
private void initRepo(String repoRoot) {
cd(repoRoot);
hg("init");
touch("file.txt");
hg("add file.txt");
hg("commit -m initial");
private static void initRepo(String repoRoot) {
Executor.cd(repoRoot);
HgExecutor.hg("init");
Executor.touch("file.txt");
HgExecutor.hg("add file.txt");
HgExecutor.hg("commit -m initial");
}
}
@@ -251,12 +251,7 @@ public class HgMockVcsManager extends ProjectLevelVcsManager {
@NotNull
@Override
public VcsRoot[] getAllVcsRoots() {
List<VcsRoot> vcsRoots = new ArrayList<VcsRoot>();
List<VirtualFile> repositories = myPlatformFacade.getRepositoryManager(myProject).getRepositories();
for (VirtualFile repository : repositories) {
vcsRoots.add(new VcsRoot(getVcsFor(repository), repository));
}
return vcsRoots.toArray(new VcsRoot[0]);
throw new UnsupportedOperationException();
}
@Override
@@ -20,19 +20,17 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import org.jetbrains.annotations.NotNull;
import org.zmlx.hg4idea.*;
import org.zmlx.hg4idea.HgGlobalSettings;
import org.zmlx.hg4idea.HgPlatformFacade;
import org.zmlx.hg4idea.HgProjectSettings;
import org.zmlx.hg4idea.HgVcs;
/**
* @author Nadya Zabrodina
*/
class HgTestPlatformFacade extends DvcsTestPlatformFacade implements HgPlatformFacade {
public class HgTestPlatformFacade extends DvcsTestPlatformFacade implements HgPlatformFacade {
private HgMockVcs myVcs;
private HgMockVcsManager myVcsManager;
private HgTestRepositoryManager myRepositoryManager;
HgTestPlatformFacade() {
myRepositoryManager = new HgTestRepositoryManager();
}
@NotNull
@Override
@@ -44,6 +42,7 @@ class HgTestPlatformFacade extends DvcsTestPlatformFacade implements HgPlatformF
return myVcs;
}
@NotNull
@Override
public ProjectLevelVcsManager getVcsManager(@NotNull Project project) {
@@ -58,11 +57,5 @@ class HgTestPlatformFacade extends DvcsTestPlatformFacade implements HgPlatformF
public void showDialog(@NotNull DialogWrapper dialog) {
throw new UnsupportedOperationException();
}
@NotNull
@Override
public HgRepositoryManager getRepositoryManager(@NotNull Project project) {
return myRepositoryManager;
}
}
@@ -1,41 +0,0 @@
/*
* Copyright 2000-2013 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 hg4idea.test;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.zmlx.hg4idea.HgRepositoryManager;
import java.util.ArrayList;
import java.util.List;
/**
* @author Nadya Zabrodina
*/
public class HgTestRepositoryManager implements HgRepositoryManager {
private final List<VirtualFile> myRepositories = new ArrayList<VirtualFile>();
public void add(VirtualFile repository) {
myRepositories.add(repository);
}
@NotNull
@Override
public List<VirtualFile> getRepositories() {
return myRepositories;
}
}
@@ -15,9 +15,11 @@
*/
package hg4idea.test.diff;
import com.intellij.dvcs.test.Executor;
import com.intellij.dvcs.test.MockVirtualFile;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.changes.Change;
import hg4idea.test.HgExecutor;
import hg4idea.test.HgLightTest;
import org.junit.After;
import org.junit.Test;
@@ -53,28 +55,28 @@ public class HgGetDiffForDirTest extends HgLightTest {
@Test
public void testDiffForDir() {
cd(myProjectRoot);
touch("A.txt", "dsfdfdsf");
hg("add A.txt");
touch("B.txt");
hg("add B.txt");
hg("commit -m 2files_added");
mkdir("dir");
cd("dir");
touch("C.txt");
touch("D.txt");
hg("add C.txt");
hg("add D.txt");
hg("commit -m createDir");
Executor.cd(myProjectRoot);
Executor.touch("A.txt", "dsfdfdsf");
HgExecutor.hg("add A.txt");
Executor.touch("B.txt");
HgExecutor.hg("add B.txt");
HgExecutor.hg("commit -m 2files_added");
Executor.mkdir("dir");
Executor.cd("dir");
Executor.touch("C.txt");
Executor.touch("D.txt");
HgExecutor.hg("add C.txt");
HgExecutor.hg("add D.txt");
HgExecutor.hg("commit -m createDir");
File dirFile = new File(myProjectRoot, "dir");
String[] hash1 = hg("log -l 1 --template=" + SHORT_TEMPLATE_REVISION).split(":");
String[] hash1 = HgExecutor.hg("log -l 1 --template=" + SHORT_TEMPLATE_REVISION).split(":");
HgRevisionNumber r1number = HgRevisionNumber.getInstance(hash1[0], hash1[1]);
HgFileRevision rev1 =
new HgFileRevision(myProject, new HgFile(myRepository, dirFile), r1number, "", null, "", "", null, null, null, null);
echo("C.txt", "aaaa");
echo("D.txt", "dddd");
hg("commit -m modifyDir");
String[] hash2 = hg("log -l 1 --template=" + SHORT_TEMPLATE_REVISION).split(":");
Executor.echo("C.txt", "aaaa");
Executor.echo("D.txt", "dddd");
HgExecutor.hg("commit -m modifyDir");
String[] hash2 = HgExecutor.hg("log -l 1 --template=" + SHORT_TEMPLATE_REVISION).split(":");
HgRevisionNumber r2number = HgRevisionNumber.getInstance(hash2[0], hash2[1]);
HgFileRevision rev2 =
new HgFileRevision(myProject, new HgFile(myRepository, dirFile), r2number, "", null, "", "", null, null, null, null);
+1
View File
@@ -18,5 +18,6 @@
<codeInsight.unresolvedReferenceQuickFixProvider implementation="org.jetbrains.plugins.javaFX.fxml.refs.JavaFxTagNameReference$JavaFxUnresolvedTagRefsProvider"/>
<multiHostInjector implementation="org.jetbrains.plugins.javaFX.fxml.ScriptLanguageInjector"/>
<annotator language="XML" implementationClass="org.jetbrains.plugins.javaFX.fxml.refs.JavaFxAnnotator"/>
<codeInsight.lineMarkerProvider language="JAVA" implementationClass="org.jetbrains.plugins.javaFX.fxml.codeInsight.JavaFxRelatedItemLineMarkerProvider"/>
</extensions>
</idea-plugin>
@@ -39,6 +39,8 @@ public class FxmlConstants {
@NonNls public static final String FX_DEFINE = "fx:define";
@NonNls public static final String FX_SCRIPT = "fx:script";
@NonNls public static final String FX_INCLUDE = "fx:include";
@NonNls public static final String FX_ROOT = "fx:root";
@NonNls public static final String TYPE = "type";
public static final List<String> FX_DEFAULT_PROPERTIES = Arrays.asList(FX_ID, FX_CONTROLLER, VALUE, FX_VALUE, FX_FACTORY, FX_CONSTANT);
public static final List<String> FX_DEFAULT_ELEMENTS = Arrays.asList(FX_INCLUDE, FX_REFERENCE, FX_COPY, FX_DEFINE, FX_SCRIPT);
@@ -49,12 +51,15 @@ public class FxmlConstants {
static {
FX_ELEMENT_ATTRIBUTES.put(FX_INCLUDE, Arrays.asList(FX_ELEMENT_SOURCE, FX_ID));
FX_ELEMENT_ATTRIBUTES.put(FX_REFERENCE, Arrays.asList(FX_ELEMENT_SOURCE));
FX_ELEMENT_ATTRIBUTES.put(FX_ROOT, Arrays.asList(TYPE));
}
public static final Map<String, List<String>> FX_REQUIRED_ELEMENT_ATTRIBUTES = new HashMap<String, List<String>>();
static {
FX_REQUIRED_ELEMENT_ATTRIBUTES.put(FX_INCLUDE, Arrays.asList(FX_ELEMENT_SOURCE));
FX_REQUIRED_ELEMENT_ATTRIBUTES.put(FX_REFERENCE, Arrays.asList(FX_ELEMENT_SOURCE));
FX_REQUIRED_ELEMENT_ATTRIBUTES.put(FX_ROOT, Arrays.asList(TYPE));
}
}
@@ -9,6 +9,7 @@ import com.intellij.xml.XmlNSDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxClassBackedElementDescriptor;
import org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxDefaultPropertyElementDescriptor;
/**
* User: anna
@@ -22,7 +23,9 @@ public class JavaFXNSDescriptor implements XmlNSDescriptor, Validator<XmlDocumen
public XmlElementDescriptor getElementDescriptor(@NotNull XmlTag tag) {
final String name = tag.getName();
if (JavaFxPsiUtil.isClassTag(name)) {
if (tag.getName().equals(FxmlConstants.FX_ROOT)) {
return new JavaFxDefaultPropertyElementDescriptor(name, tag);
} else if (JavaFxPsiUtil.isClassTag(name)) {
return new JavaFxClassBackedElementDescriptor(name, tag);
}
else {
@@ -31,4 +31,5 @@ public class JavaFxCommonClassNames {
@NonNls public static final String JAVAFX_EVENT_EVENT_HANDLER = "javafx.event.EventHandler";
@NonNls public static final String JAVAFX_SCENE_NODE = "javafx.scene.Node";
@NonNls public static final String JAVAFX_SCENE_PAINT = "javafx.scene.paint.Paint";
@NonNls public static final String JAVAFX_FXML_BUILDER = "javafx.util.Builder";
}
@@ -15,12 +15,14 @@
*/
package org.jetbrains.plugins.javaFX.fxml;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.lang.ASTNode;
import com.intellij.lang.xml.XMLLanguage;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PropertyUtil;
import com.intellij.psi.util.PsiTreeUtil;
@@ -82,7 +84,11 @@ public class JavaFxPsiUtil {
}
public static PsiClass findPsiClass(String name, XmlTag tag) {
return findPsiClass(name, parseImports((XmlFile)tag.getContainingFile()), tag, tag.getProject());
final Project project = tag.getProject();
if (!StringUtil.getShortName(name).equals(name)) {
return JavaPsiFacade.getInstance(project).findClass(name, GlobalSearchScope.allScope(project));
}
return findPsiClass(name, parseImports((XmlFile)tag.getContainingFile()), tag, project);
}
private static PsiClass findPsiClass(String name, List<String> imports, XmlTag tag, Project project) {
@@ -155,7 +161,11 @@ public class JavaFxPsiUtil {
public static boolean isClassTag(String name) {
final String shortName = StringUtil.getShortName(name);
return StringUtil.isCapitalized(name) && name.equals(shortName);
final boolean capitalized = StringUtil.isCapitalized(name);
if (name.equals(shortName)) {
return capitalized;
}
return !capitalized;
}
public static PsiMethod findPropertySetter(String attributeName, XmlTag context) {
@@ -220,4 +230,26 @@ public class JavaFxPsiUtil {
}
return true;
}
@Nullable
public static PsiClass getTagClass(XmlAttributeValue xmlAttributeValue) {
if (xmlAttributeValue == null) return null;
final PsiElement xmlAttribute = xmlAttributeValue.getParent();
final XmlTag xmlTag = ((XmlAttribute)xmlAttribute).getParent();
if (xmlTag != null) {
final XmlElementDescriptor descriptor = xmlTag.getDescriptor();
if (descriptor != null) {
final PsiElement declaration = descriptor.getDeclaration();
if (declaration instanceof PsiClass) {
return (PsiClass)declaration;
}
}
}
return null;
}
public static boolean isVisibleInFxml(PsiMember psiMember) {
return psiMember.hasModifierProperty(PsiModifier.PUBLIC) ||
AnnotationUtil.isAnnotated(psiMember, JavaFxCommonClassNames.JAVAFX_FXML_ANNOTATION, false);
}
}
@@ -0,0 +1,108 @@
/*
* Copyright 2000-2013 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.javaFX.fxml.codeInsight;
import com.intellij.codeHighlighting.Pass;
import com.intellij.codeInsight.daemon.GutterIconNavigationHandler;
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo;
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider;
import com.intellij.codeInsight.navigation.NavigationUtil;
import com.intellij.icons.AllIcons;
import com.intellij.navigation.GotoRelatedItem;
import com.intellij.openapi.editor.markup.GutterIconRenderer;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.psi.*;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlAttributeValue;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.CommonProcessors;
import com.intellij.util.ConstantFunction;
import com.intellij.util.Function;
import com.intellij.util.Processor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.javaFX.fxml.JavaFxFileTypeFactory;
import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collection;
/**
* User: anna
*/
public class JavaFxRelatedItemLineMarkerProvider extends RelatedItemLineMarkerProvider {
@Override
protected void collectNavigationMarkers(@NotNull PsiElement element, final Collection<? super RelatedItemLineMarkerInfo> result) {
if (element instanceof PsiField) {
final PsiField field = (PsiField)element;
if (JavaFxPsiUtil.isVisibleInFxml(field) && !field.hasModifierProperty(PsiModifier.STATIC)) {
final PsiClass containingClass = field.getContainingClass();
if (containingClass != null && containingClass.hasModifierProperty(PsiModifier.PUBLIC)) {
final ArrayList<GotoRelatedItem> targets = new ArrayList<GotoRelatedItem>();
collectTargets(element, targets, new Function<PsiElement, GotoRelatedItem>() {
@Override
public GotoRelatedItem fun(PsiElement element) {
return new GotoRelatedItem(element);
}
}, true);
if (targets.isEmpty()) return;
result.add(new RelatedItemLineMarkerInfo<PsiField>(field, field.getNameIdentifier().getTextRange(),
AllIcons.FileTypes.Xml, Pass.UPDATE_OVERRIDEN_MARKERS, null,
new JavaFXIdIconNavigationHandler(), GutterIconRenderer.Alignment.LEFT,
targets));
}
}
}
}
private static <T> void collectTargets(PsiElement element, final ArrayList<T> targets, final Function<PsiElement, T> fun, final boolean stopAtFirst) {
ReferencesSearch.search(element).forEach(new Processor<PsiReference>() {
@Override
public boolean process(PsiReference reference) {
final PsiElement referenceElement = reference.getElement();
if (referenceElement == null) return true;
if (!(referenceElement instanceof XmlAttributeValue)) return true;
final XmlAttributeValue attributeValue = (XmlAttributeValue)referenceElement;
final PsiElement parent = attributeValue.getParent();
if (!(parent instanceof XmlAttribute)) return true;
final PsiFile containingFile = referenceElement.getContainingFile();
if (containingFile == null) return true;
if (JavaFxFileTypeFactory.isFxml(containingFile)) {
targets.add(fun.fun(parent));
if (stopAtFirst) return false;
}
return true;
}
});
}
private static class JavaFXIdIconNavigationHandler implements GutterIconNavigationHandler<PsiField> {
@Override
public void navigate(MouseEvent e, PsiField field) {
final ArrayList<PsiElement> relatedItems = new ArrayList<PsiElement>();
collectTargets(field, relatedItems, Function.ID, false);
if (relatedItems.size() == 1) {
NavigationUtil.activateFileWithPsiElement(relatedItems.get(0));
return;
}
final JBPopup popup = NavigationUtil
.getPsiElementPopup(relatedItems.toArray(new PsiElement[relatedItems.size()]), "<html>Choose component with fx:id <b>" + field.getName() + "<b></html>");
popup.show(new RelativePoint(e));
}
}
}
@@ -4,17 +4,22 @@ import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.codeInsight.daemon.Validator;
import com.intellij.codeInsight.daemon.impl.analysis.GenericsHighlightUtil;
import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.xml.XmlAttributeImpl;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.searches.ClassInheritorsSearch;
import com.intellij.psi.util.InheritanceUtil;
import com.intellij.psi.util.PropertyUtil;
import com.intellij.psi.util.PsiUtil;
import com.intellij.psi.util.TypeConversionUtil;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Function;
import com.intellij.util.Processor;
import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlElementDescriptor;
import com.intellij.xml.XmlElementsGroup;
@@ -279,6 +284,31 @@ public class JavaFxClassBackedElementDescriptor implements XmlElementDescriptor,
}
}
validateTagAccordingToFieldType(context, parentTag, host);
if (myPsiClass != null && myPsiClass.isValid()) {
if(myPsiClass.getConstructors().length > 0) {
final Project project = myPsiClass.getProject();
final PsiMethod noArgConstructor = myPsiClass
.findMethodBySignature(JavaPsiFacade.getElementFactory(project).createConstructor(myPsiClass.getName()), false);
if (noArgConstructor == null) {
final PsiClass builderClass = JavaPsiFacade.getInstance(project).findClass(JavaFxCommonClassNames.JAVAFX_FXML_BUILDER,
GlobalSearchScope.allScope(project));
if (builderClass != null) {
//todo cache this info
final PsiTypeParameter typeParameter = builderClass.getTypeParameters()[0];
if (ClassInheritorsSearch.search(builderClass).forEach(new Processor<PsiClass>() {
@Override
public boolean process(PsiClass aClass) {
final PsiType initType =
TypeConversionUtil.getSuperClassSubstitutor(builderClass, aClass, PsiSubstitutor.EMPTY).substitute(typeParameter);
return !Comparing.equal(myPsiClass, PsiUtil.resolveClassInClassTypeOnly(initType));
}
})) {
host.addMessage(context, "Unable to instantiate", ValidationHost.ErrorType.ERROR);
}
}
}
}
}
}
private void validateTagAccordingToFieldType(XmlTag context, XmlTag parentTag, ValidationHost host) {
@@ -16,10 +16,16 @@
package org.jetbrains.plugins.javaFX.fxml.descriptors;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiField;
import com.intellij.psi.PsiModifier;
import com.intellij.psi.*;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlAttributeValue;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlTag;
import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlElementDescriptor;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.javaFX.fxml.FxmlConstants;
import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil;
import java.util.List;
@@ -29,6 +35,7 @@ import java.util.List;
*/
public class JavaFxDefaultAttributeDescriptor extends JavaFxPropertyAttributeDescriptor {
private static final Logger LOG = Logger.getInstance("#" + JavaFxDefaultAttributeDescriptor.class.getName());
public static final String VALUE_OF = "valueOf";
private String myDefaultPropertyName = null;
public JavaFxDefaultAttributeDescriptor(String name, PsiClass psiClass) {
@@ -67,4 +74,41 @@ public class JavaFxDefaultAttributeDescriptor extends JavaFxPropertyAttributeDes
protected boolean isConstant(PsiField field) {
return field.hasModifierProperty(PsiModifier.STATIC) && field.hasModifierProperty(PsiModifier.FINAL) && field.hasModifierProperty(PsiModifier.PUBLIC);
}
@Nullable
@Override
public String validateValue(XmlElement context, String value) {
if (context instanceof XmlAttributeValue) {
final PsiElement parent = context.getParent();
if (parent instanceof XmlAttribute) {
final XmlAttribute attribute = (XmlAttribute)parent;
if (FxmlConstants.FX_VALUE.equals(attribute.getName())) {
final PsiClass tagClass = JavaFxPsiUtil.getTagClass((XmlAttributeValue)context);
if (tagClass != null) {
final PsiMethod method = getValueOfMethod(tagClass);
if (method == null) {
return "Unable to coerce '" + value + "' to " + tagClass.getQualifiedName() + ".";
}
}
}
}
}
return super.validateValue(context, value);
}
private static PsiMethod getValueOfMethod(PsiClass tagClass) {
final PsiMethod[] methods = tagClass.findMethodsByName(VALUE_OF, false);
for (PsiMethod method : methods) {
if (method.hasModifierProperty(PsiModifier.STATIC)) {
final PsiParameter[] parameters = method.getParameterList().getParameters();
if (parameters.length == 1) {
final PsiType type = parameters[0].getType();
if (type.equalsToText(CommonClassNames.JAVA_LANG_STRING) || type.equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
return method;
}
}
}
}
return null;
}
}
@@ -66,7 +66,7 @@ public class JavaFxDefaultPropertyElementDescriptor implements XmlElementDescrip
@Nullable
@Override
public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) {
if (myName.equals(FxmlConstants.FX_DEFINE)) {
if (myName.equals(FxmlConstants.FX_DEFINE) || myName.equals(FxmlConstants.FX_ROOT)) {
final String name = childTag.getName();
if (JavaFxPsiUtil.isClassTag(name)) {
return new JavaFxClassBackedElementDescriptor(name, childTag);
@@ -15,15 +15,14 @@
*/
package org.jetbrains.plugins.javaFX.fxml.refs;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.psi.PsiReferenceBase;
import com.intellij.psi.PsiReferenceProvider;
import com.intellij.psi.*;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlAttributeValue;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ProcessingContext;
import com.intellij.xml.XmlAttributeDescriptor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.javaFX.fxml.descriptors.JavaFxPropertyAttributeDescriptor;
/**
@@ -39,7 +38,20 @@ class EnumeratedAttributeReferenceProvider extends PsiReferenceProvider {
if (parent instanceof XmlAttribute) {
final XmlAttributeDescriptor descriptor = ((XmlAttribute)parent).getDescriptor();
if (descriptor instanceof JavaFxPropertyAttributeDescriptor && descriptor.isEnumerated()) {
return new PsiReference[] {new PsiReferenceBase.Immediate<XmlAttributeValue>(xmlAttributeValue, ((JavaFxPropertyAttributeDescriptor)descriptor).getEnumConstant(xmlAttributeValue.getValue()))};
final PsiField enumConstant = ((JavaFxPropertyAttributeDescriptor)descriptor).getEnumConstant(xmlAttributeValue.getValue());
return new PsiReference[] {new PsiReferenceBase<XmlAttributeValue>(xmlAttributeValue){
@Nullable
@Override
public PsiElement resolve() {
return enumConstant;
}
@NotNull
@Override
public Object[] getVariants() {
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
}};
}
}
}
@@ -41,6 +41,12 @@ public class FxmlReferencesContributor extends PsiReferenceContributor {
.and(attributeValueInFxml),
CLASS_REFERENCE_PROVIDER);
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue()
.withParent(XmlPatterns.xmlAttribute().withName("type")
.withParent(XmlPatterns.xmlTag().withName(FxmlConstants.FX_ROOT)))
.and(attributeValueInFxml),
CLASS_REFERENCE_PROVIDER);
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withParent(XmlPatterns.xmlAttribute().withName(FxmlConstants.FX_ID))
.and(attributeValueInFxml),
new JavaFxFieldIdReferenceProvider());
@@ -57,6 +63,10 @@ public class FxmlReferencesContributor extends PsiReferenceContributor {
.and(attributeValueInFxml),
new JavaFxComponentIdReferenceProvider());
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withParent(XmlPatterns.xmlAttribute().withName(FxmlConstants.FX_FACTORY))
.and(attributeValueInFxml),
new JavaFxFactoryReferenceProvider());
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("#"))
.and(attributeValueInFxml),
new JavaFxEventHandlerReferenceProvider());
@@ -64,6 +74,9 @@ public class FxmlReferencesContributor extends PsiReferenceContributor {
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withValue(string().startsWith("@")).and(attributeValueInFxml),
new JavaFxLocationReferenceProvider());
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().withParent(XmlPatterns.xmlAttribute().withName("url")).and(attributeValueInFxml),
new JavaFxLocationReferenceProvider());
registrar.registerReferenceProvider(PlatformPatterns.psiElement(XmlTokenType.XML_TAG_CHARACTERS).inFile(inFxmlElementPattern()), new ImportReferenceProvider());
registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue().and(attributeValueInFxml),
@@ -59,8 +59,7 @@ public class JavaFxAnnotator implements Annotator {
for (PsiReference reference : references) {
final PsiElement resolve = reference.resolve();
if (resolve instanceof PsiMember) {
if (!((PsiMember)resolve).hasModifierProperty(PsiModifier.PUBLIC) &&
!AnnotationUtil.isAnnotated((PsiMember)resolve, Collections.singleton(JavaFxCommonClassNames.JAVAFX_FXML_ANNOTATION))) {
if (!JavaFxPsiUtil.isVisibleInFxml((PsiMember)resolve)) {
final String symbolPresentation = "'" + SymbolPresentationUtil.getSymbolPresentableText(resolve) + "'";
final Annotation annotation = holder.createErrorAnnotation(element,
symbolPresentation + (resolve instanceof PsiClass ? " should be public" : " should be public or annotated with @FXML"));
@@ -15,16 +15,12 @@
*/
package org.jetbrains.plugins.javaFX.fxml.refs;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.*;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlAttributeValue;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.javaFX.fxml.FxmlConstants;
import org.jetbrains.plugins.javaFX.fxml.JavaFxFileTypeFactory;
import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil;
/**
* User: anna
@@ -38,21 +34,8 @@ public abstract class JavaFxControllerBasedReferenceProvider extends PsiReferenc
final PsiFile containingFile = xmlAttrVal.getContainingFile();
if (!JavaFxFileTypeFactory.isFxml(containingFile)) return PsiReference.EMPTY_ARRAY;
final XmlTag rootTag = ((XmlFile)containingFile).getRootTag();
if (rootTag != null) {
final XmlAttribute attribute = rootTag.getAttribute(FxmlConstants.FX_CONTROLLER);
if (attribute != null) {
final String attributeValue = attribute.getValue();
if (!StringUtil.isEmptyOrSpaces(attributeValue)) {
final PsiClass controllerClass =
JavaPsiFacade.getInstance(xmlAttrVal.getProject()).findClass(attributeValue, xmlAttrVal.getResolveScope());
if (controllerClass != null) {
return getReferencesByElement(controllerClass, xmlAttrVal, context);
}
}
}
}
return PsiReference.EMPTY_ARRAY;
final PsiClass controllerClass = JavaFxPsiUtil.getControllerClass(containingFile);
return controllerClass != null ? getReferencesByElement(controllerClass, xmlAttrVal, context) : PsiReference.EMPTY_ARRAY;
}
protected abstract PsiReference[] getReferencesByElement(@NotNull PsiClass controllerClass, XmlAttributeValue element, ProcessingContext context);
@@ -0,0 +1,81 @@
/*
* Copyright 2000-2013 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.javaFX.fxml.refs;
import com.intellij.psi.*;
import com.intellij.psi.xml.XmlAttributeValue;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil;
import java.util.ArrayList;
import java.util.List;
/**
* User: anna
*/
class JavaFxFactoryReferenceProvider extends PsiReferenceProvider {
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement element,
@NotNull ProcessingContext context) {
final XmlAttributeValue attributeValue = (XmlAttributeValue)element;
return new PsiReference[] {new JavaFXFactoryReference(attributeValue)};
}
private static class JavaFXFactoryReference extends PsiReferenceBase<XmlAttributeValue> {
public JavaFXFactoryReference(XmlAttributeValue attributeValue) {
super(attributeValue);
}
@Nullable
@Override
public PsiElement resolve() {
final PsiClass psiClass = JavaFxPsiUtil.getTagClass(getElement());
if (psiClass != null) {
final PsiMethod[] psiMethods = psiClass.findMethodsByName(getElement().getValue(), false);
for (PsiMethod method : psiMethods) {
if (isFactoryMethod(method)) {
return method;
}
}
}
return null;
}
private static boolean isFactoryMethod(PsiMethod method) {
return method.hasModifierProperty(PsiModifier.STATIC) && method.getParameterList().getParametersCount() == 0;
}
@NotNull
@Override
public Object[] getVariants() {
final PsiClass psiClass = JavaFxPsiUtil.getTagClass(getElement());
if (psiClass != null) {
final List<PsiMethod> methods = new ArrayList<PsiMethod>();
for (PsiMethod method : psiClass.getMethods()) {
if (isFactoryMethod(method)) {
methods.add(method);
}
}
return ArrayUtil.toObjectArray(methods);
}
return ArrayUtil.EMPTY_OBJECT_ARRAY;
}
}
}
@@ -15,14 +15,13 @@
*/
package org.jetbrains.plugins.javaFX.fxml.refs;
import com.intellij.codeInsight.AnnotationUtil;
import com.intellij.psi.*;
import com.intellij.psi.xml.XmlAttributeValue;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ProcessingContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.javaFX.fxml.JavaFxCommonClassNames;
import org.jetbrains.plugins.javaFX.fxml.JavaFxPsiUtil;
import java.util.ArrayList;
import java.util.List;
@@ -51,7 +50,7 @@ class JavaFxFieldIdReferenceProvider extends JavaFxControllerBasedReferenceProvi
final PsiField[] fields = aClass.getFields();
for (PsiField psiField : fields) {
if (!psiField.hasModifierProperty(PsiModifier.STATIC)) {
if (psiField.hasModifierProperty(PsiModifier.PUBLIC) || AnnotationUtil.isAnnotated(psiField, JavaFxCommonClassNames.JAVAFX_FXML_ANNOTATION, false)) {
if (JavaFxPsiUtil.isVisibleInFxml(psiField)) {
fieldsToSuggest.add(psiField);
}
}
@@ -32,8 +32,16 @@ class JavaFxLocationReferenceProvider extends PsiReferenceProvider {
public PsiReference[] getReferencesByElement(@NotNull final PsiElement element,
@NotNull ProcessingContext context) {
final String value = ((XmlAttributeValue)element).getValue();
final String relativePathToResource = value.substring(1);
final FileReferenceSet set = new FileReferenceSet(relativePathToResource, element, 2, null, true);
final FileReferenceSet set;
if (value.startsWith("@")) {
set = new FileReferenceSet(value.substring(1), element, 2, null, true);
}
else {
set = new FileReferenceSet(value, element, 1, null, true);
if (value.startsWith("/")) {
set.addCustomization(FileReferenceSet.DEFAULT_PATH_EVALUATOR_OPTION, FileReferenceSet.ABSOLUTE_TOP_LEVEL);
}
}
return set.getAllReferences();
}
}
@@ -0,0 +1,10 @@
<?import javafx.scene.layout.GridPane?>
<?import java.lang.String?>
<?import javafx.collections.FXCollections?>
<GridPane xmlns:fx="http://javafx.com/fxml" fx:controller="sample.Controller">
<fx:define>
<FXCollections fx:factory="<caret>">
<String fx:value="A"/>
</FXCollections>
</fx:define>
</GridPane>
@@ -0,0 +1,10 @@
<?import javafx.scene.layout.GridPane?>
<?import java.lang.String?>
<?import javafx.collections.FXCollections?>
<GridPane xmlns:fx="http://javafx.com/fxml" fx:controller="sample.Controller">
<fx:define>
<FXCollections fx:factory="observableArrayList">
<String fx:value="A"/>
</FXCollections>
</fx:define>
</GridPane>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<javafx.scene.layout.AnchorPane xmlns:fx="http://javafx.com/fxml">
</javafx.scene.layout.AnchorPane>
@@ -10,6 +10,11 @@
<Image url="@appIcon.png"/>
</image>
</ImageView>
<ImageView>
<image>
<Image url="appIcon.png"/>
</image>
</ImageView>
<ImageView>
<image>
<Image url="@<error descr="Cannot resolve file 'unknownIcon.png'">unknownIcon.png</error>"/>
@@ -0,0 +1,9 @@
<?import javafx.scene.layout.GridPane?>
<?import java.io.File?>
<?import javafx.scene.control.Label?>
<GridPane xmlns:fx="http://javafx.com/fxml">
<fx:define>
<<error descr="Unable to instantiate">File</error>/>
<Label/>
</fx:define>
</GridPane>
@@ -0,0 +1,7 @@
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.Label?>
<fx:root type="javafx.scene.layout.VBox" xmlns:fx="http://javafx.com/fxml">
<TextField fx:id="textField" text=""/>
<Label text="Hello"/>
</fx:root>
@@ -0,0 +1,7 @@
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.Label?>
<<error descr="Element fx:root doesn't have required attribute type">fx:root</error> xmlns:fx="http://javafx.com/fxml">
<TextField fx:id="textField" text=""/>
<Label text="Hello"/>
</<error descr="Element fx:root doesn't have required attribute type">fx:root</error>>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.Label?>
<fx:root type="<error descr="Cannot resolve class or package 'unknownPackage'">unknownPackage</error>.<error descr="Cannot resolve class 'unknownClass'">unknownClass</error>" xmlns:fx="http://javafx.com/fxml">
<TextField fx:id="textField" text=""/>
<Label text="Hello"/>
</fx:root>
@@ -0,0 +1,16 @@
<?import javafx.scene.layout.GridPane?>
<?import java.lang.String?>
<?import javafx.collections.FXCollections?>
<?import java.util.ArrayList?>
<GridPane xmlns:fx="http://javafx.com/fxml">
<fx:define>
<FXCollections fx:factory="observableArrayList">
<ArrayList fx:value=<error descr="Unable to coerce 'A' to java.util.ArrayList.">"A"</error>/>
</FXCollections>
<FXCollections fx:factory="observableArrayList">
<String fx:value="A"/>
</FXCollections>
</fx:define>
</GridPane>
@@ -147,6 +147,30 @@ public class JavaFXHighlightingTest extends DaemonAnalyzerTestCase {
doDoTest(false, false);
}
public void testValueOfAcceptance() throws Exception {
doTest();
}
public void testInstantiationAcceptance() throws Exception {
doTest();
}
public void testFQNtagNames() throws Exception {
doTest();
}
public void testRootTag() throws Exception {
doTest();
}
public void testUnresolvedRootTag() throws Exception {
doTest();
}
public void testRootTagWithoutType() throws Exception {
doTest();
}
@NotNull
@Override
protected String getTestDataPath() {
@@ -85,6 +85,10 @@ public class JavaFxCompletionTest extends CompletionTestCase {
doTest("text");
}
public void testFactoryMethods() throws Exception {
doTest("observableArrayList");
}
private void doTest() throws Exception {
doTest(null);
}

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