mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.intellij.lang.regexp;
|
||||
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageParserDefinitions;
|
||||
import com.intellij.lang.ParserDefinition;
|
||||
import com.intellij.openapi.fileTypes.SingleLazyInstanceSyntaxHighlighterFactory;
|
||||
@@ -25,9 +26,14 @@ public class RegExpSyntaxHighlighterFactory extends SingleLazyInstanceSyntaxHigh
|
||||
private final ParserDefinition myParserDefinition;
|
||||
|
||||
public RegExpSyntaxHighlighterFactory() {
|
||||
myParserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(RegExpLanguage.INSTANCE);
|
||||
this(RegExpLanguage.INSTANCE);
|
||||
}
|
||||
|
||||
protected RegExpSyntaxHighlighterFactory(@NotNull Language language) {
|
||||
myParserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
protected SyntaxHighlighter createHighlighter() {
|
||||
return new RegExpHighlighter(null, myParserDefinition);
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
/* The following code was generated by JFlex 1.4.3 on 21.06.11 21:06 */
|
||||
/* The following code was generated by JFlex 1.4.3 on 10/1/12 11:19 AM */
|
||||
|
||||
/* 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 java.util.EnumSet;
|
||||
import com.intellij.psi.StringEscapesTokenTypes;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedList;
|
||||
|
||||
// IDEADEV-11055
|
||||
@SuppressWarnings({ "ALL", "SameParameterValue", "WeakerAccess", "SameReturnValue", "RedundantThrows", "UnusedDeclaration", "UnusedDeclaration" })
|
||||
@@ -15,8 +16,8 @@ import com.intellij.psi.StringEscapesTokenTypes;
|
||||
/**
|
||||
* This class is a scanner generated by
|
||||
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
|
||||
* on 21.06.11 21:06 from the specification file
|
||||
* <tt>C:/IDEA/tools/lexer/../../community/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex</tt>
|
||||
* on 10/1/12 11:19 AM from the specification file
|
||||
* <tt>C:/work/IDEA/tools/lexer/../../community/RegExpSupport/src/org/intellij/lang/regexp/regexp-lexer.flex</tt>
|
||||
*/
|
||||
class _RegExLexer implements FlexLexer {
|
||||
/** initial size of the lookahead buffer */
|
||||
@@ -680,106 +681,6 @@ class _RegExLexer implements FlexLexer {
|
||||
{ return RegExpTT.STAR;
|
||||
}
|
||||
case 81: break;
|
||||
case 58:
|
||||
{ yybegin(PY_COND_REF); return RegExpTT.PYTHON_COND_REF;
|
||||
}
|
||||
case 82: break;
|
||||
case 48:
|
||||
{ return RegExpTT.CHAR_CLASS;
|
||||
}
|
||||
case 83: break;
|
||||
case 35:
|
||||
{ handleOptions(); return RegExpTT.OPTIONS_OFF;
|
||||
}
|
||||
case 84: break;
|
||||
case 54:
|
||||
{ yypopstate(); return RegExpTT.QUOTE_END;
|
||||
}
|
||||
case 85: break;
|
||||
case 34:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.GROUP_END;
|
||||
}
|
||||
case 86: break;
|
||||
case 5:
|
||||
{ return RegExpTT.GROUP_BEGIN;
|
||||
}
|
||||
case 87: break;
|
||||
case 36:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.COLON;
|
||||
}
|
||||
case 88: break;
|
||||
case 6:
|
||||
{ return RegExpTT.GROUP_END;
|
||||
}
|
||||
case 89: break;
|
||||
case 25:
|
||||
{ assert false : yytext();
|
||||
}
|
||||
case 90: break;
|
||||
case 18:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER;
|
||||
}
|
||||
case 91: break;
|
||||
case 45:
|
||||
{ return commentMode ? RegExpTT.CHARACTER : RegExpTT.REDUNDANT_ESCAPE;
|
||||
}
|
||||
case 92: break;
|
||||
case 23:
|
||||
{ return RegExpTT.NAME;
|
||||
}
|
||||
case 93: break;
|
||||
case 72:
|
||||
{ if (allowOctalNoLeadingZero) return RegExpTT.OCT_CHAR;
|
||||
return yystate() != CLASS2 ? RegExpTT.BACKREF : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 94: break;
|
||||
case 29:
|
||||
{ yypopstate(); return RegExpTT.CLASS_END;
|
||||
}
|
||||
case 95: break;
|
||||
case 33:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER;
|
||||
}
|
||||
case 96: break;
|
||||
case 51:
|
||||
{ yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN;
|
||||
}
|
||||
case 97: break;
|
||||
case 21:
|
||||
{ return RegExpTT.NUMBER;
|
||||
}
|
||||
case 98: break;
|
||||
case 4:
|
||||
{ return RegExpTT.DOT;
|
||||
}
|
||||
case 99: break;
|
||||
case 70:
|
||||
{ return RegExpTT.NEG_LOOKBEHIND;
|
||||
}
|
||||
case 100: break;
|
||||
case 40:
|
||||
// lookahead expression with fixed base length
|
||||
zzMarkedPos = zzStartRead + 1;
|
||||
{ yypushstate(CLASS1);
|
||||
return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 101: break;
|
||||
case 61:
|
||||
{ return RegExpTT.NEG_LOOKAHEAD;
|
||||
}
|
||||
case 102: break;
|
||||
case 10:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CTRL_CHARACTER;
|
||||
}
|
||||
case 103: break;
|
||||
case 59:
|
||||
{ return RegExpTT.NON_CAPT_GROUP;
|
||||
}
|
||||
case 104: break;
|
||||
case 63:
|
||||
{ yybegin(QUOTED_NAMED_GROUP); return RegExpTT.RUBY_QUOTED_NAMED_GROUP;
|
||||
}
|
||||
case 105: break;
|
||||
case 28:
|
||||
{ if (allowNestedCharacterClasses) {
|
||||
yypushstate(CLASS2);
|
||||
@@ -787,6 +688,105 @@ class _RegExLexer implements FlexLexer {
|
||||
}
|
||||
return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 82: break;
|
||||
case 58:
|
||||
{ yybegin(PY_COND_REF); return RegExpTT.PYTHON_COND_REF;
|
||||
}
|
||||
case 83: break;
|
||||
case 48:
|
||||
{ return RegExpTT.CHAR_CLASS;
|
||||
}
|
||||
case 84: break;
|
||||
case 35:
|
||||
{ handleOptions(); return RegExpTT.OPTIONS_OFF;
|
||||
}
|
||||
case 85: break;
|
||||
case 40:
|
||||
// lookahead expression with fixed base length
|
||||
zzMarkedPos = zzStartRead + 1;
|
||||
{ yypushstate(CLASS1);
|
||||
return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 86: break;
|
||||
case 54:
|
||||
{ yypopstate(); return RegExpTT.QUOTE_END;
|
||||
}
|
||||
case 87: break;
|
||||
case 34:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.GROUP_END;
|
||||
}
|
||||
case 88: break;
|
||||
case 5:
|
||||
{ return RegExpTT.GROUP_BEGIN;
|
||||
}
|
||||
case 89: break;
|
||||
case 36:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.COLON;
|
||||
}
|
||||
case 90: break;
|
||||
case 6:
|
||||
{ return RegExpTT.GROUP_END;
|
||||
}
|
||||
case 91: break;
|
||||
case 25:
|
||||
{ assert false : yytext();
|
||||
}
|
||||
case 92: break;
|
||||
case 18:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CHARACTER;
|
||||
}
|
||||
case 93: break;
|
||||
case 45:
|
||||
{ return commentMode ? RegExpTT.CHARACTER : RegExpTT.REDUNDANT_ESCAPE;
|
||||
}
|
||||
case 94: break;
|
||||
case 23:
|
||||
{ return RegExpTT.NAME;
|
||||
}
|
||||
case 95: break;
|
||||
case 29:
|
||||
{ yypopstate(); return RegExpTT.CLASS_END;
|
||||
}
|
||||
case 96: break;
|
||||
case 33:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.BAD_CHARACTER;
|
||||
}
|
||||
case 97: break;
|
||||
case 51:
|
||||
{ yypushstate(QUOTED); return RegExpTT.QUOTE_BEGIN;
|
||||
}
|
||||
case 98: break;
|
||||
case 21:
|
||||
{ return RegExpTT.NUMBER;
|
||||
}
|
||||
case 99: break;
|
||||
case 4:
|
||||
{ return RegExpTT.DOT;
|
||||
}
|
||||
case 100: break;
|
||||
case 70:
|
||||
{ return RegExpTT.NEG_LOOKBEHIND;
|
||||
}
|
||||
case 101: break;
|
||||
case 43:
|
||||
{ return (allowOctalNoLeadingZero ? RegExpTT.OCT_CHAR : RegExpTT.BAD_OCT_VALUE);
|
||||
}
|
||||
case 102: break;
|
||||
case 61:
|
||||
{ return RegExpTT.NEG_LOOKAHEAD;
|
||||
}
|
||||
case 103: break;
|
||||
case 10:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.CTRL_CHARACTER;
|
||||
}
|
||||
case 104: break;
|
||||
case 59:
|
||||
{ return RegExpTT.NON_CAPT_GROUP;
|
||||
}
|
||||
case 105: break;
|
||||
case 63:
|
||||
{ yybegin(QUOTED_NAMED_GROUP); return RegExpTT.RUBY_QUOTED_NAMED_GROUP;
|
||||
}
|
||||
case 106: break;
|
||||
case 19:
|
||||
{ if (commentMode) { yypushstate(COMMENT); return RegExpTT.COMMENT; } else return RegExpTT.CHARACTER;
|
||||
@@ -796,75 +796,51 @@ class _RegExLexer implements FlexLexer {
|
||||
{ yypushstate(PROP); return RegExpTT.PROPERTY;
|
||||
}
|
||||
case 108: break;
|
||||
case 8:
|
||||
{ yypushstate(CLASS2);
|
||||
return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 109: break;
|
||||
case 69:
|
||||
{ return RegExpTT.POS_LOOKBEHIND;
|
||||
}
|
||||
case 110: break;
|
||||
case 109: break;
|
||||
case 42:
|
||||
{ return yystate() != CLASS2 ? RegExpTT.BACKREF : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 111: break;
|
||||
case 110: break;
|
||||
case 71:
|
||||
{ return RegExpTT.HEX_CHAR;
|
||||
}
|
||||
case 112: break;
|
||||
case 111: break;
|
||||
case 1:
|
||||
{ handleOptions(); return RegExpTT.OPTIONS_ON;
|
||||
}
|
||||
case 113: break;
|
||||
case 112: break;
|
||||
case 57:
|
||||
{ return allowNestedCharacterClasses ? RegExpTT.ANDAND : RegExpTT.CHARACTER;
|
||||
}
|
||||
case 114: break;
|
||||
case 113: break;
|
||||
case 2:
|
||||
{ yypopstate(); return RegExpTT.COMMENT;
|
||||
}
|
||||
case 115: break;
|
||||
case 114: break;
|
||||
case 17:
|
||||
{ return RegExpTT.MINUS;
|
||||
}
|
||||
case 116: break;
|
||||
case 115: break;
|
||||
case 46:
|
||||
{ return RegExpTT.ESC_CTRL_CHARACTER;
|
||||
}
|
||||
case 117: break;
|
||||
case 116: break;
|
||||
case 32:
|
||||
{ yypopstate(); yypushstate(EMBRACED); return RegExpTT.LBRACE;
|
||||
}
|
||||
case 117: break;
|
||||
case 56:
|
||||
{ if (!allowNestedCharacterClasses) return RegExpTT.CHARACTER;
|
||||
return RegExpTT.REDUNDANT_ESCAPE;
|
||||
}
|
||||
case 118: break;
|
||||
case 13:
|
||||
{ return RegExpTT.QUEST;
|
||||
}
|
||||
case 119: break;
|
||||
case 15:
|
||||
{ return RegExpTT.PLUS;
|
||||
}
|
||||
case 120: break;
|
||||
case 65:
|
||||
{ return RegExpTT.OCT_CHAR;
|
||||
}
|
||||
case 121: break;
|
||||
case 38:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.QUOTE;
|
||||
}
|
||||
case 122: break;
|
||||
case 64:
|
||||
// lookahead expression with fixed base length
|
||||
zzMarkedPos = zzStartRead + 1;
|
||||
{ if (!allowNestedCharacterClasses) {
|
||||
yypushstate(CLASS1PY);
|
||||
}
|
||||
else {
|
||||
yypushstate(CLASS2);
|
||||
}
|
||||
return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 123: break;
|
||||
case 20:
|
||||
{ if (allowDanglingMetacharacters) {
|
||||
yypopstate(); yypushback(1);
|
||||
@@ -872,6 +848,23 @@ class _RegExLexer implements FlexLexer {
|
||||
return RegExpTT.BAD_CHARACTER;
|
||||
}
|
||||
}
|
||||
case 120: break;
|
||||
case 15:
|
||||
{ return RegExpTT.PLUS;
|
||||
}
|
||||
case 121: break;
|
||||
case 65:
|
||||
{ return RegExpTT.OCT_CHAR;
|
||||
}
|
||||
case 122: break;
|
||||
case 72:
|
||||
{ if (allowOctalNoLeadingZero) return RegExpTT.OCT_CHAR;
|
||||
return yystate() != CLASS2 ? RegExpTT.BACKREF : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 123: break;
|
||||
case 38:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.QUOTE;
|
||||
}
|
||||
case 124: break;
|
||||
case 31:
|
||||
{ yypopstate(); yypushback(1);
|
||||
@@ -881,6 +874,87 @@ class _RegExLexer implements FlexLexer {
|
||||
{ yybegin(CLASS1); return RegExpTT.CARET;
|
||||
}
|
||||
case 126: break;
|
||||
case 37:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.GT;
|
||||
}
|
||||
case 127: break;
|
||||
case 67:
|
||||
{ yybegin(PY_NAMED_GROUP_REF); return RegExpTT.PYTHON_NAMED_GROUP_REF;
|
||||
}
|
||||
case 128: break;
|
||||
case 16:
|
||||
{ return RegExpTT.UNION;
|
||||
}
|
||||
case 129: break;
|
||||
case 3:
|
||||
{ return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 130: break;
|
||||
case 62:
|
||||
{ yybegin(NAMED_GROUP); return RegExpTT.RUBY_NAMED_GROUP;
|
||||
}
|
||||
case 131: break;
|
||||
case 39:
|
||||
{ yybegin(OPTIONS); return RegExpTT.SET_OPTIONS;
|
||||
}
|
||||
case 132: break;
|
||||
case 26:
|
||||
{ yybegin(CLASS2); return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 133: break;
|
||||
case 66:
|
||||
{ if (xmlSchemaMode) { yypushback(1); return RegExpTT.CHAR_CLASS; } else return RegExpTT.CTRL;
|
||||
}
|
||||
case 134: break;
|
||||
case 30:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 135: break;
|
||||
case 12:
|
||||
{ return RegExpTT.DOLLAR;
|
||||
}
|
||||
case 136: break;
|
||||
case 49:
|
||||
{ if (xmlSchemaMode) return RegExpTT.CHAR_CLASS; else return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
|
||||
}
|
||||
case 137: break;
|
||||
case 41:
|
||||
{ return RegExpTT.REDUNDANT_ESCAPE;
|
||||
}
|
||||
case 138: break;
|
||||
case 47:
|
||||
{ return yystate() != CLASS2 ? RegExpTT.BOUNDARY : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 139: break;
|
||||
case 8:
|
||||
{ yypushstate(CLASS2);
|
||||
return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 140: break;
|
||||
case 22:
|
||||
{ yypopstate(); return RegExpTT.RBRACE;
|
||||
}
|
||||
case 141: break;
|
||||
case 53:
|
||||
{ return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
|
||||
}
|
||||
case 142: break;
|
||||
case 52:
|
||||
{ return RegExpTT.BAD_HEX_VALUE;
|
||||
}
|
||||
case 143: break;
|
||||
case 9:
|
||||
{ return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
|
||||
}
|
||||
case 144: break;
|
||||
case 11:
|
||||
{ return RegExpTT.CARET;
|
||||
}
|
||||
case 145: break;
|
||||
case 44:
|
||||
{ return RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 146: break;
|
||||
case 55:
|
||||
// lookahead expression with fixed base length
|
||||
zzMarkedPos = zzStartRead + 1;
|
||||
@@ -890,90 +964,17 @@ class _RegExLexer implements FlexLexer {
|
||||
}
|
||||
return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 127: break;
|
||||
case 56:
|
||||
{ if (!allowNestedCharacterClasses) return RegExpTT.CHARACTER;
|
||||
return RegExpTT.REDUNDANT_ESCAPE;
|
||||
}
|
||||
case 128: break;
|
||||
case 37:
|
||||
{ yybegin(YYINITIAL); return RegExpTT.GT;
|
||||
}
|
||||
case 129: break;
|
||||
case 67:
|
||||
{ yybegin(PY_NAMED_GROUP_REF); return RegExpTT.PYTHON_NAMED_GROUP_REF;
|
||||
}
|
||||
case 130: break;
|
||||
case 16:
|
||||
{ return RegExpTT.UNION;
|
||||
}
|
||||
case 131: break;
|
||||
case 3:
|
||||
{ return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 132: break;
|
||||
case 62:
|
||||
{ yybegin(NAMED_GROUP); return RegExpTT.RUBY_NAMED_GROUP;
|
||||
}
|
||||
case 133: break;
|
||||
case 39:
|
||||
{ yybegin(OPTIONS); return RegExpTT.SET_OPTIONS;
|
||||
}
|
||||
case 134: break;
|
||||
case 26:
|
||||
{ yybegin(CLASS2); return RegExpTT.CHARACTER;
|
||||
}
|
||||
case 135: break;
|
||||
case 66:
|
||||
{ if (xmlSchemaMode) { yypushback(1); return RegExpTT.CHAR_CLASS; } else return RegExpTT.CTRL;
|
||||
}
|
||||
case 136: break;
|
||||
case 30:
|
||||
{ return commentMode ? com.intellij.psi.TokenType.WHITE_SPACE : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 137: break;
|
||||
case 12:
|
||||
{ return RegExpTT.DOLLAR;
|
||||
}
|
||||
case 138: break;
|
||||
case 49:
|
||||
{ if (xmlSchemaMode) return RegExpTT.CHAR_CLASS; else return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
|
||||
}
|
||||
case 139: break;
|
||||
case 41:
|
||||
{ return RegExpTT.REDUNDANT_ESCAPE;
|
||||
}
|
||||
case 140: break;
|
||||
case 47:
|
||||
{ return yystate() != CLASS2 ? RegExpTT.BOUNDARY : RegExpTT.ESC_CHARACTER;
|
||||
}
|
||||
case 141: break;
|
||||
case 22:
|
||||
{ yypopstate(); return RegExpTT.RBRACE;
|
||||
}
|
||||
case 142: break;
|
||||
case 53:
|
||||
{ return StringEscapesTokenTypes.INVALID_UNICODE_ESCAPE_TOKEN;
|
||||
}
|
||||
case 143: break;
|
||||
case 43:
|
||||
{ return RegExpTT.BAD_OCT_VALUE;
|
||||
}
|
||||
case 144: break;
|
||||
case 52:
|
||||
{ return RegExpTT.BAD_HEX_VALUE;
|
||||
}
|
||||
case 145: break;
|
||||
case 9:
|
||||
{ return StringEscapesTokenTypes.INVALID_CHARACTER_ESCAPE_TOKEN;
|
||||
}
|
||||
case 146: break;
|
||||
case 11:
|
||||
{ return RegExpTT.CARET;
|
||||
}
|
||||
case 147: break;
|
||||
case 44:
|
||||
{ return RegExpTT.ESC_CHARACTER;
|
||||
case 64:
|
||||
// lookahead expression with fixed base length
|
||||
zzMarkedPos = zzStartRead + 1;
|
||||
{ if (!allowNestedCharacterClasses) {
|
||||
yypushstate(CLASS1PY);
|
||||
}
|
||||
else {
|
||||
yypushstate(CLASS2);
|
||||
}
|
||||
return RegExpTT.CLASS_BEGIN;
|
||||
}
|
||||
case 148: break;
|
||||
default:
|
||||
|
||||
@@ -123,7 +123,7 @@ HEX_CHAR=[0-9a-fA-F]
|
||||
|
||||
/* octal escapes */
|
||||
{ESCAPE} "0" [0-7]{1,3} { return RegExpTT.OCT_CHAR; }
|
||||
{ESCAPE} "0" { return RegExpTT.BAD_OCT_VALUE; }
|
||||
{ESCAPE} "0" { return (allowOctalNoLeadingZero ? RegExpTT.OCT_CHAR : RegExpTT.BAD_OCT_VALUE); }
|
||||
|
||||
/* single character after "\c" */
|
||||
{ESCAPE} "c" {ANY} { if (xmlSchemaMode) { yypushback(1); return RegExpTT.CHAR_CLASS; } else return RegExpTT.CTRL; }
|
||||
|
||||
@@ -75,10 +75,12 @@ public class SelectTemplateStep extends ModuleWizardStep {
|
||||
ProjectTemplate template = getSelectedTemplate();
|
||||
if (template != null) {
|
||||
JComponent settingsPanel = template.getSettingsPanel();
|
||||
mySettingsPanel.add(settingsPanel, BorderLayout.NORTH);
|
||||
mySettingsPanel.repaint();
|
||||
if (settingsPanel != null) {
|
||||
mySettingsPanel.add(settingsPanel, BorderLayout.NORTH);
|
||||
}
|
||||
}
|
||||
mySettingsPanel.revalidate();
|
||||
mySettingsPanel.repaint();
|
||||
}
|
||||
});
|
||||
if (myTemplatesList.getModel().getSize() > 0) {
|
||||
|
||||
+39
-40
@@ -16,84 +16,83 @@
|
||||
package com.intellij.platform.templates;
|
||||
|
||||
import com.intellij.ide.util.newProjectWizard.modes.ImportImlMode;
|
||||
import com.intellij.ide.util.projectWizard.ExistingModuleLoader;
|
||||
import com.intellij.ide.util.projectWizard.ProjectBuilder;
|
||||
import com.intellij.ide.util.projectWizard.WizardContext;
|
||||
import com.intellij.openapi.module.ModifiableModuleModel;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ui.configuration.ModulesProvider;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.platform.templates.github.AbstractGithubTagDownloadedProjectGenerator;
|
||||
import com.intellij.platform.ProjectTemplate;
|
||||
import com.intellij.platform.templates.github.ZipUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 10/1/12
|
||||
*/
|
||||
public class GithubBasedProjectTemplate extends AbstractGithubTagDownloadedProjectGenerator {
|
||||
private String myDisplayName;
|
||||
private String myGithubUserName;
|
||||
private String myGithubRepositoryName;
|
||||
private String myHomepageUrl;
|
||||
private String myDescription;
|
||||
public class ArchivedProjectTemplate implements ProjectTemplate {
|
||||
private final String myDisplayName;
|
||||
private final String myDescription;
|
||||
private final String myArchivePath;
|
||||
private final ClassLoader myResourceLoader;
|
||||
private final WizardContext myContext;
|
||||
|
||||
public GithubBasedProjectTemplate(String displayName,
|
||||
String githubRepositoryName,
|
||||
String homepageUrl,
|
||||
String description,
|
||||
WizardContext context) {
|
||||
public ArchivedProjectTemplate(String displayName,
|
||||
String description,
|
||||
String archivePath,
|
||||
ClassLoader resourceLoader,
|
||||
WizardContext context) {
|
||||
|
||||
myDisplayName = displayName;
|
||||
myGithubRepositoryName = githubRepositoryName;
|
||||
myHomepageUrl = homepageUrl;
|
||||
myDescription = description;
|
||||
myArchivePath = archivePath;
|
||||
myResourceLoader = resourceLoader;
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getDisplayName() {
|
||||
public String getName() {
|
||||
return myDisplayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getGithubUserName() {
|
||||
return myGithubUserName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getGithubRepositoryName() {
|
||||
return myGithubRepositoryName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHomepageUrl() {
|
||||
return myHomepageUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return myDescription;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectBuilder createModuleBuilder() {
|
||||
final String path = myContext.getProjectFileDirectory() + "/empty-java.iml";
|
||||
final ExistingModuleLoader loader = ImportImlMode.setUpLoader(path);
|
||||
return new ProjectBuilder() {
|
||||
@Nullable
|
||||
@Override
|
||||
public List<Module> commit(Project project, ModifiableModuleModel model, ModulesProvider modulesProvider) {
|
||||
VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(myContext.getProjectFileDirectory());
|
||||
doGenerate(project, file, myPeer.getValue().getSettings());
|
||||
return loader.commit(project, model, modulesProvider);
|
||||
InputStream stream = myResourceLoader.getResourceAsStream(myArchivePath);
|
||||
if (stream == null) {
|
||||
throw new RuntimeException("Can't open " + myArchivePath);
|
||||
}
|
||||
final String path = myContext.getProjectFileDirectory();
|
||||
try {
|
||||
ZipUtil.unzip(null, new File(path), new ZipInputStream(stream));
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return ImportImlMode.setUpLoader(path).commit(project, model, modulesProvider);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getSettingsPanel() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -24,13 +24,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author Dmitry Avdeev
|
||||
* Date: 10/1/12
|
||||
*/
|
||||
public class GithubBasedTemplatesFactory implements ProjectTemplatesFactory {
|
||||
public class ArchivedTemplatesFactory implements ProjectTemplatesFactory {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectTemplate[] createTemplates(WizardContext context) {
|
||||
return new ProjectTemplate[]{
|
||||
new GithubBasedProjectTemplate("Web Application", "JetBrains/idea-templates/web/empty-java", null, null, context)
|
||||
new ArchivedProjectTemplate("Web Application", null, "foo", ClassLoader.getSystemClassLoader(), context)
|
||||
};
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import java.io.File;
|
||||
import java.lang.Object;
|
||||
import java.util.Map;
|
||||
|
||||
class Foo {
|
||||
void foo(Map<File, Object> files, File file, Object filx) {
|
||||
for (File file1 : file.<caret>) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import java.io.File;
|
||||
import java.lang.Object;
|
||||
import java.util.Map;
|
||||
|
||||
class Foo {
|
||||
void foo(Map<File, Object> files, File file, Object filx) {
|
||||
<caret>
|
||||
}
|
||||
}
|
||||
@@ -190,6 +190,14 @@ public class LiveTemplateTest extends LightCodeInsightFixtureTestCase {
|
||||
assert !state.finished
|
||||
}
|
||||
|
||||
public void testAllowTypingRandomExpressionsWithLookupOpen() {
|
||||
configure();
|
||||
startTemplate("iter", "iterations")
|
||||
myFixture.type('file.')
|
||||
checkResult()
|
||||
assert !state.finished
|
||||
}
|
||||
|
||||
private TemplateState getState() {
|
||||
TemplateManagerImpl.getTemplateState(getEditor())
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package org.jetbrains.jps.builders;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
@@ -43,7 +43,7 @@ public interface BuildRootIndex {
|
||||
<R extends BuildRootDescriptor> Collection<R> findAllParentDescriptors(@NotNull File file, @Nullable CompileContext context);
|
||||
|
||||
@Nullable
|
||||
RootDescriptor getModuleAndRoot(@Nullable CompileContext context, File file);
|
||||
JavaSourceRootDescriptor getModuleAndRoot(@Nullable CompileContext context, File file);
|
||||
|
||||
@NotNull
|
||||
FileFilter getRootFilter(@NotNull BuildRootDescriptor descriptor);
|
||||
|
||||
@@ -9,11 +9,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.builders.*;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.incremental.BuilderRegistry;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.indices.IgnoredFileIndex;
|
||||
import org.jetbrains.jps.indices.ModuleExcludeIndex;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.service.JpsServiceManager;
|
||||
|
||||
@@ -213,7 +213,7 @@ public class BuildRootIndexImpl implements BuildRootIndex {
|
||||
public Collection<? extends BuildRootDescriptor> clearTempRoots(@NotNull CompileContext context) {
|
||||
try {
|
||||
final Map<File, BuildRootDescriptor> map = ROOT_DESCRIPTOR_MAP.get(context);
|
||||
return map != null? map.values() : Collections.<RootDescriptor>emptyList();
|
||||
return map != null? map.values() : Collections.<BuildRootDescriptor>emptyList();
|
||||
}
|
||||
finally {
|
||||
TEMP_TARGET_ROOTS_MAP.set(context, null);
|
||||
@@ -223,7 +223,7 @@ public class BuildRootIndexImpl implements BuildRootIndex {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public RootDescriptor getModuleAndRoot(@Nullable CompileContext context, File file) {
|
||||
public JavaSourceRootDescriptor getModuleAndRoot(@Nullable CompileContext context, File file) {
|
||||
return findParentDescriptor(file, JavaModuleBuildTargetType.ALL_TYPES, context);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.FSOperations;
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget;
|
||||
import org.jetbrains.jps.incremental.Utils;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
@@ -164,7 +163,7 @@ public class JavaBuilderUtil {
|
||||
final List<Pair<File, JpsModule>> result = new ArrayList<Pair<File, JpsModule>>();
|
||||
for (File file : affected) {
|
||||
if (!moduleBasedFilter.accept(file)) {
|
||||
final RootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
result.add(Pair.create(file, moduleAndRoot != null ? moduleAndRoot.target.getModule() : null));
|
||||
}
|
||||
}
|
||||
@@ -176,7 +175,7 @@ public class JavaBuilderUtil {
|
||||
final Set<JpsModule> chunkModules = chunk.getModules();
|
||||
if (!chunkModules.isEmpty()) {
|
||||
for (File file : affected) {
|
||||
final RootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
if (moduleAndRoot != null && chunkModules.contains(moduleAndRoot.target.getModule())) {
|
||||
return true;
|
||||
}
|
||||
@@ -250,7 +249,7 @@ public class JavaBuilderUtil {
|
||||
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
final RootDescriptor rd = myContext.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(myContext, file);
|
||||
final JavaSourceRootDescriptor rd = myContext.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(myContext, file);
|
||||
if (rd == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+10
-3
@@ -1,4 +1,4 @@
|
||||
package org.jetbrains.jps.incremental.fs;
|
||||
package org.jetbrains.jps.builders.java;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -15,19 +15,21 @@ import java.io.FileFilter;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 1/3/12
|
||||
*/
|
||||
public final class RootDescriptor extends BuildRootDescriptor {
|
||||
public final class JavaSourceRootDescriptor extends BuildRootDescriptor {
|
||||
@NotNull
|
||||
public final File root;
|
||||
@NotNull
|
||||
public final ModuleBuildTarget target;
|
||||
public final boolean isGeneratedSources;
|
||||
public final boolean isTemp;
|
||||
private final String myPackagePrefix;
|
||||
|
||||
public RootDescriptor(@NotNull File root, @NotNull ModuleBuildTarget target, boolean isGenerated, boolean isTemp) {
|
||||
public JavaSourceRootDescriptor(@NotNull File root, @NotNull ModuleBuildTarget target, boolean isGenerated, boolean isTemp, @NotNull String packagePrefix) {
|
||||
this.root = root;
|
||||
this.target = target;
|
||||
this.isGeneratedSources = isGenerated;
|
||||
this.isTemp = isTemp;
|
||||
myPackagePrefix = packagePrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,6 +41,11 @@ public final class RootDescriptor extends BuildRootDescriptor {
|
||||
'}';
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getPackagePrefix() {
|
||||
return myPackagePrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRootId() {
|
||||
return FileUtil.toSystemIndependentName(root.getPath());
|
||||
@@ -153,7 +153,7 @@ public class BuildRunner {
|
||||
targetTypes.add(targetType);
|
||||
}
|
||||
else {
|
||||
BuildTargetLoader<?> loader = targetType.createLoader(pd.jpsModel);
|
||||
BuildTargetLoader<?> loader = targetType.createLoader(pd.getModel());
|
||||
for (String targetId : scope.getTargetIdList()) {
|
||||
BuildTarget<?> target = loader.createTarget(targetId);
|
||||
if (target != null) {
|
||||
|
||||
@@ -166,7 +166,7 @@ final class BuildSession implements Runnable, CanceledStatus {
|
||||
if (fsStateStream != null) {
|
||||
try {
|
||||
try {
|
||||
fsState.load(fsStateStream, pd.jpsModel, pd.getBuildRootIndex());
|
||||
fsState.load(fsStateStream, pd.getModel(), pd.getBuildRootIndex());
|
||||
applyFSEvent(pd, myInitialFSDelta);
|
||||
}
|
||||
finally {
|
||||
@@ -330,7 +330,7 @@ final class BuildSession implements Runnable, CanceledStatus {
|
||||
out.writeInt(FSState.VERSION);
|
||||
out.writeLong(myLastEventOrdinal);
|
||||
boolean hasWorkToDoWithModules = false;
|
||||
for (JpsModule module : pd.jpsProject.getModules()) {
|
||||
for (JpsModule module : pd.getProject().getModules()) {
|
||||
for (JavaModuleBuildTargetType type : JavaModuleBuildTargetType.ALL_TYPES) {
|
||||
if (state.hasWorkToDo(new ModuleBuildTarget(module, type))) {
|
||||
hasWorkToDoWithModules = true;
|
||||
|
||||
@@ -25,14 +25,14 @@ import java.util.Set;
|
||||
* Date: 1/8/12
|
||||
*/
|
||||
public final class ProjectDescriptor {
|
||||
public final JpsProject jpsProject;
|
||||
public final JpsModel jpsModel;
|
||||
private final JpsProject myProject;
|
||||
private final JpsModel myModel;
|
||||
public final BuildFSState fsState;
|
||||
public final ProjectTimestamps timestamps;
|
||||
public final BuildDataManager dataManager;
|
||||
private final BuildLoggingManager myLoggingManager;
|
||||
private final BuildTargetsState myTargetsState;
|
||||
public ModuleExcludeIndex moduleExcludeIndex;
|
||||
private final ModuleExcludeIndex myModuleExcludeIndex;
|
||||
private int myUseCounter = 1;
|
||||
private Set<JpsSdk<?>> myProjectJavaSdks;
|
||||
private CompilerEncodingConfiguration myEncodingConfiguration;
|
||||
@@ -40,7 +40,7 @@ public final class ProjectDescriptor {
|
||||
private final BuildTargetIndex myBuildTargetIndex;
|
||||
private final IgnoredFileIndex myIgnoredFileIndex;
|
||||
|
||||
public ProjectDescriptor(JpsModel jpsModel,
|
||||
public ProjectDescriptor(JpsModel model,
|
||||
BuildFSState fsState,
|
||||
ProjectTimestamps timestamps,
|
||||
BuildDataManager dataManager,
|
||||
@@ -48,19 +48,19 @@ public final class ProjectDescriptor {
|
||||
final ModuleExcludeIndex moduleExcludeIndex,
|
||||
final BuildTargetsState targetsState,
|
||||
final BuildTargetIndex buildTargetIndex, final BuildRootIndex buildRootIndex, IgnoredFileIndex ignoredFileIndex) {
|
||||
this.jpsModel = jpsModel;
|
||||
myModel = model;
|
||||
myIgnoredFileIndex = ignoredFileIndex;
|
||||
this.jpsProject = jpsModel.getProject();
|
||||
myProject = model.getProject();
|
||||
this.fsState = fsState;
|
||||
this.timestamps = timestamps;
|
||||
this.dataManager = dataManager;
|
||||
myBuildTargetIndex = buildTargetIndex;
|
||||
myBuildRootIndex = buildRootIndex;
|
||||
myLoggingManager = loggingManager;
|
||||
this.moduleExcludeIndex = moduleExcludeIndex;
|
||||
myModuleExcludeIndex = moduleExcludeIndex;
|
||||
myProjectJavaSdks = new HashSet<JpsSdk<?>>();
|
||||
myEncodingConfiguration = new CompilerEncodingConfiguration(jpsModel, buildRootIndex);
|
||||
for (JpsModule module : jpsProject.getModules()) {
|
||||
myEncodingConfiguration = new CompilerEncodingConfiguration(model, buildRootIndex);
|
||||
for (JpsModule module : myProject.getModules()) {
|
||||
final JpsSdk<?> sdk = module.getSdk(JpsJavaSdkType.INSTANCE);
|
||||
if (sdk != null && !myProjectJavaSdks.contains(sdk) && sdk.getVersionString() != null && sdk.getHomePath() != null) {
|
||||
myProjectJavaSdks.add(sdk);
|
||||
@@ -121,4 +121,16 @@ public final class ProjectDescriptor {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ModuleExcludeIndex getModuleExcludeIndex() {
|
||||
return myModuleExcludeIndex;
|
||||
}
|
||||
|
||||
public JpsModel getModel() {
|
||||
return myModel;
|
||||
}
|
||||
|
||||
public JpsProject getProject() {
|
||||
return myProject;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
|
||||
myIsProjectRebuild = isProjectRebuild;
|
||||
myIsMake = !isProjectRebuild && isMake;
|
||||
myDelegateMessageHandler = delegateMessageHandler;
|
||||
myProjectPaths = new ProjectPaths(pd.jpsProject);
|
||||
myProjectPaths = new ProjectPaths(pd.getProject());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,12 +102,13 @@ public class CompileContextImpl extends UserDataHolderBase implements CompileCon
|
||||
@Override
|
||||
@NotNull
|
||||
public ProcessorConfigProfile getAnnotationProcessingProfile(JpsModule module) {
|
||||
final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(getProjectDescriptor().jpsProject);
|
||||
final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(
|
||||
getProjectDescriptor().getProject());
|
||||
Map<JpsModule, ProcessorConfigProfile> map = myAnnotationProcessingProfileMap;
|
||||
if (map == null) {
|
||||
map = new HashMap<JpsModule, ProcessorConfigProfile>();
|
||||
final Map<String, JpsModule> namesMap = new HashMap<String, JpsModule>();
|
||||
for (JpsModule m : getProjectDescriptor().jpsProject.getModules()) {
|
||||
for (JpsModule m : getProjectDescriptor().getProject().getModules()) {
|
||||
namesMap.put(m.getName(), m);
|
||||
}
|
||||
if (!namesMap.isEmpty()) {
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.JpsPathUtil;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.builders.BuildRootIndex;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.model.JpsEncodingConfigurationService;
|
||||
import org.jetbrains.jps.model.JpsEncodingProjectConfiguration;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
@@ -49,7 +49,7 @@ public class CompilerEncodingConfiguration {
|
||||
File file = JpsPathUtil.urlToFile(fileUrl);
|
||||
if (charset == null || (!file.isDirectory() && !shouldHonorEncodingForCompilation(builders, file))) continue;
|
||||
|
||||
final RootDescriptor rootDescriptor = myRootsIndex.getModuleAndRoot(null, file);
|
||||
final JavaSourceRootDescriptor rootDescriptor = myRootsIndex.getModuleAndRoot(null, file);
|
||||
if (rootDescriptor == null) continue;
|
||||
|
||||
final JpsModule module = rootDescriptor.target.getModule();
|
||||
|
||||
@@ -10,9 +10,9 @@ import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
import org.jetbrains.jps.builders.FileProcessor;
|
||||
import org.jetbrains.jps.builders.impl.BuildTargetChunk;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.fs.BuildFSState;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.incremental.storage.Timestamps;
|
||||
import org.jetbrains.jps.indices.ModuleExcludeIndex;
|
||||
import org.jetbrains.jps.model.java.JpsJavaClasspathKind;
|
||||
@@ -30,7 +30,7 @@ import java.util.Set;
|
||||
*/
|
||||
public class FSOperations {
|
||||
public static void markDirty(CompileContext context, final File file) throws IOException {
|
||||
final RootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
if (rd != null) {
|
||||
final ProjectDescriptor pd = context.getProjectDescriptor();
|
||||
pd.fsState.markDirty(context, file, rd, pd.timestamps.getStorage());
|
||||
@@ -38,7 +38,7 @@ public class FSOperations {
|
||||
}
|
||||
|
||||
public static void markDirtyIfNotDeleted(CompileContext context, final File file) throws IOException {
|
||||
final RootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
if (rd != null) {
|
||||
final ProjectDescriptor pd = context.getProjectDescriptor();
|
||||
pd.fsState.markDirtyIfNotDeleted(context, file, rd, pd.timestamps.getStorage());
|
||||
@@ -46,7 +46,7 @@ public class FSOperations {
|
||||
}
|
||||
|
||||
public static void markDeleted(CompileContext context, File file) throws IOException {
|
||||
final RootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
final JavaSourceRootDescriptor rd = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
if (rd != null) {
|
||||
final ProjectDescriptor pd = context.getProjectDescriptor();
|
||||
pd.fsState.registerDeleted(rd.target, file, pd.timestamps.getStorage());
|
||||
@@ -130,9 +130,9 @@ public class FSOperations {
|
||||
ModuleBuildTarget target,
|
||||
Timestamps timestamps, boolean forceMarkDirty,
|
||||
@Nullable THashSet<File> currentFiles) throws IOException {
|
||||
final ModuleExcludeIndex rootsIndex = context.getProjectDescriptor().moduleExcludeIndex;
|
||||
final ModuleExcludeIndex rootsIndex = context.getProjectDescriptor().getModuleExcludeIndex();
|
||||
final Set<File> excludes = new HashSet<File>(rootsIndex.getModuleExcludes(target.getModule()));
|
||||
for (RootDescriptor rd : context.getProjectDescriptor().getBuildRootIndex().getTargetRoots(target, context)) {
|
||||
for (JavaSourceRootDescriptor rd : context.getProjectDescriptor().getBuildRootIndex().getTargetRoots(target, context)) {
|
||||
if (!rd.root.exists()) {
|
||||
continue;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ public class FSOperations {
|
||||
}
|
||||
}
|
||||
|
||||
private static void traverseRecursively(CompileContext context, final RootDescriptor rd, final File file, Set<File> excludes, @NotNull final Timestamps tsStorage, final boolean forceDirty, @Nullable Set<File> currentFiles) throws IOException {
|
||||
private static void traverseRecursively(CompileContext context, final JavaSourceRootDescriptor rd, final File file, Set<File> excludes, @NotNull final Timestamps tsStorage, final boolean forceDirty, @Nullable Set<File> currentFiles) throws IOException {
|
||||
final File[] children = file.listFiles();
|
||||
if (children != null) { // is directory
|
||||
if (children.length > 0 && !JpsPathUtil.isUnder(excludes, file)) {
|
||||
|
||||
@@ -24,12 +24,12 @@ import org.jetbrains.jps.builders.*;
|
||||
import org.jetbrains.jps.builders.impl.BuildTargetChunk;
|
||||
import org.jetbrains.jps.builders.java.JavaBuilderUtil;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.cmdline.BuildRunner;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.fs.BuildFSState;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.incremental.java.ExternalJavacDescriptor;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilder;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilderLogger;
|
||||
@@ -262,7 +262,7 @@ public class IncProjectBuilder {
|
||||
private void cleanOutputRoots(CompileContext context) throws ProjectBuildException {
|
||||
// whole project is affected
|
||||
final boolean shouldClear = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(
|
||||
context.getProjectDescriptor().jpsProject).isClearOutputDirectoryOnRebuild();
|
||||
context.getProjectDescriptor().getProject()).isClearOutputDirectoryOnRebuild();
|
||||
try {
|
||||
if (shouldClear) {
|
||||
clearOutputs(context);
|
||||
@@ -598,9 +598,7 @@ public class IncProjectBuilder {
|
||||
rootFiles.add(rd.getRootFile());
|
||||
context.getProjectDescriptor().fsState.clearRecompile(rd);
|
||||
}
|
||||
myAsyncTasks.add(
|
||||
FileUtil.asyncDelete(rootFiles)
|
||||
);
|
||||
myAsyncTasks.add(FileUtil.asyncDelete(rootFiles));
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -760,9 +758,9 @@ public class IncProjectBuilder {
|
||||
nextPassRequired = false;
|
||||
myProjectDescriptor.fsState.beforeNextRoundStart(context, chunk);
|
||||
|
||||
DirtyFilesHolder<RootDescriptor, ModuleBuildTarget> dirtyFilesHolder = new DirtyFilesHolder<RootDescriptor, ModuleBuildTarget>() {
|
||||
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder = new DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget>() {
|
||||
@Override
|
||||
public void processDirtyFiles(@NotNull FileProcessor<RootDescriptor, ModuleBuildTarget> processor) throws IOException {
|
||||
public void processDirtyFiles(@NotNull FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget> processor) throws IOException {
|
||||
FSOperations.processFilesToRecompile(context, chunk, processor);
|
||||
}
|
||||
};
|
||||
@@ -834,16 +832,16 @@ public class IncProjectBuilder {
|
||||
}
|
||||
|
||||
private static void syncOutputFiles(final CompileContext context,
|
||||
DirtyFilesHolder<RootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException {
|
||||
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException {
|
||||
final BuildDataManager dataManager = context.getProjectDescriptor().dataManager;
|
||||
try {
|
||||
final Collection<String> allOutputs = new LinkedList<String>();
|
||||
|
||||
dirtyFilesHolder.processDirtyFiles(new FileProcessor<RootDescriptor, ModuleBuildTarget>() {
|
||||
dirtyFilesHolder.processDirtyFiles(new FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget>() {
|
||||
private final Map<ModuleBuildTarget, SourceToOutputMapping> storageMap = new HashMap<ModuleBuildTarget, SourceToOutputMapping>();
|
||||
|
||||
@Override
|
||||
public boolean apply(ModuleBuildTarget target, File file, RootDescriptor sourceRoot) throws IOException {
|
||||
public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor sourceRoot) throws IOException {
|
||||
SourceToOutputMapping srcToOut = storageMap.get(target);
|
||||
if (srcToOut == null) {
|
||||
srcToOut = dataManager.getSourceToOutputMap(target);
|
||||
@@ -943,7 +941,7 @@ public class IncProjectBuilder {
|
||||
fsState.markInitialScanPerformed(target);
|
||||
}
|
||||
final Timestamps timestamps = pd.timestamps.getStorage();
|
||||
for (RootDescriptor rd : pd.getBuildRootIndex().getTargetRoots(target, context)) {
|
||||
for (JavaSourceRootDescriptor rd : pd.getBuildRootIndex().getTargetRoots(target, context)) {
|
||||
marked |= fsState.markAllUpToDate(context, rd, timestamps);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,16 +6,18 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.JpsPathUtil;
|
||||
import org.jetbrains.jps.builders.BuildRootIndex;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.indices.IgnoredFileIndex;
|
||||
import org.jetbrains.jps.indices.ModuleExcludeIndex;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsSimpleElement;
|
||||
import org.jetbrains.jps.model.java.JavaSourceRootProperties;
|
||||
import org.jetbrains.jps.model.java.JavaSourceRootType;
|
||||
import org.jetbrains.jps.model.java.JpsJavaDependenciesEnumerator;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.model.module.JpsModuleSourceRoot;
|
||||
import org.jetbrains.jps.model.module.JpsTypedModuleSourceRoot;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -26,7 +28,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ModuleBuildTarget extends BuildTarget<RootDescriptor> {
|
||||
public class ModuleBuildTarget extends BuildTarget<JavaSourceRootDescriptor> {
|
||||
private final JpsModule myModule;
|
||||
private final String myModuleName;
|
||||
private final JavaModuleBuildTargetType myTargetType;
|
||||
@@ -77,21 +79,19 @@ public class ModuleBuildTarget extends BuildTarget<RootDescriptor> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<RootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex) {
|
||||
List<RootDescriptor> roots = new ArrayList<RootDescriptor>();
|
||||
for (JpsModuleSourceRoot sourceRoot : myModule.getSourceRoots()) {
|
||||
public List<JavaSourceRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex) {
|
||||
List<JavaSourceRootDescriptor> roots = new ArrayList<JavaSourceRootDescriptor>();
|
||||
JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
|
||||
for (JpsTypedModuleSourceRoot<JpsSimpleElement<JavaSourceRootProperties>> sourceRoot : myModule.getSourceRoots(type)) {
|
||||
final File root = JpsPathUtil.urlToFile(sourceRoot.getUrl());
|
||||
final boolean testRoot = JavaSourceRootType.TEST_SOURCE.equals(sourceRoot.getRootType());
|
||||
if (testRoot == isTests()) {
|
||||
roots.add(new RootDescriptor(root, this, false, false));
|
||||
}
|
||||
roots.add(new JavaSourceRootDescriptor(root, this, false, false, sourceRoot.getProperties().getData().getPackagePrefix()));
|
||||
}
|
||||
return roots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RootDescriptor findRootDescriptor(String rootId, BuildRootIndex rootIndex) {
|
||||
List<RootDescriptor> descriptors = rootIndex.getRootDescriptors(new File(rootId), Collections.<JavaModuleBuildTargetType>singletonList(myTargetType), null);
|
||||
public JavaSourceRootDescriptor findRootDescriptor(String rootId, BuildRootIndex rootIndex) {
|
||||
List<JavaSourceRootDescriptor> descriptors = rootIndex.getRootDescriptors(new File(rootId), Collections.<JavaModuleBuildTargetType>singletonList(myTargetType), null);
|
||||
return ContainerUtil.getFirstItem(descriptors);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.jetbrains.jps.incremental;
|
||||
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -25,7 +25,7 @@ public abstract class ModuleLevelBuilder extends Builder {
|
||||
|
||||
public abstract ExitCode build(CompileContext context,
|
||||
ModuleChunk chunk,
|
||||
DirtyFilesHolder<RootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException;
|
||||
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException;
|
||||
|
||||
public boolean shouldHonorFileEncodingForCompilation(File file) {
|
||||
return false;
|
||||
|
||||
+1
-2
@@ -3,7 +3,6 @@ package org.jetbrains.jps.incremental.artifacts;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.builders.BuildRootDescriptor;
|
||||
import org.jetbrains.jps.builders.BuildRootIndex;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
@@ -105,7 +104,7 @@ public class ArtifactBuildTarget extends BuildTarget<ArtifactRootDescriptor> {
|
||||
@Override
|
||||
public List<ArtifactRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex) {
|
||||
ArtifactInstructionsBuilderImpl builder = new ArtifactInstructionsBuilderImpl(index, ignoredFileIndex, this);
|
||||
ArtifactInstructionsBuilderContext context = new ArtifactInstructionsBuilderContextImpl(model, new ProjectPaths(model.getProject()));
|
||||
ArtifactInstructionsBuilderContext context = new ArtifactInstructionsBuilderContextImpl();
|
||||
String outputPath = StringUtil.notNullize(myArtifact.getOutputPath());
|
||||
final CopyToDirectoryInstructionCreator instructionCreator = new CopyToDirectoryInstructionCreator(builder, outputPath);
|
||||
LayoutElementBuildersRegistry.getInstance().generateInstructions(myArtifact, instructionCreator, context);
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ public class IncArtifactBuilder extends TargetBuilder<ArtifactBuildTarget> {
|
||||
return;
|
||||
}
|
||||
final ProjectDescriptor pd = context.getProjectDescriptor();
|
||||
final ArtifactSorter sorter = new ArtifactSorter(pd.jpsModel);
|
||||
final ArtifactSorter sorter = new ArtifactSorter(pd.getModel());
|
||||
final Map<JpsArtifact, JpsArtifact> selfIncludingNameMap = sorter.getArtifactToSelfIncludingNameMap();
|
||||
final JpsArtifact selfIncluding = selfIncludingNameMap.get(artifact);
|
||||
if (selfIncluding != null) {
|
||||
|
||||
-11
@@ -1,9 +1,5 @@
|
||||
package org.jetbrains.jps.incremental.artifacts.instructions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifact;
|
||||
|
||||
/**
|
||||
@@ -11,13 +7,6 @@ import org.jetbrains.jps.model.artifact.JpsArtifact;
|
||||
*/
|
||||
public interface ArtifactInstructionsBuilderContext {
|
||||
|
||||
@NotNull
|
||||
ProjectPaths getProjectPaths();
|
||||
|
||||
JpsProject getJpsProject();
|
||||
|
||||
JpsModel getJpsModel();
|
||||
|
||||
boolean enterArtifact(JpsArtifact artifact);
|
||||
|
||||
void leaveArtifact(JpsArtifact artifact);
|
||||
|
||||
+1
-27
@@ -1,9 +1,5 @@
|
||||
package org.jetbrains.jps.incremental.artifacts.instructions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifact;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -13,28 +9,12 @@ import java.util.Set;
|
||||
* @author nik
|
||||
*/
|
||||
public class ArtifactInstructionsBuilderContextImpl implements ArtifactInstructionsBuilderContext {
|
||||
private final JpsProject myJpsProject;
|
||||
private final ProjectPaths myProjectPaths;
|
||||
private final Set<JpsArtifact> myParentArtifacts;
|
||||
private JpsModel myModel;
|
||||
|
||||
public ArtifactInstructionsBuilderContextImpl(JpsModel jpsModel, ProjectPaths projectPaths) {
|
||||
myJpsProject = jpsModel.getProject();
|
||||
myModel = jpsModel;
|
||||
myProjectPaths = projectPaths;
|
||||
public ArtifactInstructionsBuilderContextImpl() {
|
||||
myParentArtifacts = new HashSet<JpsArtifact>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsProject getJpsProject() {
|
||||
return myJpsProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsModel getJpsModel() {
|
||||
return myModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enterArtifact(JpsArtifact artifact) {
|
||||
return myParentArtifacts.add(artifact);
|
||||
@@ -44,10 +24,4 @@ public class ArtifactInstructionsBuilderContextImpl implements ArtifactInstructi
|
||||
public void leaveArtifact(JpsArtifact artifact) {
|
||||
myParentArtifacts.remove(artifact);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectPaths getProjectPaths() {
|
||||
return myProjectPaths;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ import org.jetbrains.jps.builders.BuildRootDescriptor;
|
||||
import org.jetbrains.jps.builders.BuildRootIndex;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
import org.jetbrains.jps.builders.FileProcessor;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.CompileScope;
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget;
|
||||
import org.jetbrains.jps.incremental.Utils;
|
||||
import org.jetbrains.jps.incremental.artifacts.instructions.ArtifactRootDescriptor;
|
||||
import org.jetbrains.jps.incremental.storage.Timestamps;
|
||||
@@ -30,7 +30,7 @@ import java.util.Set;
|
||||
*/
|
||||
public class BuildFSState extends FSState {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.jps.incremental.fs.BuildFSState");
|
||||
private static final Key<Set<ModuleBuildTarget>> CONTEXT_TARGETS_KEY = Key.create("_fssfate_context_modules_");
|
||||
private static final Key<Set<? extends BuildTarget<?>>> CONTEXT_TARGETS_KEY = Key.create("_fssfate_context_targets_");
|
||||
private static final Key<FilesDelta> CURRENT_ROUND_DELTA_KEY = Key.create("_current_round_delta_");
|
||||
private static final Key<FilesDelta> LAST_ROUND_DELTA_KEY = Key.create("_last_round_delta_");
|
||||
|
||||
@@ -69,12 +69,12 @@ public class BuildFSState extends FSState {
|
||||
if (context == null) {
|
||||
return false;
|
||||
}
|
||||
Set<ModuleBuildTarget> targets = CONTEXT_TARGETS_KEY.get(context, Collections.<ModuleBuildTarget>emptySet());
|
||||
Set<? extends BuildTarget<?>> targets = CONTEXT_TARGETS_KEY.get(context, Collections.<BuildTarget<?>>emptySet());
|
||||
return targets.contains(rd.getTarget());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean markDirtyIfNotDeleted(@Nullable CompileContext context, File file, final RootDescriptor rd, @Nullable Timestamps tsStorage) throws IOException {
|
||||
public boolean markDirtyIfNotDeleted(@Nullable CompileContext context, File file, final BuildRootDescriptor rd, @Nullable Timestamps tsStorage) throws IOException {
|
||||
final boolean marked = super.markDirtyIfNotDeleted(context, file, rd, tsStorage);
|
||||
if (marked) {
|
||||
final FilesDelta roundDelta = getRoundDelta(CURRENT_ROUND_DELTA_KEY, context);
|
||||
@@ -112,7 +112,7 @@ public class BuildFSState extends FSState {
|
||||
setRoundDelta(CURRENT_ROUND_DELTA_KEY, context, new FilesDelta());
|
||||
}
|
||||
|
||||
public <R extends RootDescriptor, T extends BuildTarget<R>> boolean processFilesToRecompile(CompileContext context, final T target, final FileProcessor<R, T> processor) throws IOException {
|
||||
public <R extends BuildRootDescriptor, T extends BuildTarget<R>> boolean processFilesToRecompile(CompileContext context, final T target, final FileProcessor<R, T> processor) throws IOException {
|
||||
final Map<BuildRootDescriptor, Set<File>> data = getSourcesToRecompile(context, target);
|
||||
BuildRootIndex rootIndex = context.getProjectDescriptor().getBuildRootIndex();
|
||||
final CompileScope scope = context.getScope();
|
||||
@@ -137,7 +137,7 @@ public class BuildFSState extends FSState {
|
||||
/**
|
||||
* @return true if marked something, false otherwise
|
||||
*/
|
||||
public boolean markAllUpToDate(CompileContext context, final RootDescriptor rd, final Timestamps stamps) throws IOException {
|
||||
public boolean markAllUpToDate(CompileContext context, final JavaSourceRootDescriptor rd, final Timestamps stamps) throws IOException {
|
||||
boolean marked = false;
|
||||
final FilesDelta delta = getDelta(rd.target);
|
||||
final Set<File> files = delta.clearRecompile(rd);
|
||||
@@ -192,7 +192,7 @@ public class BuildFSState extends FSState {
|
||||
return marked;
|
||||
}
|
||||
|
||||
private static void setContextTargets(@Nullable CompileContext context, @Nullable Set<ModuleBuildTarget> targets) {
|
||||
private static void setContextTargets(@Nullable CompileContext context, @Nullable Set<? extends BuildTarget<?>> targets) {
|
||||
if (context != null) {
|
||||
CONTEXT_TARGETS_KEY.set(context, targets);
|
||||
}
|
||||
|
||||
@@ -89,11 +89,11 @@ public class FSState {
|
||||
|
||||
public boolean markDirtyIfNotDeleted(@Nullable CompileContext context,
|
||||
final File file,
|
||||
final RootDescriptor rd,
|
||||
final BuildRootDescriptor rd,
|
||||
final @Nullable Timestamps tsStorage) throws IOException {
|
||||
final boolean marked = getDelta(rd.target).markRecompileIfNotDeleted(rd, file);
|
||||
final boolean marked = getDelta(rd.getTarget()).markRecompileIfNotDeleted(rd, file);
|
||||
if (marked && tsStorage != null) {
|
||||
tsStorage.removeStamp(file, rd.target);
|
||||
tsStorage.removeStamp(file, rd.getTarget());
|
||||
}
|
||||
return marked;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ final class FilesDelta {
|
||||
return added;
|
||||
}
|
||||
|
||||
public boolean markRecompileIfNotDeleted(RootDescriptor root, File file) {
|
||||
public boolean markRecompileIfNotDeleted(BuildRootDescriptor root, File file) {
|
||||
final boolean isMarkedDeleted;
|
||||
synchronized (myDeletedPaths) {
|
||||
isMarkedDeleted = !myDeletedPaths.isEmpty() && myDeletedPaths.contains(FileUtil.toCanonicalPath(file.getPath()));
|
||||
|
||||
@@ -35,11 +35,11 @@ import org.jetbrains.jps.builders.BuildRootIndex;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.FileProcessor;
|
||||
import org.jetbrains.jps.builders.java.JavaBuilderUtil;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Mappings;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
@@ -124,7 +124,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
if (srcFile != null && content != null) {
|
||||
final String outputPath = FileUtil.toSystemIndependentName(out.getFile().getPath());
|
||||
final String sourcePath = FileUtil.toSystemIndependentName(srcFile.getPath());
|
||||
final RootDescriptor rootDescriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, srcFile);
|
||||
final JavaSourceRootDescriptor rootDescriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, srcFile);
|
||||
final BuildDataManager dataManager = context.getProjectDescriptor().dataManager;
|
||||
boolean isTemp = false;
|
||||
if (rootDescriptor != null) {
|
||||
@@ -172,13 +172,13 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
|
||||
public ExitCode build(final CompileContext context,
|
||||
final ModuleChunk chunk,
|
||||
DirtyFilesHolder<RootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException {
|
||||
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException {
|
||||
try {
|
||||
final Set<File> filesToCompile = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
final Set<File> formsToCompile = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
|
||||
dirtyFilesHolder.processDirtyFiles(new FileProcessor<RootDescriptor, ModuleBuildTarget>() {
|
||||
public boolean apply(ModuleBuildTarget target, File file, RootDescriptor sourceRoot) throws IOException {
|
||||
dirtyFilesHolder.processDirtyFiles(new FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget>() {
|
||||
public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor sourceRoot) throws IOException {
|
||||
if (JAVA_SOURCES_FILTER.accept(file)) {
|
||||
filesToCompile.add(file);
|
||||
}
|
||||
@@ -190,15 +190,16 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
});
|
||||
|
||||
// force compilation of bound source file if the form is dirty
|
||||
final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(context.getProjectDescriptor().jpsProject).getCompilerExcludes();
|
||||
final JpsCompilerExcludes excludes = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(
|
||||
context.getProjectDescriptor().getProject()).getCompilerExcludes();
|
||||
if (!context.isProjectRebuild()) {
|
||||
for (Iterator<File> formsIterator = formsToCompile.iterator(); formsIterator.hasNext(); ) {
|
||||
final File form = formsIterator.next();
|
||||
final RootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, form);
|
||||
final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, form);
|
||||
if (descriptor == null) {
|
||||
continue;
|
||||
}
|
||||
for (RootDescriptor rd : context.getProjectDescriptor().getBuildRootIndex().getTargetRoots(descriptor.target, context)) {
|
||||
for (JavaSourceRootDescriptor rd : context.getProjectDescriptor().getBuildRootIndex().getTargetRoots(descriptor.target, context)) {
|
||||
final File boundSource = getBoundSource(rd.root, form);
|
||||
if (boundSource == null) {
|
||||
continue;
|
||||
@@ -311,7 +312,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
final ProjectPaths paths = context.getProjectPaths();
|
||||
final ProjectDescriptor pd = context.getProjectDescriptor();
|
||||
final boolean addNotNullAssertions = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(
|
||||
pd.jpsProject).isAddNotNullAssertions();
|
||||
pd.getProject()).isAddNotNullAssertions();
|
||||
|
||||
final Collection<File> classpath =
|
||||
paths.getCompilationClasspath(chunk, false/*context.isProjectRebuild()*/);
|
||||
@@ -329,7 +330,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
final Set<File> tempRootsSourcePath = new HashSet<File>();
|
||||
final BuildRootIndex index = pd.getBuildRootIndex();
|
||||
for (ModuleBuildTarget target : chunk.getTargets()) {
|
||||
for (RootDescriptor rd : index.getTempTargetRoots(target, context)) {
|
||||
for (JavaSourceRootDescriptor rd : index.getTempTargetRoots(target, context)) {
|
||||
tempRootsSourcePath.add(rd.root);
|
||||
}
|
||||
}
|
||||
@@ -365,7 +366,8 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
try {
|
||||
context.processMessage(new ProgressMessage("Instrumenting forms [" + chunkName + "]"));
|
||||
instrumentForms(context, chunk, chunkSourcePath, finder, forms, outputSink);
|
||||
JpsUiDesignerConfiguration configuration = JpsUiDesignerExtensionService.getInstance().getUiDesignerConfiguration(pd.jpsProject);
|
||||
JpsUiDesignerConfiguration configuration = JpsUiDesignerExtensionService.getInstance().getUiDesignerConfiguration(
|
||||
pd.getProject());
|
||||
if (configuration != null && configuration.isCopyFormsRuntimeToOutput() && !chunk.containsTests()) {
|
||||
for (JpsModule module : chunk.getModules()) {
|
||||
final File outputDir = paths.getModuleOutputDir(module, false);
|
||||
@@ -505,7 +507,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
|
||||
private static boolean useEclipseCompiler(CompileContext context) {
|
||||
JpsProject project = context.getProjectDescriptor().jpsProject;
|
||||
JpsProject project = context.getProjectDescriptor().getProject();
|
||||
return USE_EMBEDDED_JAVAC && "Eclipse".equalsIgnoreCase(JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project).getJavaCompilerId());
|
||||
}
|
||||
|
||||
@@ -625,7 +627,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
|
||||
private static int getJavacServerHeapSize(CompileContext context) {
|
||||
final JpsProject project = context.getProjectDescriptor().jpsProject;
|
||||
final JpsProject project = context.getProjectDescriptor().getProject();
|
||||
final JpsJavaCompilerConfiguration config = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
|
||||
final JpsJavaCompilerOptions options = config.getCurrentCompilerOptions();
|
||||
return options.MAXIMUM_HEAP_SIZE;
|
||||
@@ -705,7 +707,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
|
||||
JpsJavaCompilerConfiguration compilerConfiguration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(
|
||||
context.getProjectDescriptor().jpsProject);
|
||||
context.getProjectDescriptor().getProject());
|
||||
String bytecodeTarget = null;
|
||||
int chunkSdkVersion = -1;
|
||||
for (JpsModule module : chunk.getModules()) {
|
||||
@@ -823,7 +825,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
final List<String> options = new ArrayList<String>();
|
||||
final List<String> vmOptions = new ArrayList<String>();
|
||||
|
||||
final JpsProject project = context.getProjectDescriptor().jpsProject;
|
||||
final JpsProject project = context.getProjectDescriptor().getProject();
|
||||
final JpsJavaCompilerConfiguration compilerConfig = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
|
||||
final boolean useEclipseCompiler = useEclipseCompiler(context);
|
||||
final JpsJavaCompilerOptions compilerOptions = compilerConfig.getCurrentCompilerOptions();
|
||||
@@ -891,7 +893,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
continue;
|
||||
}
|
||||
final Set<File> roots = new LinkedHashSet<File>();
|
||||
for (RootDescriptor descriptor : context.getProjectDescriptor().getBuildRootIndex().getTargetRoots(target, context)) {
|
||||
for (JavaSourceRootDescriptor descriptor : context.getProjectDescriptor().getBuildRootIndex().getTargetRoots(target, context)) {
|
||||
roots.add(descriptor.root);
|
||||
}
|
||||
map.put(outputDir, roots);
|
||||
|
||||
@@ -8,9 +8,9 @@ import org.jetbrains.jps.JpsPathUtil;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.FileProcessor;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
@@ -43,13 +43,13 @@ public class ResourcesBuilder extends ModuleLevelBuilder {
|
||||
// init patterns
|
||||
ResourcePatterns patterns = ResourcePatterns.KEY.get(context);
|
||||
if (patterns == null) {
|
||||
ResourcePatterns.KEY.set(context, new ResourcePatterns(context.getProjectDescriptor().jpsProject));
|
||||
ResourcePatterns.KEY.set(context, new ResourcePatterns(context.getProjectDescriptor().getProject()));
|
||||
}
|
||||
}
|
||||
|
||||
public ExitCode build(final CompileContext context,
|
||||
final ModuleChunk chunk,
|
||||
DirtyFilesHolder<RootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException {
|
||||
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException {
|
||||
final ResourcePatterns patterns = ResourcePatterns.KEY.get(context);
|
||||
assert patterns != null;
|
||||
try {
|
||||
@@ -66,8 +66,8 @@ public class ResourcesBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
};
|
||||
|
||||
FSOperations.processFilesToRecompile(context, chunk, moduleFilter, new FileProcessor<RootDescriptor, ModuleBuildTarget>() {
|
||||
public boolean apply(final ModuleBuildTarget target, final File file, final RootDescriptor sourceRoot) throws IOException {
|
||||
FSOperations.processFilesToRecompile(context, chunk, moduleFilter, new FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget>() {
|
||||
public boolean apply(final ModuleBuildTarget target, final File file, final JavaSourceRootDescriptor sourceRoot) throws IOException {
|
||||
if (patterns.isResourceFile(file, sourceRoot.root)) {
|
||||
try {
|
||||
context.processMessage(new ProgressMessage("Copying " + file.getPath()));
|
||||
@@ -99,7 +99,7 @@ public class ResourcesBuilder extends ModuleLevelBuilder {
|
||||
private static void copyResource(CompileContext context,
|
||||
JpsModule module,
|
||||
File file,
|
||||
RootDescriptor sourceRoot,
|
||||
JavaSourceRootDescriptor sourceRoot,
|
||||
final SourceToOutputMapping outputToSourceMapping, final boolean tests) throws IOException {
|
||||
final String outputRootUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, tests);
|
||||
if (outputRootUrl == null) {
|
||||
@@ -107,11 +107,11 @@ public class ResourcesBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
String rootPath = FileUtil.toSystemIndependentName(sourceRoot.root.getAbsolutePath());
|
||||
final String relativePath = FileUtil.getRelativePath(rootPath, FileUtil.toSystemIndependentName(file.getPath()), '/');
|
||||
final String prefix = JpsJavaExtensionService.getInstance().getSourcePrefix(module, JpsPathUtil.pathToUrl(rootPath));
|
||||
final String prefix = sourceRoot.getPackagePrefix();
|
||||
|
||||
final StringBuilder targetPath = new StringBuilder();
|
||||
targetPath.append(JpsPathUtil.urlToPath(outputRootUrl));
|
||||
if (prefix != null && prefix.length() > 0) {
|
||||
if (prefix.length() > 0) {
|
||||
targetPath.append('/').append(prefix.replace('.', '/'));
|
||||
}
|
||||
targetPath.append('/').append(relativePath);
|
||||
|
||||
@@ -76,7 +76,12 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
|
||||
});
|
||||
|
||||
String outputPath = getAbsolutePath("out");
|
||||
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myJpsProject).setOutputUrl(JpsPathUtil.pathToUrl(outputPath));
|
||||
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject).setOutputUrl(JpsPathUtil.pathToUrl(outputPath));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File doGetProjectDir() throws IOException {
|
||||
return workDir;
|
||||
}
|
||||
|
||||
protected String getUrl(String pathRelativeToProjectRoot) {
|
||||
@@ -244,7 +249,7 @@ public abstract class IncrementalTestCase extends JpsBuildTestCase {
|
||||
}
|
||||
|
||||
protected JpsLibrary addLibrary(final String jarPath) {
|
||||
JpsLibrary library = myJpsProject.addLibrary("l", JpsJavaLibraryType.INSTANCE);
|
||||
JpsLibrary library = myProject.addLibrary("l", JpsJavaLibraryType.INSTANCE);
|
||||
library.addRoot(new File(getAbsolutePath(jarPath)), JpsOrderRootType.COMPILED);
|
||||
return library;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package org.jetbrains.jps.builders;
|
||||
|
||||
import com.intellij.openapi.util.io.FileSystemUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.util.io.TestFileSystemBuilder;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.JpsPathUtil;
|
||||
import org.jetbrains.jps.api.CanceledStatus;
|
||||
import org.jetbrains.jps.builders.impl.BuildRootIndexImpl;
|
||||
import org.jetbrains.jps.builders.impl.BuildTargetIndexImpl;
|
||||
import org.jetbrains.jps.indices.impl.IgnoredFileIndexImpl;
|
||||
import org.jetbrains.jps.indices.impl.ModuleExcludeIndexImpl;
|
||||
import org.jetbrains.jps.indices.ModuleExcludeIndex;
|
||||
import org.jetbrains.jps.cmdline.ClasspathBootstrap;
|
||||
import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
@@ -20,6 +19,9 @@ import org.jetbrains.jps.incremental.java.JavaBuilderLoggerImpl;
|
||||
import org.jetbrains.jps.incremental.storage.BuildDataManager;
|
||||
import org.jetbrains.jps.incremental.storage.BuildTargetsState;
|
||||
import org.jetbrains.jps.incremental.storage.ProjectTimestamps;
|
||||
import org.jetbrains.jps.indices.ModuleExcludeIndex;
|
||||
import org.jetbrains.jps.indices.impl.IgnoredFileIndexImpl;
|
||||
import org.jetbrains.jps.indices.impl.ModuleExcludeIndexImpl;
|
||||
import org.jetbrains.jps.model.JpsDummyElement;
|
||||
import org.jetbrains.jps.model.JpsElementFactory;
|
||||
import org.jetbrains.jps.model.JpsModel;
|
||||
@@ -41,18 +43,62 @@ import java.util.Set;
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsBuildTestCase extends UsefulTestCase {
|
||||
protected JpsProject myJpsProject;
|
||||
private File myProjectDir;
|
||||
protected JpsProject myProject;
|
||||
protected JpsModel myModel;
|
||||
private JpsSdk<JpsDummyElement> myJdk;
|
||||
private File myDataStorageRoot;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myModel = JpsElementFactory.getInstance().createModel();
|
||||
myJpsProject = myModel.getProject();
|
||||
myProject = myModel.getProject();
|
||||
myDataStorageRoot = FileUtil.createTempDirectory("compile-server-" + getProjectName(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
myProjectDir = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected static void assertOutput(final String outputPath, TestFileSystemBuilder expected) {
|
||||
expected.build().assertDirectoryEqual(new File(FileUtil.toSystemDependentName(outputPath)));
|
||||
}
|
||||
|
||||
protected static void assertOutput(JpsModule module, TestFileSystemBuilder expected) {
|
||||
String outputUrl = JpsJavaExtensionService.getInstance().getOutputUrl(module, false);
|
||||
assertNotNull(outputUrl);
|
||||
assertOutput(JpsPathUtil.urlToPath(outputUrl), expected);
|
||||
}
|
||||
|
||||
protected static void change(String filePath) {
|
||||
change(filePath, null);
|
||||
}
|
||||
|
||||
protected static void change(String filePath, final @Nullable String newContent) {
|
||||
try {
|
||||
File file = new File(FileUtil.toSystemDependentName(filePath));
|
||||
assertTrue("File " + file.getAbsolutePath() + " doesn't exist", file.exists());
|
||||
if (newContent != null) {
|
||||
FileUtil.writeToFile(file, newContent);
|
||||
}
|
||||
boolean updated = file.setLastModified(FileSystemUtil.lastModified(file) + Utils.TIMESTAMP_ACCURACY);
|
||||
assertTrue("Cannot modify timestamp for " + file.getAbsolutePath(), updated);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void delete(String filePath) {
|
||||
File file = new File(FileUtil.toSystemDependentName(filePath));
|
||||
assertTrue("File " + file.getAbsolutePath() + " doesn't exist", file.exists());
|
||||
final boolean deleted = FileUtil.delete(file);
|
||||
assertTrue("Cannot delete file " + file.getAbsolutePath(), deleted);
|
||||
}
|
||||
|
||||
protected JpsSdk<JpsDummyElement> addJdk(final String name) {
|
||||
try {
|
||||
return addJdk(name, FileUtil.toSystemIndependentName(ClasspathBootstrap.getResourcePath(Object.class).getCanonicalPath()));
|
||||
@@ -101,7 +147,7 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
|
||||
String testDataRootPath = getTestDataRootPath();
|
||||
String fullProjectPath = FileUtil.toSystemDependentName(testDataRootPath != null ? testDataRootPath + "/" + projectPath : projectPath);
|
||||
pathVariables = addPathVariables(pathVariables);
|
||||
JpsProjectLoader.loadProject(myJpsProject, pathVariables, fullProjectPath);
|
||||
JpsProjectLoader.loadProject(myProject, pathVariables, fullProjectPath);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -121,7 +167,7 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
|
||||
String[] srcPaths,
|
||||
@Nullable final String outputPath,
|
||||
final JpsSdk<JpsDummyElement> jdk) {
|
||||
final JpsModule module = myJpsProject.addModule(moduleName, JpsJavaModuleType.INSTANCE);
|
||||
final JpsModule module = myProject.addModule(moduleName, JpsJavaModuleType.INSTANCE);
|
||||
module.getSdkReferencesTable().setSdkReference(JpsJavaSdkType.INSTANCE, jdk.createReference());
|
||||
module.getDependenciesList().addSdkDependency(JpsJavaSdkType.INSTANCE);
|
||||
if (srcPaths.length > 0) {
|
||||
@@ -164,4 +210,52 @@ public abstract class JpsBuildTestCase extends UsefulTestCase {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected String createFile(String relativePath) {
|
||||
return createFile(relativePath, "");
|
||||
}
|
||||
|
||||
protected String createFile(String relativePath, final String text) {
|
||||
try {
|
||||
File file = new File(getOrCreateProjectDir(), relativePath);
|
||||
FileUtil.writeToFile(file, text);
|
||||
return FileUtil.toSystemIndependentName(file.getAbsolutePath());
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private File getOrCreateProjectDir() {
|
||||
if (myProjectDir == null) {
|
||||
try {
|
||||
myProjectDir = doGetProjectDir();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return myProjectDir;
|
||||
}
|
||||
|
||||
protected File doGetProjectDir() throws IOException {
|
||||
return FileUtil.createTempDirectory("prj", null);
|
||||
}
|
||||
|
||||
protected String getAbsolutePath(final String pathRelativeToProjectRoot) {
|
||||
return FileUtil.toSystemIndependentName(new File(getOrCreateProjectDir(), pathRelativeToProjectRoot).getAbsolutePath());
|
||||
}
|
||||
|
||||
protected JpsModule addModule(String moduleName, String... srcPaths) {
|
||||
if (myJdk == null) {
|
||||
myJdk = addJdk("1.6");
|
||||
}
|
||||
return addModule(moduleName, srcPaths, getAbsolutePath("out/production/" + moduleName), myJdk);
|
||||
}
|
||||
|
||||
protected String getProjectRelativePath(String path) {
|
||||
assertNotNull(myProjectDir);
|
||||
final String projectDir = FileUtil.toSystemIndependentName(myProjectDir.getAbsolutePath());
|
||||
return FileUtil.getRelativePath(projectDir, path, '/');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,17 +50,17 @@ public class ModuleClasspathTest extends JpsRebuildTestCase {
|
||||
}
|
||||
|
||||
private ProjectPaths getProjectPaths() {
|
||||
return new ProjectPaths(myJpsProject)
|
||||
return new ProjectPaths(myProject)
|
||||
}
|
||||
|
||||
private def assertClasspath(String moduleName, boolean includeTests, List<String> expected) {
|
||||
ModuleChunk chunk = createChunk(moduleName)
|
||||
final List<String> classpath = getPathsList(new ProjectPaths(myJpsProject).getCompilationClasspathFiles(chunk, includeTests, true, true))
|
||||
final List<String> classpath = getPathsList(new ProjectPaths(myProject).getCompilationClasspathFiles(chunk, includeTests, true, true))
|
||||
assertClasspath(expected, toSystemIndependentPaths(classpath))
|
||||
}
|
||||
|
||||
private ModuleChunk createChunk(String moduleName) {
|
||||
def module = myJpsProject.modules.find {it.name == moduleName}
|
||||
def module = myProject.modules.find {it.name == moduleName}
|
||||
return new ModuleChunk([new ModuleBuildTarget(module, JavaModuleBuildTargetType.PRODUCTION)] as Set)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ abstract class JpsRebuildTestCase extends JpsBuildTestCase {
|
||||
}
|
||||
|
||||
protected void rebuild() {
|
||||
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myJpsProject).outputUrl = JpsPathUtil.pathToUrl(FileUtil.toSystemIndependentName(getOrCreateOutputDirectory().getAbsolutePath()))
|
||||
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject).outputUrl = JpsPathUtil.pathToUrl(FileUtil.toSystemIndependentName(getOrCreateOutputDirectory().getAbsolutePath()))
|
||||
doRebuild()
|
||||
}
|
||||
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package org.jetbrains.jps.builders.resources;
|
||||
|
||||
import com.intellij.util.PathUtil;
|
||||
import org.jetbrains.jps.builders.JpsBuildTestCase;
|
||||
import org.jetbrains.jps.model.JpsSimpleElement;
|
||||
import org.jetbrains.jps.model.java.JavaSourceRootProperties;
|
||||
import org.jetbrains.jps.model.java.JavaSourceRootType;
|
||||
import org.jetbrains.jps.model.java.JpsJavaExtensionService;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
import org.jetbrains.jps.model.module.JpsModuleSourceRoot;
|
||||
import org.jetbrains.jps.model.module.JpsTypedModuleSourceRoot;
|
||||
|
||||
import static com.intellij.util.io.TestFileSystemItem.fs;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class ResourceCopyingTest extends JpsBuildTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(myProject).addResourcePattern("*.xml");
|
||||
}
|
||||
|
||||
public void testSimple() {
|
||||
String file = createFile("src/a.xml");
|
||||
JpsModule m = addModule("m", PathUtil.getParentPath(file));
|
||||
doRebuild();
|
||||
assertOutput(m, fs().file("a.xml"));
|
||||
}
|
||||
public void testPackagePrefix() {
|
||||
String file = createFile("src/a.xml");
|
||||
JpsModule m = addModule("m", PathUtil.getParentPath(file));
|
||||
JpsModuleSourceRoot sourceRoot = assertOneElement(m.getSourceRoots());
|
||||
JpsTypedModuleSourceRoot<JpsSimpleElement<JavaSourceRootProperties>> typed = sourceRoot.asTyped(JavaSourceRootType.SOURCE);
|
||||
assertNotNull(typed);
|
||||
typed.getProperties().setData(new JavaSourceRootProperties("xxx"));
|
||||
doRebuild();
|
||||
assertOutput(m, fs().dir("xxx").file("a.xml"));
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package org.jetbrains.jps.builders.util
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.util.io.ZipUtil
|
||||
import junit.framework.Assert
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
class FileSystemItem {
|
||||
boolean directory = false
|
||||
boolean archive = false
|
||||
String name
|
||||
String content = null
|
||||
private final Map<String, FileSystemItem> children = [:]
|
||||
|
||||
FileSystemItem leftShift(FileSystemItem item) {
|
||||
assert !children.containsKey(item.getName()) : "${item.name} already added"
|
||||
children[item.name] = item
|
||||
return this
|
||||
}
|
||||
|
||||
def assertDirectoryEqual(File file, String relativePath) throws IOException {
|
||||
Set<String> notFound = new HashSet<String>(children.keySet());
|
||||
file.listFiles()?.each {File child ->
|
||||
final def name = child.name
|
||||
final def item = children[name]
|
||||
Assert.assertNotNull("unexpected file: $relativePath$name", item)
|
||||
item.assertFileEqual(child, relativePath + name + "/")
|
||||
notFound.remove(name)
|
||||
}
|
||||
Assert.assertTrue("files $notFound not found in $relativePath", notFound.isEmpty());
|
||||
}
|
||||
|
||||
def assertFileEqual(File file, String relativePath) throws IOException {
|
||||
Assert.assertEquals("in $relativePath", name, file.name);
|
||||
if (archive) {
|
||||
final File dirForExtracted = FileUtil.createTempDirectory("extracted_archive", "");
|
||||
ZipUtil.extract(file, dirForExtracted, null);
|
||||
assertDirectoryEqual(dirForExtracted, relativePath);
|
||||
}
|
||||
else if (directory) {
|
||||
Assert.assertTrue("$relativePath${file.name} is not a directory", file.isDirectory());
|
||||
assertDirectoryEqual(file, relativePath);
|
||||
}
|
||||
else if (content != null) {
|
||||
final String actualContent = FileUtil.loadFile(file);
|
||||
Assert.assertEquals("content mismatch for " + relativePath, content, actualContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
package org.jetbrains.jps.builders.util;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author Pavel.Sher
|
||||
* Date: 05.03.2008
|
||||
*/
|
||||
public class TempFiles {
|
||||
private static final File ourCurrentTempDir = new File(System.getProperty("java.io.tmpdir"));
|
||||
private final File myCurrentTempDir;
|
||||
|
||||
private static Random ourRandom;
|
||||
|
||||
static {
|
||||
ourRandom = new Random();
|
||||
ourRandom.setSeed(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private final List<File> myFilesToDelete = new ArrayList<File>();
|
||||
|
||||
public TempFiles() {
|
||||
myCurrentTempDir = ourCurrentTempDir;
|
||||
if (!myCurrentTempDir.isDirectory()) {
|
||||
throw new IllegalStateException("Temp directory is not a directory, was deleted by some process: " + myCurrentTempDir.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
private File doCreateTempDir(String prefix, String suffix) throws IOException {
|
||||
prefix = prefix == null ? "" : prefix;
|
||||
suffix = suffix == null ? ".tmp" : suffix;
|
||||
|
||||
do {
|
||||
int count = ourRandom.nextInt();
|
||||
final File f = new File(myCurrentTempDir, prefix + count + suffix);
|
||||
if (!f.exists() && f.mkdirs()) {
|
||||
return f.getCanonicalFile();
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
private File doCreateTempFile(String prefix, String suffix) throws IOException {
|
||||
final File file = doCreateTempDir(prefix, suffix);
|
||||
file.delete();
|
||||
file.createNewFile();
|
||||
return file;
|
||||
}
|
||||
|
||||
public final File createTempFile() throws IOException {
|
||||
File tempFile = doCreateTempFile("test", null);
|
||||
registerAsTempFile(tempFile);
|
||||
return tempFile;
|
||||
}
|
||||
|
||||
private void registerAsTempFile(final File tempFile) {
|
||||
myFilesToDelete.add(tempFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a File object for created temp directory.
|
||||
*
|
||||
* @return a File object for created temp directory
|
||||
* @throws IOException if directory creation fails.
|
||||
*/
|
||||
public final File createTempDir() throws IOException {
|
||||
File f = doCreateTempDir("test", "");
|
||||
registerAsTempFile(f);
|
||||
return f;
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
for (File file : myFilesToDelete) {
|
||||
if (file.exists()) {
|
||||
FileUtil.delete(file);
|
||||
}
|
||||
}
|
||||
myFilesToDelete.clear();
|
||||
}
|
||||
}
|
||||
+5
-88
@@ -16,11 +16,9 @@
|
||||
package org.jetbrains.jps.incremental.artifacts;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.io.FileSystemUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.io.TestFileSystemBuilder;
|
||||
import com.intellij.util.text.UniqueNameGenerator;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.JpsPathUtil;
|
||||
import org.jetbrains.jps.builders.BuildResult;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
@@ -30,9 +28,7 @@ import org.jetbrains.jps.cmdline.ProjectDescriptor;
|
||||
import org.jetbrains.jps.incremental.BuildLoggingManager;
|
||||
import org.jetbrains.jps.incremental.CompileScope;
|
||||
import org.jetbrains.jps.incremental.CompileScopeImpl;
|
||||
import org.jetbrains.jps.incremental.Utils;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilderLoggerImpl;
|
||||
import org.jetbrains.jps.model.JpsDummyElement;
|
||||
import org.jetbrains.jps.model.JpsElementFactory;
|
||||
import org.jetbrains.jps.model.artifact.DirectoryArtifactType;
|
||||
import org.jetbrains.jps.model.artifact.JpsArtifact;
|
||||
@@ -40,8 +36,6 @@ import org.jetbrains.jps.model.artifact.JpsArtifactService;
|
||||
import org.jetbrains.jps.model.java.JpsJavaLibraryType;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.JpsOrderRootType;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdk;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -53,9 +47,7 @@ import static com.intellij.util.io.TestFileSystemItem.fs;
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
|
||||
private File myProjectDir;
|
||||
private TestArtifactBuilderLogger myArtifactBuilderLogger;
|
||||
private JpsSdk<JpsDummyElement> myJdk;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@@ -64,31 +56,15 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
for (JpsArtifact artifact : JpsArtifactService.getInstance().getArtifacts(myJpsProject)) {
|
||||
for (JpsArtifact artifact : JpsArtifactService.getInstance().getArtifacts(myProject)) {
|
||||
String outputPath = artifact.getOutputPath();
|
||||
if (outputPath != null) {
|
||||
FileUtil.delete(new File(FileUtil.toSystemDependentName(outputPath)));
|
||||
}
|
||||
}
|
||||
myProjectDir = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected String createFile(String relativePath) {
|
||||
return createFile(relativePath, "");
|
||||
}
|
||||
|
||||
protected String createFile(String relativePath, final String text) {
|
||||
try {
|
||||
File file = new File(getOrCreateProjectDir(), relativePath);
|
||||
FileUtil.writeToFile(file, text);
|
||||
return FileUtil.toSystemIndependentName(file.getAbsolutePath());
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected JpsArtifact addArtifact(LayoutElementTestUtil.LayoutElementCreator root) {
|
||||
Set<String> usedNames = getArtifactNames();
|
||||
final String name = UniqueNameGenerator.generateUniqueName("a", usedNames);
|
||||
@@ -97,51 +73,28 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
|
||||
|
||||
private Set<String> getArtifactNames() {
|
||||
Set<String> usedNames = new HashSet<String>();
|
||||
for (JpsArtifact artifact : JpsArtifactService.getInstance().getArtifacts(myJpsProject)) {
|
||||
for (JpsArtifact artifact : JpsArtifactService.getInstance().getArtifacts(myProject)) {
|
||||
usedNames.add(artifact.getName());
|
||||
}
|
||||
return usedNames;
|
||||
}
|
||||
|
||||
private File getOrCreateProjectDir() {
|
||||
if (myProjectDir == null) {
|
||||
try {
|
||||
myProjectDir = FileUtil.createTempDirectory("prj", null);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return myProjectDir;
|
||||
}
|
||||
|
||||
protected JpsArtifact addArtifact(String name, LayoutElementTestUtil.LayoutElementCreator root) {
|
||||
assertFalse("JpsArtifact " + name + " already exists", getArtifactNames().contains(name));
|
||||
JpsArtifact artifact = JpsArtifactService.getInstance().addArtifact(myJpsProject, name, root.buildElement(), DirectoryArtifactType.INSTANCE,
|
||||
JpsArtifact artifact = JpsArtifactService.getInstance().addArtifact(myProject, name, root.buildElement(), DirectoryArtifactType.INSTANCE,
|
||||
JpsElementFactory.getInstance().createDummyElement());
|
||||
artifact.setOutputPath(getAbsolutePath("out/artifacts/" + name));
|
||||
return artifact;
|
||||
}
|
||||
|
||||
private String getAbsolutePath(final String pathRelativeToProjectRoot) {
|
||||
return FileUtil.toSystemIndependentName(new File(getOrCreateProjectDir(), pathRelativeToProjectRoot).getAbsolutePath());
|
||||
}
|
||||
|
||||
protected JpsModule addModule(String moduleName, String... srcPaths) {
|
||||
if (myJdk == null) {
|
||||
myJdk = addJdk("1.6");
|
||||
}
|
||||
return addModule(moduleName, srcPaths, getAbsolutePath("out/production/" + moduleName), myJdk);
|
||||
}
|
||||
|
||||
protected JpsLibrary addProjectLibrary(String name, String jarPath) {
|
||||
final JpsLibrary library = myJpsProject.getLibraryCollection().addLibrary(name, JpsJavaLibraryType.INSTANCE);
|
||||
final JpsLibrary library = myProject.getLibraryCollection().addLibrary(name, JpsJavaLibraryType.INSTANCE);
|
||||
library.addRoot(JpsPathUtil.pathToUrl(jarPath), JpsOrderRootType.COMPILED);
|
||||
return library;
|
||||
}
|
||||
|
||||
protected void buildAll() {
|
||||
Collection<JpsArtifact> artifacts = JpsArtifactService.getInstance().getArtifacts(myJpsProject);
|
||||
Collection<JpsArtifact> artifacts = JpsArtifactService.getInstance().getArtifacts(myProject);
|
||||
buildArtifacts(artifacts.toArray(new JpsArtifact[artifacts.size()]));
|
||||
}
|
||||
|
||||
@@ -182,32 +135,6 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
|
||||
doBuild(false, a).assertFailed();
|
||||
}
|
||||
|
||||
protected static void change(String filePath) {
|
||||
change(filePath, null);
|
||||
}
|
||||
|
||||
protected static void change(String filePath, final @Nullable String newContent) {
|
||||
try {
|
||||
File file = new File(FileUtil.toSystemDependentName(filePath));
|
||||
assertTrue("File " + file.getAbsolutePath() + " doesn't exist", file.exists());
|
||||
if (newContent != null) {
|
||||
FileUtil.writeToFile(file, newContent);
|
||||
}
|
||||
boolean updated = file.setLastModified(FileSystemUtil.lastModified(file) + Utils.TIMESTAMP_ACCURACY);
|
||||
assertTrue("Cannot modify timestamp for " + file.getAbsolutePath(), updated);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected static void delete(String filePath) {
|
||||
File file = new File(FileUtil.toSystemDependentName(filePath));
|
||||
assertTrue("File " + file.getAbsolutePath() + " doesn't exist", file.exists());
|
||||
final boolean deleted = FileUtil.delete(file);
|
||||
assertTrue("Cannot delete file " + file.getAbsolutePath(), deleted);
|
||||
}
|
||||
|
||||
protected void assertCopied(String... filePaths) {
|
||||
assertSameElements(myArtifactBuilderLogger.myCopiedFilePaths, filePaths);
|
||||
assertEmpty(myArtifactBuilderLogger.myDeletedFilePaths);
|
||||
@@ -226,10 +153,6 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
|
||||
assertOutput(a.getOutputPath(), expected);
|
||||
}
|
||||
|
||||
protected static void assertOutput(final String outputPath, TestFileSystemBuilder expected) {
|
||||
expected.build().assertDirectoryEqual(new File(FileUtil.toSystemDependentName(outputPath)));
|
||||
}
|
||||
|
||||
protected void assertDeleted(String... filePaths) {
|
||||
assertSameElements(myArtifactBuilderLogger.myDeletedFilePaths, filePaths);
|
||||
assertEmpty(myArtifactBuilderLogger.myCopiedFilePaths);
|
||||
@@ -245,12 +168,6 @@ public abstract class ArtifactBuilderTestCase extends JpsBuildTestCase {
|
||||
assertEmpty(myArtifactBuilderLogger.myCopiedFilePaths);
|
||||
}
|
||||
|
||||
private String getProjectRelativePath(String path) {
|
||||
assertNotNull(myProjectDir);
|
||||
final String projectDir = FileUtil.toSystemIndependentName(myProjectDir.getAbsolutePath());
|
||||
return FileUtil.getRelativePath(projectDir, path, '/');
|
||||
}
|
||||
|
||||
protected static void rename(String path, String newName) {
|
||||
try {
|
||||
File file = new File(FileUtil.toSystemDependentName(path));
|
||||
|
||||
@@ -83,9 +83,6 @@ public abstract class JpsJavaExtensionService {
|
||||
@Nullable
|
||||
public abstract File getOutputDirectory(JpsModule module, boolean forTests);
|
||||
|
||||
@Nullable
|
||||
public abstract String getSourcePrefix(JpsModule module, String rootUrl);
|
||||
|
||||
public abstract JpsTypedLibrary<JpsSdk<JpsDummyElement>> addJavaSdk(@NotNull JpsGlobal global, @NotNull String name,
|
||||
@NotNull String homePath);
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ public interface JpsModule extends JpsNamedElement, JpsReferenceableElement<JpsM
|
||||
@NotNull
|
||||
List<JpsModuleSourceRoot> getSourceRoots();
|
||||
|
||||
@NotNull
|
||||
<P extends JpsElement>
|
||||
Iterable<JpsTypedModuleSourceRoot<P>> getSourceRoots(@NotNull JpsModuleSourceRootType<P> type);
|
||||
|
||||
@NotNull
|
||||
<P extends JpsElement, Type extends JpsModuleSourceRootType<P> & JpsElementTypeWithDefaultProperties<P>>
|
||||
JpsModuleSourceRoot addSourceRoot(@NotNull String url, @NotNull Type rootType);
|
||||
|
||||
@@ -16,6 +16,9 @@ public interface JpsModuleSourceRoot extends JpsElement {
|
||||
@Nullable
|
||||
<P extends JpsElement> P getProperties(@NotNull JpsModuleSourceRootType<P> type);
|
||||
|
||||
@Nullable
|
||||
<P extends JpsElement> JpsTypedModuleSourceRoot<P> asTyped(@NotNull JpsModuleSourceRootType<P> type);
|
||||
|
||||
@NotNull
|
||||
JpsElement getProperties();
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.jetbrains.jps.model.module;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.JpsTypedElement;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public interface JpsTypedModuleSourceRoot<P extends JpsElement> extends JpsModuleSourceRoot, JpsTypedElement<P> {
|
||||
@NotNull
|
||||
@Override
|
||||
P getProperties();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
JpsModuleSourceRootType<P> getRootType();
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import org.jetbrains.jps.JpsPathUtil;
|
||||
import org.jetbrains.jps.model.JpsDummyElement;
|
||||
import org.jetbrains.jps.model.JpsGlobal;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.model.JpsSimpleElement;
|
||||
import org.jetbrains.jps.model.java.*;
|
||||
import org.jetbrains.jps.model.java.compiler.JpsJavaCompilerConfiguration;
|
||||
import org.jetbrains.jps.model.java.impl.compiler.JpsJavaCompilerConfigurationImpl;
|
||||
@@ -118,22 +117,6 @@ public class JpsJavaExtensionServiceImpl extends JpsJavaExtensionService {
|
||||
return url != null ? JpsPathUtil.urlToFile(url) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSourcePrefix(JpsModule module, String rootUrl) {
|
||||
for (JpsModuleSourceRoot root : module.getSourceRoots()) {
|
||||
if (root.getUrl().equals(rootUrl)) {
|
||||
JpsModuleSourceRootType<?> type = root.getRootType();
|
||||
if (type instanceof JavaSourceRootType) {
|
||||
final JpsSimpleElement<JavaSourceRootProperties> properties = root.getProperties((JavaSourceRootType)type);
|
||||
if (properties != null) {
|
||||
return properties.getData().getPackagePrefix();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsTypedLibrary<JpsSdk<JpsDummyElement>> addJavaSdk(@NotNull JpsGlobal global, @NotNull String name, @NotNull String homePath) {
|
||||
String version = JdkVersionDetector.getInstance().detectJdkVersion(homePath);
|
||||
|
||||
@@ -90,6 +90,12 @@ public class JpsModuleImpl<P extends JpsElement> extends JpsNamedCompositeElemen
|
||||
return myContainer.getChild(JpsModuleSourceRootRole.ROOT_COLLECTION_ROLE).getElements();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <P extends JpsElement> Iterable<JpsTypedModuleSourceRoot<P>> getSourceRoots(@NotNull JpsModuleSourceRootType<P> type) {
|
||||
return myContainer.getChild(JpsModuleSourceRootRole.ROOT_COLLECTION_ROLE).getElementsOfType(type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <P extends JpsElement, T extends JpsModuleSourceRootType<P> & JpsElementTypeWithDefaultProperties<P>>
|
||||
|
||||
+17
-3
@@ -1,18 +1,20 @@
|
||||
package org.jetbrains.jps.model.module.impl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.JpsPathUtil;
|
||||
import org.jetbrains.jps.model.JpsElement;
|
||||
import org.jetbrains.jps.model.JpsElementType;
|
||||
import org.jetbrains.jps.model.impl.JpsCompositeElementBase;
|
||||
import org.jetbrains.jps.model.module.JpsModuleSourceRoot;
|
||||
import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
|
||||
import org.jetbrains.jps.model.module.JpsTypedModuleSourceRoot;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JpsModuleSourceRootImpl<P extends JpsElement> extends JpsCompositeElementBase<JpsModuleSourceRootImpl<P>> implements JpsModuleSourceRoot {
|
||||
public class JpsModuleSourceRootImpl<P extends JpsElement> extends JpsCompositeElementBase<JpsModuleSourceRootImpl<P>> implements JpsTypedModuleSourceRoot<P> {
|
||||
private final JpsModuleSourceRootType<P> myRootType;
|
||||
private final String myUrl;
|
||||
|
||||
@@ -38,6 +40,18 @@ public class JpsModuleSourceRootImpl<P extends JpsElement> extends JpsCompositeE
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <P extends JpsElement> JpsTypedModuleSourceRoot<P> asTyped(@NotNull JpsModuleSourceRootType<P> type) {
|
||||
//noinspection unchecked
|
||||
return myRootType.equals(type) ? (JpsTypedModuleSourceRoot<P>)this : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JpsElementType<?> getType() {
|
||||
return myRootType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public P getProperties() {
|
||||
@@ -46,7 +60,7 @@ public class JpsModuleSourceRootImpl<P extends JpsElement> extends JpsCompositeE
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JpsModuleSourceRootType<?> getRootType() {
|
||||
public JpsModuleSourceRootType<P> getRootType() {
|
||||
return myRootType;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.jps.model;
|
||||
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import org.jetbrains.jps.model.java.*;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdk;
|
||||
@@ -23,9 +24,11 @@ public class JpsModuleTest extends JpsModelTestCase {
|
||||
|
||||
final JpsModuleSourceRoot root = assertOneElement(module.getSourceRoots());
|
||||
assertEquals("file://url", root.getUrl());
|
||||
final JpsSimpleElement<JavaSourceRootProperties> properties2 = root.getProperties(JavaSourceRootType.SOURCE);
|
||||
assertNotNull(properties2);
|
||||
assertEquals("com.xxx", properties2.getData().getPackagePrefix());
|
||||
assertSameElements(ContainerUtilRt.newArrayList(module.getSourceRoots(JavaSourceRootType.SOURCE)), root);
|
||||
assertEmpty(ContainerUtil.newArrayList(module.getSourceRoots(JavaSourceRootType.TEST_SOURCE)));
|
||||
JpsTypedModuleSourceRoot<JpsSimpleElement<JavaSourceRootProperties>> typedRoot = root.asTyped(JavaSourceRootType.SOURCE);
|
||||
assertNotNull(typedRoot);
|
||||
assertEquals("com.xxx", typedRoot.getProperties().getData().getPackagePrefix());
|
||||
}
|
||||
|
||||
public void testGetModulesOfType() {
|
||||
|
||||
+6
-1
@@ -95,7 +95,12 @@ public class CompletionLookupArranger extends LookupArranger {
|
||||
}
|
||||
|
||||
private MultiMap<CompletionSorterImpl, LookupElement> groupItemsBySorter(List<LookupElement> source) {
|
||||
MultiMap<CompletionSorterImpl, LookupElement> inputBySorter = new MultiMap<CompletionSorterImpl, LookupElement>();
|
||||
MultiMap<CompletionSorterImpl, LookupElement> inputBySorter = new MultiMap<CompletionSorterImpl, LookupElement>() {
|
||||
@Override
|
||||
protected Map<CompletionSorterImpl, Collection<LookupElement>> createMap() {
|
||||
return ContainerUtil.newLinkedHashMap();
|
||||
}
|
||||
};
|
||||
for (LookupElement element : source) {
|
||||
inputBySorter.putValue(obtainSorter(element), element);
|
||||
}
|
||||
|
||||
+4
@@ -34,6 +34,10 @@ public class LiveTemplateCharFilter extends CharFilter {
|
||||
}
|
||||
return Result.HIDE_LOOKUP;
|
||||
}
|
||||
if (item instanceof TemplateExpressionLookupElement) {
|
||||
if (Character.isJavaIdentifierPart(c)) return Result.ADD_TO_PREFIX;
|
||||
return Result.HIDE_LOOKUP;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
+10
-6
@@ -98,17 +98,21 @@ public class LiveTemplateSettingsEditor extends JPanel {
|
||||
myTemplate.setId(null);
|
||||
|
||||
createComponents(allowNoContext);
|
||||
|
||||
com.intellij.ui.DocumentAdapter listener = new com.intellij.ui.DocumentAdapter() {
|
||||
|
||||
myKeyField.getDocument().addDocumentListener(new com.intellij.ui.DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(javax.swing.event.DocumentEvent e) {
|
||||
myTemplate.setKey(myKeyField.getText().trim());
|
||||
nodeChanged.run();
|
||||
}
|
||||
});
|
||||
myDescription.getDocument().addDocumentListener(new com.intellij.ui.DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(javax.swing.event.DocumentEvent e) {
|
||||
myTemplate.setDescription(myDescription.getText().trim());
|
||||
nodeChanged.run();
|
||||
}
|
||||
};
|
||||
myKeyField.getDocument().addDocumentListener(listener);
|
||||
myDescription.getDocument().addDocumentListener(listener);
|
||||
});
|
||||
|
||||
new UiNotifyConnector(this, new Activatable.Adapter() {
|
||||
@Override
|
||||
@@ -474,7 +478,7 @@ public class LiveTemplateSettingsEditor extends JPanel {
|
||||
myEditVariablesButton.setEnabled(!parseVariables(myTemplateEditor.getDocument().getCharsSequence()).isEmpty());
|
||||
}
|
||||
|
||||
private void reset() {
|
||||
void resetUi() {
|
||||
myKeyField.setText(myTemplate.getKey());
|
||||
myDescription.setText(myTemplate.getDescription());
|
||||
|
||||
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.template.impl;
|
||||
|
||||
import com.intellij.codeInsight.AutoPopupController;
|
||||
import com.intellij.codeInsight.completion.CompletionInitializationContext;
|
||||
import com.intellij.codeInsight.completion.InsertionContext;
|
||||
import com.intellij.codeInsight.completion.OffsetMap;
|
||||
import com.intellij.codeInsight.completion.PrioritizedLookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementDecorator;
|
||||
import com.intellij.codeInsight.lookup.LookupItem;
|
||||
import com.intellij.codeInsight.template.TemplateLookupSelectionHandler;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorModificationUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
class TemplateExpressionLookupElement extends LookupElementDecorator<LookupElement> {
|
||||
private TemplateState myState;
|
||||
|
||||
public TemplateExpressionLookupElement(final TemplateState state, LookupElement element, int index) {
|
||||
super(PrioritizedLookupElement.withPriority(element, Integer.MAX_VALUE - 10 - index));
|
||||
myState = state;
|
||||
}
|
||||
|
||||
private static InsertionContext createInsertionContext(LookupElement item,
|
||||
PsiFile psiFile,
|
||||
List<? extends LookupElement> elements,
|
||||
Editor editor) {
|
||||
final OffsetMap offsetMap = new OffsetMap(editor.getDocument());
|
||||
final InsertionContext context = new InsertionContext(offsetMap, (char)0, elements.toArray(new LookupElement[elements.size()]), psiFile, editor, false);
|
||||
context.setTailOffset(editor.getCaretModel().getOffset());
|
||||
offsetMap.addOffset(CompletionInitializationContext.START_OFFSET, context.getTailOffset() - item.getLookupString().length());
|
||||
offsetMap.addOffset(CompletionInitializationContext.SELECTION_END_OFFSET, context.getTailOffset());
|
||||
offsetMap.addOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET, context.getTailOffset());
|
||||
return context;
|
||||
}
|
||||
|
||||
void handleTemplateInsert(List<? extends LookupElement> elements) {
|
||||
InsertionContext context = createInsertionContext(this, myState.getPsiFile(), elements, myState.getEditor());
|
||||
handleInsert(context);
|
||||
Disposer.dispose(context.getOffsetMap());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInsert(InsertionContext context) {
|
||||
LookupElement item = getDelegate();
|
||||
Project project = context.getProject();
|
||||
Editor editor = context.getEditor();
|
||||
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
|
||||
TextRange range = myState.getCurrentVariableRange();
|
||||
final TemplateLookupSelectionHandler handler =
|
||||
item instanceof LookupItem ? ((LookupItem<?>)item).getAttribute(TemplateLookupSelectionHandler.KEY_IN_LOOKUP_ITEM) : null;
|
||||
if (handler != null && range != null) {
|
||||
handler.itemSelected(item, context.getFile(), context.getDocument(), range.getStartOffset(), range.getEndOffset());
|
||||
}
|
||||
else {
|
||||
super.handleInsert(context);
|
||||
}
|
||||
|
||||
if (context.getCompletionChar() == '.') {
|
||||
EditorModificationUtil.insertStringAtCaret(editor, ".");
|
||||
AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!myState.isFinished()) {
|
||||
myState.calcResults(true);
|
||||
}
|
||||
|
||||
myState.nextTab();
|
||||
}
|
||||
}
|
||||
@@ -892,6 +892,7 @@ public class TemplateListPanel extends JPanel implements Disposable {
|
||||
}
|
||||
createTemplateEditor(newTemplate, (String)myExpandByCombo.getSelectedItem(), getTemplateOptions(newTemplate),
|
||||
getTemplateContext(newTemplate));
|
||||
myCurrentTemplateEditor.resetUi();
|
||||
if (focusKey) {
|
||||
myCurrentTemplateEditor.focusKey();
|
||||
}
|
||||
|
||||
@@ -16,12 +16,11 @@
|
||||
|
||||
package com.intellij.codeInsight.template.impl;
|
||||
|
||||
import com.intellij.codeInsight.AutoPopupController;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.completion.CompletionInitializationContext;
|
||||
import com.intellij.codeInsight.completion.InsertionContext;
|
||||
import com.intellij.codeInsight.completion.OffsetMap;
|
||||
import com.intellij.codeInsight.lookup.*;
|
||||
import com.intellij.codeInsight.lookup.LookupAdapter;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupEvent;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.codeInsight.template.*;
|
||||
import com.intellij.lang.LanguageLiteralEscapers;
|
||||
@@ -31,7 +30,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandAdapter;
|
||||
import com.intellij.openapi.command.CommandEvent;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.command.undo.BasicUndoableAction;
|
||||
import com.intellij.openapi.command.undo.DocumentReference;
|
||||
import com.intellij.openapi.command.undo.DocumentReferenceManager;
|
||||
@@ -44,7 +42,6 @@ import com.intellij.openapi.editor.ex.DocumentEx;
|
||||
import com.intellij.openapi.editor.markup.*;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -57,6 +54,7 @@ import com.intellij.psi.util.PsiUtilBase;
|
||||
import com.intellij.refactoring.rename.inplace.InplaceRefactoring;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.PairProcessor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.containers.IntArrayList;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -313,7 +311,7 @@ public class TemplateState implements Disposable {
|
||||
myTemplateRange = myDocument.createRangeMarker(caretOffset, caretOffset + template.getTemplateText().length());
|
||||
}
|
||||
else {
|
||||
PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument);
|
||||
PsiFile file = getPsiFile();
|
||||
preprocessTemplate(file, myEditor.getCaretModel().getOffset(), myTemplate.getTemplateText());
|
||||
int caretOffset = myEditor.getCaretModel().getOffset();
|
||||
myTemplateRange = myDocument.createRangeMarker(caretOffset, caretOffset);
|
||||
@@ -402,7 +400,7 @@ public class TemplateState implements Disposable {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument);
|
||||
final PsiFile file = getPsiFile();
|
||||
if (file != null) {
|
||||
IntArrayList indices = initEmptyVariables();
|
||||
mySegments.setSegmentsGreedy(false);
|
||||
@@ -486,26 +484,23 @@ public class TemplateState implements Disposable {
|
||||
myEditor.getSelectionModel().setSelection(start, end);
|
||||
}
|
||||
|
||||
Expression expressionNode = myTemplate.getExpressionAt(myCurrentVariableNumber);
|
||||
final ExpressionContext context = createExpressionContext(start);
|
||||
final LookupElement[] lookupItems = expressionNode.calculateLookupItems(context);
|
||||
final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument);
|
||||
if (lookupItems != null && lookupItems.length > 0) {
|
||||
Expression expressionNode = getCurrentExpression();
|
||||
final List<TemplateExpressionLookupElement> lookupItems = getCurrentExpressionLookupItems();
|
||||
final PsiFile psiFile = getPsiFile();
|
||||
if (!lookupItems.isEmpty()) {
|
||||
if (((TemplateManagerImpl)TemplateManager.getInstance(myProject)).shouldSkipInTests()) {
|
||||
final String s = lookupItems[0].getLookupString();
|
||||
EditorModificationUtil.insertStringAtCaret(myEditor, s);
|
||||
itemSelected(lookupItems[0], psiFile, currentSegmentNumber, ' ', lookupItems);
|
||||
insertSingleItem(lookupItems);
|
||||
}
|
||||
else {
|
||||
for (LookupElement lookupItem : lookupItems) {
|
||||
assert lookupItem != null : expressionNode;
|
||||
}
|
||||
|
||||
runLookup(currentSegmentNumber, lookupItems, expressionNode.getAdvertisingText(), psiFile);
|
||||
runLookup(lookupItems, expressionNode.getAdvertisingText());
|
||||
}
|
||||
}
|
||||
else {
|
||||
Result result = expressionNode.calculateResult(context);
|
||||
Result result = expressionNode.calculateResult(getCurrentExpressionContext());
|
||||
if (result != null) {
|
||||
result.handleFocused(psiFile, myDocument, mySegments.getSegmentStart(currentSegmentNumber),
|
||||
mySegments.getSegmentEnd(currentSegmentNumber));
|
||||
@@ -514,12 +509,42 @@ public class TemplateState implements Disposable {
|
||||
focusCurrentHighlighter(true);
|
||||
}
|
||||
|
||||
private void runLookup(final int currentSegmentNumber, final LookupElement[] lookupItems, String advertisingText, final PsiFile psiFile) {
|
||||
PsiFile getPsiFile() {
|
||||
return PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument);
|
||||
}
|
||||
|
||||
private void insertSingleItem(List<TemplateExpressionLookupElement> lookupItems) {
|
||||
TemplateExpressionLookupElement first = lookupItems.get(0);
|
||||
EditorModificationUtil.insertStringAtCaret(myEditor, first.getLookupString());
|
||||
first.handleTemplateInsert(lookupItems);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
List<TemplateExpressionLookupElement> getCurrentExpressionLookupItems() {
|
||||
LookupElement[] elements = getCurrentExpression().calculateLookupItems(getCurrentExpressionContext());
|
||||
if (elements == null) return Collections.emptyList();
|
||||
|
||||
List<TemplateExpressionLookupElement> result = ContainerUtil.newArrayList();
|
||||
for (int i = 0; i < elements.length; i++) {
|
||||
result.add(new TemplateExpressionLookupElement(this, elements[i], i));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ExpressionContext getCurrentExpressionContext() {
|
||||
return createExpressionContext(mySegments.getSegmentStart(getCurrentSegmentNumber()));
|
||||
}
|
||||
|
||||
Expression getCurrentExpression() {
|
||||
return myTemplate.getExpressionAt(myCurrentVariableNumber);
|
||||
}
|
||||
|
||||
private void runLookup(final List<TemplateExpressionLookupElement> lookupItems, String advertisingText) {
|
||||
if (myEditor == null) return;
|
||||
|
||||
final LookupManager lookupManager = LookupManager.getInstance(myProject);
|
||||
|
||||
final LookupImpl lookup = (LookupImpl)lookupManager.showLookup(myEditor, lookupItems);
|
||||
final LookupImpl lookup = (LookupImpl)lookupManager.showLookup(myEditor, lookupItems.toArray(new LookupElement[lookupItems.size()]));
|
||||
if (lookup == null) return;
|
||||
|
||||
if (CodeInsightSettings.getInstance().AUTO_POPUP_COMPLETION_LOOKUP && myEditor.getUserData(InplaceRefactoring.INPLACE_RENAMER) == null) {
|
||||
@@ -542,68 +567,21 @@ public class TemplateState implements Disposable {
|
||||
if (isFinished()) return;
|
||||
ourLookupShown = false;
|
||||
|
||||
TemplateState.this.itemSelected(event.getItem(), psiFile, currentSegmentNumber, event.getCompletionChar(), lookupItems);
|
||||
LookupElement item = event.getItem();
|
||||
if (item instanceof TemplateExpressionLookupElement) {
|
||||
((TemplateExpressionLookupElement)item).handleTemplateInsert(lookupItems);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void itemSelected(final LookupElement item,
|
||||
final PsiFile psiFile,
|
||||
final int currentSegmentNumber,
|
||||
final char completionChar,
|
||||
LookupElement[] elements) {
|
||||
if (item != null) {
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
|
||||
final OffsetMap offsetMap = new OffsetMap(myDocument);
|
||||
final InsertionContext context = new InsertionContext(offsetMap, (char)0, elements, psiFile, myEditor, false);
|
||||
context.setTailOffset(myEditor.getCaretModel().getOffset());
|
||||
offsetMap.addOffset(CompletionInitializationContext.START_OFFSET, context.getTailOffset() - item.getLookupString().length());
|
||||
offsetMap.addOffset(CompletionInitializationContext.SELECTION_END_OFFSET, context.getTailOffset());
|
||||
offsetMap.addOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET, context.getTailOffset());
|
||||
|
||||
final TemplateLookupSelectionHandler handler =
|
||||
item instanceof LookupItem ? ((LookupItem<?>)item).getAttribute(TemplateLookupSelectionHandler.KEY_IN_LOOKUP_ITEM) : null;
|
||||
if (handler != null) {
|
||||
handler.itemSelected(item, psiFile, myDocument, mySegments.getSegmentStart(currentSegmentNumber),
|
||||
mySegments.getSegmentEnd(currentSegmentNumber));
|
||||
}
|
||||
else {
|
||||
new WriteCommandAction(myProject) {
|
||||
@Override
|
||||
protected void run(com.intellij.openapi.application.Result result) throws Throwable {
|
||||
item.handleInsert(context);
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
Disposer.dispose(offsetMap);
|
||||
|
||||
if (completionChar == '.') {
|
||||
EditorModificationUtil.insertStringAtCaret(myEditor, ".");
|
||||
AutoPopupController.getInstance(myProject).autoPopupMemberLookup(myEditor, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isFinished()) {
|
||||
calcResults(true);
|
||||
}
|
||||
}
|
||||
|
||||
new WriteCommandAction(myProject) {
|
||||
@Override
|
||||
protected void run(com.intellij.openapi.application.Result result) throws Throwable {
|
||||
nextTab();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void unblockDocument() {
|
||||
PsiDocumentManager.getInstance(myProject).commitDocument(myDocument);
|
||||
PsiDocumentManager.getInstance(myProject).doPostponedOperationsAndUnblockDocument(myDocument);
|
||||
}
|
||||
|
||||
// Hours spent fixing code : 1
|
||||
private void calcResults(final boolean isQuick) {
|
||||
void calcResults(final boolean isQuick) {
|
||||
if (myProcessor != null && myCurrentVariableNumber >= 0) {
|
||||
final String variableName = myTemplate.getVariableNameAt(myCurrentVariableNumber);
|
||||
final TextResult value = getVariableValue(variableName);
|
||||
@@ -672,7 +650,7 @@ public class TemplateState implements Disposable {
|
||||
int end = mySegments.getSegmentEnd(segmentNumber);
|
||||
|
||||
PsiDocumentManager.getInstance(myProject).commitDocument(myDocument);
|
||||
PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument);
|
||||
PsiFile psiFile = getPsiFile();
|
||||
PsiElement element = psiFile.findElementAt(start);
|
||||
|
||||
ExpressionContext context = createExpressionContext(start);
|
||||
@@ -1012,7 +990,7 @@ public class TemplateState implements Disposable {
|
||||
}
|
||||
|
||||
private void reformat(RangeMarker rangeMarkerToReformat) {
|
||||
final PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument);
|
||||
final PsiFile file = getPsiFile();
|
||||
if (file != null) {
|
||||
CodeStyleManager style = CodeStyleManager.getInstance(myProject);
|
||||
for (TemplateOptionalProcessor optionalProcessor : Extensions.getExtensions(TemplateOptionalProcessor.EP_NAME)) {
|
||||
|
||||
@@ -282,7 +282,14 @@ public class ExecutionManagerImpl extends ExecutionManager implements ProjectCom
|
||||
return CommonBundle.message("dialog.options.do.not.show");
|
||||
}
|
||||
};
|
||||
if (Messages.OK != Messages.showOkCancelDialog(ExecutionBundle.message("rerun.confirmation.message", configuration.getName()),
|
||||
String message;
|
||||
if (allHandlers.size() == 1 && handler != null) {//we restart single running configuration
|
||||
message = ExecutionBundle.message("rerun.confirmation.message", configuration.getName());
|
||||
}
|
||||
else {
|
||||
message = ExecutionBundle.message("rerun.singleton.confirmation.message", configuration.getName());
|
||||
}
|
||||
if (Messages.OK != Messages.showOkCancelDialog(message,
|
||||
ExecutionBundle.message("rerun.confirmation.title") +
|
||||
" (" +
|
||||
pair.getSecond().getId() +
|
||||
|
||||
@@ -43,16 +43,12 @@ public abstract class WebProjectTemplate<T> extends WebProjectGenerator<T> imple
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void generateProject(Module module) {
|
||||
generateProject(module.getProject(), module.getProject().getBaseDir(), myPeer.getValue().getSettings(), module);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getSettingsPanel() {
|
||||
return myPeer.getValue().getComponent();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectBuilder createModuleBuilder() {
|
||||
final ModuleBuilder builder = WebModuleType.getInstance().createModuleBuilder();
|
||||
@@ -62,7 +58,8 @@ public abstract class WebProjectTemplate<T> extends WebProjectGenerator<T> imple
|
||||
public List<Module> commit(Project project, ModifiableModuleModel model, ModulesProvider modulesProvider) {
|
||||
List<Module> modules = builder.commit(project, model, modulesProvider);
|
||||
if (modules != null && !modules.isEmpty()) {
|
||||
generateProject(modules.get(0));
|
||||
Module module = modules.get(0);
|
||||
generateProject(module.getProject(), module.getProject().getBaseDir(), myPeer.getValue().getSettings(), module);
|
||||
}
|
||||
return modules;
|
||||
}
|
||||
|
||||
+1
-67
@@ -17,7 +17,6 @@
|
||||
package com.intellij.openapi.projectRoots.impl;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.PathChooserDialog;
|
||||
@@ -33,11 +32,6 @@ import com.intellij.openapi.projectRoots.SdkType;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.ui.popup.ListPopupStep;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -48,7 +42,6 @@ import com.intellij.util.Consumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -166,7 +159,7 @@ public class SdkConfigurationUtil {
|
||||
e.getMessage() +
|
||||
".\nPlease make sure that " +
|
||||
FileUtil.toSystemDependentName(homeDir.getPath()) +
|
||||
" is a valid home path for this SDK type.", "Error configuring SDK");
|
||||
" is a valid home path for this SDK type.", "Error Configuring SDK");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -298,65 +291,6 @@ public class SdkConfigurationUtil {
|
||||
return LocalFileSystem.getInstance().findFileByPath(homepath);
|
||||
}
|
||||
|
||||
public static void suggestAndAddSdk(@Nullable final Project project,
|
||||
final Sdk[] existingSdks,
|
||||
JComponent popupOwner,
|
||||
final Consumer<Sdk> callback,
|
||||
final SdkType... sdkTypes) {
|
||||
assert sdkTypes.length > 0;
|
||||
final Map<String, SdkType> suggestedSdkHomes = new LinkedHashMap<String, SdkType>();
|
||||
for (SdkType sdkType : sdkTypes) {
|
||||
final Collection<String> sdkHomes = sdkType.suggestHomePaths();
|
||||
for (String sdkHome : filterExistingPaths(sdkType, sdkHomes, existingSdks)) {
|
||||
suggestedSdkHomes.put(sdkHome, sdkType);
|
||||
}
|
||||
}
|
||||
if (suggestedSdkHomes.size() > 0) {
|
||||
suggestedSdkHomes.put(null, sdkTypes[0]);
|
||||
showSuggestedHomesPopup(project, existingSdks, suggestedSdkHomes, sdkTypes, popupOwner, callback);
|
||||
}
|
||||
else {
|
||||
createSdk(project, existingSdks, callback, sdkTypes);
|
||||
}
|
||||
}
|
||||
|
||||
private static void showSuggestedHomesPopup(@Nullable final Project project,
|
||||
final Sdk[] existingSdks,
|
||||
final Map<String, SdkType> suggestedSdkHomes,
|
||||
final SdkType[] sdkTypes,
|
||||
final JComponent popupOwner,
|
||||
final Consumer<Sdk> callback) {
|
||||
final List<String> list = new ArrayList<String>(suggestedSdkHomes.keySet());
|
||||
ListPopupStep sdkHomesStep = new BaseListPopupStep<String>("Select Interpreter Path", list) {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTextFor(String value) {
|
||||
return value == null ? "Specify Other..." : FileUtil.toSystemDependentName(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PopupStep onChosen(final String selectedValue, boolean finalChoice) {
|
||||
final SdkType sdkType = suggestedSdkHomes.get(selectedValue);
|
||||
if (selectedValue == null) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
createSdk(project, existingSdks, callback, sdkTypes);
|
||||
}
|
||||
}, ModalityState.current());
|
||||
}
|
||||
else {
|
||||
Sdk sdk = setupSdk(existingSdks, LocalFileSystem.getInstance().findFileByPath(selectedValue),
|
||||
sdkType, false, null, null);
|
||||
callback.consume(sdk);
|
||||
}
|
||||
return FINAL_CHOICE;
|
||||
}
|
||||
};
|
||||
final ListPopup popup = JBPopupFactory.getInstance().createListPopup(sdkHomesStep);
|
||||
popup.showUnderneathOf(popupOwner);
|
||||
}
|
||||
|
||||
public static List<String> filterExistingPaths(SdkType sdkType, Collection<String> sdkHomes, final Sdk[] sdks) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
for (String sdkHome : sdkHomes) {
|
||||
|
||||
@@ -11,18 +11,18 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
* @author Sergey Simonchik
|
||||
*/
|
||||
class ZipUtil {
|
||||
public class ZipUtil {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance(ZipUtil.class);
|
||||
|
||||
@@ -38,7 +38,8 @@ class ZipUtil {
|
||||
@Override
|
||||
public Boolean call() throws IOException {
|
||||
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
|
||||
unzip(progress, zipArchive, extractToDir);
|
||||
ZipInputStream stream = new ZipInputStream(new FileInputStream(zipArchive));
|
||||
unzip(progress, extractToDir, stream);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
@@ -60,21 +61,17 @@ class ZipUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static void unzip(@Nullable ProgressIndicator progress,
|
||||
@NotNull File zipArchiveFile,
|
||||
@NotNull File extractToDir) throws IOException {
|
||||
public static void unzip(@Nullable ProgressIndicator progress, File extractToDir, ZipInputStream stream) throws IOException {
|
||||
if (progress != null) {
|
||||
progress.setText("Extracting...");
|
||||
}
|
||||
ZipFile zipFile = new ZipFile(zipArchiveFile);
|
||||
try {
|
||||
boolean singleTopLevelDir = isSingleTopLevelDir(zipFile.entries());
|
||||
for (Enumeration<? extends ZipEntry> e = zipFile.entries(); e.hasMoreElements();) {
|
||||
ZipEntry zipEntry = e.nextElement();
|
||||
unzipEntryToDir(progress, zipFile, zipEntry, extractToDir, singleTopLevelDir);
|
||||
ZipEntry entry;
|
||||
while ((entry = stream.getNextEntry()) != null) {
|
||||
unzipEntryToDir(progress, entry, extractToDir, stream);
|
||||
}
|
||||
} finally {
|
||||
zipFile.close();
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,12 +96,11 @@ class ZipUtil {
|
||||
}
|
||||
|
||||
private static void unzipEntryToDir(@Nullable ProgressIndicator progress,
|
||||
@NotNull final ZipFile zipFile,
|
||||
@NotNull final ZipEntry zipEntry,
|
||||
@NotNull final File extractToDir,
|
||||
boolean singleTopLevelDir) throws IOException {
|
||||
ZipInputStream stream) throws IOException {
|
||||
final char pathDelimiterChar = '/';
|
||||
String relativeExtractPath = createRelativeExtractPath(zipEntry, pathDelimiterChar, singleTopLevelDir);
|
||||
String relativeExtractPath = createRelativeExtractPath(zipEntry, pathDelimiterChar, true);
|
||||
int ind = relativeExtractPath.lastIndexOf(pathDelimiterChar);
|
||||
final String relativeParentDir;
|
||||
final String name;
|
||||
@@ -129,13 +125,11 @@ class ZipUtil {
|
||||
}
|
||||
}
|
||||
File child = new File(parentDir, name);
|
||||
InputStream stream = zipFile.getInputStream(zipEntry);
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(child);
|
||||
try {
|
||||
FileUtil.copy(stream, fileOutputStream);
|
||||
} finally {
|
||||
fileOutputStream.close();
|
||||
stream.close();
|
||||
}
|
||||
LOG.info("Extract: " + relativeExtractPath);
|
||||
}
|
||||
|
||||
+5
-4
@@ -16,12 +16,13 @@
|
||||
package com.intellij.openapi.editor.highlighter;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
@@ -38,11 +39,11 @@ public abstract class EditorHighlighterFactory {
|
||||
|
||||
public abstract EditorHighlighter createEditorHighlighter(final Project project, final FileType fileType);
|
||||
|
||||
public abstract EditorHighlighter createEditorHighlighter(@NotNull final VirtualFile file, final EditorColorsScheme globalScheme, final Project project);
|
||||
public abstract EditorHighlighter createEditorHighlighter(@NotNull final VirtualFile file, final EditorColorsScheme globalScheme, @Nullable final Project project);
|
||||
|
||||
public abstract EditorHighlighter createEditorHighlighter(final Project project, final VirtualFile file);
|
||||
|
||||
public abstract EditorHighlighter createEditorHighlighter(final Project project, final String fileName);
|
||||
|
||||
public abstract EditorHighlighter createEditorHighlighter(final EditorColorsScheme settings, final String fileName, final Project project);
|
||||
public abstract EditorHighlighter createEditorHighlighter(final EditorColorsScheme settings, final String fileName, @Nullable final Project project);
|
||||
}
|
||||
+18
-2
@@ -36,10 +36,26 @@ public abstract class SyntaxHighlighterFactory {
|
||||
}
|
||||
};
|
||||
|
||||
public static SyntaxHighlighter getSyntaxHighlighter(Language lang, Project project, VirtualFile virtualFile) {
|
||||
/**
|
||||
* Returns syntax highlighter for the given language.
|
||||
* @param lang a {@code Language} to get highlighter for
|
||||
* @param project might be necessary to gather various project settings from
|
||||
* @param virtualFile might be necessary to collect file specific settings
|
||||
* @return {@code SyntaxHighlighter} interface implementation for the given file type
|
||||
*/
|
||||
public static SyntaxHighlighter getSyntaxHighlighter(@NotNull Language lang, @Nullable Project project, @Nullable final VirtualFile virtualFile) {
|
||||
return LANGUAGE_FACTORY.forLanguage(lang).getSyntaxHighlighter(project, virtualFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns syntax highlighter for the given file type.
|
||||
* Note: it is recommended to use {@link #getSyntaxHighlighter(Language, Project, VirtualFile)} in most cases,
|
||||
* and use this method only when you are do not know the language you use.
|
||||
* @param fileType a file type to use to select appropriate highlighter
|
||||
* @param project might be necessary to gather various project settings from
|
||||
* @param virtualFile might be necessary to collect file specific settings
|
||||
* @return {@code SyntaxHighlighter} interface implementation for the given file type
|
||||
*/
|
||||
@Nullable
|
||||
public static SyntaxHighlighter getSyntaxHighlighter(final FileType fileType, final @Nullable Project project, final @Nullable VirtualFile virtualFile) {
|
||||
return PROVIDER.getValue().create(fileType, project, virtualFile);
|
||||
@@ -57,5 +73,5 @@ public abstract class SyntaxHighlighterFactory {
|
||||
* @return <code>SyntaxHighlighter</code> interface implementation for this particular language.
|
||||
*/
|
||||
@NotNull
|
||||
public abstract SyntaxHighlighter getSyntaxHighlighter(Project project, final VirtualFile virtualFile);
|
||||
public abstract SyntaxHighlighter getSyntaxHighlighter(@Nullable Project project, @Nullable VirtualFile virtualFile);
|
||||
}
|
||||
@@ -49,6 +49,7 @@ public abstract class NamedItemsListEditor<T> extends MasterDetailsComponent {
|
||||
private final Equality<T> myComparer;
|
||||
private List<T> myResultItems;
|
||||
private final List<T> myOriginalItems;
|
||||
private boolean myShowIcons;
|
||||
|
||||
protected NamedItemsListEditor(Namer<T> namer,
|
||||
Factory<T> factory,
|
||||
@@ -160,6 +161,10 @@ public abstract class NamedItemsListEditor<T> extends MasterDetailsComponent {
|
||||
myNamer.setName(item, name);
|
||||
}
|
||||
|
||||
public void setShowIcons(boolean showIcons) {
|
||||
myShowIcons = showIcons;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected UnnamedConfigurable getItemConfigurable(final T item) {
|
||||
final Ref<UnnamedConfigurable> result = new Ref<UnnamedConfigurable>();
|
||||
@@ -213,6 +218,14 @@ public abstract class NamedItemsListEditor<T> extends MasterDetailsComponent {
|
||||
return myNamer.getName(myItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getIcon(boolean expanded) {
|
||||
if (myShowIcons && myConfigurable instanceof Iconable) {
|
||||
return ((Iconable)myConfigurable).getIcon(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getHelpTopic() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
|
||||
public void customize(DiffToolbar toolbar) {
|
||||
ActionManager actionManager = ActionManager.getInstance();
|
||||
toolbar.addAction(actionManager.getAction("DiffPanel.Toolbar"));
|
||||
toolbar.addAction(actionManager.getAction("ContextHelp"));
|
||||
}
|
||||
};
|
||||
private boolean myDisposed = false;
|
||||
@@ -830,6 +831,9 @@ public class DiffPanelImpl implements DiffPanelEx, ContentChangeListener, TwoSid
|
||||
return new DiffNavigatable(currentSide);
|
||||
}
|
||||
}
|
||||
if (PlatformDataKeys.HELP_ID.is(dataId)) {
|
||||
return "reference.dialogs.diff.file";
|
||||
}
|
||||
|
||||
return super.getData(dataId);
|
||||
}
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ public class EditorHighlighterFactoryImpl extends EditorHighlighterFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditorHighlighter createEditorHighlighter(@NotNull final VirtualFile vFile, @NotNull final EditorColorsScheme settings, final Project project) {
|
||||
public EditorHighlighter createEditorHighlighter(@NotNull final VirtualFile vFile, @NotNull final EditorColorsScheme settings, @Nullable final Project project) {
|
||||
final FileType fileType = vFile.getFileType();
|
||||
if (fileType instanceof LanguageFileType) {
|
||||
LanguageFileType substFileType = substituteFileType(((LanguageFileType)fileType).getLanguage(), vFile, project);
|
||||
@@ -120,7 +120,7 @@ public class EditorHighlighterFactoryImpl extends EditorHighlighterFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public EditorHighlighter createEditorHighlighter(final EditorColorsScheme settings, final String fileName, final Project project) {
|
||||
public EditorHighlighter createEditorHighlighter(final EditorColorsScheme settings, final String fileName, @Nullable final Project project) {
|
||||
return createEditorHighlighter(new LightVirtualFile(fileName), settings, project);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,8 @@
|
||||
package com.intellij.platform;
|
||||
|
||||
import com.intellij.ide.util.projectWizard.ProjectBuilder;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -30,9 +31,9 @@ public interface ProjectTemplate {
|
||||
|
||||
String getDescription();
|
||||
|
||||
ProjectBuilder createModuleBuilder();
|
||||
|
||||
@Nullable
|
||||
JComponent getSettingsPanel();
|
||||
|
||||
void generateProject(Module module);
|
||||
@NotNull
|
||||
ProjectBuilder createModuleBuilder();
|
||||
}
|
||||
|
||||
@@ -160,7 +160,8 @@ terminating.process.progress.kill=Kill process
|
||||
waiting.for.vm.detach.progress.text=Waiting for process detach
|
||||
restart.error.message.title=Restart Error
|
||||
rerun.configuration.action.name=Rerun ''{0}''
|
||||
rerun.confirmation.message=''{0}'' is single-instance run configuration.\nAre you sure you want to stop running one?
|
||||
rerun.singleton.confirmation.message=''{0}'' is single-instance run configuration.\nAre you sure you want to stop running one?
|
||||
rerun.confirmation.message=Are you sure you want to stop ''{0}''?
|
||||
rerun.confirmation.title=Stop Confirmation
|
||||
rerun.confirmation.checkbox=Confirm rerun with process termination
|
||||
run.configuration.dump.threads.action.name=Dump Threads
|
||||
|
||||
@@ -323,9 +323,7 @@ changes.action.rollback.text=Rollback
|
||||
changes.action.rollback.description=Rollback changes
|
||||
changes.action.setdefaultchangelist.text=Set Active Changelist
|
||||
changes.action.setdefaultchangelist.description=Set changelist to which new changes are placed by default
|
||||
create.patch.file.name.field=&Patch file name:
|
||||
create.patch.commit.action.text=Create Patc_h...
|
||||
create.patch.commit.action.description=Creates a patch from the selected changes
|
||||
patch.apply.file.name.field=&Patch file name:
|
||||
create.patch.commit.action.title=Create Patch
|
||||
create.patch.error.title=Error creating patch: {0}
|
||||
patch.apply.dialog.title=Apply Patch
|
||||
@@ -424,7 +422,10 @@ changes.remove.active.prompt=Select the changelist to which the changes should b
|
||||
changes.remove.active.empty.prompt=Select the changelist to make active:
|
||||
changes.remove.active.title=Delete Active Changelist
|
||||
create.patch.loading.content.progress=Loading content revisions
|
||||
create.patch.reverse.patch.checkbox=&Reverse patch
|
||||
create.patch.reverse.checkbox=&Reverse patch
|
||||
create.patch.base.revision=&Include base revision text(s) into patch file
|
||||
create.patch.file.path=&Patch file:
|
||||
create.patch.encoding=Encoding:
|
||||
committed.changes.refresh.progress=Refreshing VCS history
|
||||
cache.settings.dialog.title=VCS History Cache Settings
|
||||
diff.commit.message.title=Commit Message
|
||||
@@ -555,7 +556,6 @@ line.annotation.aspect.author=Author
|
||||
line.annotation.aspect.date=Date
|
||||
line.annotation.aspect.revision=Revision
|
||||
annotation.commit.number=Commit number
|
||||
create.patch.file.path=&Patch file:
|
||||
todo.handler.only.skipped=<html><body>TODO check has skipped {0,choice, 0#|1#one file|2#{0} files}.<br/>\n\
|
||||
No new, edited, or located in changed fragments TODO items found.</body></html>
|
||||
todo.handler.only.added=<html><body><b>There {0,choice, 0#|1#was one|2#were {0}} added or edited TODO {0,choice, 0#|1#item|2#items} found.</b><br/>\
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.openapi.util.text;
|
||||
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class StringUtilPerformanceTest {
|
||||
private static final String TEST_STRING = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
@Test
|
||||
public void containsAnyChar() throws Exception {
|
||||
assertTrue(StringUtil.containsAnyChar(TEST_STRING, Integer.toString(new Random().nextInt())));
|
||||
|
||||
PlatformTestUtil.startPerformanceTest("StringUtil.containsAnyChar()", 200, new ThrowableRunnable() {
|
||||
@Override
|
||||
public void run() throws Throwable {
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
StringUtil.containsAnyChar(TEST_STRING, "XYZ");
|
||||
StringUtil.containsAnyChar("XYZ", TEST_STRING);
|
||||
}
|
||||
}
|
||||
}).cpuBound().assertTiming();
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.util;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface Consumer<T> {
|
||||
Consumer EMPTY_CONSUMER = new Consumer() {
|
||||
public void consume(final Object t) {
|
||||
@@ -24,7 +26,7 @@ public interface Consumer<T> {
|
||||
/**
|
||||
* @param t consequently takes value of each element of the set this processor is passed to for processing.
|
||||
*/
|
||||
void consume(T t);
|
||||
void consume(@Nullable T t);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1331,7 +1331,12 @@ public class StringUtil extends StringUtilRt {
|
||||
}
|
||||
|
||||
public static boolean containsAnyChar(@NotNull final String value, @NotNull final String chars) {
|
||||
return containsAnyChar(value, chars, 0, value.length());
|
||||
if (chars.length() > value.length()) {
|
||||
return containsAnyChar(value, chars, 0, value.length());
|
||||
}
|
||||
else {
|
||||
return containsAnyChar(chars, value, 0, chars.length());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean containsAnyChar(@NotNull final String value,
|
||||
|
||||
@@ -49,8 +49,8 @@ public class BufferedListConsumer<T> implements Consumer<List<T>> {
|
||||
if ((mySize <= myBuffer.size()) || (myInterval > 0) && ((ts - myInterval) > myTs)) {
|
||||
myConsumer.consume(new ArrayList<T>(myBuffer));
|
||||
myBuffer.clear();
|
||||
myTs = ts;
|
||||
}
|
||||
myTs = ts;
|
||||
}
|
||||
|
||||
public void flushPart() {
|
||||
|
||||
@@ -37,7 +37,10 @@ import com.intellij.openapi.vcs.actions.VcsContextFactory;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
|
||||
import com.intellij.openapi.vfs.*;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileVisitor;
|
||||
import com.intellij.openapi.vfs.newvfs.RefreshQueue;
|
||||
import com.intellij.openapi.wm.StatusBar;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -591,4 +594,8 @@ public class VcsUtil {
|
||||
}
|
||||
return idx > 0;
|
||||
}
|
||||
|
||||
public static String getPathForProgressPresentation(@NotNull final File file) {
|
||||
return file.getName() + " (" + file.getParent() + ")";
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -390,7 +390,7 @@ public class ApplyPatchDifferentiatedDialog extends DialogWrapper {
|
||||
final GridBagConstraints gb =
|
||||
new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0);
|
||||
|
||||
myPatchFileLabel = new JLabel(VcsBundle.message("create.patch.file.name.field"));
|
||||
myPatchFileLabel = new JLabel(VcsBundle.message("patch.apply.file.name.field"));
|
||||
myPatchFileLabel.setLabelFor(myPatchFile);
|
||||
myCenterPanel.add(myPatchFileLabel, gb);
|
||||
|
||||
|
||||
+4
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -150,16 +150,16 @@ public class CreatePatchConfigurationPanel {
|
||||
|
||||
private void initMainPanel() {
|
||||
myFileNameField = new TextFieldWithBrowseButton();
|
||||
myReversePatchCheckbox = new JCheckBox(VcsBundle.message("create.patch.reverse.patch.checkbox"));
|
||||
myReversePatchCheckbox = new JCheckBox(VcsBundle.message("create.patch.reverse.checkbox"));
|
||||
myEncoding = new JComboBox();
|
||||
myIncludeBaseRevisionTextCheckBox = new JCheckBox("Include base revision text(s) into patch file");
|
||||
myIncludeBaseRevisionTextCheckBox = new JCheckBox(VcsBundle.message("create.patch.base.revision"));
|
||||
myErrorLabel = new JLabel();
|
||||
|
||||
myMainPanel = FormBuilder.createFormBuilder()
|
||||
.addLabeledComponent(VcsBundle.message("create.patch.file.path"), myFileNameField)
|
||||
.addComponent(myReversePatchCheckbox)
|
||||
.addLabeledComponent("Encoding:", myEncoding)
|
||||
.addComponent(myIncludeBaseRevisionTextCheckBox)
|
||||
.addLabeledComponent(VcsBundle.message("create.patch.encoding"), myEncoding)
|
||||
.addComponent(myErrorLabel)
|
||||
.getPanel();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,10 @@
|
||||
*/
|
||||
package com.intellij.openapi.vcs.ui;
|
||||
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.application.Application;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -23,11 +26,14 @@ import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.BalloonBuilder;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.NamedRunnable;
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import java.awt.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -43,32 +49,37 @@ public class VcsBalloonProblemNotifier implements Runnable {
|
||||
private final String myMessage;
|
||||
private final MessageType myMessageType;
|
||||
private final boolean myShowOverChangesView;
|
||||
@Nullable private final NamedRunnable[] myNotificationListener;
|
||||
|
||||
public VcsBalloonProblemNotifier(@NotNull final Project project, @NotNull final String message, final MessageType messageType) {
|
||||
this(project, message, messageType, true);
|
||||
this(project, message, messageType, true, null);
|
||||
}
|
||||
|
||||
public VcsBalloonProblemNotifier(@NotNull final Project project, @NotNull final String message, final MessageType messageType, boolean showOverChangesView) {
|
||||
public VcsBalloonProblemNotifier(@NotNull final Project project, @NotNull final String message, final MessageType messageType, boolean showOverChangesView,
|
||||
@Nullable final NamedRunnable[] notificationListener) {
|
||||
myProject = project;
|
||||
myMessage = message;
|
||||
myMessageType = messageType;
|
||||
myShowOverChangesView = showOverChangesView;
|
||||
myNotificationListener = notificationListener;
|
||||
}
|
||||
|
||||
public static void showOverChangesView(@NotNull final Project project, @NotNull final String message, final MessageType type) {
|
||||
show(project, message, type, true);
|
||||
public static void showOverChangesView(@NotNull final Project project, @NotNull final String message, final MessageType type,
|
||||
final NamedRunnable... notificationListener) {
|
||||
show(project, message, type, true, notificationListener);
|
||||
}
|
||||
|
||||
public static void showOverVersionControlView(@NotNull final Project project, @NotNull final String message, final MessageType type) {
|
||||
show(project, message, type, false);
|
||||
show(project, message, type, false, null);
|
||||
}
|
||||
|
||||
private static void show(final Project project, final String message, final MessageType type, final boolean showOverChangesView) {
|
||||
private static void show(final Project project, final String message, final MessageType type, final boolean showOverChangesView,
|
||||
@Nullable final NamedRunnable[] notificationListener) {
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
if (application.isHeadlessEnvironment()) return;
|
||||
final Runnable showErrorAction = new Runnable() {
|
||||
public void run() {
|
||||
new VcsBalloonProblemNotifier(project, message, type, showOverChangesView).run();
|
||||
new VcsBalloonProblemNotifier(project, message, type, showOverChangesView, notificationListener).run();
|
||||
}
|
||||
};
|
||||
if (application.isDispatchThread()) {
|
||||
@@ -80,7 +91,40 @@ public class VcsBalloonProblemNotifier implements Runnable {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
NOTIFICATION_GROUP.createNotification(myMessage, myMessageType).notify(myProject.isDefault() ? null : myProject);
|
||||
final Notification notification;
|
||||
if (myNotificationListener != null && myNotificationListener.length > 0) {
|
||||
final NotificationType type = myMessageType.toNotificationType();
|
||||
final StringBuilder sb = new StringBuilder(myMessage);
|
||||
for (NamedRunnable runnable : myNotificationListener) {
|
||||
final String name = runnable.toString();
|
||||
sb.append("<br/><a href=\"").append(name).append("\">").append(name).append("</a>");
|
||||
}
|
||||
notification = NOTIFICATION_GROUP.createNotification(type.name(), sb.toString(), myMessageType.toNotificationType(),
|
||||
new NotificationListener() {
|
||||
@Override
|
||||
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
|
||||
if (HyperlinkEvent.EventType.ACTIVATED.equals(event.getEventType())) {
|
||||
if (myNotificationListener.length == 1) {
|
||||
myNotificationListener[0].run();
|
||||
} else {
|
||||
final String description = event.getDescription();
|
||||
if (description != null) {
|
||||
for (NamedRunnable runnable : myNotificationListener) {
|
||||
if (description.equals(runnable.toString())) {
|
||||
runnable.run();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
notification.expire();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
notification = NOTIFICATION_GROUP.createNotification(myMessage, myMessageType);
|
||||
}
|
||||
notification.notify(myProject.isDefault() ? null : myProject);
|
||||
}
|
||||
|
||||
public static void showBalloonForComponent(@NotNull JComponent component, @NotNull final String message, final MessageType type,
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.intellij.util.EditSourceOnDoubleClickHandler;
|
||||
import com.intellij.util.EditSourceOnEnterKeyHandler;
|
||||
import com.intellij.util.PlatformIcons;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.ui.StatusText;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -92,7 +93,7 @@ public class UpdateInfoTree extends PanelWithActionsAndCloseButton implements Di
|
||||
UpdatedFiles updatedFiles,
|
||||
String rootName,
|
||||
ActionInfo actionInfo) {
|
||||
super(contentManager, "reference.toolWindows.versionControl");
|
||||
super(contentManager, "reference.versionControl.toolwindow.update");
|
||||
myActionInfo = actionInfo;
|
||||
|
||||
myFileStatusListener = new FileStatusListener() {
|
||||
@@ -334,8 +335,9 @@ public class UpdateInfoTree extends PanelWithActionsAndCloseButton implements Di
|
||||
myCommittedChangeLists = receivedChanges;
|
||||
myTreeBrowser.setItems(myCommittedChangeLists, CommittedChangesBrowserUseCase.UPDATE);
|
||||
if (hasEmptyCaches) {
|
||||
myTreeBrowser.getEmptyText()
|
||||
.appendText("Click ")
|
||||
final StatusText statusText = myTreeBrowser.getEmptyText();
|
||||
statusText.clear();
|
||||
statusText.appendText("Click ")
|
||||
.appendText("Refresh", SimpleTextAttributes.LINK_ATTRIBUTES, new ActionListener() {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
RefreshIncomingChangesAction.doRefresh(myProject);
|
||||
|
||||
+6
-6
@@ -4,8 +4,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.AdditionalRootsProviderService;
|
||||
import org.jetbrains.jps.builders.BuildTarget;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@@ -15,17 +15,17 @@ import java.util.List;
|
||||
/**
|
||||
* @author Eugene.Kudelevsky
|
||||
*/
|
||||
public class AndroidAdditionalRootProviderService extends AdditionalRootsProviderService<RootDescriptor> {
|
||||
public class AndroidAdditionalRootProviderService extends AdditionalRootsProviderService<JavaSourceRootDescriptor> {
|
||||
public AndroidAdditionalRootProviderService() {
|
||||
super(Collections.singletonList(JavaModuleBuildTargetType.PRODUCTION));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<RootDescriptor> getAdditionalRoots(@NotNull BuildTarget<RootDescriptor> target, File dataStorageRoot) {
|
||||
public List<JavaSourceRootDescriptor> getAdditionalRoots(@NotNull BuildTarget<JavaSourceRootDescriptor> target, File dataStorageRoot) {
|
||||
ModuleBuildTarget buildTarget = (ModuleBuildTarget)target;
|
||||
final File generatedSourcesRoot = AndroidJpsUtil.getGeneratedSourcesStorage(buildTarget.getModule(), dataStorageRoot);
|
||||
final List<RootDescriptor> result = new ArrayList<RootDescriptor>();
|
||||
final List<JavaSourceRootDescriptor> result = new ArrayList<JavaSourceRootDescriptor>();
|
||||
|
||||
addRoot(result, buildTarget, new File(generatedSourcesRoot, AndroidJpsUtil.AAPT_GENERATED_SOURCE_ROOT_NAME));
|
||||
addRoot(result, buildTarget, new File(generatedSourcesRoot, AndroidJpsUtil.AIDL_GENERATED_SOURCE_ROOT_NAME));
|
||||
@@ -35,7 +35,7 @@ public class AndroidAdditionalRootProviderService extends AdditionalRootsProvide
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void addRoot(List<RootDescriptor> result, ModuleBuildTarget buildTarget, final File file) {
|
||||
result.add(new RootDescriptor(file, buildTarget, true, false));
|
||||
private static void addRoot(List<JavaSourceRootDescriptor> result, ModuleBuildTarget buildTarget, final File file) {
|
||||
result.add(new JavaSourceRootDescriptor(file, buildTarget, true, false, ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class AndroidDexBuilder extends TargetBuilder<AndroidProjectBuildTarget>
|
||||
@NotNull AndroidFileSetStorage proguardStateStorage) throws IOException {
|
||||
boolean success = true;
|
||||
|
||||
for (JpsModule module : context.getProjectDescriptor().jpsProject.getModules()) {
|
||||
for (JpsModule module : context.getProjectDescriptor().getProject().getModules()) {
|
||||
final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(module);
|
||||
if (extension == null || extension.isLibrary()) {
|
||||
continue;
|
||||
@@ -344,7 +344,7 @@ public class AndroidDexBuilder extends TargetBuilder<AndroidProjectBuildTarget>
|
||||
|
||||
final JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> sdk = platform.getSdk();
|
||||
final String jdkName = sdk.getSdkProperties().getData().getJdkName();
|
||||
final JpsLibrary javaSdk = context.getProjectDescriptor().jpsModel.getGlobal().getLibraryCollection().findLibrary(jdkName);
|
||||
final JpsLibrary javaSdk = context.getProjectDescriptor().getModel().getGlobal().getLibraryCollection().findLibrary(jdkName);
|
||||
if (javaSdk == null || !javaSdk.getType().equals(JpsJavaSdkType.INSTANCE)) {
|
||||
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.errors.java.sdk.not.specified", jdkName)));
|
||||
return false;
|
||||
|
||||
+2
-2
@@ -8,8 +8,8 @@ import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.android.model.JpsAndroidModuleExtension;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
import org.jetbrains.jps.model.module.JpsModule;
|
||||
|
||||
@@ -28,7 +28,7 @@ public class AndroidLibraryPackagingBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExitCode build(CompileContext context, ModuleChunk chunk, DirtyFilesHolder<RootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException {
|
||||
public ExitCode build(CompileContext context, ModuleChunk chunk, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException {
|
||||
if (chunk.containsTests() || !AndroidJpsUtil.containsAndroidFacet(chunk) || AndroidJpsUtil.isLightBuild(context)) {
|
||||
return ExitCode.NOTHING_DONE;
|
||||
}
|
||||
|
||||
+3
-3
@@ -62,7 +62,7 @@ public class AndroidPackagingBuilder extends TargetBuilder<AndroidProjectBuildTa
|
||||
if (target.getKind() != AndroidProjectBuildTarget.AndroidBuilderKind.PACKAGING || AndroidJpsUtil.isLightBuild(context)) {
|
||||
return;
|
||||
}
|
||||
final Collection<JpsModule> modules = context.getProjectDescriptor().jpsProject.getModules();
|
||||
final Collection<JpsModule> modules = context.getProjectDescriptor().getProject().getModules();
|
||||
final Map<JpsModule, AndroidFileSetState> resourcesStates = new HashMap<JpsModule, AndroidFileSetState>();
|
||||
final Map<JpsModule, AndroidFileSetState> assetsStates = new HashMap<JpsModule, AndroidFileSetState>();
|
||||
final Map<JpsModule, File> manifestFiles = new HashMap<JpsModule, File>();
|
||||
@@ -384,7 +384,7 @@ public class AndroidPackagingBuilder extends TargetBuilder<AndroidProjectBuildTa
|
||||
final List<AndroidNativeLibData> additionalNativeLibs = extension.getAdditionalNativeLibs();
|
||||
|
||||
final AndroidFileSetState currentFileSetState =
|
||||
buildCurrentApkBuilderState(context.getProjectDescriptor().jpsProject, resPackagePath, classesDexFilePath, nativeLibDirs, sourceRoots,
|
||||
buildCurrentApkBuilderState(context.getProjectDescriptor().getProject(), resPackagePath, classesDexFilePath, nativeLibDirs, sourceRoots,
|
||||
externalJars, release);
|
||||
|
||||
final AndroidApkBuilderConfigState currentApkBuilderConfigState =
|
||||
@@ -404,7 +404,7 @@ public class AndroidPackagingBuilder extends TargetBuilder<AndroidProjectBuildTa
|
||||
|
||||
final Map<AndroidCompilerMessageKind, List<String>> messages = AndroidApkBuilder
|
||||
.execute(resPackagePath, classesDexFilePath, sourceRoots, externalJars, nativeLibDirs, additionalNativeLibs,
|
||||
outputApkPath, release, sdkPath, customKeyStorePath, new MyExcludedSourcesFilter(context.getProjectDescriptor().jpsProject));
|
||||
outputApkPath, release, sdkPath, customKeyStorePath, new MyExcludedSourcesFilter(context.getProjectDescriptor().getProject()));
|
||||
|
||||
AndroidJpsUtil.addMessages(context, messages, BUILDER_NAME, module.getName());
|
||||
final boolean success = messages.get(AndroidCompilerMessageKind.ERROR).isEmpty();
|
||||
|
||||
+7
-7
@@ -23,9 +23,9 @@ import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.android.model.JpsAndroidModuleExtension;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.FileProcessor;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.incremental.java.FormsParsing;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
@@ -75,7 +75,7 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder {
|
||||
@Override
|
||||
public ModuleLevelBuilder.ExitCode build(CompileContext context,
|
||||
ModuleChunk chunk,
|
||||
DirtyFilesHolder<RootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException {
|
||||
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException {
|
||||
if (chunk.containsTests() || !AndroidJpsUtil.containsAndroidFacet(chunk)) {
|
||||
return ExitCode.NOTHING_DONE;
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder {
|
||||
|
||||
private static ModuleLevelBuilder.ExitCode doBuild(CompileContext context,
|
||||
ModuleChunk chunk,
|
||||
DirtyFilesHolder<RootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws IOException {
|
||||
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws IOException {
|
||||
final Map<JpsModule, MyModuleData> moduleDataMap = computeModuleDatas(chunk.getModules(), context);
|
||||
if (moduleDataMap == null || moduleDataMap.size() == 0) {
|
||||
return ExitCode.ABORT;
|
||||
@@ -110,9 +110,9 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder {
|
||||
final Map<File, ModuleBuildTarget> idlFilesToCompile = new HashMap<File, ModuleBuildTarget>();
|
||||
final Map<File, ModuleBuildTarget> rsFilesToCompile = new HashMap<File, ModuleBuildTarget>();
|
||||
|
||||
dirtyFilesHolder.processDirtyFiles(new FileProcessor<RootDescriptor, ModuleBuildTarget>() {
|
||||
dirtyFilesHolder.processDirtyFiles(new FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget>() {
|
||||
@Override
|
||||
public boolean apply(ModuleBuildTarget target, File file, RootDescriptor sourceRoot) throws IOException {
|
||||
public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor sourceRoot) throws IOException {
|
||||
final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(target.getModule());
|
||||
|
||||
if (extension == null) {
|
||||
@@ -905,7 +905,7 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder {
|
||||
|
||||
@Nullable
|
||||
private static String getDependencyFolder(@NotNull CompileContext context, @NotNull File sourceFile, @NotNull File genFolder) {
|
||||
final RootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, sourceFile);
|
||||
final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, sourceFile);
|
||||
if (descriptor == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -975,7 +975,7 @@ public class AndroidSourceGeneratingBuilder extends ModuleLevelBuilder {
|
||||
|
||||
@Nullable
|
||||
private static String computePackageForFile(@NotNull CompileContext context, @NotNull File file) throws IOException {
|
||||
final RootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
final JavaSourceRootDescriptor descriptor = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, file);
|
||||
if (descriptor == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -156,19 +156,20 @@ public class DetailsCache {
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
if (!recheck.process(abstractHash)) return;
|
||||
if (getBranches(root, abstractHash) != null) return;
|
||||
final List<String> branches;
|
||||
List<String> branches;
|
||||
try {
|
||||
branches = new LowLevelAccessImpl(myProject, root).getBranchesWithCommit(abstractHash.getString());
|
||||
}
|
||||
catch (VcsException e) {
|
||||
LOG.info(e);
|
||||
return;
|
||||
branches = Collections.singletonList("Can not load branches due to error: " + e.getMessage());
|
||||
}
|
||||
putBranches(root, abstractHash, branches);
|
||||
final List<String> finalBranches = branches;
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
continuation.consume(branches);
|
||||
continuation.consume(finalBranches);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+10
-9
@@ -14,12 +14,12 @@ import org.jetbrains.jps.builders.BuildRootIndex;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.FileProcessor;
|
||||
import org.jetbrains.jps.builders.java.JavaBuilderUtil;
|
||||
import org.jetbrains.jps.builders.java.JavaSourceRootDescriptor;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Callbacks;
|
||||
import org.jetbrains.jps.builders.java.dependencyView.Mappings;
|
||||
import org.jetbrains.jps.builders.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.cmdline.ClasspathBootstrap;
|
||||
import org.jetbrains.jps.incremental.*;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.incremental.java.ClassPostProcessor;
|
||||
import org.jetbrains.jps.incremental.java.JavaBuilder;
|
||||
import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
@@ -67,7 +67,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
|
||||
public ModuleLevelBuilder.ExitCode build(final CompileContext context,
|
||||
ModuleChunk chunk,
|
||||
DirtyFilesHolder<RootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException {
|
||||
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws ProjectBuildException {
|
||||
try {
|
||||
final List<File> toCompile = collectChangedFiles(context, dirtyFilesHolder);
|
||||
if (toCompile.isEmpty()) {
|
||||
@@ -136,7 +136,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
final BuildRootIndex rootsIndex = context.getProjectDescriptor().getBuildRootIndex();
|
||||
for (ModuleBuildTarget target : generationOutputs.keySet()) {
|
||||
File root = new File(generationOutputs.get(target));
|
||||
rootsIndex.associateTempRoot(context, target, new RootDescriptor(root, target, true, true));
|
||||
rootsIndex.associateTempRoot(context, target, new JavaSourceRootDescriptor(root, target, true, true, ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
GroovycOSProcessHandler.OutputItem item, Map<ModuleBuildTarget, String> generationOutputs, String compilerOutput) throws IOException {
|
||||
if (chunk.getModules().size() > 1) {
|
||||
final BuildRootIndex rootsIndex = context.getProjectDescriptor().getBuildRootIndex();
|
||||
RootDescriptor descriptor = rootsIndex.getModuleAndRoot(context, new File(item.sourcePath));
|
||||
JavaSourceRootDescriptor descriptor = rootsIndex.getModuleAndRoot(context, new File(item.sourcePath));
|
||||
if (descriptor != null) {
|
||||
ModuleBuildTarget srcTarget = descriptor.target;
|
||||
if (!srcTarget.equals(chunk.representativeTarget())) {
|
||||
@@ -238,12 +238,12 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
|
||||
private static List<File> collectChangedFiles(CompileContext context,
|
||||
DirtyFilesHolder<RootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws IOException {
|
||||
DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder) throws IOException {
|
||||
final ResourcePatterns patterns = ResourcePatterns.KEY.get(context);
|
||||
assert patterns != null;
|
||||
final List<File> toCompile = new ArrayList<File>();
|
||||
dirtyFilesHolder.processDirtyFiles(new FileProcessor<RootDescriptor, ModuleBuildTarget>() {
|
||||
public boolean apply(ModuleBuildTarget target, File file, RootDescriptor sourceRoot) throws IOException {
|
||||
dirtyFilesHolder.processDirtyFiles(new FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget>() {
|
||||
public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor sourceRoot) throws IOException {
|
||||
final String path = file.getPath();
|
||||
if (isGroovyFile(path) && !patterns.isResourceFile(file, sourceRoot.root)) { //todo file type check
|
||||
toCompile.add(file);
|
||||
@@ -269,7 +269,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
for (GroovycOSProcessHandler.OutputItem item : successfullyCompiled) {
|
||||
final String sourcePath = FileUtil.toSystemIndependentName(item.sourcePath);
|
||||
final String outputPath = FileUtil.toSystemIndependentName(item.outputPath);
|
||||
final RootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, new File(sourcePath));
|
||||
final JavaSourceRootDescriptor moduleAndRoot = context.getProjectDescriptor().getBuildRootIndex().getModuleAndRoot(context, new File(sourcePath));
|
||||
if (moduleAndRoot != null) {
|
||||
final ModuleBuildTarget target = moduleAndRoot.target;
|
||||
context.getProjectDescriptor().dataManager.getSourceToOutputMap(target).appendOutput(sourcePath, outputPath);
|
||||
@@ -313,7 +313,8 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
|
||||
private static Map<String, String> buildClassToSourceMap(ModuleChunk chunk, CompileContext context, Set<String> toCompilePaths, Map<ModuleBuildTarget, String> finalOutputs) throws IOException {
|
||||
final Map<String, String> class2Src = new HashMap<String, String>();
|
||||
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(context.getProjectDescriptor().jpsProject);
|
||||
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(
|
||||
context.getProjectDescriptor().getProject());
|
||||
for (ModuleBuildTarget target : chunk.getTargets()) {
|
||||
String moduleOutputPath = finalOutputs.get(target);
|
||||
final SourceToOutputMapping srcToOut = context.getProjectDescriptor().dataManager.getSourceToOutputMap(target);
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.util.NamedRunnable;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.impl.GenericNotifierImpl;
|
||||
@@ -33,6 +34,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.IdeFrame;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ThreeState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -321,14 +323,37 @@ public class SvnAuthenticationNotifier extends GenericNotifierImpl<SvnAuthentica
|
||||
} catch (SVNCancelException e) {
|
||||
log(e); // auth canceled
|
||||
return false;
|
||||
} catch (SVNException e) {
|
||||
} catch (final SVNException e) {
|
||||
if (e.getErrorMessage().getErrorCode().isAuthentication()) {
|
||||
log(e);
|
||||
return false;
|
||||
}
|
||||
LOG.info("some other exc", e);
|
||||
if (interactive) {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(project, "Authentication failed: " + e.getMessage(), MessageType.ERROR);
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
VcsBalloonProblemNotifier.showOverChangesView(project, "Authentication failed: " + e.getMessage(), MessageType.ERROR,
|
||||
new NamedRunnable(SvnBundle.message("confirmation.title.clear.authentication.cache")) {
|
||||
@Override
|
||||
public void run() {
|
||||
SvnConfigurable.clearAuthenticationCache(project, null, configuration.getConfigurationDirectory());
|
||||
}
|
||||
},
|
||||
new NamedRunnable(SvnBundle.message("action.title.select.configuration.directory")) {
|
||||
@Override
|
||||
public void run() {
|
||||
SvnConfigurable.selectConfigirationDirectory(configuration.getConfigurationDirectory(),
|
||||
new Consumer<String>() {
|
||||
@Override
|
||||
public void consume(String s) {
|
||||
configuration.setConfigurationDirectory(s);
|
||||
}
|
||||
}, project, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, ModalityState.NON_MODAL, project.getDisposed());
|
||||
}
|
||||
return false; /// !!!! any exception means user should be notified that authorization failed
|
||||
}
|
||||
|
||||
@@ -154,6 +154,7 @@ status.group.name.locked=Locked
|
||||
checkbox.configure.use.system.default.configuration.directory=&Use system default Subversion configuration directory
|
||||
label.configuration.configuration.directory=Subversion configuration &directory:
|
||||
dialog.title.select.configuration.directory=Select Configuration Directory
|
||||
action.title.select.configuration.directory=Change Configuration Directory
|
||||
dialog.description.select.configuration.directory=Select Subversion configuration directory or create new one
|
||||
button.text.clear.authentication.cache=&Clear Auth Cache
|
||||
label.text.delete.stored.credentials=Delete all stored credentials for 'http', 'svn' and 'svn+ssh' protocols
|
||||
|
||||
@@ -32,8 +32,11 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.ui.MultiLineTooltipUI;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.idea.svn.config.ConfigureProxiesListener;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -93,37 +96,21 @@ public class SvnConfigurable implements Configurable {
|
||||
|
||||
myClearAuthButton.addActionListener(new ActionListener(){
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
String path = myConfigurationDirectoryText.getText();
|
||||
if (path != null) {
|
||||
int result = Messages.showYesNoDialog(myComponent, SvnBundle.message("confirmation.text.delete.stored.authentication.information"),
|
||||
SvnBundle.message("confirmation.title.clear.authentication.cache"),
|
||||
Messages.getWarningIcon());
|
||||
if (result == 0) {
|
||||
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
|
||||
SvnConfiguration.getInstance(myProject).clearAuthenticationDirectory(myProject);
|
||||
}
|
||||
}
|
||||
|
||||
clearAuthenticationCache(myProject, myComponent, myConfigurationDirectoryText.getText());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
final FileChooserDescriptor descriptor = createFileDescriptor();
|
||||
|
||||
myConfigurationDirectoryText.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@NonNls String path = myConfigurationDirectoryText.getText().trim();
|
||||
path = "file://" + path.replace(File.separatorChar, '/');
|
||||
VirtualFile root = VirtualFileManager.getInstance().findFileByUrl(path);
|
||||
|
||||
String oldValue = PropertiesComponent.getInstance().getValue("FileChooser.showHiddens");
|
||||
PropertiesComponent.getInstance().setValue("FileChooser.showHiddens", Boolean.TRUE.toString());
|
||||
VirtualFile file = FileChooser.chooseFile(descriptor, myComponent, myProject, root);
|
||||
PropertiesComponent.getInstance().setValue("FileChooser.showHiddens", oldValue);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
myConfigurationDirectoryText.setText(file.getPath().replace('/', File.separatorChar));
|
||||
selectConfigirationDirectory(path, new Consumer<String>() {
|
||||
@Override
|
||||
public void consume(String s) {
|
||||
myConfigurationDirectoryText.setText(s);
|
||||
}
|
||||
}, myProject, myComponent);
|
||||
}
|
||||
});
|
||||
myConfigurationDirectoryText.setEditable(false);
|
||||
@@ -150,6 +137,42 @@ public class SvnConfigurable implements Configurable {
|
||||
myJavaHLInfo.setVisible(internal);
|
||||
}
|
||||
|
||||
public static void selectConfigirationDirectory(@NotNull String path, @NotNull final Consumer<String> dirConsumer,
|
||||
final Project project, @Nullable final Component component) {
|
||||
final FileChooserDescriptor descriptor = createFileDescriptor();
|
||||
path = "file://" + path.replace(File.separatorChar, '/');
|
||||
VirtualFile root = VirtualFileManager.getInstance().findFileByUrl(path);
|
||||
|
||||
String oldValue = PropertiesComponent.getInstance().getValue("FileChooser.showHiddens");
|
||||
PropertiesComponent.getInstance().setValue("FileChooser.showHiddens", Boolean.TRUE.toString());
|
||||
VirtualFile file = FileChooser.chooseFile(descriptor, component, project, root);
|
||||
PropertiesComponent.getInstance().setValue("FileChooser.showHiddens", oldValue);
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
final String resultPath = file.getPath().replace('/', File.separatorChar);
|
||||
dirConsumer.consume(resultPath);
|
||||
}
|
||||
|
||||
public static void clearAuthenticationCache(@NotNull final Project project, final Component component, final String configDirPath) {
|
||||
if (configDirPath != null) {
|
||||
int result;
|
||||
if (component == null) {
|
||||
result = Messages.showYesNoDialog(project, SvnBundle.message("confirmation.text.delete.stored.authentication.information"),
|
||||
SvnBundle.message("confirmation.title.clear.authentication.cache"),
|
||||
Messages.getWarningIcon());
|
||||
} else {
|
||||
result = Messages.showYesNoDialog(component, SvnBundle.message("confirmation.text.delete.stored.authentication.information"),
|
||||
SvnBundle.message("confirmation.title.clear.authentication.cache"),
|
||||
Messages.getWarningIcon());
|
||||
}
|
||||
if (result == 0) {
|
||||
SvnConfiguration.RUNTIME_AUTH_CACHE.clear();
|
||||
SvnConfiguration.getInstance(project).clearAuthenticationDirectory(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static FileChooserDescriptor createFileDescriptor() {
|
||||
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
|
||||
descriptor.setShowFileSystemRoots(true);
|
||||
|
||||
@@ -488,7 +488,7 @@ public class SvnConfiguration implements PersistentStateComponent<Element> {
|
||||
|
||||
public static class AuthStorage implements ISVNAuthenticationStorage {
|
||||
|
||||
private final Map<String, Object> myStorage = new Hashtable<String, Object>();
|
||||
private final Map<String, Object> myStorage = Collections.synchronizedMap(new HashMap<String, Object>());
|
||||
|
||||
public void clear() {
|
||||
myStorage.clear();
|
||||
|
||||
@@ -185,12 +185,13 @@ public class SvnVcs extends AbstractVcs<CommittedChangeList> {
|
||||
}
|
||||
|
||||
static {
|
||||
SVNJNAUtil.setJNAEnabled(true);
|
||||
SvnHttpAuthMethodsDefaultChecker.check();
|
||||
|
||||
//noinspection UseOfArchaicSystemPropertyAccessors
|
||||
final JavaSVNDebugLogger logger = new JavaSVNDebugLogger(Boolean.getBoolean(LOG_PARAMETER_NAME), LOG);
|
||||
SVNDebugLog.setDefaultLog(logger);
|
||||
|
||||
SVNJNAUtil.setJNAEnabled(true);
|
||||
SvnHttpAuthMethodsDefaultChecker.check();
|
||||
|
||||
SVNAdminAreaFactory.setSelector(new SvnFormatSelector());
|
||||
|
||||
DAVRepositoryFactory.setup();
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.ChangeListManager;
|
||||
import com.intellij.openapi.vcs.changes.LocalChangeList;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.idea.svn.SvnBundle;
|
||||
import org.jetbrains.idea.svn.SvnUtil;
|
||||
@@ -35,6 +36,7 @@ import org.tmatesoft.svn.core.SVNCancelException;
|
||||
import org.tmatesoft.svn.core.SVNException;
|
||||
import org.tmatesoft.svn.core.wc.ISVNEventHandler;
|
||||
import org.tmatesoft.svn.core.wc.SVNEvent;
|
||||
import org.tmatesoft.svn.core.wc.SVNEventAction;
|
||||
import org.tmatesoft.svn.core.wc.SVNWCClient;
|
||||
|
||||
import java.io.File;
|
||||
@@ -124,10 +126,14 @@ public class SvnFormatWorker extends Task.Backgroundable {
|
||||
wcClient.setEventHandler(new ISVNEventHandler() {
|
||||
@Override
|
||||
public void handleEvent(SVNEvent event, double progress) throws SVNException {
|
||||
if (SVNEventAction.UPGRADED_PATH.equals(event.getAction()) && event.getFile() != null) {
|
||||
indicator.setText2("Upgraded path " + VcsUtil.getPathForProgressPresentation(event.getFile()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkCancelled() throws SVNCancelException {
|
||||
if (indicator.isCanceled()) throw new SVNCancelException();
|
||||
indicator.checkCanceled();
|
||||
}
|
||||
});
|
||||
try {
|
||||
|
||||
@@ -297,7 +297,7 @@
|
||||
<wizardMode implementation="com.intellij.ide.util.newProjectWizard.modes.ImportImlMode" id="ImportImlMode"/>
|
||||
|
||||
<wizardMode implementation="com.intellij.ide.util.newProjectWizard.modes.CreateFromTemplateMode" id="CreateFromTemplateMode" order="last"/>
|
||||
<projectTemplatesFactory implementation="com.intellij.platform.templates.GithubBasedTemplatesFactory"/>
|
||||
<projectTemplatesFactory implementation="com.intellij.platform.templates.ArchivedTemplatesFactory"/>
|
||||
|
||||
<gotoFileContributor implementation="com.intellij.ide.util.gotoByName.ProjectBaseDirNavigationContributor"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user