mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' into upsource-master
This commit is contained in:
+14
-3
@@ -180,10 +180,21 @@ public class JavaLineMarkerProvider implements LineMarkerProvider, DumbAware {
|
||||
}
|
||||
|
||||
private static boolean isRecursiveMethodCall(@NotNull PsiMethodCallExpression methodCall){
|
||||
PsiMethod referencedMethod = methodCall.resolveMethod();
|
||||
final PsiMethod referencedMethod = methodCall.resolveMethod();
|
||||
|
||||
TextRange rmRange = referencedMethod == null ? null : referencedMethod.getTextRange();
|
||||
int mcOffset = methodCall.getTextRange().getStartOffset();
|
||||
if (referencedMethod == null || !referencedMethod.isValid() || !methodCall.isValid()){
|
||||
return false;
|
||||
}
|
||||
|
||||
final PsiFile methodCallFile = methodCall.getContainingFile();
|
||||
final PsiFile methodFile = referencedMethod.getContainingFile();
|
||||
|
||||
if (methodCallFile == null || methodFile == null || !methodCallFile.equals(methodFile)){
|
||||
return false;
|
||||
}
|
||||
|
||||
final TextRange rmRange = referencedMethod.getTextRange();
|
||||
final int mcOffset = methodCall.getTextRange().getStartOffset();
|
||||
return rmRange != null && rmRange.contains(mcOffset);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -25,6 +25,8 @@ import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.JavaDocTokenType;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.StringEscapesTokenTypes;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
import com.intellij.psi.impl.source.tree.JavaDocElementType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.xml.XmlTokenType;
|
||||
@@ -51,9 +53,8 @@ public class JavaFileHighlighter extends SyntaxHighlighterBase {
|
||||
ourMap1 = new HashMap<IElementType, TextAttributesKey>();
|
||||
ourMap2 = new HashMap<IElementType, TextAttributesKey>();
|
||||
|
||||
fillMap(ourMap1, JavaTokenType.KEYWORD_BIT_SET, SyntaxHighlighterColors.KEYWORD);
|
||||
fillMap(ourMap1, JavaTokenType.OPERATION_BIT_SET, SyntaxHighlighterColors.OPERATION_SIGN);
|
||||
fillMap(ourMap1, JavaTokenType.OPERATION_BIT_SET, SyntaxHighlighterColors.OPERATION_SIGN);
|
||||
fillMap(ourMap1, ElementType.KEYWORD_BIT_SET, SyntaxHighlighterColors.KEYWORD);
|
||||
fillMap(ourMap1, ElementType.OPERATION_BIT_SET, SyntaxHighlighterColors.OPERATION_SIGN);
|
||||
|
||||
for (IElementType type : JavaDocTokenType.ALL_JAVADOC_TOKENS.getTypes()) {
|
||||
ourMap1.put(type, SyntaxHighlighterColors.DOC_COMMENT);
|
||||
@@ -86,12 +87,10 @@ public class JavaFileHighlighter extends SyntaxHighlighterBase {
|
||||
ourMap1.put(JavaTokenType.DOT, SyntaxHighlighterColors.DOT);
|
||||
ourMap1.put(JavaTokenType.SEMICOLON, SyntaxHighlighterColors.JAVA_SEMICOLON);
|
||||
|
||||
//ourMap1[JavaTokenType.BOOLEAN_LITERAL] = HighlighterColors.JAVA_KEYWORD;
|
||||
//ourMap1[JavaTokenType.NULL_LITERAL] = HighlighterColors.JAVA_KEYWORD;
|
||||
ourMap1.put(JavaTokenType.C_STYLE_COMMENT, SyntaxHighlighterColors.JAVA_BLOCK_COMMENT);
|
||||
ourMap1.put(JavaDocElementType.DOC_COMMENT, SyntaxHighlighterColors.DOC_COMMENT);
|
||||
ourMap1.put(JavaTokenType.END_OF_LINE_COMMENT, SyntaxHighlighterColors.LINE_COMMENT);
|
||||
ourMap1.put(JavaTokenType.BAD_CHARACTER, HighlighterColors.BAD_CHARACTER);
|
||||
ourMap1.put(TokenType.BAD_CHARACTER, HighlighterColors.BAD_CHARACTER);
|
||||
|
||||
ourMap1.put(JavaDocTokenType.DOC_TAG_NAME, SyntaxHighlighterColors.DOC_COMMENT);
|
||||
ourMap2.put(JavaDocTokenType.DOC_TAG_NAME, SyntaxHighlighterColors.DOC_COMMENT_TAG);
|
||||
|
||||
+4
-3
@@ -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.
|
||||
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.cache.impl.idCache;
|
||||
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.impl.cache.impl.BaseFilterLexer;
|
||||
import com.intellij.psi.impl.cache.impl.OccurrenceConsumer;
|
||||
import com.intellij.psi.impl.source.tree.ElementType;
|
||||
@@ -30,7 +31,7 @@ import com.intellij.psi.tree.TokenSet;
|
||||
public class JavaFilterLexer extends BaseFilterLexer {
|
||||
private static final TokenSet ourSkipWordsScanSet = TokenSet.orSet(
|
||||
TokenSet.create(
|
||||
JavaTokenType.WHITE_SPACE,
|
||||
TokenType.WHITE_SPACE,
|
||||
JavaTokenType.LPARENTH,
|
||||
JavaTokenType.RPARENTH,
|
||||
JavaTokenType.LBRACE,
|
||||
@@ -43,7 +44,7 @@ public class JavaFilterLexer extends BaseFilterLexer {
|
||||
JavaTokenType.ELLIPSIS,
|
||||
JavaTokenType.AT
|
||||
),
|
||||
JavaTokenType.OPERATION_BIT_SET
|
||||
ElementType.OPERATION_BIT_SET
|
||||
);
|
||||
|
||||
public JavaFilterLexer(final Lexer originalLexer, final OccurrenceConsumer table) {
|
||||
|
||||
@@ -20,8 +20,7 @@ import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.psi.tree.java.IJavaElementType;
|
||||
import com.intellij.psi.tree.java.IKeywordElementType;
|
||||
|
||||
|
||||
public interface JavaTokenType extends TokenType{
|
||||
public interface JavaTokenType extends TokenType {
|
||||
IElementType IDENTIFIER = new IJavaElementType("IDENTIFIER");
|
||||
IElementType C_STYLE_COMMENT = new IJavaElementType("C_STYLE_COMMENT");
|
||||
IElementType END_OF_LINE_COMMENT = new IJavaElementType("END_OF_LINE_COMMENT");
|
||||
@@ -87,7 +86,6 @@ public interface JavaTokenType extends TokenType{
|
||||
IElementType TRY_KEYWORD = new IKeywordElementType("TRY_KEYWORD");
|
||||
IElementType VOLATILE_KEYWORD = new IKeywordElementType("VOLATILE_KEYWORD");
|
||||
IElementType THROWS_KEYWORD = new IKeywordElementType("THROWS_KEYWORD");
|
||||
IElementType NONE_KEYWORD = new IKeywordElementType("NONE_KEYWORD");
|
||||
|
||||
IElementType LPARENTH = new IJavaElementType("LPARENTH");
|
||||
IElementType RPARENTH = new IJavaElementType("RPARENTH");
|
||||
@@ -143,13 +141,15 @@ public interface JavaTokenType extends TokenType{
|
||||
IElementType DOUBLE_COLON = new IJavaElementType("DOUBLE_COLON");
|
||||
IElementType ARROW = new IJavaElementType("ARROW");
|
||||
|
||||
TokenSet OPERATION_BIT_SET = TokenSet.create(
|
||||
/** @deprecated use {@linkplain com.intellij.psi.impl.source.tree.ElementType#OPERATION_BIT_SET} (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration") TokenSet OPERATION_BIT_SET = TokenSet.create(
|
||||
EQ, GT, LT, EXCL, TILDE, QUEST, COLON, PLUS, MINUS, ASTERISK, DIV, AND, OR, XOR,
|
||||
PERC, EQEQ, LE, GE, NE, ANDAND, OROR, PLUSPLUS, MINUSMINUS, LTLT, GTGT, GTGTGT,
|
||||
PLUSEQ, MINUSEQ, ASTERISKEQ, DIVEQ, ANDEQ, OREQ, XOREQ, PERCEQ, LTLTEQ, GTGTEQ, GTGTGTEQ
|
||||
);
|
||||
|
||||
TokenSet KEYWORD_BIT_SET = TokenSet.create(
|
||||
/** @deprecated use {@linkplain com.intellij.psi.impl.source.tree.ElementType#KEYWORD_BIT_SET} (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration") TokenSet KEYWORD_BIT_SET = TokenSet.create(
|
||||
ABSTRACT_KEYWORD, ASSERT_KEYWORD, BOOLEAN_KEYWORD, BREAK_KEYWORD, BYTE_KEYWORD, CASE_KEYWORD,
|
||||
CATCH_KEYWORD, CHAR_KEYWORD, CLASS_KEYWORD, CONST_KEYWORD, CONTINUE_KEYWORD,
|
||||
DEFAULT_KEYWORD, DO_KEYWORD, DOUBLE_KEYWORD, ELSE_KEYWORD, ENUM_KEYWORD, EXTENDS_KEYWORD,
|
||||
@@ -162,7 +162,8 @@ public interface JavaTokenType extends TokenType{
|
||||
VOID_KEYWORD, VOLATILE_KEYWORD, WHILE_KEYWORD, TRUE_KEYWORD, FALSE_KEYWORD, NULL_KEYWORD
|
||||
);
|
||||
|
||||
TokenSet MODIFIER_BIT_SET = TokenSet.create(
|
||||
/** @deprecated use {@linkplain com.intellij.psi.impl.source.tree.ElementType#MODIFIER_BIT_SET} (to remove in IDEA 13) */
|
||||
@SuppressWarnings("UnusedDeclaration") TokenSet MODIFIER_BIT_SET = TokenSet.create(
|
||||
PUBLIC_KEYWORD, PROTECTED_KEYWORD, PRIVATE_KEYWORD, STATIC_KEYWORD,
|
||||
ABSTRACT_KEYWORD, FINAL_KEYWORD, NATIVE_KEYWORD, STRICTFP_KEYWORD,
|
||||
SYNCHRONIZED_KEYWORD, TRANSIENT_KEYWORD, VOLATILE_KEYWORD
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.util.Set;
|
||||
|
||||
public class JavaLexer extends LexerBase {
|
||||
private static final HashTable[] TABLES = new HashTable[]{
|
||||
new HashTable(LanguageLevel.JDK_1_8),
|
||||
new HashTable(LanguageLevel.JDK_1_5),
|
||||
new HashTable(LanguageLevel.JDK_1_4),
|
||||
new HashTable(LanguageLevel.JDK_1_3)
|
||||
@@ -118,9 +117,6 @@ public class JavaLexer extends LexerBase {
|
||||
add("assert", JavaTokenType.ASSERT_KEYWORD);
|
||||
if (level.isAtLeast(LanguageLevel.JDK_1_5)) {
|
||||
add("enum", JavaTokenType.ENUM_KEYWORD);
|
||||
if (level.isAtLeast(LanguageLevel.JDK_1_8)) {
|
||||
add("none", JavaTokenType.NONE_KEYWORD);
|
||||
}
|
||||
}
|
||||
}
|
||||
add("abstract", JavaTokenType.ABSTRACT_KEYWORD);
|
||||
|
||||
@@ -12,13 +12,11 @@ import com.intellij.psi.tree.IElementType;
|
||||
%{
|
||||
private boolean myAssertKeyword;
|
||||
private boolean myEnumKeyword;
|
||||
private boolean myNoneKeyword;
|
||||
|
||||
public _JavaLexer(LanguageLevel level) {
|
||||
this((java.io.Reader)null);
|
||||
myAssertKeyword = level.isAtLeast(LanguageLevel.JDK_1_4);
|
||||
myEnumKeyword = level.isAtLeast(LanguageLevel.JDK_1_5);
|
||||
myNoneKeyword = level.isAtLeast(LanguageLevel.JDK_1_8);
|
||||
}
|
||||
|
||||
public void goTo(int offset) {
|
||||
@@ -154,7 +152,6 @@ ESCAPE_SEQUENCE=\\[^\r\n]
|
||||
<YYINITIAL> "try" { return JavaTokenType.TRY_KEYWORD; }
|
||||
<YYINITIAL> "volatile" { return JavaTokenType.VOLATILE_KEYWORD; }
|
||||
<YYINITIAL> "throws" { return JavaTokenType.THROWS_KEYWORD; }
|
||||
<YYINITIAL> "none" { return myNoneKeyword ? JavaTokenType.NONE_KEYWORD : JavaTokenType.IDENTIFIER; }
|
||||
|
||||
<YYINITIAL> {IDENTIFIER} { return JavaTokenType.IDENTIFIER; }
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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.
|
||||
@@ -40,6 +40,11 @@ public interface ElementType extends JavaTokenType, JavaDocTokenType,
|
||||
TRANSIENT_KEYWORD, RETURN_KEYWORD, VOID_KEYWORD, STATIC_KEYWORD, WHILE_KEYWORD, TRY_KEYWORD, VOLATILE_KEYWORD, THROWS_KEYWORD,
|
||||
ENUM_KEYWORD);
|
||||
|
||||
TokenSet OPERATION_BIT_SET = TokenSet.create(
|
||||
EQ, GT, LT, EXCL, TILDE, QUEST, COLON, PLUS, MINUS, ASTERISK, DIV, AND, OR, XOR,
|
||||
PERC, EQEQ, LE, GE, NE, ANDAND, OROR, PLUSPLUS, MINUSMINUS, LTLT, GTGT, GTGTGT,
|
||||
PLUSEQ, MINUSEQ, ASTERISKEQ, DIVEQ, ANDEQ, OREQ, XOREQ, PERCEQ, LTLTEQ, GTGTEQ, GTGTGTEQ);
|
||||
|
||||
TokenSet MODIFIER_BIT_SET = TokenSet.create(
|
||||
PUBLIC_KEYWORD, PROTECTED_KEYWORD, PRIVATE_KEYWORD, STATIC_KEYWORD, ABSTRACT_KEYWORD, FINAL_KEYWORD, NATIVE_KEYWORD, SYNCHRONIZED_KEYWORD,
|
||||
STRICTFP_KEYWORD, TRANSIENT_KEYWORD, VOLATILE_KEYWORD);
|
||||
|
||||
@@ -136,7 +136,7 @@ public class JavaLexerTest extends LexerTestCase {
|
||||
|
||||
public void testJava8Tokens() {
|
||||
doTest("none :: ->",
|
||||
"NONE_KEYWORD ('none')\nWHITE_SPACE (' ')\nDOUBLE_COLON ('::')\nWHITE_SPACE (' ')\nARROW ('->')");
|
||||
"IDENTIFIER ('none')\nWHITE_SPACE (' ')\nDOUBLE_COLON ('::')\nWHITE_SPACE (' ')\nARROW ('->')");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
package org.jetbrains.ether;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.ether.dependencyView.Mappings;
|
||||
import org.jetbrains.jps.Project;
|
||||
import org.jetbrains.jps.Sdk;
|
||||
import org.jetbrains.jps.idea.IdeaProjectLoader;
|
||||
import org.jetbrains.jps.incremental.Utils;
|
||||
import org.jetbrains.jps.server.ClasspathBootstrap;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: db
|
||||
* Date: 14.05.12
|
||||
* Time: 13:02
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class StorageDumper {
|
||||
private static class Env {
|
||||
final String myProjectPath;
|
||||
final String myOutputPath;
|
||||
final String myErrors;
|
||||
final boolean myHelp;
|
||||
|
||||
Env(final String[] args) {
|
||||
int s = 0;
|
||||
|
||||
String projectPath = null;
|
||||
String outputPath = null;
|
||||
boolean help = false;
|
||||
|
||||
final StringBuilder errors = new StringBuilder();
|
||||
|
||||
for (final String arg : args) {
|
||||
switch (s) {
|
||||
case 0: // Initial state
|
||||
if (arg.equals("-o")) {
|
||||
s = 1;
|
||||
}
|
||||
else if (arg.equals("-h")) {
|
||||
help = true;
|
||||
}
|
||||
else if (arg.startsWith("-")) {
|
||||
errors.append("Unrecognized option: ");
|
||||
errors.append(arg);
|
||||
errors.append("\n");
|
||||
}
|
||||
else {
|
||||
if (projectPath != null) {
|
||||
errors.append("Multiple projects specified, skipping ");
|
||||
errors.append(arg);
|
||||
errors.append("\n");
|
||||
}
|
||||
else {
|
||||
projectPath = arg;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: // -o
|
||||
if (arg.startsWith("-")) {
|
||||
errors.append("Output path expected after \"-o\", but found: ");
|
||||
errors.append(arg);
|
||||
errors.append("\n");
|
||||
}
|
||||
else {
|
||||
if (outputPath != null) {
|
||||
errors.append("Multiple output paths specified, skipping ");
|
||||
errors.append(arg);
|
||||
errors.append("\n");
|
||||
}
|
||||
else {
|
||||
outputPath = arg;
|
||||
}
|
||||
}
|
||||
s = 0;
|
||||
}
|
||||
}
|
||||
|
||||
myOutputPath = outputPath;
|
||||
myProjectPath = projectPath;
|
||||
myHelp = help;
|
||||
|
||||
myErrors = errors.toString();
|
||||
}
|
||||
|
||||
String getProjectPath() {
|
||||
return myProjectPath;
|
||||
}
|
||||
|
||||
String getOutputPath() {
|
||||
return myOutputPath;
|
||||
}
|
||||
|
||||
String getErrors() {
|
||||
return myErrors;
|
||||
}
|
||||
|
||||
void report() {
|
||||
if (myHelp) {
|
||||
System.out.println("Usage: <executable> [-o <output-path> | -h ] <project-path>");
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
System.err.println(myErrors);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(final String[] args) {
|
||||
final Env env = new Env(args);
|
||||
|
||||
env.report();
|
||||
|
||||
final String path = env.getProjectPath();
|
||||
final String oath = env.getOutputPath();
|
||||
|
||||
if (path == null) {
|
||||
System.err.println("No project path specified.");
|
||||
}
|
||||
else {
|
||||
try {
|
||||
final String projectPath = path + File.separator + ".idea";
|
||||
final String outputPath = (oath == null ? "" : oath) + File.separator + "snapshot-" + new SimpleDateFormat("dd-MM-yy(hh:mm:ss)").format(new Date()) + ".log";
|
||||
final Project project = new Project();
|
||||
|
||||
final Sdk jdk = project.createSdk("JavaSDK", "IDEA jdk", "1.6", System.getProperty("java.home"), null);
|
||||
final List<String> paths = new LinkedList<String>();
|
||||
|
||||
paths.add(FileUtil.toSystemIndependentName(ClasspathBootstrap.getResourcePath(Object.class).getCanonicalPath()));
|
||||
|
||||
jdk.setClasspath(paths);
|
||||
|
||||
IdeaProjectLoader.loadFromPath(project, projectPath, "");
|
||||
|
||||
final File dataStorageRoot = Utils.getDataStorageRoot(project);
|
||||
|
||||
final Mappings mappings = new Mappings(dataStorageRoot, true);
|
||||
final PrintStream p = new PrintStream(outputPath);
|
||||
|
||||
mappings.toStream(p);
|
||||
|
||||
p.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,8 +46,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@NonNls public class PsiTestUtil {
|
||||
public static VirtualFile createTestProjectStructure(Project project,
|
||||
@@ -215,12 +217,16 @@ import java.util.Collection;
|
||||
}
|
||||
|
||||
public static void removeContentEntry(final Module module, final ContentEntry e) {
|
||||
new WriteCommandAction.Simple(module.getProject()) {
|
||||
ModuleRootManager rootModel = ModuleRootManager.getInstance(module);
|
||||
final ModifiableRootModel model = rootModel.getModifiableModel();
|
||||
model.removeContentEntry(e);
|
||||
commitModel(model);
|
||||
}
|
||||
|
||||
private static void commitModel(final ModifiableRootModel model) {
|
||||
new WriteCommandAction.Simple(model.getProject()) {
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
ModuleRootManager rootModel = ModuleRootManager.getInstance(module);
|
||||
ModifiableRootModel model = rootModel.getModifiableModel();
|
||||
model.removeContentEntry(e);
|
||||
model.commit();
|
||||
}
|
||||
}.execute().throwException();
|
||||
@@ -234,7 +240,6 @@ import java.util.Collection;
|
||||
}
|
||||
|
||||
public static void addLibrary(final Module module, final String libName, final String libPath, final String... jarArr) {
|
||||
assert ModuleRootManager.getInstance(module).getContentRoots().length > 0 : "content roots must not be empty";
|
||||
new WriteCommandAction(module.getProject()) {
|
||||
@Override
|
||||
protected void run(Result result) throws Throwable {
|
||||
@@ -245,40 +250,52 @@ import java.util.Collection;
|
||||
}.execute().throwException();
|
||||
}
|
||||
|
||||
public static void addLibrary(final Module module, final ModifiableRootModel model, final String libName, final String libPath, final String... jarArr) {
|
||||
public static void addProjectLibrary(Module module, String libName, VirtualFile... classesRoots) {
|
||||
final ModifiableRootModel modifiableModel = ModuleRootManager.getInstance(module).getModifiableModel();
|
||||
addProjectLibrary(module, modifiableModel, libName, classesRoots);
|
||||
commitModel(modifiableModel);
|
||||
}
|
||||
|
||||
private static void addProjectLibrary(final Module module, final ModifiableRootModel model, final String libName, final VirtualFile... classesRoots) {
|
||||
new WriteCommandAction.Simple(module.getProject()) {
|
||||
@Override
|
||||
protected void run() throws Throwable {
|
||||
final LibraryTable libraryTable = ProjectLibraryTable.getInstance(module.getProject());
|
||||
final Library library = libraryTable.createLibrary(libName);
|
||||
final Library.ModifiableModel libraryModel = library.getModifiableModel();
|
||||
for (String jar : jarArr) {
|
||||
if (!libPath.endsWith("/") && !jar.startsWith("/")) {
|
||||
jar = "/" + jar;
|
||||
}
|
||||
final String path = libPath + jar;
|
||||
VirtualFile root;
|
||||
if (path.endsWith(".jar")) {
|
||||
root = JarFileSystem.getInstance().refreshAndFindFileByPath(path + "!/");
|
||||
} else {
|
||||
root = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
|
||||
}
|
||||
assert root != null : "Library root folder not found: " + path + "!/";
|
||||
for (VirtualFile root : classesRoots) {
|
||||
libraryModel.addRoot(root, OrderRootType.CLASSES);
|
||||
}
|
||||
libraryModel.commit();
|
||||
model.addLibraryEntry(library);
|
||||
final OrderEntry[] orderEntries = model.getOrderEntries();
|
||||
OrderEntry last = orderEntries[orderEntries.length - 1];
|
||||
for (int i = orderEntries.length - 2; i > -1; i--) {
|
||||
orderEntries[i + 1] = orderEntries[i];
|
||||
}
|
||||
System.arraycopy(orderEntries, 0, orderEntries, 1, orderEntries.length - 1);
|
||||
orderEntries[0] = last;
|
||||
model.rearrangeOrderEntries(orderEntries);
|
||||
}
|
||||
}.execute().throwException();
|
||||
}
|
||||
|
||||
public static void addLibrary(final Module module, final ModifiableRootModel model, final String libName, final String libPath, final String... jarArr) {
|
||||
List<VirtualFile> classesRoots = new ArrayList<VirtualFile>();
|
||||
for (String jar : jarArr) {
|
||||
if (!libPath.endsWith("/") && !jar.startsWith("/")) {
|
||||
jar = "/" + jar;
|
||||
}
|
||||
final String path = libPath + jar;
|
||||
VirtualFile root;
|
||||
if (path.endsWith(".jar")) {
|
||||
root = JarFileSystem.getInstance().refreshAndFindFileByPath(path + "!/");
|
||||
} else {
|
||||
root = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
|
||||
}
|
||||
assert root != null : "Library root folder not found: " + path + "!/";
|
||||
classesRoots.add(root);
|
||||
}
|
||||
addProjectLibrary(module, model, libName, VfsUtil.toVirtualFileArray(classesRoots));
|
||||
}
|
||||
|
||||
public static void addLibrary(final Module module,
|
||||
final String libName, final String libDir,
|
||||
final String[] classRoots,
|
||||
|
||||
+2
@@ -52,6 +52,8 @@ public class GroovyDocCompletionProvider extends CompletionProvider<CompletionPa
|
||||
@NotNull CompletionResultSet result) {
|
||||
final PsiElement position = parameters.getPosition();
|
||||
GrDocMemberReference reference = PsiTreeUtil.getParentOfType(position, GrDocMemberReference.class);
|
||||
if (reference == null) return;
|
||||
|
||||
GrDocReferenceElement holder = reference.getReferenceHolder();
|
||||
PsiElement resolved;
|
||||
if (holder != null) {
|
||||
|
||||
Reference in New Issue
Block a user