mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
+1
-2
@@ -108,9 +108,8 @@ public class LibraryCompositionSettings implements Disposable {
|
||||
@Nullable
|
||||
private Library createLibrary(final ModifiableRootModel rootModel, @Nullable LibrariesContainer additionalContainer) {
|
||||
if (myNewLibraryEditor != null) {
|
||||
VirtualFile[] roots = myNewLibraryEditor.getFiles(OrderRootType.CLASSES);
|
||||
return LibrariesContainerFactory.createLibrary(additionalContainer, LibrariesContainerFactory.createContainer(rootModel),
|
||||
myNewLibraryEditor.getName(), getLibraryLevel(), roots, VirtualFile.EMPTY_ARRAY);
|
||||
myNewLibraryEditor, getLibraryLevel());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+15
@@ -126,6 +126,10 @@ public class NewLibraryEditor implements LibraryEditor {
|
||||
|
||||
public void apply(@NotNull Library.ModifiableModel model) {
|
||||
model.setName(myLibraryName);
|
||||
applyRoots(model);
|
||||
}
|
||||
|
||||
public void applyRoots(Library.ModifiableModel model) {
|
||||
for (OrderRootType type : myRoots.keySet()) {
|
||||
for (LightFilePointer pointer : myRoots.get(type)) {
|
||||
model.addRoot(pointer.getUrl(), type);
|
||||
@@ -135,4 +139,15 @@ public class NewLibraryEditor implements LibraryEditor {
|
||||
model.addJarDirectory(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void copyRoots(ExistingLibraryEditor editor) {
|
||||
for (OrderRootType type : myRoots.keySet()) {
|
||||
for (LightFilePointer pointer : myRoots.get(type)) {
|
||||
editor.addRoot(pointer.getUrl(), type);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Boolean> entry : myJarDirectories.entrySet()) {
|
||||
editor.addJarDirectory(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -19,6 +19,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -54,6 +55,8 @@ public interface LibrariesContainer {
|
||||
Library createLibrary(@NotNull @NonNls String name, @NotNull LibraryLevel level,
|
||||
@NotNull VirtualFile[] classRoots, @NotNull VirtualFile[] sourceRoots);
|
||||
|
||||
Library createLibrary(@NotNull NewLibraryEditor libraryEditor, @NotNull LibraryLevel level);
|
||||
|
||||
@NotNull
|
||||
String suggestUniqueLibraryName(@NotNull String baseName);
|
||||
|
||||
|
||||
+34
-26
@@ -25,6 +25,7 @@ import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
|
||||
import com.intellij.openapi.roots.ui.configuration.LibraryTableModifiableModelProvider;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -72,27 +73,21 @@ public class LibrariesContainerFactory {
|
||||
}
|
||||
|
||||
public static Library createLibrary(@Nullable LibrariesContainer container1, @NotNull LibrariesContainer container2,
|
||||
@NotNull @NonNls final String name, @NotNull final LibrariesContainer.LibraryLevel level,
|
||||
@NotNull final VirtualFile[] classRoots, @NotNull final VirtualFile[] sourceRoots) {
|
||||
@NotNull @NonNls final NewLibraryEditor editor, @NotNull final LibrariesContainer.LibraryLevel level) {
|
||||
if (container1 != null && container1.canCreateLibrary(level)) {
|
||||
return container1.createLibrary(name, level, classRoots, sourceRoots);
|
||||
return container1.createLibrary(editor, level);
|
||||
}
|
||||
else {
|
||||
return container2.createLibrary(name, level, classRoots, sourceRoots);
|
||||
return container2.createLibrary(editor, level);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Library createLibraryInTable(final @NonNls String name, final VirtualFile[] roots, final VirtualFile[] sources, final LibraryTable table) {
|
||||
private static Library createLibraryInTable(final @NotNull NewLibraryEditor editor, final LibraryTable table) {
|
||||
LibraryTable.ModifiableModel modifiableModel = table.getModifiableModel();
|
||||
Library library = modifiableModel.createLibrary(getUniqueLibraryName(name, modifiableModel));
|
||||
Library library = modifiableModel.createLibrary(getUniqueLibraryName(editor.getName(), modifiableModel));
|
||||
final Library.ModifiableModel model = library.getModifiableModel();
|
||||
for (VirtualFile root : roots) {
|
||||
model.addRoot(root, OrderRootType.CLASSES);
|
||||
}
|
||||
for (VirtualFile root : sources) {
|
||||
model.addRoot(root, OrderRootType.SOURCES);
|
||||
}
|
||||
editor.applyRoots(model);
|
||||
model.commit();
|
||||
modifiableModel.commit();
|
||||
return library;
|
||||
@@ -111,6 +106,22 @@ public class LibrariesContainerFactory {
|
||||
private abstract static class LibrariesContainerBase implements LibrariesContainer {
|
||||
private UniqueNameGenerator myNameGenerator;
|
||||
|
||||
@Override
|
||||
public Library createLibrary(@NotNull @NonNls String name,
|
||||
@NotNull LibraryLevel level,
|
||||
@NotNull VirtualFile[] classRoots,
|
||||
@NotNull VirtualFile[] sourceRoots) {
|
||||
NewLibraryEditor editor = new NewLibraryEditor();
|
||||
editor.setName(name);
|
||||
for (VirtualFile classRoot : classRoots) {
|
||||
editor.addRoot(classRoot, OrderRootType.CLASSES);
|
||||
}
|
||||
for (VirtualFile sourceRoot : sourceRoots) {
|
||||
editor.addRoot(sourceRoot, OrderRootType.SOURCES);
|
||||
}
|
||||
return createLibrary(editor, level);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Library[] getAllLibraries() {
|
||||
Library[] libraries = getLibraries(LibraryLevel.GLOBAL);
|
||||
@@ -204,10 +215,11 @@ public class LibrariesContainerFactory {
|
||||
return level == LibraryLevel.GLOBAL || myProject != null;
|
||||
}
|
||||
|
||||
public Library createLibrary(@NotNull @NonNls final String name, @NotNull final LibraryLevel level,
|
||||
@NotNull final VirtualFile[] classRoots, @NotNull final VirtualFile[] sourceRoots) {
|
||||
@Override
|
||||
public Library createLibrary(@NotNull NewLibraryEditor libraryEditor,
|
||||
@NotNull LibraryLevel level) {
|
||||
if (level == LibraryLevel.MODULE && myRootModel != null) {
|
||||
return createLibraryInTable(name, classRoots, sourceRoots, myRootModel.getModuleLibraryTable());
|
||||
return createLibraryInTable(libraryEditor, myRootModel.getModuleLibraryTable());
|
||||
}
|
||||
|
||||
LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
|
||||
@@ -221,7 +233,7 @@ public class LibrariesContainerFactory {
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
return createLibraryInTable(name, classRoots, sourceRoots, table);
|
||||
return createLibraryInTable(libraryEditor, table);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -239,22 +251,18 @@ public class LibrariesContainerFactory {
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
public Library createLibrary(@NotNull @NonNls final String name, @NotNull final LibraryLevel level,
|
||||
@NotNull final VirtualFile[] classRoots, @NotNull final VirtualFile[] sourceRoots) {
|
||||
@Override
|
||||
public Library createLibrary(@NotNull NewLibraryEditor libraryEditor,
|
||||
@NotNull LibraryLevel level) {
|
||||
LibraryTableModifiableModelProvider provider = getProvider(level);
|
||||
if (provider == null) {
|
||||
LOG.error("cannot create module library in this context");
|
||||
}
|
||||
|
||||
LibraryTable.ModifiableModel model = provider.getModifiableModel();
|
||||
Library library = model.createLibrary(getUniqueLibraryName(name, model));
|
||||
LibraryEditor libraryEditor = ((LibrariesModifiableModel)model).getLibraryEditor(library);
|
||||
for (VirtualFile root : classRoots) {
|
||||
libraryEditor.addRoot(root, OrderRootType.CLASSES);
|
||||
}
|
||||
for (VirtualFile source : sourceRoots) {
|
||||
libraryEditor.addRoot(source, OrderRootType.SOURCES);
|
||||
}
|
||||
Library library = model.createLibrary(getUniqueLibraryName(libraryEditor.getName(), model));
|
||||
ExistingLibraryEditor createdLibraryEditor = ((LibrariesModifiableModel)model).getLibraryEditor(library);
|
||||
libraryEditor.copyRoots(createdLibraryEditor);
|
||||
return library;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,6 +134,9 @@ class CacheUpdateRunner {
|
||||
final boolean[] isFinished = new boolean[1];
|
||||
try {
|
||||
int threadsCount = Registry.intValue("caches.indexerThreadsCount");
|
||||
if (threadsCount == -1) {
|
||||
threadsCount = Math.min(Runtime.getRuntime().availableProcessors(), 2);
|
||||
}
|
||||
if (threadsCount == 1) {
|
||||
Runnable process = new MyRunnable(innerIndicator, queue, isFinished, progressUpdater, processInReadAction, application);
|
||||
ProgressManager.getInstance().runProcess(process, innerIndicator);
|
||||
|
||||
@@ -99,4 +99,4 @@ jar.build=false
|
||||
|
||||
keymap.show.alias.actions=false
|
||||
frameworks.download.libraries.server.url=http://pluginsrepo-test:8080
|
||||
caches.indexerThreadsCount=1
|
||||
caches.indexerThreadsCount=-1
|
||||
+1
-1
@@ -198,7 +198,7 @@ public class ReplaceForEachLoopWithIndexedForLoopIntention extends Intention {
|
||||
return createVariable(variableName, expression, context);
|
||||
}
|
||||
final PsiElement target = referenceElement.resolve();
|
||||
if (target instanceof PsiLocalVariable) {
|
||||
if (target instanceof PsiVariable) {
|
||||
// maybe should not do this for local variables outside of
|
||||
// anonymous classes
|
||||
return variableName;
|
||||
|
||||
+28
-14
@@ -28,21 +28,35 @@ import java.text.DecimalFormat;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ConvertToEngineeringNotationIntention extends Intention {
|
||||
private static final DecimalFormat FORMAT = new DecimalFormat("0.00000000000000E00");
|
||||
private static final ConvertToEngineeringNotationPredicate PREDICATE = new ConvertToEngineeringNotationPredicate();
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
String text = FORMAT.format(Double.parseDouble(element.getText())).replace(',', '.');
|
||||
while (text.contains("0E") && !text.contains(".0E")) {
|
||||
text = text.replace("0E", "E");
|
||||
private static final DecimalFormat FORMAT =
|
||||
new DecimalFormat("0.00000000000000E00");
|
||||
private static final ConvertToEngineeringNotationPredicate PREDICATE =
|
||||
new ConvertToEngineeringNotationPredicate();
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element)
|
||||
throws IncorrectOperationException {
|
||||
final String elementText = element.getText();
|
||||
if (elementText.length() == 0) {
|
||||
return;
|
||||
}
|
||||
final int lastIndex = elementText.length() - 1;
|
||||
final char lastChar = elementText.charAt(lastIndex);
|
||||
String text = FORMAT.format(Double.parseDouble(elementText)).replace(',', '.');
|
||||
while (text.contains("0E") && !text.contains(".0E")) {
|
||||
text = text.replace("0E", "E");
|
||||
}
|
||||
if (lastChar == 'f' || lastChar == 'F') {
|
||||
replaceExpression(text + lastChar, (PsiExpression)element);
|
||||
} else {
|
||||
replaceExpression(text, (PsiExpression)element);
|
||||
}
|
||||
}
|
||||
replaceExpression(text, (PsiExpression)element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected PsiElementPredicate getElementPredicate() {
|
||||
return PREDICATE;
|
||||
}
|
||||
@NotNull
|
||||
@Override
|
||||
protected PsiElementPredicate getElementPredicate() {
|
||||
return PREDICATE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,24 +22,43 @@ import com.siyeh.ipp.base.Intention;
|
||||
import com.siyeh.ipp.base.PsiElementPredicate;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ConvertToPlainIntention extends Intention {
|
||||
private static final ConvertToPlainPredicate PREDICATE = new ConvertToPlainPredicate();
|
||||
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
try {
|
||||
replaceExpression(Double.toString(Double.parseDouble(element.getText())), (PsiExpression)element);
|
||||
}
|
||||
catch (Exception e) {//
|
||||
}
|
||||
}
|
||||
private static final ConvertToPlainPredicate PREDICATE =
|
||||
new ConvertToPlainPredicate();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected PsiElementPredicate getElementPredicate() {
|
||||
return PREDICATE;
|
||||
}
|
||||
@Override
|
||||
protected void processIntention(@NotNull PsiElement element)
|
||||
throws IncorrectOperationException {
|
||||
try {
|
||||
final String elementText = element.getText();
|
||||
if (elementText.length() == 0) {
|
||||
return;
|
||||
}
|
||||
final int lastIndex = elementText.length() - 1;
|
||||
final char lastChar = elementText.charAt(lastIndex);
|
||||
if (lastChar == 'f' || lastChar == 'F') {
|
||||
final BigDecimal bigDecimal =
|
||||
new BigDecimal(elementText.substring(0, lastIndex));
|
||||
replaceExpression(bigDecimal.toPlainString() + lastChar,
|
||||
(PsiExpression) element);
|
||||
} else {
|
||||
final BigDecimal bigDecimal = new BigDecimal(elementText);
|
||||
replaceExpression(bigDecimal.toPlainString(),
|
||||
(PsiExpression) element);
|
||||
}
|
||||
} catch (Exception e) {//
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected PsiElementPredicate getElementPredicate() {
|
||||
return PREDICATE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.siyeh.ipp.base.PsiElementPredicate;
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class ConvertToPlainPredicate implements PsiElementPredicate {
|
||||
@Override
|
||||
|
||||
public boolean satisfiedBy(PsiElement element) {
|
||||
if (element instanceof PsiLiteralExpression) {
|
||||
final PsiLiteralExpression expression = (PsiLiteralExpression)element;
|
||||
|
||||
Reference in New Issue
Block a user