diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpFile.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpFile.java index 9b5afbc2877c..298e1c663a34 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpFile.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpFile.java @@ -16,14 +16,15 @@ package org.intellij.lang.regexp; import com.intellij.extapi.psi.PsiFileBase; +import com.intellij.lang.Language; import com.intellij.openapi.fileTypes.FileType; import com.intellij.psi.FileViewProvider; import org.jetbrains.annotations.NotNull; public class RegExpFile extends PsiFileBase { - public RegExpFile(FileViewProvider viewProvider) { - super(viewProvider, RegExpLanguage.INSTANCE); + public RegExpFile(FileViewProvider viewProvider, final Language language) { + super(viewProvider, language); } @NotNull diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpLexer.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpLexer.java index 03773f7d4f7f..82642e336963 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpLexer.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpLexer.java @@ -17,12 +17,12 @@ package org.intellij.lang.regexp; import com.intellij.lexer.FlexAdapter; -class RegExpLexer extends FlexAdapter { +public class RegExpLexer extends FlexAdapter { private static final int COMMENT_MODE = 1 << 14; - public RegExpLexer(boolean xmlSchemaMode) { - super(new _RegExLexer(xmlSchemaMode)); + public RegExpLexer(boolean xmlSchemaMode, boolean allowDanglingMetacharacters) { + super(new _RegExLexer(xmlSchemaMode, allowDanglingMetacharacters)); } public void start(CharSequence buffer, int startOffset, int endOffset, int initialState) { diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpParser.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpParser.java index 4785d1759251..b8497416ba6b 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpParser.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpParser.java @@ -18,13 +18,19 @@ package org.intellij.lang.regexp; import com.intellij.lang.ASTNode; import com.intellij.lang.PsiBuilder; import com.intellij.lang.PsiParser; -import com.intellij.psi.tree.IElementType; import com.intellij.psi.StringEscapesTokenTypes; +import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @SuppressWarnings({ "RedundantIfStatement" }) -class RegExpParser implements PsiParser { +public class RegExpParser implements PsiParser { + private boolean myAllowDanglingMetacharacters; + + public void setAllowDanglingMetacharacters(boolean allowDanglingMetacharacters) { + myAllowDanglingMetacharacters = allowDanglingMetacharacters; + } + @NotNull public ASTNode parse(IElementType root, PsiBuilder builder) { // builder.setDebugMode(true); @@ -123,6 +129,10 @@ class RegExpParser implements PsiParser { if (builder.getTokenType() == RegExpTT.LBRACE) { builder.advanceLexer(); + if (builder.getTokenType() != RegExpTT.NUMBER && myAllowDanglingMetacharacters) { + marker.done(RegExpTT.CHARACTER); + return true; + } checkMatches(builder, RegExpTT.NUMBER, "Number expected"); if (builder.getTokenType() == RegExpTT.RBRACE) { builder.advanceLexer(); @@ -157,7 +167,7 @@ class RegExpParser implements PsiParser { return true; } - private void parseQuantifierType(PsiBuilder builder) { + private static void parseQuantifierType(PsiBuilder builder) { if (builder.getTokenType() == RegExpTT.PLUS) { builder.advanceLexer(); } else if (builder.getTokenType() == RegExpTT.QUEST) { @@ -344,14 +354,19 @@ class RegExpParser implements PsiParser { } else if (type == RegExpTT.CLASS_BEGIN) { marker.drop(); return parseClass(builder); - } else { + } + else if (type == RegExpTT.LBRACE && myAllowDanglingMetacharacters) { + builder.advanceLexer(); + marker.done(RegExpElementTypes.CHAR); + } + else { marker.drop(); return null; } return marker; } - private void parseProperty(PsiBuilder builder) { + private static void parseProperty(PsiBuilder builder) { checkMatches(builder, RegExpTT.PROPERTY, "'\\p' expected"); checkMatches(builder, RegExpTT.LBRACE, "Character category expected"); diff --git a/RegExpSupport/src/org/intellij/lang/regexp/RegExpParserDefinition.java b/RegExpSupport/src/org/intellij/lang/regexp/RegExpParserDefinition.java index 5ff73845191e..95f9100736f1 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/RegExpParserDefinition.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/RegExpParserDefinition.java @@ -34,9 +34,9 @@ import org.jetbrains.annotations.NotNull; public class RegExpParserDefinition implements ParserDefinition { private static final TokenSet COMMENT_TOKENS = TokenSet.create(RegExpTT.COMMENT); - @NotNull + @NotNull public Lexer createLexer(Project project) { - return new RegExpLexer(false); + return new RegExpLexer(false, false); } public PsiParser createParser(Project project) { @@ -86,7 +86,7 @@ public class RegExpParserDefinition implements ParserDefinition { return new RegExpSetOptionsImpl(node); } else if (type == RegExpElementTypes.OPTIONS) { return new RegExpOptionsImpl(node); - } else if (type == RegExpElementTypes.BACKREF) { + } else if (type == RegExpElementTypes.BACKREF) { return new RegExpBackrefImpl(node); } else if (type == RegExpElementTypes.CLOSURE) { return new RegExpClosureImpl(node); @@ -101,7 +101,7 @@ public class RegExpParserDefinition implements ParserDefinition { } public PsiFile createFile(FileViewProvider viewProvider) { - return new RegExpFile(viewProvider); + return new RegExpFile(viewProvider, RegExpLanguage.INSTANCE); } public SpaceRequirements spaceExistanceTypeBetweenTokens(ASTNode left, ASTNode right) { diff --git a/RegExpSupport/src/org/intellij/lang/regexp/_RegExLexer.java b/RegExpSupport/src/org/intellij/lang/regexp/_RegExLexer.java index 89ccdee550b8..8de1c26644c5 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/_RegExLexer.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/_RegExLexer.java @@ -1,26 +1,13 @@ -/* - * Copyright 2000-2009 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. - */ +/* The following code was generated by JFlex 1.4.1 on 18.12.09 20:27 */ /* It's an automatically generated code. Do not modify it. */ package org.intellij.lang.regexp; import com.intellij.lexer.FlexLexer; -import com.intellij.psi.tree.IElementType; -import java.util.LinkedList; import com.intellij.psi.StringEscapesTokenTypes; +import com.intellij.psi.tree.IElementType; + +import java.util.LinkedList; // IDEADEV-11055 @SuppressWarnings({ "ALL", "SameParameterValue", "WeakerAccess", "SameReturnValue", "RedundantThrows", "UnusedDeclaration", "UnusedDeclaration" }) @@ -28,8 +15,8 @@ import com.intellij.psi.StringEscapesTokenTypes; /** * This class is a scanner generated by * JFlex 1.4.1 - * on 04.11.09 17:54 from the specification file - * RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex + * on 18.12.09 20:27 from the specification file + * C:/JetBrains/IDEA/tools/lexer/../../community/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex */ class _RegExLexer implements FlexLexer { /** initial size of the lookahead buffer */ @@ -352,9 +339,12 @@ class _RegExLexer implements FlexLexer { // as well, but is currently unfinished as it requires to tweak more places than just the lexer. private boolean xmlSchemaMode; - _RegExLexer(boolean xmlSchemaMode) { + private boolean allowDanglingMetacharacters; + + _RegExLexer(boolean xmlSchemaMode, boolean allowDanglingMetacharacters) { this((java.io.Reader)null); - this.xmlSchemaMode = xmlSchemaMode; + this.xmlSchemaMode = xmlSchemaMode; + this.allowDanglingMetacharacters = allowDanglingMetacharacters; } private void yypushstate(int state) { @@ -431,7 +421,14 @@ class _RegExLexer implements FlexLexer { // For Demetra compatibility public void reset(CharSequence buffer, int initialState){ - reset(buffer, 0, buffer.length(), initialState); + zzBuffer = buffer; + zzBufferArray = null; + zzCurrentPos = zzMarkedPos = zzStartRead = 0; + zzPushbackPos = 0; + zzAtEOF = false; + zzAtBOL = true; + zzEndRead = buffer.length(); + yybegin(initialState); } /** @@ -591,7 +588,7 @@ class _RegExLexer implements FlexLexer { while (true) { if (zzCurrentPosL < zzEndReadL) - zzInput = zzBufferL.charAt(zzCurrentPosL++); + zzInput = zzBufferArrayL != null ? zzBufferArrayL[zzCurrentPosL++]:zzBufferL.charAt(zzCurrentPosL++); else if (zzAtEOF) { zzInput = YYEOF; break zzForAction; @@ -613,7 +610,7 @@ class _RegExLexer implements FlexLexer { break zzForAction; } else { - zzInput = zzBufferL.charAt(zzCurrentPosL++); + zzInput = zzBufferArrayL != null ? zzBufferArrayL[zzCurrentPosL++]:zzBufferL.charAt(zzCurrentPosL++); } } int zzNext = zzTransL[ zzRowMapL[zzState] + zzCMapL[zzInput] ]; @@ -840,45 +837,49 @@ class _RegExLexer implements FlexLexer { { return RegExpTT.HEX_CHAR; } case 111: break; - case 20: - { return RegExpTT.BAD_CHARACTER; - } - case 112: break; case 5: { return RegExpTT.GROUP_BEGIN; } - case 113: break; + case 112: break; case 8: { yypushstate(CLASS2); return RegExpTT.CLASS_BEGIN; } - case 114: break; + case 113: break; case 52: { return RegExpTT.NON_CAPT_GROUP; } - case 115: break; + case 114: break; case 9: { return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN; } - case 116: break; + case 115: break; case 48: { return RegExpTT.BAD_HEX_VALUE; } - case 117: break; + case 116: break; case 2: { yypopstate(); return RegExpTT.COMMENT; } - case 118: break; + case 117: break; case 47: { yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN; } - case 119: break; + case 118: break; case 26: { yybegin(CLASS2); return RegExpTT.CHARACTER; } - case 120: break; + case 119: break; case 15: { return RegExpTT.PLUS; } + case 120: break; + case 20: + { if (allowDanglingMetacharacters) { + yypopstate(); yypushback(1); + } else { + return RegExpTT.BAD_CHARACTER; + } + } case 121: break; case 31: { yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER; diff --git a/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex b/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex index dcd94c284ed0..621fc89cf6e6 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex +++ b/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex @@ -26,9 +26,12 @@ import com.intellij.psi.StringEscapesTokenTypes; // as well, but is currently unfinished as it requires to tweak more places than just the lexer. private boolean xmlSchemaMode; - _RegExLexer(boolean xmlSchemaMode) { + private boolean allowDanglingMetacharacters; + + _RegExLexer(boolean xmlSchemaMode, boolean allowDanglingMetacharacters) { this((java.io.Reader)null); - this.xmlSchemaMode = xmlSchemaMode; + this.xmlSchemaMode = xmlSchemaMode; + this.allowDanglingMetacharacters = allowDanglingMetacharacters; } private void yypushstate(int state) { @@ -157,7 +160,12 @@ HEX_CHAR=[0-9a-fA-F] "," { return RegExpTT.COMMA; } {RBRACE} { yypopstate(); return RegExpTT.RBRACE; } - {ANY} { return RegExpTT.BAD_CHARACTER; } + {ANY} { if (allowDanglingMetacharacters) { + yypopstate(); yypushback(1); + } else { + return RegExpTT.BAD_CHARACTER; + } + } } "-" { return RegExpTT.MINUS; } diff --git a/java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java b/java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java index 1be9dbf1b728..ad4e96779750 100644 --- a/java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java +++ b/java/java-impl/src/com/intellij/psi/search/scope/packageSet/PatternPackageSetParserExtension.java @@ -27,9 +27,9 @@ import com.intellij.psi.search.scope.packageSet.lexer.ScopeTokenTypes; public class PatternPackageSetParserExtension implements PackageSetParserExtension { public PackageSet parsePackageSet(final Lexer lexer, final String scope, final String modulePattern) throws ParsingException { - if (scope == PatternPackageSet.SCOPE_ANY && modulePattern == null) { + /*if (scope == PatternPackageSet.SCOPE_ANY && modulePattern == null) { error(AnalysisScopeBundle.message("error.packageset.common.expectations"), lexer); - } + }*/ if (scope != PatternPackageSet.SCOPE_ANY && scope != PatternPackageSet.SCOPE_LIBRARY && scope != PatternPackageSet.SCOPE_PROBLEM && diff --git a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserConfigurable.java b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserConfigurable.java index 5b703b80f650..a18e67007092 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserConfigurable.java +++ b/platform/lang-impl/src/com/intellij/ide/util/scopeChooser/ScopeChooserConfigurable.java @@ -33,10 +33,7 @@ import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.IconLoader; import com.intellij.packageDependencies.DependencyValidationManager; -import com.intellij.psi.search.scope.packageSet.NamedScope; -import com.intellij.psi.search.scope.packageSet.NamedScopeManager; -import com.intellij.psi.search.scope.packageSet.NamedScopesHolder; -import com.intellij.psi.search.scope.packageSet.PackageSet; +import com.intellij.psi.search.scope.packageSet.*; import com.intellij.ui.TreeSpeedSearch; import com.intellij.util.Icons; import com.intellij.util.containers.Convertor; @@ -126,6 +123,28 @@ public class ScopeChooserConfigurable extends MasterDetailsComponent implements loadStateOrder(); } + @Override + protected void checkApply(Set rootNodes, String prefix, String title) throws ConfigurationException { + super.checkApply(rootNodes, prefix, title); + final Set predefinedScopes = new HashSet(); + for (CustomScopesProvider scopesProvider : myProject.getExtensions(CustomScopesProvider.CUSTOM_SCOPES_PROVIDER)) { + for (NamedScope namedScope : scopesProvider.getCustomScopes()) { + predefinedScopes.add(namedScope.getName()); + } + } + for (MyNode rootNode : rootNodes) { + for (int i = 0; i < rootNode.getChildCount(); i++) { + final MyNode node = (MyNode)rootNode.getChildAt(i); + final NamedConfigurable scopeConfigurable = node.getConfigurable(); + final String name = scopeConfigurable.getDisplayName(); + if (predefinedScopes.contains(name)) { + selectNodeInTree(node); + throw new ConfigurationException("Scope name equals to predefined one", ProjectBundle.message("rename.scope.title")); + } + } + } + } + @Override protected PersistentStateComponent getAdditionalSettings() { return myScopesState; diff --git a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationComponent.java b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationComponent.java index 7ebddd53d6ca..220e049e3061 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationComponent.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationComponent.java @@ -57,7 +57,7 @@ public class NotificationComponent extends JLabel implements NotificationModelLi @Override public void mousePressed(final MouseEvent e) { if (UIUtil.isActionClick(e)) { - showList(); + toggleList(); } } }); @@ -97,16 +97,16 @@ public class NotificationComponent extends JLabel implements NotificationModelLi getManager().addListener(this); } - private void showList() { + private void toggleList() { + JBPopup popup = null; if (myPopupRef != null) { - final JBPopup popup = myPopupRef.get(); - if (popup != null && !popup.isVisible()) { - myPopupRef = null; - } - else if (popup == null) myPopupRef = null; + popup = myPopupRef.get(); + myPopupRef = null; } - if (myPopupRef == null) { + if (popup != null && popup.isVisible()) { + popup.cancel(); + } else { myPopupRef = new WeakReference(NotificationsListPanel.show(getProject(), this)); } } diff --git a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsConfigurablePanel.java b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsConfigurablePanel.java index 1c8b7974521a..0eea82a24e77 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsConfigurablePanel.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/ui/NotificationsConfigurablePanel.java @@ -29,7 +29,9 @@ import javax.swing.table.TableColumn; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; import java.util.ArrayList; +import java.util.EventObject; import java.util.Iterator; import java.util.List; @@ -111,6 +113,15 @@ public class NotificationsConfigurablePanel extends JPanel implements Disposable }); displayTypeColumn.setCellEditor(new ComboBoxTableRenderer(NotificationDisplayType.values()) { + @Override + public boolean isCellEditable(EventObject event) { + if (event instanceof MouseEvent) { + return ((MouseEvent)event).getClickCount() >= 1; + } + + return false; + } + @Override protected String getTextFor(@NotNull NotificationDisplayType value) { return value.getTitle(); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java index c0f79ded8f58..188f00b54b80 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/InfoAndProgressPanel.java @@ -86,6 +86,8 @@ public class InfoAndProgressPanel extends JPanel implements StatusBarPatch { public void mousePressed(MouseEvent e) { if (!myPopup.isShowing()) { openProcessPopup(); + } else { + hideProcessPopup(); } } }); diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseClasspathStorageProvider.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseClasspathStorageProvider.java index ac569f7acc0c..8668f3876f42 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseClasspathStorageProvider.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseClasspathStorageProvider.java @@ -36,10 +36,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.idea.eclipse.EclipseBundle; import org.jetbrains.idea.eclipse.EclipseXml; import org.jetbrains.idea.eclipse.IdeaXml; -import org.jetbrains.idea.eclipse.conversion.ConversionException; -import org.jetbrains.idea.eclipse.conversion.DotProjectFileHelper; -import org.jetbrains.idea.eclipse.conversion.EclipseClasspathReader; -import org.jetbrains.idea.eclipse.conversion.EclipseClasspathWriter; +import org.jetbrains.idea.eclipse.conversion.*; import java.io.File; import java.io.IOException; @@ -70,8 +67,6 @@ public class EclipseClasspathStorageProvider implements ClasspathStorageProvider final Library library = ((LibraryOrderEntry)entry).getLibrary(); if (library == null || entry.getUrls(OrderRootType.CLASSES).length != 1 || - entry.getUrls(OrderRootType.SOURCES).length > 1 || - entry.getUrls(JavadocOrderRootType.getInstance()).length > 1 || library.isJarDirectory(library.getUrls(OrderRootType.CLASSES)[0])) { throw new ConfigurationException( "Library \'" + entry.getPresentableName() + "\' is incompatible with eclipse format which supports only one content root"); @@ -98,7 +93,7 @@ public class EclipseClasspathStorageProvider implements ClasspathStorageProvider return new EclipseClasspathConverter(module); } - static void registerFiles(final CachedXmlDocumentSet fileCache, final Module module, final String moduleRoot, final String storageRoot) { + public static void registerFiles(final CachedXmlDocumentSet fileCache, final Module module, final String moduleRoot, final String storageRoot) { fileCache.register(EclipseXml.CLASSPATH_FILE, storageRoot); fileCache.register(EclipseXml.PROJECT_FILE, storageRoot); fileCache.register(EclipseXml.PLUGIN_XML_FILE, storageRoot); @@ -171,15 +166,16 @@ public class EclipseClasspathStorageProvider implements ClasspathStorageProvider final EclipseClasspathReader classpathReader = new EclipseClasspathReader(path, module.getProject(), null); classpathReader.init(model); if (documentSet.exists(EclipseXml.CLASSPATH_FILE)) { - classpathReader.readClasspath(model, new ArrayList(), new ArrayList(), usedVariables, new HashSet(), null, documentSet.read(EclipseXml.CLASSPATH_FILE).getRootElement()); - final String eml = model.getModule().getName() + EclipseXml.IDEA_SETTINGS_POSTFIX; - if (documentSet.exists(eml)) { - EclipseClasspathReader.readIDEASpecific(documentSet.read(eml).getRootElement(), model); - } else { - model.getModuleExtension(CompilerModuleExtension.class).setExcludeOutput(false); - } + } else { + EclipseClasspathReader.setupOutput(model, path + "/bin"); + } + final String eml = model.getModule().getName() + EclipseXml.IDEA_SETTINGS_POSTFIX; + if (documentSet.exists(eml)) { + IdeaSpecificSettings.readIDEASpecific(documentSet.read(eml).getRootElement(), model); + } else { + model.getModuleExtension(CompilerModuleExtension.class).setExcludeOutput(false); } ((RootModelImpl)model).writeExternal(element); @@ -224,7 +220,7 @@ public class EclipseClasspathStorageProvider implements ClasspathStorageProvider final Element ideaSpecific = new Element(IdeaXml.COMPONENT_TAG); final String emlFilename = model.getModule().getName() + EclipseXml.IDEA_SETTINGS_POSTFIX; - if (classpathWriter.writeIDEASpecificClasspath(ideaSpecific)) { + if (IdeaSpecificSettings.writeIDEASpecificClasspath(ideaSpecific, model)) { fileSet.write(new Document(ideaSpecific), emlFilename); } else { diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java index 3a089d2144ae..10a203cf9696 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java @@ -32,9 +32,7 @@ import com.intellij.openapi.roots.libraries.Library; import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.InvalidDataException; import com.intellij.openapi.util.SystemInfo; -import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.JarFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -153,9 +151,7 @@ public class EclipseClasspathReader { } else if (kind.equals(EclipseXml.OUTPUT_KIND)) { - final CompilerModuleExtension compilerModuleExtension = rootModel.getModuleExtension(CompilerModuleExtension.class); - compilerModuleExtension.setCompilerOutputPath(VfsUtil.pathToUrl(myRootPath + "/" + path)); - compilerModuleExtension.inheritCompilerOutputPath(false); + setupOutput(rootModel, myRootPath + "/" + path); } else if (kind.equals(EclipseXml.LIB_KIND)) { @@ -277,6 +273,12 @@ public class EclipseClasspathReader { } } + public static void setupOutput(ModifiableRootModel rootModel, final String path) { + final CompilerModuleExtension compilerModuleExtension = rootModel.getModuleExtension(CompilerModuleExtension.class); + compilerModuleExtension.setCompilerOutputPath(VfsUtil.pathToUrl(path)); + compilerModuleExtension.inheritCompilerOutputPath(false); + } + private static void setLibraryEntryExported(ModifiableRootModel rootModel, boolean exported, Library library) { for (OrderEntry orderEntry : rootModel.getOrderEntries()) { if (orderEntry instanceof LibraryOrderEntry && @@ -485,109 +487,4 @@ public class EclipseClasspathReader { return url; } - public static void readIDEASpecific(final Element root, ModifiableRootModel model) throws InvalidDataException { - PathMacroManager.getInstance(model.getModule()).expandPaths(root); - - model.getModuleExtension(LanguageLevelModuleExtension.class).readExternal(root); - - final CompilerModuleExtension compilerModuleExtension = model.getModuleExtension(CompilerModuleExtension.class); - final Element testOutputElement = root.getChild(IdeaXml.OUTPUT_TEST_TAG); - if (testOutputElement != null) { - compilerModuleExtension.setCompilerOutputPathForTests(testOutputElement.getAttributeValue(IdeaXml.URL_ATTR)); - } - - final String inheritedOutput = root.getAttributeValue(IdeaXml.INHERIT_COMPILER_OUTPUT_ATTR); - if (inheritedOutput != null && Boolean.valueOf(inheritedOutput).booleanValue()) { - compilerModuleExtension.inheritCompilerOutputPath(true); - } - - compilerModuleExtension.setExcludeOutput(root.getChild(IdeaXml.EXCLUDE_OUTPUT_TAG) != null); - - final List entriesElements = root.getChildren(IdeaXml.CONTENT_ENTRY_TAG); - if (!entriesElements.isEmpty()) { - for (Object o : entriesElements) { - readContentEntry((Element)o, model.addContentEntry(((Element)o).getAttributeValue(IdeaXml.URL_ATTR))); - } - } else { - final ContentEntry[] entries = model.getContentEntries(); - if (entries.length > 0) { - readContentEntry(root, entries[0]); - } - } - - for (Object o : root.getChildren("lib")) { - Element libElement = (Element)o; - final String libName = libElement.getAttributeValue("name"); - final Library libraryByName = model.getModuleLibraryTable().getLibraryByName(libName); - if (libraryByName != null) { - final LibraryOrderEntry libraryOrderEntry = model.findLibraryOrderEntry(libraryByName); - if (libraryOrderEntry != null) { - final String scopeAttribute = libElement.getAttributeValue("scope"); - libraryOrderEntry.setScope(scopeAttribute == null ? DependencyScope.COMPILE : DependencyScope.valueOf(scopeAttribute)); - } - final Library.ModifiableModel modifiableModel = libraryByName.getModifiableModel(); - for (Object r : libElement.getChildren("srcroot")) { - modifiableModel.addRoot(((Element)r).getAttributeValue("url"), OrderRootType.SOURCES); - } - replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, OrderRootType.SOURCES, "relative-module-src"); - replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, OrderRootType.CLASSES, "relative-module-cls"); - modifiableModel.commit(); - } else { //try to replace everywhere - final Library[] libraries = model.getModuleLibraryTable().getLibraries(); - for (Library library : libraries) { - final Library.ModifiableModel modifiableModel = library.getModifiableModel(); - replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, OrderRootType.SOURCES, "relative-module-src"); - replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, OrderRootType.CLASSES, "relative-module-cls"); - modifiableModel.commit(); - } - } - } - } - - private static void replaceModuleRelatedRoots(final Project project, final Library.ModifiableModel modifiableModel, final Element libElement, - final OrderRootType orderRootType, final String relativeModuleName) { - final List urls = new ArrayList(Arrays.asList(modifiableModel.getUrls(orderRootType))); - for (Object r : libElement.getChildren(relativeModuleName)) { - final String root = PathMacroManager.getInstance(project).expandPath(((Element)r).getAttributeValue("project-related")); - for (Iterator iterator = urls.iterator(); iterator.hasNext();) { - String url = iterator.next(); - if (root.contains(VfsUtil.urlToPath(url))) { - iterator.remove(); - modifiableModel.removeRoot(url, orderRootType); - modifiableModel.addRoot(root, orderRootType); - break; - } - } - } - } - - private static void readContentEntry(Element root, ContentEntry entry) { - for (Object o : root.getChildren(IdeaXml.TEST_FOLDER_TAG)) { - final String url = ((Element)o).getAttributeValue(IdeaXml.URL_ATTR); - SourceFolder folderToBeTest = null; - for (SourceFolder folder : entry.getSourceFolders()) { - if (Comparing.strEqual(folder.getUrl(), url)) { - folderToBeTest = folder; - break; - } - } - if (folderToBeTest != null) { - entry.removeSourceFolder(folderToBeTest); - } - entry.addSourceFolder(url, true); - } - - final String url = entry.getUrl(); - for (Object o : root.getChildren(IdeaXml.EXCLUDE_FOLDER_TAG)) { - final String excludeUrl = ((Element)o).getAttributeValue(IdeaXml.URL_ATTR); - try { - if (FileUtil.isAncestor(new File(url), new File(excludeUrl), false)) { //check if it is excluded manually - entry.addExcludeFolder(excludeUrl); - } - } - catch (IOException e) { - //ignore - } - } - } } diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathWriter.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathWriter.java index 012a3915606a..cf71b7650dd5 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathWriter.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathWriter.java @@ -30,7 +30,6 @@ import com.intellij.openapi.projectRoots.Sdk; import com.intellij.openapi.roots.*; import com.intellij.openapi.roots.impl.ProjectRootManagerImpl; import com.intellij.openapi.util.Comparing; -import com.intellij.openapi.util.WriteExternalException; import com.intellij.openapi.util.text.CharFilter; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.JarFileSystem; @@ -38,7 +37,6 @@ import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileManager; import com.intellij.openapi.vfs.ex.http.HttpFileSystem; -import com.intellij.pom.java.LanguageLevel; import org.jdom.Element; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.Nullable; @@ -309,111 +307,6 @@ public class EclipseClasspathWriter { return (leaveLeadingSlash ? "/" : "") + stripped; } - public boolean writeIDEASpecificClasspath(final Element root) throws WriteExternalException { - - boolean isModified = false; - - final CompilerModuleExtension compilerModuleExtension = myModel.getModuleExtension(CompilerModuleExtension.class); - - if (compilerModuleExtension.getCompilerOutputPathForTests() != null) { - final Element pathElement = new Element(IdeaXml.OUTPUT_TEST_TAG); - pathElement.setAttribute(IdeaXml.URL_ATTR, compilerModuleExtension.getCompilerOutputUrlForTests()); - root.addContent(pathElement); - isModified = true; - } - if (compilerModuleExtension.isCompilerOutputPathInherited()) { - root.setAttribute(IdeaXml.INHERIT_COMPILER_OUTPUT_ATTR, String.valueOf(true)); - isModified = true; - } - if (compilerModuleExtension.isExcludeOutput()) { - root.addContent(new Element(IdeaXml.EXCLUDE_OUTPUT_TAG)); - isModified = true; - } - - final LanguageLevelModuleExtension languageLevelModuleExtension = myModel.getModuleExtension(LanguageLevelModuleExtension.class); - final LanguageLevel languageLevel = languageLevelModuleExtension.getLanguageLevel(); - if (languageLevel != null) { - languageLevelModuleExtension.writeExternal(root); - isModified = true; - } - - for (ContentEntry entry : myModel.getContentEntries()) { - final Element contentEntryElement = new Element(IdeaXml.CONTENT_ENTRY_TAG); - contentEntryElement.setAttribute(IdeaXml.URL_ATTR, entry.getUrl()); - root.addContent(contentEntryElement); - for (SourceFolder sourceFolder : entry.getSourceFolders()) { - if (sourceFolder.isTestSource()) { - Element element = new Element(IdeaXml.TEST_FOLDER_TAG); - contentEntryElement.addContent(element); - element.setAttribute(IdeaXml.URL_ATTR, sourceFolder.getUrl()); - isModified = true; - } - } - - final VirtualFile entryFile = entry.getFile(); - for (ExcludeFolder excludeFolder : entry.getExcludeFolders()) { - final String exludeFolderUrl = excludeFolder.getUrl(); - final VirtualFile excludeFile = excludeFolder.getFile(); - if (entryFile == null || excludeFile == null || VfsUtil.isAncestor(entryFile, excludeFile, false)) { - Element element = new Element(IdeaXml.EXCLUDE_FOLDER_TAG); - contentEntryElement.addContent(element); - element.setAttribute(IdeaXml.URL_ATTR, exludeFolderUrl); - isModified = true; - } - } - } - - for (OrderEntry entry : myModel.getOrderEntries()) { - if (entry instanceof LibraryOrderEntry && ((LibraryOrderEntry)entry).isModuleLevel()) { - final Element element = new Element("lib"); - element.setAttribute("name", entry.getPresentableName()); - final DependencyScope scope = ((LibraryOrderEntry)entry).getScope(); - element.setAttribute("scope", scope.name()); - final String[] urls = entry.getUrls(OrderRootType.SOURCES); - if (urls.length > 1) { - for (int i = 0; i < urls.length - 1; i++) { - Element srcElement = new Element("srcroot"); - srcElement.setAttribute("url", urls[i]); - element.addContent(srcElement); - } - } - - for (String srcUrl : entry.getUrls(OrderRootType.SOURCES)) { - appendModuleRelatedRoot(element, srcUrl, "relative-module-src"); - } - for (String classesUrl : entry.getUrls(OrderRootType.CLASSES)) { - appendModuleRelatedRoot(element, classesUrl, "relative-module-cls"); - } - if (!element.getChildren().isEmpty() || !scope.equals(DependencyScope.COMPILE)) root.addContent(element); - } - } - - PathMacroManager.getInstance(myModel.getModule()).collapsePaths(root); - - return isModified; - } - - private boolean appendModuleRelatedRoot(Element element, String classesUrl, final String rootMame) { - VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(classesUrl); - if (file != null) { - if (file.getFileSystem() instanceof JarFileSystem) { - file = JarFileSystem.getInstance().getVirtualFileForJar(file); - assert file != null; - } - final Module module = ModuleUtil.findModuleForFile(file, myModel.getProject()); - if (module != null && module != myModel.getModule()) { - final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots(); - if (contentRoots.length > 0 && VfsUtil.isAncestor(contentRoots[0], file, false)) { - final Element clsElement = new Element(rootMame); - clsElement.setAttribute("project-related", PathMacroManager.getInstance(module.getProject()).collapsePath(classesUrl)); - element.addContent(clsElement); - return true; - } - } - } - return false; - } - private static Element addOrderEntry(String kind, String path, Element classpathRoot, Element oldRoot) { if (oldRoot != null) { diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java new file mode 100644 index 000000000000..5d3ec44f1b26 --- /dev/null +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/IdeaSpecificSettings.java @@ -0,0 +1,297 @@ +/* + * Copyright 2000-2009 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. + */ + +/* + * User: anna + * Date: 18-Dec-2009 + */ +package org.jetbrains.idea.eclipse.conversion; + +import com.intellij.openapi.components.PathMacroManager; +import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleUtil; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.*; +import com.intellij.openapi.roots.libraries.Library; +import com.intellij.openapi.util.Comparing; +import com.intellij.openapi.util.InvalidDataException; +import com.intellij.openapi.util.WriteExternalException; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.vfs.JarFileSystem; +import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.pom.java.LanguageLevel; +import org.jdom.Element; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.idea.eclipse.IdeaXml; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +/** + * Read/write .eml + */ +public class IdeaSpecificSettings { + @NonNls private static final String RELATIVE_MODULE_SRC = "relative-module-src"; + @NonNls private static final String RELATIVE_MODULE_CLS = "relative-module-cls"; + @NonNls private static final String PROJECT_RELATED = "project-related"; + @NonNls private static final String SRCROOT_ATTR = "srcroot"; + private static final Logger LOG = Logger.getInstance("#" + IdeaSpecificSettings.class.getName()); + + private IdeaSpecificSettings() { + } + + public static void readIDEASpecific(final Element root, ModifiableRootModel model) throws InvalidDataException { + PathMacroManager.getInstance(model.getModule()).expandPaths(root); + + model.getModuleExtension(LanguageLevelModuleExtension.class).readExternal(root); + + final CompilerModuleExtension compilerModuleExtension = model.getModuleExtension(CompilerModuleExtension.class); + final Element testOutputElement = root.getChild(IdeaXml.OUTPUT_TEST_TAG); + if (testOutputElement != null) { + compilerModuleExtension.setCompilerOutputPathForTests(testOutputElement.getAttributeValue(IdeaXml.URL_ATTR)); + } + + final String inheritedOutput = root.getAttributeValue(IdeaXml.INHERIT_COMPILER_OUTPUT_ATTR); + if (inheritedOutput != null && Boolean.valueOf(inheritedOutput).booleanValue()) { + compilerModuleExtension.inheritCompilerOutputPath(true); + } + + compilerModuleExtension.setExcludeOutput(root.getChild(IdeaXml.EXCLUDE_OUTPUT_TAG) != null); + + final List entriesElements = root.getChildren(IdeaXml.CONTENT_ENTRY_TAG); + if (!entriesElements.isEmpty()) { + for (Object o : entriesElements) { + readContentEntry((Element)o, model.addContentEntry(((Element)o).getAttributeValue(IdeaXml.URL_ATTR))); + } + } else { + final ContentEntry[] entries = model.getContentEntries(); + if (entries.length > 0) { + readContentEntry(root, entries[0]); + } + } + + for (Object o : root.getChildren("lib")) { + Element libElement = (Element)o; + final String libName = libElement.getAttributeValue("name"); + final Library libraryByName = model.getModuleLibraryTable().getLibraryByName(libName); + if (libraryByName != null) { + final LibraryOrderEntry libraryOrderEntry = model.findLibraryOrderEntry(libraryByName); + if (libraryOrderEntry != null) { + final String scopeAttribute = libElement.getAttributeValue("scope"); + libraryOrderEntry.setScope(scopeAttribute == null ? DependencyScope.COMPILE : DependencyScope.valueOf(scopeAttribute)); + } + final Library.ModifiableModel modifiableModel = libraryByName.getModifiableModel(); + replaceCollapsedByEclipseSourceRoots(libElement, modifiableModel); + replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, OrderRootType.SOURCES, RELATIVE_MODULE_SRC); + replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, OrderRootType.CLASSES, RELATIVE_MODULE_CLS); + modifiableModel.commit(); + } else { //try to replace everywhere + final Library[] libraries = model.getModuleLibraryTable().getLibraries(); + for (Library library : libraries) { + final Library.ModifiableModel modifiableModel = library.getModifiableModel(); + replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, OrderRootType.SOURCES, RELATIVE_MODULE_SRC); + replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, OrderRootType.CLASSES, RELATIVE_MODULE_CLS); + modifiableModel.commit(); + } + } + } + } + + /** + * Eclipse detect sources inside zip automatically while IDEA doesn't. + * So .eml contains expanded roots which should replace zip root read from .classpath + */ + private static void replaceCollapsedByEclipseSourceRoots(Element libElement, Library.ModifiableModel modifiableModel) { + String[] srcUrlsFromClasspath = modifiableModel.getUrls(OrderRootType.SOURCES); + LOG.assertTrue(srcUrlsFromClasspath.length <= 1); + for (Object r : libElement.getChildren(SRCROOT_ATTR)) { + final String url = ((Element)r).getAttributeValue("url"); + modifiableModel.addRoot(url, OrderRootType.SOURCES); + if (srcUrlsFromClasspath != null && srcUrlsFromClasspath.length == 1 && url.contains(VfsUtil.urlToPath(srcUrlsFromClasspath[0]))) { //remove compound root + modifiableModel.removeRoot(srcUrlsFromClasspath[0], OrderRootType.SOURCES); + srcUrlsFromClasspath = null; + } + } + } + + public static void replaceModuleRelatedRoots(final Project project, + final Library.ModifiableModel modifiableModel, final Element libElement, + final OrderRootType orderRootType, final String relativeModuleName) { + final List urls = new ArrayList(Arrays.asList(modifiableModel.getUrls(orderRootType))); + for (Object r : libElement.getChildren(relativeModuleName)) { + final String root = PathMacroManager.getInstance(project).expandPath(((Element)r).getAttributeValue(PROJECT_RELATED)); + for (Iterator iterator = urls.iterator(); iterator.hasNext();) { + String url = iterator.next(); + if (root.contains(VfsUtil.urlToPath(url))) { + iterator.remove(); + modifiableModel.removeRoot(url, orderRootType); + modifiableModel.addRoot(root, orderRootType); + break; + } + } + } + } + + public static void readContentEntry(Element root, ContentEntry entry) { + for (Object o : root.getChildren(IdeaXml.TEST_FOLDER_TAG)) { + final String url = ((Element)o).getAttributeValue(IdeaXml.URL_ATTR); + SourceFolder folderToBeTest = null; + for (SourceFolder folder : entry.getSourceFolders()) { + if (Comparing.strEqual(folder.getUrl(), url)) { + folderToBeTest = folder; + break; + } + } + if (folderToBeTest != null) { + entry.removeSourceFolder(folderToBeTest); + } + entry.addSourceFolder(url, true); + } + + final String url = entry.getUrl(); + for (Object o : root.getChildren(IdeaXml.EXCLUDE_FOLDER_TAG)) { + final String excludeUrl = ((Element)o).getAttributeValue(IdeaXml.URL_ATTR); + try { + if (FileUtil.isAncestor(new File(url), new File(excludeUrl), false)) { //check if it is excluded manually + entry.addExcludeFolder(excludeUrl); + } + } + catch (IOException e) { + //ignore + } + } + } + + public static boolean writeIDEASpecificClasspath(final Element root, ModifiableRootModel model) throws WriteExternalException { + + boolean isModified = false; + + final CompilerModuleExtension compilerModuleExtension = model.getModuleExtension(CompilerModuleExtension.class); + + if (compilerModuleExtension.getCompilerOutputPathForTests() != null) { + final Element pathElement = new Element(IdeaXml.OUTPUT_TEST_TAG); + pathElement.setAttribute(IdeaXml.URL_ATTR, compilerModuleExtension.getCompilerOutputUrlForTests()); + root.addContent(pathElement); + isModified = true; + } + if (compilerModuleExtension.isCompilerOutputPathInherited()) { + root.setAttribute(IdeaXml.INHERIT_COMPILER_OUTPUT_ATTR, String.valueOf(true)); + isModified = true; + } + if (compilerModuleExtension.isExcludeOutput()) { + root.addContent(new Element(IdeaXml.EXCLUDE_OUTPUT_TAG)); + isModified = true; + } + + final LanguageLevelModuleExtension languageLevelModuleExtension = model.getModuleExtension(LanguageLevelModuleExtension.class); + final LanguageLevel languageLevel = languageLevelModuleExtension.getLanguageLevel(); + if (languageLevel != null) { + languageLevelModuleExtension.writeExternal(root); + isModified = true; + } + + for (ContentEntry entry : model.getContentEntries()) { + final Element contentEntryElement = new Element(IdeaXml.CONTENT_ENTRY_TAG); + contentEntryElement.setAttribute(IdeaXml.URL_ATTR, entry.getUrl()); + root.addContent(contentEntryElement); + for (SourceFolder sourceFolder : entry.getSourceFolders()) { + if (sourceFolder.isTestSource()) { + Element element = new Element(IdeaXml.TEST_FOLDER_TAG); + contentEntryElement.addContent(element); + element.setAttribute(IdeaXml.URL_ATTR, sourceFolder.getUrl()); + isModified = true; + } + } + + final VirtualFile entryFile = entry.getFile(); + for (ExcludeFolder excludeFolder : entry.getExcludeFolders()) { + final String exludeFolderUrl = excludeFolder.getUrl(); + final VirtualFile excludeFile = excludeFolder.getFile(); + if (entryFile == null || excludeFile == null || VfsUtil.isAncestor(entryFile, excludeFile, false)) { + Element element = new Element(IdeaXml.EXCLUDE_FOLDER_TAG); + contentEntryElement.addContent(element); + element.setAttribute(IdeaXml.URL_ATTR, exludeFolderUrl); + isModified = true; + } + } + } + + for (OrderEntry entry : model.getOrderEntries()) { + if (entry instanceof LibraryOrderEntry && ((LibraryOrderEntry)entry).isModuleLevel()) { + final Element element = new Element("lib"); + element.setAttribute("name", entry.getPresentableName()); + final DependencyScope scope = ((LibraryOrderEntry)entry).getScope(); + element.setAttribute("scope", scope.name()); + final String[] urls = entry.getUrls(OrderRootType.SOURCES); + if (urls.length > 1) { + for (int i = 0; i < urls.length - 1; i++) { + Element srcElement = new Element(SRCROOT_ATTR); + srcElement.setAttribute("url", urls[i]); + element.addContent(srcElement); + } + } + else if (urls.length == 1 && urls[0].contains(JarFileSystem.JAR_SEPARATOR)) { + final VirtualFile virtualFile = JarFileSystem.getInstance().findFileByPath(VfsUtil.urlToPath(urls[0])); + if (virtualFile != null) { + Element srcElement = new Element(SRCROOT_ATTR); + srcElement.setAttribute("url", urls[0]); + element.addContent(srcElement); + } + } + + for (String srcUrl : entry.getUrls(OrderRootType.SOURCES)) { + appendModuleRelatedRoot(element, srcUrl, RELATIVE_MODULE_SRC, model); + } + for (String classesUrl : entry.getUrls(OrderRootType.CLASSES)) { + appendModuleRelatedRoot(element, classesUrl, RELATIVE_MODULE_CLS, model); + } + if (!element.getChildren().isEmpty() || !scope.equals(DependencyScope.COMPILE)) root.addContent(element); + } + } + + PathMacroManager.getInstance(model.getModule()).collapsePaths(root); + + return isModified; + } + + public static boolean appendModuleRelatedRoot(Element element, String classesUrl, final String rootMame, ModifiableRootModel model) { + VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(classesUrl); + if (file != null) { + if (file.getFileSystem() instanceof JarFileSystem) { + file = JarFileSystem.getInstance().getVirtualFileForJar(file); + assert file != null; + } + final Module module = ModuleUtil.findModuleForFile(file, model.getProject()); + if (module != null && module != model.getModule()) { + final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots(); + if (contentRoots.length > 0 && VfsUtil.isAncestor(contentRoots[0], file, false)) { + final Element clsElement = new Element(rootMame); + clsElement.setAttribute(PROJECT_RELATED, PathMacroManager.getInstance(module.getProject()).collapsePath(classesUrl)); + element.addContent(clsElement); + return true; + } + } + } + return false; + } +} \ No newline at end of file diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/export/ExportEclipseProjectsAction.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/export/ExportEclipseProjectsAction.java index 297c863e9a34..0b1f554a2006 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/export/ExportEclipseProjectsAction.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/export/ExportEclipseProjectsAction.java @@ -39,10 +39,7 @@ import org.jetbrains.idea.eclipse.EclipseBundle; import org.jetbrains.idea.eclipse.EclipseXml; import org.jetbrains.idea.eclipse.IdeaXml; import org.jetbrains.idea.eclipse.config.EclipseClasspathStorageProvider; -import org.jetbrains.idea.eclipse.conversion.ConversionException; -import org.jetbrains.idea.eclipse.conversion.DotProjectFileHelper; -import org.jetbrains.idea.eclipse.conversion.EclipseClasspathWriter; -import org.jetbrains.idea.eclipse.conversion.EclipseUserLibrariesHelper; +import org.jetbrains.idea.eclipse.conversion.*; import java.io.File; import java.io.IOException; @@ -115,7 +112,7 @@ public class ExportEclipseProjectsAction extends AnAction implements DumbAware { EclipseJDOMUtil.output(new Document(classpathEleemnt), classpathFile, project); final Element ideaSpecific = new Element(IdeaXml.COMPONENT_TAG); - if (classpathWriter.writeIDEASpecificClasspath(ideaSpecific)) { + if (IdeaSpecificSettings.writeIDEASpecificClasspath(ideaSpecific, model)) { final File emlFile = new File(storageRoot, module.getName() + EclipseXml.IDEA_SETTINGS_POSTFIX); if (!FileUtil.createIfDoesntExist(emlFile)) continue; EclipseJDOMUtil.output(new Document(ideaSpecific), emlFile, project); diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseImportBuilder.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseImportBuilder.java index c4359c29c00f..23c0da2aeb0b 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseImportBuilder.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseImportBuilder.java @@ -47,9 +47,9 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.packaging.artifacts.ModifiableArtifactModel; import com.intellij.projectImport.ProjectImportBuilder; import com.intellij.util.Function; -import com.intellij.packaging.artifacts.ModifiableArtifactModel; import org.jdom.Element; import org.jdom.JDOMException; import org.jetbrains.annotations.NotNull; @@ -264,6 +264,8 @@ public class EclipseImportBuilder extends ProjectImportBuilder implement final Element classpathElement = JDOMUtil.loadDocument(classpathFile).getRootElement(); classpathReader.readClasspath(rootModel, unknownLibraries, unknownJdks, usedVariables, refsToModules, getParameters().converterOptions.testPattern, classpathElement); + } else { + EclipseClasspathReader.setupOutput(rootModel, path + "/bin"); } ClasspathStorage.setStorageType(rootModel, getParameters().linkConverted ? EclipseClasspathStorageProvider.ID : ClasspathStorage.DEFAULT_STORAGE); diff --git a/plugins/eclipse/testData/eml/srcInZip/test/.classpath b/plugins/eclipse/testData/eml/srcInZip/test/.classpath new file mode 100644 index 000000000000..a4a768058976 --- /dev/null +++ b/plugins/eclipse/testData/eml/srcInZip/test/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/plugins/eclipse/testData/eml/srcInZip/test/.project b/plugins/eclipse/testData/eml/srcInZip/test/.project new file mode 100644 index 000000000000..ffcb70792087 --- /dev/null +++ b/plugins/eclipse/testData/eml/srcInZip/test/.project @@ -0,0 +1,16 @@ + + + srcInZip + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.jdt.core.javanature + + + diff --git a/plugins/eclipse/testData/eml/srcInZip/test/lib/jar-all-5.zip b/plugins/eclipse/testData/eml/srcInZip/test/lib/jar-all-5.zip new file mode 100644 index 000000000000..1c4f645ac0c7 Binary files /dev/null and b/plugins/eclipse/testData/eml/srcInZip/test/lib/jar-all-5.zip differ diff --git a/plugins/eclipse/testData/eml/srcInZip/test/srcInZip.eml b/plugins/eclipse/testData/eml/srcInZip/test/srcInZip.eml new file mode 100644 index 000000000000..dd848dc722cd --- /dev/null +++ b/plugins/eclipse/testData/eml/srcInZip/test/srcInZip.eml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEmlTest.java b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEmlTest.java new file mode 100644 index 000000000000..3375ee5a2921 --- /dev/null +++ b/plugins/eclipse/testSources/org/jetbrains/idea/eclipse/EclipseEmlTest.java @@ -0,0 +1,118 @@ +/* + * Copyright 2000-2009 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. + */ + +/* + * User: anna + * Date: 28-Nov-2008 + */ +package org.jetbrains.idea.eclipse; + +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.application.PluginPathManager; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.module.ModuleManager; +import com.intellij.openapi.module.StdModuleTypes; +import com.intellij.openapi.roots.ModifiableRootModel; +import com.intellij.openapi.roots.ModuleRootManager; +import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.JDOMUtil; +import com.intellij.openapi.util.SystemInfo; +import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.testFramework.IdeaTestCase; +import com.intellij.testFramework.IdeaTestUtil; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jetbrains.idea.eclipse.config.CachedXmlDocumentSet; +import org.jetbrains.idea.eclipse.config.EclipseClasspathStorageProvider; +import org.jetbrains.idea.eclipse.config.EclipseModuleManager; +import org.jetbrains.idea.eclipse.importWizard.EclipseProjectFinder; + +import java.io.File; +import java.io.IOException; + +public class EclipseEmlTest extends IdeaTestCase { + @Override + protected void setUp() throws Exception { + super.setUp(); + final File testRoot = new File(PluginPathManager.getPluginHomePath("eclipse") + "/testData", "eml"); + assertTrue(testRoot.getAbsolutePath(), testRoot.isDirectory()); + + final File currentTestRoot = new File(testRoot, getTestName(true)); + assertTrue(currentTestRoot.getAbsolutePath(), currentTestRoot.isDirectory()); + + FileUtil.copyDir(currentTestRoot, new File(getProject().getBaseDir().getPath())); + + + } + + + + private void doTest(String relativePath) throws Exception { + final String path = getProject().getBaseDir().getPath() + relativePath; + final Module module = ApplicationManager.getApplication().runWriteAction(new Computable() { + public Module compute() { + return ModuleManager.getInstance(getProject()) + .newModule(path + "/" + EclipseProjectFinder.findProjectName(path) + IdeaXml.IML_EXT, StdModuleTypes.JAVA); + } + }); + + replaceRoot(path, module.getName() + EclipseXml.IDEA_SETTINGS_POSTFIX); + replaceRoot(path, EclipseXml.DOT_CLASSPATH_EXT); + + + final EclipseClasspathStorageProvider.EclipseClasspathConverter converter = + new EclipseClasspathStorageProvider.EclipseClasspathConverter(module); + final ModifiableRootModel rootModel = ModuleRootManager.getInstance(module).getModifiableModel(); + + final Element classpathElement = JDOMUtil.loadDocument(new String(FileUtil.loadFileText(new File(path, EclipseXml.DOT_CLASSPATH_EXT)))).getRootElement(); + converter.getClasspath(rootModel, classpathElement); + + final File tempDirectory = FileUtil.createTempDirectory("", ""); + tempDirectory.deleteOnExit(); + FileUtil.copyDir(new File(path), tempDirectory); + + new EclipseClasspathStorageProvider.EclipseClasspathConverter(module) { + @Override + public CachedXmlDocumentSet getFileSet() { + CachedXmlDocumentSet fileCache = new CachedXmlDocumentSet(module.getProject()); + EclipseModuleManager.getInstance(module).setDocumentSet(fileCache); + EclipseClasspathStorageProvider + .registerFiles(fileCache, module, tempDirectory.getPath(), tempDirectory.getPath()); + fileCache.preload(); + return fileCache; + } + }.setClasspath(rootModel); + rootModel.dispose(); + + IdeaTestUtil.assertDirectoriesEqual(LocalFileSystem.getInstance().findFileByIoFile(new File(path, EclipseXml.DOT_CLASSPATH_EXT).getParentFile()), + LocalFileSystem.getInstance().findFileByIoFile(tempDirectory), null); + } + + private void replaceRoot(String path, final String child) throws IOException, JDOMException { + final File emlFile = new File(path, child); + String fileText = new String(FileUtil.loadFileText(emlFile)).replaceAll("\\$ROOT\\$", getProject().getBaseDir().getPath()); + if (!SystemInfo.isWindows) { + fileText = fileText.replaceAll(EclipseXml.FILE_PROTOCOL + "/", EclipseXml.FILE_PROTOCOL); + } + JDOMUtil.writeDocument(JDOMUtil.loadDocument(fileText), emlFile, "\n"); + } + + public void testSrcInZip() throws Exception { + doTest("/test"); + } + +} \ No newline at end of file diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/compiler/MavenResourceCompiler.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/compiler/MavenResourceCompiler.java index 07d0813e8a60..cc643a3942cf 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/compiler/MavenResourceCompiler.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/compiler/MavenResourceCompiler.java @@ -147,7 +147,7 @@ public class MavenResourceCompiler implements ClassPostProcessingCompiler { MavenProject mavenProject = mavenProjectManager.findProject(eachModule); if (mavenProject == null) continue; - Properties properties = loadFilters(context, mavenProject); + Properties properties = loadPropertiesAndFilters(context, mavenProject); List nonFilteredExtensions = collectNonFilteredExtensions(mavenProject); String escapeString = mavenProject.findPluginConfigurationValue("org.apache.maven.plugins", @@ -202,8 +202,10 @@ public class MavenResourceCompiler implements ClassPostProcessingCompiler { return sorted.hashCode(); } - private static Properties loadFilters(CompileContext context, MavenProject mavenProject) { + private static Properties loadPropertiesAndFilters(CompileContext context, MavenProject mavenProject) { Properties properties = new Properties(); + properties.putAll(mavenProject.getProperties()); + for (String each : mavenProject.getFilters()) { try { FileInputStream in = new FileInputStream(each); @@ -509,7 +511,7 @@ public class MavenResourceCompiler implements ClassPostProcessingCompiler { private LightVirtualFile myFile; private FakeProcessingItem() { - myFile = new LightVirtualFile("fooBar"); + myFile = new LightVirtualFile(this.getClass().getName()); } @NotNull @@ -523,52 +525,50 @@ public class MavenResourceCompiler implements ClassPostProcessingCompiler { } private static class MyValididtyState implements ValidityState { - private final TimestampValidityState myTimestampState; + private final long mySourceFileTimestamp; private volatile long myOutputFileTimestamp; private final boolean myFiltered; private final long myPropertiesHashCode; private final String myEscapeString; public static MyValididtyState load(DataInput in) throws IOException { - return new MyValididtyState(TimestampValidityState.load(in), in.readLong(), in.readBoolean(), in.readLong(), in.readUTF()); - } - - public MyValididtyState(long sourceFileTimestamp, - long outputFileTimestamp, - boolean isFiltered, - long propertiesHashCode, - String escapeString) { - this(new TimestampValidityState(sourceFileTimestamp), outputFileTimestamp, isFiltered, propertiesHashCode, escapeString); + return new MyValididtyState(in.readLong(), in.readLong(), in.readBoolean(), in.readLong(), in.readUTF()); } public void setOutputFileTimestamp(long outputFileTimestamp) { myOutputFileTimestamp = outputFileTimestamp; } - private MyValididtyState(TimestampValidityState timestampState, + private MyValididtyState(long sourceFileTimestamp, long outputFileTimestamp, boolean isFiltered, long propertiesHashCode, String escapeString) { - myTimestampState = timestampState; + mySourceFileTimestamp = sourceFileTimestamp; myOutputFileTimestamp = outputFileTimestamp; myFiltered = isFiltered; myPropertiesHashCode = propertiesHashCode; myEscapeString = escapeString; } + @Override + public String toString() { + return mySourceFileTimestamp + " " + myOutputFileTimestamp + " " + myFiltered + " " + myPropertiesHashCode + " " + myEscapeString; + } + public boolean equalsTo(ValidityState otherState) { if (!(otherState instanceof MyValididtyState)) return false; - MyValididtyState state = (MyValididtyState)otherState; - return myTimestampState.equalsTo(state.myTimestampState) - && myOutputFileTimestamp == state.myOutputFileTimestamp - && myFiltered == state.myFiltered - && myPropertiesHashCode == state.myPropertiesHashCode - && Comparing.strEqual(myEscapeString, state.myEscapeString); + MyValididtyState that = (MyValididtyState)otherState; + + return mySourceFileTimestamp == that.mySourceFileTimestamp + && myOutputFileTimestamp == that.myOutputFileTimestamp + && myFiltered == that.myFiltered + && myPropertiesHashCode == that.myPropertiesHashCode + && Comparing.strEqual(myEscapeString, that.myEscapeString); } public void save(DataOutput out) throws IOException { - myTimestampState.save(out); + out.writeLong(mySourceFileTimestamp); out.writeLong(myOutputFileTimestamp); out.writeBoolean(myFiltered); out.writeLong(myPropertiesHashCode); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java index 03645729e4b8..e70f1ee42a8c 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenTestCase.java @@ -367,7 +367,7 @@ public abstract class MavenTestCase extends UsefulTestCase { } private void setFileContent(VirtualFile file, String content) throws IOException { - file.setBinaryContent(content.getBytes(), -1, file.getTimeStamp() + 1000); + file.setBinaryContent(content.getBytes(), file.getModificationStamp() + 4000, file.getTimeStamp() + 4000); } protected void assertPathEquals(String expected, String actual) { diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java index 755a4b580476..eaa612b1623b 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/compiler/ResourceFilteringTest.java @@ -15,13 +15,25 @@ */ package org.jetbrains.idea.maven.compiler; +import com.intellij.compiler.CompilerManagerImpl; +import com.intellij.compiler.CompilerWorkspaceConfiguration; +import com.intellij.compiler.impl.ModuleCompileScope; +import com.intellij.compiler.impl.TranslatingCompilerFilesMonitor; +import com.intellij.openapi.compiler.*; +import com.intellij.openapi.module.Module; +import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.idea.maven.MavenImportingTestCase; import org.jetbrains.idea.maven.importing.MavenDefaultModifiableModelsProvider; import org.jetbrains.idea.maven.importing.MavenRootModelAdapter; +import java.io.File; import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class ResourceFilteringTest extends MavenImportingTestCase { public void testBasic() throws Exception { @@ -114,7 +126,7 @@ public class ResourceFilteringTest extends MavenImportingTestCase { assertResult("target/classes/file.bmp", "value=${project.version}"); } - + public void testCustomNonFilteredExtensions() throws Exception { createProjectSubFile("resources/file.bmp", "value=${project.version}"); createProjectSubFile("resources/file.xxx", "value=${project.version}"); @@ -239,7 +251,7 @@ public class ResourceFilteringTest extends MavenImportingTestCase { assertResult("target/classes/file1.properties", "value=project"); assertResult("target/classes/file2.properties", "value=${project.artifactId}"); } - + public void testEscapingSpecialCharsInProperties() throws Exception { createProjectSubFile("resources/file.txt", "value=${foo}"); @@ -414,7 +426,7 @@ public class ResourceFilteringTest extends MavenImportingTestCase { assertResult("target/classes/file.properties", "value=${project.version}"); } - public void testUpdatingWhenPropertiesAreChanged() throws Exception { + public void testUpdatingWhenPropertiesInFiltersAreChanged() throws Exception { VirtualFile filter = createProjectSubFile("filters/filter.properties", "xxx=1"); createProjectSubFile("resources/file.properties", "value=${xxx}"); @@ -441,6 +453,127 @@ public class ResourceFilteringTest extends MavenImportingTestCase { assertResult("target/classes/file.properties", "value=2"); } + public void testUpdatingWhenPropertiesAreChanged() throws Exception { + createProjectSubFile("resources/file.properties", "value=${foo}"); + + importProject("test" + + "project" + + "1" + + + "" + + " val1" + + "" + + + "" + + " " + + " " + + " resources" + + " true" + + " " + + " " + + ""); + compileModules("project"); + assertResult("target/classes/file.properties", "value=val1"); + + importProject("test" + + "project" + + "1" + + + "" + + " val2" + + "" + + + "" + + " " + + " " + + " resources" + + " true" + + " " + + " " + + ""); + compileModules("project"); + assertResult("target/classes/file.properties", "value=val2"); + } + + public void testUpdatingWhenPropertiesInModelAreChanged() throws Exception { + createProjectSubFile("resources/file.properties", "value=${project.name}"); + + importProject("test" + + "project" + + "1" + + + "val1" + + + "" + + " " + + " " + + " resources" + + " true" + + " " + + " " + + ""); + compileModules("project"); + assertResult("target/classes/file.properties", "value=val1"); + + importProject("test" + + "project" + + "1" + + + "val2" + + + "" + + " " + + " " + + " resources" + + " true" + + " " + + " " + + ""); + compileModules("project"); + assertResult("target/classes/file.properties", "value=val2"); + } + + public void testUpdatingWhenProfilesAreChanged() throws Exception { + createProjectSubFile("resources/file.properties", "value=${foo}"); + + createProjectPom("test" + + "project" + + "1" + + + "" + + " " + + " one" + + " " + + " val1" + + " " + + " " + + " " + + " two" + + " " + + " val2" + + " " + + " " + + "" + + + "" + + " " + + " " + + " resources" + + " true" + + " " + + " " + + ""); + importProjectWithProfiles("one"); + compileModules("project"); + assertResult("target/classes/file.properties", "value=val1"); + + myProjectsManager.setActiveProfiles(Arrays.asList("two")); + scheduleResolveAll(); + resolveDependenciesAndImport(); + compileModules("project"); + assertResult("target/classes/file.properties", "value=val2"); + } + public void testSameFileInSourcesAndTestSources() throws Exception { createProjectSubFile("src/main/resources/file.properties", "foo=${foo.main}"); createProjectSubFile("src/test/resources/file.properties", "foo=${foo.test}"); diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.java index 08bc9a7dd6d3..76540e195afa 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/importing/StructureImportingTest.java @@ -629,7 +629,7 @@ public class StructureImportingTest extends MavenImportingTestCase { ""); assertModules("project"); - assertEquals(LanguageLevel.JDK_1_4, getLanguageLevelForProject()); + assertEquals(LanguageLevel.JDK_1_4, getLanguageLevelForModule()); } public void testLanguageLevel6() throws Exception { @@ -650,7 +650,7 @@ public class StructureImportingTest extends MavenImportingTestCase { ""); assertModules("project"); - assertEquals(LanguageLevel.JDK_1_6, getLanguageLevelForProject()); + assertEquals(LanguageLevel.JDK_1_6, getLanguageLevelForModule()); } public void testLanguageLevelWhenCompilerPluginIsNotSpecified() throws Exception { @@ -659,7 +659,7 @@ public class StructureImportingTest extends MavenImportingTestCase { "1"); assertModules("project"); - assertNull(getLanguageLevelForProject()); + assertNull(getLanguageLevelForModule()); } public void testLanguageLevelWhenConfigurationIsNotSpecified() throws Exception { @@ -677,10 +677,10 @@ public class StructureImportingTest extends MavenImportingTestCase { ""); assertModules("project"); - assertNull(getLanguageLevelForProject()); + assertNull(getLanguageLevelForModule()); } - public void testLanguageLevelWhenSourseLanguageLevelIsNotSpecified() throws Exception { + public void testLanguageLevelWhenSourceLanguageLevelIsNotSpecified() throws Exception { importProject("test" + "project" + "1" + @@ -697,10 +697,10 @@ public class StructureImportingTest extends MavenImportingTestCase { ""); assertModules("project"); - assertNull(getLanguageLevelForProject()); + assertNull(getLanguageLevelForModule()); } - private LanguageLevel getLanguageLevelForProject() { + private LanguageLevel getLanguageLevelForModule() { return LanguageLevelModuleExtension.getInstance(getModule("project")).getLanguageLevel(); } diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.form b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.form index 624b3c10e24b..3fe747cfff27 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.form +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.form @@ -282,6 +282,8 @@ + + @@ -354,6 +356,15 @@ + + + + + + + + + diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.java index beff36b2da04..f2fb3b7bfff4 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/TestNGConfigurationEditor.java @@ -96,6 +96,7 @@ public class TestNGConfigurationEditor extends SettingsEditor annotationType; + private JCheckBox myUseDefaultReportersCheckBox; private final CommonJavaParameters commonJavaParameters = new CommonJavaParameters(); private ArrayList propertiesList; private TestNGListenersTableModel listenerModel; @@ -230,6 +231,7 @@ public class TestNGConfigurationEditor extends SettingsEditor TEST_PROPERTIES = new HashMap(); public List TEST_LISTENERS = new ArrayList(); + public boolean USE_DEFAULT_REPORTERS = false; public String PROPERTIES_FILE; public TestData() { @@ -111,7 +112,8 @@ public class TestData implements Cloneable && Comparing.equal(WORKING_DIRECTORY, data.WORKING_DIRECTORY) && Comparing.equal(OUTPUT_DIRECTORY, data.OUTPUT_DIRECTORY) && Comparing.equal(VM_PARAMETERS, data.VM_PARAMETERS) - && Comparing.equal(PARAMETERS, data.PARAMETERS); + && Comparing.equal(PARAMETERS, data.PARAMETERS) + && USE_DEFAULT_REPORTERS == data.USE_DEFAULT_REPORTERS; } } @@ -125,7 +127,8 @@ public class TestData implements Cloneable Comparing.hashcode(WORKING_DIRECTORY) ^ Comparing.hashcode(OUTPUT_DIRECTORY) ^ Comparing.hashcode(VM_PARAMETERS) ^ - Comparing.hashcode(PARAMETERS); + Comparing.hashcode(PARAMETERS) ^ + Comparing.hashcode(USE_DEFAULT_REPORTERS); } @Override @@ -139,6 +142,8 @@ public class TestData implements Cloneable data.TEST_LISTENERS = new ArrayList(); data.TEST_LISTENERS.addAll(TEST_LISTENERS); + data.USE_DEFAULT_REPORTERS = USE_DEFAULT_REPORTERS; + data.setScope(getScope()); return data; }