}
if (!VfsUtil.isAncestor(outputDir, outputClassFile, true)) {
- LOG.assertTrue(false, outputClassFile.getPath() + " should be located under the output root " + outputDir.getPath());
+ LOG.error(outputClassFile.getPath() + " should be located under the output root " + outputDir.getPath());
}
final ProcessingItem item = createProcessingItem(module, outputClassFile, outputDir,
try {
buf.append("<html><body>");
if (myProblemDescriptions != null) {
+ int problems = 0;
for (ProjectStructureProblemDescription problemDescription : myProblemDescriptions) {
buf.append(problemDescription.getMessage()).append("<br>");
+ problems++;
+ if (problems >= 10 && myProblemDescriptions.size() > 12) {
+ buf.append(myProblemDescriptions.size() - problems).append(" more problems...<br>");
+ break;
+ }
}
}
buf.append("</body></html>");
import com.intellij.psi.*;
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
import com.intellij.psi.impl.PsiClassImplUtil;
-import com.intellij.psi.impl.search.PsiSearchHelperImpl;
import com.intellij.psi.impl.source.jsp.jspJava.JspxImportStatement;
import com.intellij.psi.jsp.JspFile;
import com.intellij.psi.jsp.JspSpiUtil;
import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.search.searches.MethodReferencesSearch;
import com.intellij.psi.search.searches.OverridingMethodsSearch;
// some classes may have references from within XML outside dependent modules, e.g. our actions
if (member instanceof PsiClass) scope = scope.uniteWith(GlobalSearchScope.projectScope(myProject));
- PsiSearchHelperImpl.Result cheapEnough = ((PsiSearchHelperImpl)myFile.getManager().getSearchHelper()).isItCheapEnoughToSearch(myFile, name, scope);
- if (cheapEnough == PsiSearchHelperImpl.Result.TOO_MANY_OCCURRENCES) return false;
+ PsiSearchHelper.SearchCostResult cheapEnough = myFile.getManager().getSearchHelper().isCheapEnoughToSearch(name, scope, myFile);
+ if (cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return false;
//search usages if it cheap
//if count is 0 there is no usages since we've called myRefCountHolder.isReferenced() before
- if (cheapEnough == PsiSearchHelperImpl.Result.ZERO_OCCURRENCES && !canbeReferencedViaWeirdNames(member)) return true;
+ if (cheapEnough == PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES && !canbeReferencedViaWeirdNames(member)) return true;
Query<PsiReference> query = member instanceof PsiMethod
? MethodReferencesSearch.search((PsiMethod)member, scope, true)
@Nullable
- private static String generateExternalJavadoc(final PsiElement element, String fromUrl, boolean checkCompiled, JavaDocExternalFilter filter) {
- if (!checkCompiled || element instanceof PsiCompiledElement) {
- try {
- String externalDoc = filter.getExternalDocInfoForElement(fromUrl, element);
- if (externalDoc != null && externalDoc.length() > 0) {
- return externalDoc;
- }
- }
- catch (Exception e) {
- //try to generate some javadoc
+ private static String fetchExternalJavadoc(final PsiElement element, String fromUrl, JavaDocExternalFilter filter) {
+ try {
+ String externalDoc = filter.getExternalDocInfoForElement(fromUrl, element);
+ if (externalDoc != null && externalDoc.length() > 0) {
+ return externalDoc;
}
}
+ catch (Exception e) {
+ //try to generate some javadoc
+ }
return null;
}
if (docURLs != null) {
for (String docURL : docURLs) {
try {
- final String javadoc = generateExternalJavadoc(element, docURL, true, docFilter);
+ final String javadoc = fetchExternalJavadoc(element, docURL, docFilter);
if (javadoc != null) return javadoc;
}
catch (IndexNotReadyException e) {
PsiElement currentFileResolveScope = resolveResult.getCurrentFileResolveScope();
if (!(currentFileResolveScope instanceof PsiImportStatementBase)) continue;
- if (context != null && currentFileResolveScope instanceof JspxImportStatement && context != ((JspxImportStatement)currentFileResolveScope).getDeclarationFile()) {
+ if (context != null &&
+ (!currentFileResolveScope.isValid() ||
+ currentFileResolveScope instanceof JspxImportStatement &&
+ context != ((JspxImportStatement)currentFileResolveScope).getDeclarationFile())) {
continue;
}
public void patchFileCopy(@NotNull final PsiFile fileCopy, @NotNull final Document document, @NotNull final OffsetMap map) {
if (StringUtil.isEmpty(myDummyIdentifier)) return;
- document.replaceString(map.getOffset(CompletionInitializationContext.START_OFFSET), map.getOffset(CompletionInitializationContext.SELECTION_END_OFFSET),
- myDummyIdentifier);
+ int startOffset = map.getOffset(CompletionInitializationContext.START_OFFSET);
+ int endOffset = map.getOffset(CompletionInitializationContext.SELECTION_END_OFFSET);
+ document.replaceString(startOffset, endOffset, myDummyIdentifier);
}
@Override
@NotNull String text,
short searchContext,
boolean caseSensitive);
+
+ SearchCostResult isCheapEnoughToSearch(@NotNull String name, @NotNull GlobalSearchScope scope, @Nullable PsiFile fileToIgnoreOccurencesIn);
+
+ enum SearchCostResult {
+ ZERO_OCCURRENCES, FEW_OCCURRENCES, TOO_MANY_OCCURRENCES
+ }
}
import java.util.Collection;
public abstract class StubIndex {
- private static StubIndex ourInstance = CachedSingletonsRegistry.markCachedField(StubIndex.class);
+
+ private static class StubIndexHolder {
+ private static final StubIndex ourInstance = ApplicationManager.getApplication().getComponent(StubIndex.class);
+ }
public static StubIndex getInstance() {
- if (ourInstance == null) {
- ourInstance = ApplicationManager.getApplication().getComponent(StubIndex.class);
- }
- return ourInstance;
+ return StubIndexHolder.ourInstance;
}
public abstract <Key, Psi extends PsiElement> Collection<Psi> get(
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
public class PsiTreeUtil {
public static boolean isAncestor(@Nullable PsiElement ancestor, @NotNull PsiElement element, boolean strict) {
if (ancestor == null) return false;
// fast path to avoid loading tree
- if ((ancestor instanceof StubBasedPsiElement && (((StubBasedPsiElement)ancestor).getStub() != null)) ||
- (element instanceof StubBasedPsiElement && ((StubBasedPsiElement)element).getStub() != null)) {
+ if (ancestor instanceof StubBasedPsiElement && ((StubBasedPsiElement)ancestor).getStub() != null ||
+ element instanceof StubBasedPsiElement && ((StubBasedPsiElement)element).getStub() != null) {
if (ancestor.getContainingFile() != element.getContainingFile()) return false;
}
@NotNull
public static PsiElement[] collectElements(@Nullable PsiElement element, @NotNull PsiElementFilter filter) {
- PsiElementProcessor.CollectFilteredElements processor = new PsiElementProcessor.CollectFilteredElements(filter);
+ PsiElementProcessor.CollectFilteredElements<PsiElement> processor = new PsiElementProcessor.CollectFilteredElements<PsiElement>(filter);
processElements(element, processor);
return processor.toArray();
}
return false;
}
- public static PsiElement[] filterAncestors(PsiElement[] elements) {
+ @NotNull
+ public static PsiElement[] filterAncestors(@NotNull PsiElement[] elements) {
if (LOG.isDebugEnabled()) {
for (PsiElement element : elements) {
LOG.debug("element = " + element);
}
ArrayList<PsiElement> filteredElements = new ArrayList<PsiElement>();
- for (PsiElement element : elements) {
- filteredElements.add(element);
- }
+ filteredElements.addAll(Arrays.asList(elements));
int previousSize;
do {
<grid id="cae26" binding="myWholePanel" layout-manager="GridLayoutManager" row-count="5" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
- <xy x="13" y="24" width="615" height="128"/>
+ <xy x="13" y="24" width="615" height="165"/>
</constraints>
<properties/>
<border type="none"/>
</constraints>
<properties/>
</component>
- <xy id="49cf" binding="myComponentPlace" layout-manager="XYLayout" hgap="-1" vgap="-1">
- <margin top="0" left="0" bottom="0" right="0"/>
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="2" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties/>
- <border type="none"/>
- <children/>
- </xy>
<xy id="ceb6c" binding="myOutlinePanel" layout-manager="XYLayout" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
+ <scrollpane id="9da09">
+ <constraints>
+ <grid row="1" column="0" row-span="1" col-span="2" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties/>
+ <border type="none"/>
+ <children>
+ <xy id="49cf" binding="myComponentPlace" layout-manager="XYLayout" hgap="-1" vgap="-1">
+ <margin top="0" left="0" bottom="0" right="0"/>
+ <constraints/>
+ <properties/>
+ <border type="none"/>
+ <children/>
+ </xy>
+ </children>
+ </scrollpane>
</children>
</grid>
</form>
import com.intellij.openapi.editor.impl.DocumentImpl;
import com.intellij.openapi.editor.markup.MarkupModel;
import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.ProperTextRange;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.util.UserDataHolderBase;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
-import java.util.List;
import java.util.Collections;
+import java.util.List;
/**
* @author Alexey
startOffset += perfixLength;
endOffset -= suffixLength;
s = s.subSequence(perfixLength, s.length() - suffixLength);
-
- deleteString(startOffset, endOffset);
- insertString(startOffset, s);
+
+ doReplaceString(startOffset, endOffset, s);
+ }
+
+ private void doReplaceString(int startOffset, int endOffset, CharSequence s) {
+ assert intersectWithEditable(new TextRange(startOffset, startOffset)) != null;
+ assert intersectWithEditable(new TextRange(endOffset, endOffset)) != null;
+
+ List<Pair<TextRange,CharSequence>> hostRangesToModify = new ArrayList<Pair<TextRange, CharSequence>>(myShreds.size());
+
+ int offset = startOffset;
+ int curRangeStart = 0;
+ for (int i = 0; i < myShreds.size(); i++) {
+ PsiLanguageInjectionHost.Shred shred = myShreds.get(i);
+ curRangeStart += shred.prefix.length();
+ if (offset < curRangeStart) offset = curRangeStart;
+ RangeMarker hostRange = shred.getHostRangeMarker();
+ if (!hostRange.isValid()) continue;
+ int hostRangeLength = hostRange.getEndOffset() - hostRange.getStartOffset();
+ TextRange range = TextRange.from(curRangeStart, hostRangeLength);
+ if (range.contains(offset) || range.getEndOffset() == offset/* in case of inserting at the end*/) {
+ TextRange rangeToModify = new TextRange(offset, Math.min(range.getEndOffset(), endOffset));
+ TextRange hostRangeToModify = rangeToModify.shiftRight(hostRange.getStartOffset() - curRangeStart);
+ CharSequence toReplace = i == myShreds.size() - 1 ? s : s.subSequence(0, Math.min(hostRangeToModify.getLength(), s.length()));
+ s = s.subSequence(toReplace.length(), s.length());
+ hostRangesToModify.add(Pair.create(hostRangeToModify, toReplace));
+ offset = rangeToModify.getEndOffset();
+ }
+ curRangeStart += hostRangeLength;
+ curRangeStart += shred.suffix.length();
+ if (curRangeStart >= endOffset) break;
+ }
+
+ int delta = 0;
+ for (Pair<TextRange, CharSequence> pair : hostRangesToModify) {
+ TextRange hostRange = pair.getFirst();
+ CharSequence replace = pair.getSecond();
+
+ myDelegate.replaceString(hostRange.getStartOffset() + delta, hostRange.getEndOffset() + delta, replace);
+ delta -= hostRange.getLength() - replace.length();
+ }
}
public boolean isWritable() {
import java.util.List;
public class DefaultScopesProvider implements CustomScopesProvider {
- private static NamedScope myAllScope;
private NamedScope myProblemsScope;
private final Project myProject;
return list;
}
- public static NamedScope getAllScope() {
- if (myAllScope == null) {
- myAllScope = new NamedScope("All", new PackageSet() {
- public boolean contains(final PsiFile file, final NamedScopesHolder holder) {
- return true;
- }
+ private static class NamedScopeHolder {
+ private static final NamedScope myAllScope = new NamedScope("All", new PackageSet() {
+ public boolean contains(final PsiFile file, final NamedScopesHolder holder) {
+ return true;
+ }
- public PackageSet createCopy() {
- return this;
- }
+ public PackageSet createCopy() {
+ return this;
+ }
- public String getText() {
- return FilePatternPackageSet.SCOPE_FILE + ":*//*";
- }
+ public String getText() {
+ return FilePatternPackageSet.SCOPE_FILE + ":*//*";
+ }
- public int getNodePriority() {
- return 0;
- }
- });
- }
- return myAllScope;
+ public int getNodePriority() {
+ return 0;
+ }
+ });
+ }
+
+ public static NamedScope getAllScope() {
+ return NamedScopeHolder.myAllScope;
}
public NamedScope getProblemsScope() {
}
return myProblemsScope;
}
-}
\ No newline at end of file
+}
return processElementsWithWord(occurenceProcessor, searchScope, identifier, UsageSearchContext.IN_COMMENTS, true);
}
- public boolean processElementsWithWord(@NotNull TextOccurenceProcessor processor,
+ public boolean processElementsWithWord(@NotNull final TextOccurenceProcessor processor,
@NotNull SearchScope searchScope,
- @NotNull String text,
+ @NotNull final String text,
short searchContext,
- boolean caseSensitively) {
+ final boolean caseSensitively) {
if (text.length() == 0) {
throw new IllegalArgumentException("Cannot search for elements with empty text");
}
PsiElement[] scopeElements = scope.getScope();
final boolean ignoreInjectedPsi = scope.isIgnoreInjectedPsi();
- for (final PsiElement scopeElement : scopeElements) {
- if (!processElementsWithWordInScopeElement(scopeElement, processor, text, caseSensitively, ignoreInjectedPsi)) return false;
- }
- return true;
+ return JobUtil.invokeConcurrentlyUnderMyProgress(Arrays.asList(scopeElements), new Processor<PsiElement>() {
+ public boolean process(PsiElement scopeElement) {
+ return processElementsWithWordInScopeElement(scopeElement, processor, text, caseSensitively, ignoreInjectedPsi);
+ }
+ }, "textsearch");
}
}
}).booleanValue();
}
- private boolean processElementsWithTextInGlobalScope(final TextOccurenceProcessor processor,
+ private boolean processElementsWithTextInGlobalScope(@NotNull final TextOccurenceProcessor processor,
final GlobalSearchScope scope,
final StringSearcher searcher,
final short searchContext,
myManager.getCacheManager().processFilesWithWord(processor, word, UsageSearchContext.IN_STRINGS, scope, true);
}
- public static enum Result {
- ZERO_OCCURRENCES, FEW_OCCURRENCES, TOO_MANY_OCCURRENCES
- }
- public Result isItCheapEnoughToSearch(@Nullable final PsiFile fileToIgnoreOccurencesIn, @NotNull String name, @NotNull GlobalSearchScope scope) {
+ public SearchCostResult isCheapEnoughToSearch(@NotNull String name, @NotNull GlobalSearchScope scope, @Nullable final PsiFile fileToIgnoreOccurencesIn) {
final int[] count = {0};
if (!processFilesWithText(scope, UsageSearchContext.ANY, true, name, new Processor<PsiFile>() {
public boolean process(PsiFile file) {
}
}
})) {
- return Result.TOO_MANY_OCCURRENCES;
+ return SearchCostResult.TOO_MANY_OCCURRENCES;
}
synchronized (count) {
- return count[0] == 0 ? Result.ZERO_OCCURRENCES : Result.FEW_OCCURRENCES;
+ return count[0] == 0 ? SearchCostResult.ZERO_OCCURRENCES : SearchCostResult.FEW_OCCURRENCES;
}
}
}
}
}
- private static FileBasedIndex ourInstance = CachedSingletonsRegistry.markCachedField(FileBasedIndex.class);
- public static FileBasedIndex getInstance() {
- if (ourInstance == null) {
- ourInstance = ApplicationManager.getApplication().getComponent(FileBasedIndex.class);
- }
+ private static class FileBasedIndexHolder {
+ private static final FileBasedIndex ourInstance = ApplicationManager.getApplication().getComponent(FileBasedIndex.class);
+ }
- return ourInstance;
+ public static FileBasedIndex getInstance() {
+ return FileBasedIndexHolder.ourInstance;
}
/**
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.CachedSingletonsRegistry;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
*/
public abstract class FileTypeManager{
- private static FileTypeManager ourInstance = CachedSingletonsRegistry.markCachedField(FileTypeManager.class);
+ private static class FileTypeManagerHolder {
+ private static final FileTypeManager ourInstance = createFileTypeManager();
+ }
+
/**
* Returns the singleton instance of the FileTypeManager component.
*
* @return the instace of FileTypeManager
*/
public static FileTypeManager getInstance() {
- if (ourInstance == null) {
- Application app = ApplicationManager.getApplication();
- ourInstance = app != null ? app.getComponent(FileTypeManager.class) : new MockFileTypeManager();
- }
- return ourInstance;
+ return FileTypeManagerHolder.ourInstance;
+ }
+
+ private static FileTypeManager createFileTypeManager() {
+ Application app = ApplicationManager.getApplication();
+ return app == null ? new MockFileTypeManager() : app.getComponent(FileTypeManager.class);
}
public abstract void registerFileType(@NotNull FileType type, @NotNull List<FileNameMatcher> defaultAssociations);
public boolean isDisplayInBold() {
return myDisplayInBold;
}
+
+ public void setDisplayInBold(boolean displayInBold) {
+ myDisplayInBold = displayInBold;
+ }
}
@SuppressWarnings({"ConstantConditions"})
import java.util.List;
public abstract class ManagingFS implements FileSystemInterface {
- private static ManagingFS ourInstance = CachedSingletonsRegistry.markCachedField(ManagingFS.class);
+
+ private static class ManagingFSHolder {
+ private static final ManagingFS ourInstance = ApplicationManager.getApplication().getComponent(ManagingFS.class);
+ }
public static ManagingFS getInstance() {
- if (ourInstance == null) {
- ourInstance = ApplicationManager.getApplication().getComponent(ManagingFS.class);
- }
- return ourInstance;
+ return ManagingFSHolder.ourInstance;
}
@Nullable
package com.intellij.ide.ui.search;
-import com.intellij.openapi.application.Application;
-import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.options.Configurable;
+import com.intellij.openapi.options.ConfigurableGroup;
import com.intellij.openapi.options.MasterDetails;
import com.intellij.openapi.options.SearchableConfigurable;
-import com.intellij.openapi.options.ConfigurableGroup;
import com.intellij.openapi.options.ex.GlassPanel;
+import com.intellij.openapi.options.ex.IdeConfigurablesGroup;
+import com.intellij.openapi.options.ex.ProjectConfigurablesGroup;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
}
public static void processProjectConfigurables(Project project, HashMap<SearchableConfigurable, TreeSet<OptionDescription>> options) {
- processConfigurables(project.getExtensions(Configurable.PROJECT_CONFIGURABLES), options);
- processConfigurables(project.getComponents(Configurable.class), options);
- final Application app = ApplicationManager.getApplication();
- processConfigurables(app.getExtensions(Configurable.APPLICATION_CONFIGURABLES), options);
- processConfigurables(app.getComponents(Configurable.class), options);
+ processConfigurables(new ProjectConfigurablesGroup(project, false).getConfigurables(), options);
+ processConfigurables(new IdeConfigurablesGroup().getConfigurables(), options);
}
private static void processConfigurables(final Configurable[] configurables,
myLastUpdated = fsModCount;
if (myFile == null) {
- LOG.assertTrue(myUrl != null);
+ LOG.assertTrue(myUrl != null, "Both file & url are null");
myFile = myVirtualFileManager.findFileByUrl(myUrl);
if (myFile != null) {
myUrl = null;
-error.cannot.show.in.external.browser=Cannot show \"{0}\" in external browser
title.cannot.start.browser=Cannot start browser
error.malformed.url=Malformed url: {0}
error.cannot.start.browser=Cannot start browser: {0}
checkbox.autodetect.utf=Autodetect UTF-encoded files
group.http.proxy=HTTP Proxy
group.web.browser=Web Browser
-radio.use.system.default.browser=Use system default browser
-radio.use.specified.browser=Use
group.general.options=General Options
editbox.ignore.files.and.folders=Ignore files and folders:
checkbox.confirm.application.exit=Confirm application exit
-checkbox.use.cyclic.buffer.in.console=Limit run/debug consoles output to:
label.inactive.timeout.sec= sec.
search.in.the.background=Search in the background
checkbox.save.files.automatically=Save files automatically if application is idle for
checkbox.save.files.on.frame.deactivation=Save files on frame deactivation
checkbox.synchronize.files.on.frame.activation=Synchronize files on frame activation
checkbox.reopen.last.project.on.startup=Reopen last project on startup
-label.kb= Kb.
treenode.loading= loading...
action.clear.list=_Clear List
action.descriptor.action=Action: {0}
button.remove.all=Remove &All
button.move.up=Move &Up
button.move.down=Move &Down
-column.bookmark=Bookmark
column.description=Description
-title.project.elements.bookmarks=Project Elements Bookmarks
bookmark.file.X.line.Y={0}, line {1}
button.view.source=&View Source
-title.editor.bookmarks=Editor Bookmarks
-bookmark.method.at.line={0}, {1}{2}, line {3}
-action.show.bookmarks=_Show Bookmarks
action.toggle.bookmark=Toggle _Bookmark
action.toggle.bookmark.mnemonic=Toggle Bookmark With Mnemonic
-action.set.bookmark=Set _Bookmark
progress.deleting=Deleting
select.in.commander=Commander
errortree.information=Information:
Old versions of project files will be saved to: ''{1}''</body></html>
message.text.unlock.read.only.files=<html><body>The following files are read only. IDEA will unlock them.<br>{0}</body></html>
error.message.cannot.make.files.writable=Cannot make the following files writable:\n{0}
-label.text.project.was.succesfully.converted.old.version.was.saved.to.0=<html><body>Your project was succesfully converted. \
- <br>Old versions of project files were saved to: ''{0}''</body></html>
error.cannot.convert.project=Cannot convert project: {0}
-error.some.file.is.corrupted.message=<html><body>File ''{0}'' is corrupted: <br> {1} </body></html>
message.files.doesn.t.exists.0.so.the.corresponding.modules.won.t.be.converted.do.you.want.to.continue=<html><body>The following files doesn''t exists: <br>\
{0}The corresponding modules won''t be converted. Do you want to continue?</body></html>
message.expiration.date=Expiration date: {0}
message.educational.license=1-Year Educational License. {0}
message.open.source.project.license=Open Source Project License. {0}
-message.evaluation.expires=Evaluation expires: {0}
message.non.commercial.use.only=Non-commercial use only
message.personal.license=Personal License
aboutbox.build.number=Build #{0}
aboutbox.jdk=JDK: {0}
aboutbox.vm=VM: {0}
aboutbox.vendor=Vendor: {0}
-message.license.you.will.need.upgrade=Your license key will expire on {0}.<br>You will need an upgrade to run {1}.<br>To learn more about upgrades, visit {2}
title.warning=Warning
message.upgrade.from.previous.required={0} requires an upgrade from previous versions.<br>You can purchase a license key from the JetBrains website at<br>{1}
title.upgrade.needed=Upgrade Needed
link.click.here.to.license.server.info=More info
link.purchase.commercial.license=To purchase a commercial license, please visit
license.panel.current.license.description=The license will expire on {0,date,MMMM dd, yyyy}
-license.panel.autodescovered.license.server.tile=Default license server
license.panel.buildit.evaluation.expires.in=Remains {0} day(s)
editbox.license.user.name=User name:
editbox.license.license.key=License key:
radio.evaluate=&Evaluate for free for 30 days
radio.default.license.server=&Default License Server
action.activate.tool.window=Activate {0} window
-action.change.splitter.orientations=Change Splitter O_rientations
error.checkforupdates.connection.failed=Connection failed. Please check your network connection and try again.
title.connection.error=Connection Error
editbox.export.settings.to=Export settings to:
prompt.enter.annotation.type.name=Enter a new @interface name:
title.new.annotation.type=New @interface
title.cannot.create.annotation.type=Cannot Create @interface
-progress.creating.annotation.type=Creating @interface {0}.{1}
action.create.new.class=Create New Class
action.create.new.filetype=Create New {0}
action.description.create.new.file=Create New {0}
command.create.directory=Create directory
command.create.package=Create package
action.create.new.enum=Create New Enum
-prompt.enter.new.enum.name=Enter a new enum name:
title.new.enum=New Enum
title.cannot.create.enum=Cannot Create Enum
-progress.creating.enum=Creating enum {0}.{1}
command.create.enum=Create enum
action.create.new.file=Create New File
prompt.enter.new.file.name=Enter a new file name:
command.select.all=Select All
message.no.targets.available=No targets available in this context
title.popup.select.target=Select Target
-title.popup.select.subtarget=Select in {0}
title.popup.recent.files=Recent Files
action.split.vertically=Split _Vertically
action.split.horizontally=Split Hori_zontally
action.toolwindow.todo=TODO
action.toolwindow.inspection=I&nspection
action.toolwindow.favorites=Favorites
-action.unsplit=Un_split
-action.unsplit.all=U_nsplit All
macro.classpath.entry=Entry in the classpath the element belongs to
macro.project.classpath=Project's classpath
macro.column.number=Column number
node.todo.items={0} ({1} {1, choice, 1#item|2#items})
title.appearance=Appearance
group.window.options= Window Options
-checkox.show.buttons.for.disabled.tool.windows=Show buttons for disabled tool windows
checkbox.show.memory.indicator=Show memory indicator
checkbox.show.tool.window.bars=Show tool window bars
checkbox.show.tool.window.numbers=Show tool window numbers
# this string must start with "IDEA"
idea.default.look.and.feel=IDEA (4.5 default)
error.cannot.set.look.and.feel=Cannot set {0} look and feel
-action.add.customization.schema=Add customization scheme
-customizations.schema.default=default
-action.copy.customization.schema=Copy scheme
-action.remove.customization.schema=Remove customization scheme
error.adding.action.without.icon.to.toolbar=You are adding an action without icon to the toolbar. The default icon will be added to this action.
title.unable.to.add.action.without.icon.to.toolbar=Unable to add action without icon to the toolbar
error.please.specify.new.name.for.schema=Please, specify new name for scheme ''{0}''.
button.set.icon=&Set icon
label.icon.path=Icon Path:
button.edit.action.icon=Edit Action &Icon
-editbox.schema.name=Scheme Name:
-editbox.schema.description=Description:
button.add.separator=Add &Separator
button.move.up.u=Move &Up
button.move.down.d=Move &Down
button.add.action.after=Add a&fter...
-customization.schema.default.description=Default unmodified customization scheme
title.custom.actions.schemas=Custom Actions Schemes
title.customizations=Menus and Toolbars
label.choosebyname.no.matches.found=(no matches found)
element.of.class=of class
prompt.do.you.want.to.action_verb.the.method.from_class=Do you want to {0} the base {1,choice,1#method|2#methods}?
jar.no.java.modules.in.project.error=There are no Java modules found in the project.\nOnly Java modules can be jarred.
-jar.no.java.modules.in.project.title=No Modules To Jar Found
jar.build.progress=Building jar {0}...
-jar.build.success.message=Jar has been built in {0}
-jar.build.cancelled=Jar creation has been cancelled
jar.build.error.title=Error Creating Jar
jar.build.progress.title=Building Jar
-jar.build.processing.file.progress=Processing file {0} ...
-error.message.jar.build.cannot.create.temporary.file.in.0=Cannot create temporary file in ''{0}''
-jar.build.cannot.overwrite.error=Cannot overwrite file ''{0}''. Copy has been saved to ''{1}''.
-jar.build.module.presentable.name=Build Jars for module ''{0}''
jar.build.path=Jar file &path:
jar.build.main.class=Main &class:
jar.build.dialog.title=Build Jars
-jar.build.save.title=Save Jar File
-jar.build.main.class.title=Choose Main Class
jar.build.class.not.found=Class ''{0}'' not found
help.not.found.error=Help not found for {0}
help.not.found.title=Help Not Found
updates.check.period.daily=Daily
updates.check.period.weekly=Weekly
updates.check.period.monthly=Monthly
-updates.current.build.unknown=N/A
updates.last.check.never=Never
updates.settings.caption.1=<html>$PRODUCT$ can automatically check for new and updated versions of itself, using your internet connection (when active).<html>
updates.settings.check.now.button=Check Now
jar.build.modules.to.jar=Choose Modules to Jar
jar.build.module.0.jar.settings=Module ''{0}'' Jar Settings
jar.build.include.in.jar.file=Include in jar file:
-jar.build.button=&Build
search.textfield.title=&Search:
select.in.scope=Scope
scope.view.title=Scope
select.in.title.project.view=Project View
several.plugins.depend.on.0.continue.to.remove=Several plugins depend on {0}. Continue to remove?
-project.view.combo.label=View &as:
-
child.tag.0.should.be.defined=''{0}'' child tag should be defined
attribute.0.should.be.defined=''{0}'' attribute should be defined
value.must.not.be.empty=Value must not be empty
plugin.outdated.version.status.tooltip=Plugin has newer version
plugin.download.status.tooltip=Plugin will be activated on next startup
plugin.is.already.installed.status.tooltip=Plugin is installed
-update.plugins.shutdown.action=Update and &Shutdown
update.plugins.update.action=&Update
fail.open.project.message=Unable to open project from ''{0}''
disabled.plugins.warning.message=<li>Plugin <b>\"{0}\"</b> won''t be able to load because required {2, choice, 1#plugin|2#plugins} {1} {2, choice, 1#is|2#are} disabled.</li>
no.class.name.specified=No class name specified
no.parameter.name.specified=No parameter name specified
pass.outer.class.instance.as.parameter=Pass &outer class' instance as a parameter
-pull.up.members.to=&Pull up members of {0} to:
+pull.up.members.to=P&ull up members of {0} to:
members.to.be.pulled.up=Members to be pulled up
make.abstract=Make abstract
javadoc.for.abstracts=JavaDoc for abstracts
import java.io.StringWriter;
import java.util.*;
+//TeamCity inherits StringUtil: do not add private constructors!!!
public class StringUtil {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.util.text.StringUtil");
@NonNls private static final String VOWELS = "aeiouy";
- private StringUtil() {
- }
-
public static String replace(@NonNls @NotNull String text, @NonNls @NotNull String oldS, @NonNls @Nullable String newS) {
return replace(text, oldS, newS, false);
}
import java.awt.event.*;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.util.*;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.regex.Pattern;
return g instanceof PrintGraphics;
}
+ public static int getSelectedButton(ButtonGroup group) {
+ Enumeration<AbstractButton> enumeration = group.getElements();
+ int i = 0;
+ while (enumeration.hasMoreElements()) {
+ AbstractButton button = enumeration.nextElement();
+ if (group.isSelected(button.getModel())) {
+ return i;
+ }
+ i++;
+ }
+ return -1;
+ }
+
+ public static void setSelectedButton(ButtonGroup group, int index) {
+ Enumeration<AbstractButton> enumeration = group.getElements();
+ int i = 0;
+ while (enumeration.hasMoreElements()) {
+ AbstractButton button = enumeration.nextElement();
+ group.setSelected(button.getModel(), index == i);
+ i++;
+ }
+ }
+
}
public boolean PERFORM_ROLLBACK_IN_BACKGROUND = false;
public volatile boolean CHECK_LOCALLY_CHANGED_CONFLICTS_IN_BACKGROUND = false;
public VcsShowConfirmationOption.Value MOVE_TO_FAILED_COMMIT_CHANGELIST = VcsShowConfirmationOption.Value.SHOW_CONFIRMATION;
+ public VcsShowConfirmationOption.Value REMOVE_EMPTY_INACTIVE_CHANGELISTS = VcsShowConfirmationOption.Value.SHOW_CONFIRMATION;
public boolean ENABLE_BACKGROUND_PROCESSES = false;
public int CHANGED_ON_SERVER_INTERVAL = 60;
myId = id;
}
-
+ public int getId() {
+ return myId;
+ }
+
public String toString() {
return String.valueOf(myId);
}
/**
* @author max
+ *
+ * @see com.intellij.openapi.vcs.changes.ChangeListManager#addChangeListListener(ChangeListListener)
+ * @see com.intellij.openapi.vcs.changes.ChangeListManager#removeChangeListListener(ChangeListListener)
*/
public interface ChangeListListener extends EventListener {
void changeListAdded(ChangeList list);
return (ChangeListManagerImpl) project.getComponent(ChangeListManager.class);
}
- public ChangeListManagerImpl(final Project project) {
+ public ChangeListManagerImpl(Project project, final VcsConfiguration config) {
myProject = project;
myChangesViewManager = ChangesViewManager.getInstance(myProject);
myFileStatusManager = FileStatusManager.getInstance(myProject);
myModifier = new Modifier(myWorker, myDelayedNotificator);
myConflictTracker = new ChangelistConflictTracker(project, this, myFileStatusManager, EditorNotifications.getInstance(project));
+
+ myListeners.addListener(new ChangeListAdapter() {
+ @Override
+ public void defaultListChanged(final ChangeList oldDefaultList, ChangeList newDefaultList) {
+ if (!ApplicationManager.getApplication().isUnitTestMode() &&
+ oldDefaultList instanceof LocalChangeList &&
+ oldDefaultList.getChanges().isEmpty()) {
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ switch (config.REMOVE_EMPTY_INACTIVE_CHANGELISTS) {
+
+ case SHOW_CONFIRMATION:
+ VcsConfirmationDialog dialog = new VcsConfirmationDialog(myProject, new VcsShowConfirmationOption() {
+ public Value getValue() {
+ return config.REMOVE_EMPTY_INACTIVE_CHANGELISTS;
+ }
+
+ public void setValue(Value value) {
+ config.REMOVE_EMPTY_INACTIVE_CHANGELISTS = value;
+ }
+ }, "<html>The empty changelist is no longer active.<br>" +
+ "Do you want to remove it?</html>", "Remember my choice");
+ dialog.show();
+ if (!dialog.isOK()) {
+ return;
+ }
+ break;
+ case DO_NOTHING_SILENTLY:
+ return;
+ case DO_ACTION_SILENTLY:
+ break;
+ }
+ removeChangeList((LocalChangeList)oldDefaultList);
+ }
+ });
+ }
+ }
+ });
}
public void projectOpened() {
--- /dev/null
+/*
+ * Copyright 2000-2010 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.vcs.changes;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.vcs.VcsShowConfirmationOption;
+import com.intellij.util.ui.OptionsDialog;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+
+/**
+ * @author Dmitry Avdeev
+ */
+public class VcsConfirmationDialog extends OptionsDialog {
+
+ private final VcsShowConfirmationOption myOption;
+ private final String myMessage;
+ private final String myDoNotShowMessage;
+
+ protected VcsConfirmationDialog(Project project, VcsShowConfirmationOption option, String message, String doNotShowMessage) {
+ super(project);
+ myOption = option;
+ myMessage = message;
+ myDoNotShowMessage = doNotShowMessage;
+
+ init();
+ }
+
+ @Override
+ protected boolean isToBeShown() {
+ return myOption.getValue() == VcsShowConfirmationOption.Value.SHOW_CONFIRMATION;
+ }
+
+ @Override
+ protected void setToBeShown(boolean value, boolean onOk) {
+ myOption.setValue(value ? VcsShowConfirmationOption.Value.SHOW_CONFIRMATION : onOk ? VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY : VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY);
+ }
+
+ @Override
+ protected boolean shouldSaveOptionsOnCancel() {
+ return true;
+ }
+
+ @Override
+ protected JComponent createCenterPanel() {
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.add(new JLabel(myMessage));
+ panel.add(new JLabel(Messages.getQuestionIcon()));
+ return panel;
+ }
+
+ @Override
+ protected String getDoNotShowMessage() {
+ return myDoNotShowMessage;
+ }
+
+ @Override
+ protected Action[] createActions() {
+ return new Action[] {
+ new AbstractAction("Yes") {
+ public void actionPerformed(ActionEvent e) {
+ doOKAction();
+ }
+ }, new AbstractAction("No") {
+ public void actionPerformed(ActionEvent e) {
+ doCancelAction();
+ }
+ }};
+ }
+}
--- /dev/null
+/*
+ * Copyright 2000-2010 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.vcs.changes.actions;
+
+import com.intellij.openapi.actionSystem.AnAction;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+
+public abstract class DiffRequestPresentableProxy implements DiffRequestPresentable {
+ private DiffRequestPresentable myDelegate;
+ private List<? extends AnAction> myCachedActions;
+ private MyResult myStepResult;
+
+ @Nullable
+ protected abstract DiffRequestPresentable init();
+
+ @Nullable
+ private DiffRequestPresentable initRequest() {
+ if (myDelegate == null) {
+ myDelegate = init();
+ }
+ return myDelegate;
+ }
+
+ public List<? extends AnAction> createActions(ShowDiffAction.DiffExtendUIFactory uiFactory) {
+ if (myCachedActions == null) {
+ myCachedActions = initRequest().createActions(uiFactory);
+ }
+ return myCachedActions;
+ }
+
+ public MyResult step() {
+ final DiffRequestPresentable request = initRequest();
+ if (request == null) {
+ return new MyResult(null, DiffPresentationReturnValue.removeFromList);
+ }
+ myStepResult = request.step();
+ return myStepResult;
+ }
+
+ public boolean haveStuff() {
+ final DiffRequestPresentable request = initRequest();
+ if (request == null) {
+ return false;
+ }
+ return request.haveStuff();
+ }
+}
*/
package com.intellij.openapi.vcs.changes.patch;
+import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.diff.impl.patch.FilePatch;
import com.intellij.openapi.diff.impl.patch.PatchReader;
}
private class MyShowDiff extends AnAction {
+ private final MyChangeComparator myMyChangeComparator;
private MyShowDiff() {
super("Show Diff", "Show Diff", IconLoader.getIcon("/actions/diff.png"));
+ myMyChangeComparator = new MyChangeComparator();
}
public void update(AnActionEvent e) {
public void actionPerformed(AnActionEvent e) {
if (myPatches.isEmpty() || (! myContainBasedChanges)) return;
final List<FilePatchInProgress.PatchChange> changes = getAllChanges();
- Collections.sort(changes, MyChangeComparator.getInstance());
+ Collections.sort(changes, myMyChangeComparator);
final List<FilePatchInProgress.PatchChange> selectedChanges = myChangesTreeList.getSelectedChanges();
int selectedIdx = 0;
}
}
- private static class MyChangeComparator implements Comparator<FilePatchInProgress.PatchChange> {
- private static final MyChangeComparator ourInstance = new MyChangeComparator();
-
- public static MyChangeComparator getInstance() {
- return ourInstance;
- }
-
+ private class MyChangeComparator implements Comparator<FilePatchInProgress.PatchChange> {
public int compare(FilePatchInProgress.PatchChange o1, FilePatchInProgress.PatchChange o2) {
+ if (PropertiesComponent.getInstance(myProject).isTrueValue("ChangesBrowser.SHOW_FLATTEN")) {
+ return o1.getPatchInProgress().getIoCurrentBase().getName().compareTo(o2.getPatchInProgress().getIoCurrentBase().getName());
+ }
return o1.getPatchInProgress().getIoCurrentBase().compareTo(o2.getPatchInProgress().getIoCurrentBase());
}
}
import com.intellij.openapi.vcs.changes.SimpleContentRevision;
import com.intellij.openapi.vcs.changes.actions.ChangeDiffRequestPresentable;
import com.intellij.openapi.vcs.changes.actions.DiffRequestPresentable;
+import com.intellij.openapi.vcs.changes.actions.DiffRequestPresentableProxy;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcsUtil.VcsUtil;
import org.jetbrains.annotations.NotNull;
@Nullable
public DiffRequestPresentable createDiffRequestPresentable(final Project project) {
- if (myPatchInProgress.isConflictingChange()) {
- final ApplyPatchForBaseRevisionTexts texts = ApplyPatchForBaseRevisionTexts
- .create(project, myPatchInProgress.getCurrentBase(), new FilePathImpl(myPatchInProgress.getCurrentBase()),
- myPatchInProgress.getPatch());
- if ((texts != null) &&
- (ApplyPatchStatus.SUCCESS.equals(texts.getStatus()) || ApplyPatchStatus.ALREADY_APPLIED.equals(texts.getStatus()))) {
- return new MergedDiffRequestPresentable(project, texts,
- myPatchInProgress.getCurrentBase(), myPatchInProgress.getPatch().getAfterVersionId());
+ return new DiffRequestPresentableProxy() {
+ @Override
+ protected DiffRequestPresentable init() {
+ if (myPatchInProgress.isConflictingChange()) {
+ final ApplyPatchForBaseRevisionTexts texts = ApplyPatchForBaseRevisionTexts
+ .create(project, myPatchInProgress.getCurrentBase(), new FilePathImpl(myPatchInProgress.getCurrentBase()),
+ myPatchInProgress.getPatch());
+ if ((texts != null) &&
+ (ApplyPatchStatus.SUCCESS.equals(texts.getStatus()) || ApplyPatchStatus.ALREADY_APPLIED.equals(texts.getStatus()))) {
+ return new MergedDiffRequestPresentable(project, texts,
+ myPatchInProgress.getCurrentBase(), myPatchInProgress.getPatch().getAfterVersionId());
+ }
+ return null;
+ } else {
+ return new ChangeDiffRequestPresentable(project, PatchChange.this);
+ }
}
- return null;
- } else {
- return new ChangeDiffRequestPresentable(project, this);
- }
+ };
}
}
import com.intellij.openapi.vcs.changes.ContentRevision;
import com.intellij.openapi.vcs.changes.actions.ChangeDiffRequestPresentable;
import com.intellij.openapi.vcs.changes.actions.DiffRequestPresentable;
+import com.intellij.openapi.vcs.changes.actions.DiffRequestPresentableProxy;
import com.intellij.openapi.vcs.changes.actions.ShowDiffAction;
import com.intellij.openapi.vcs.changes.patch.ApplyPatchForBaseRevisionTexts;
import com.intellij.openapi.vcs.changes.patch.MergedDiffRequestPresentable;
}
public static void showShelvedChangesDiff(final DataContext dc) {
- Project project = PlatformDataKeys.PROJECT.getData(dc);
+ final Project project = PlatformDataKeys.PROJECT.getData(dc);
ShelvedChangeList[] changeLists = ShelvedChangesViewManager.SHELVED_CHANGELIST_KEY.getData(dc);
if (changeLists == null) {
changeLists = ShelvedChangesViewManager.SHELVED_RECYCLED_CHANGELIST_KEY.getData(dc);
int toSelectIdx = 0;
final ArrayList<DiffRequestPresentable> diffRequestPresentables = new ArrayList<DiffRequestPresentable>();
- ApplyPatchContext context = new ApplyPatchContext(project.getBaseDir(), 0, false, false);
+ final ApplyPatchContext context = new ApplyPatchContext(project.getBaseDir(), 0, false, false);
final PatchesPreloader preloader = new PatchesPreloader();
final List<String> missing = new LinkedList<String>();
final Change change = shelvedChange.getChange(project);
final String beforePath = shelvedChange.getBeforePath();
try {
- VirtualFile f = FilePatch.findPatchTarget(context, beforePath, shelvedChange.getAfterPath(), beforePath == null);
+ final VirtualFile f = FilePatch.findPatchTarget(context, beforePath, shelvedChange.getAfterPath(), beforePath == null);
if ((f == null) || (! f.exists())) {
if (beforePath != null) {
missing.add(beforePath);
continue;
}
- if (isConflictingChange(change)) {
- TextFilePatch patch = preloader.getPatch(shelvedChange);
- if (patch == null) continue;
-
- final FilePath pathBeforeRename = context.getPathBeforeRename(f);
-
- final ApplyPatchForBaseRevisionTexts threeTexts = ApplyPatchForBaseRevisionTexts.create(project, f, pathBeforeRename, patch);
- if ((threeTexts == null) || (threeTexts.getStatus() == null) || (ApplyPatchStatus.FAILURE.equals(threeTexts.getStatus()))) {
- continue;
+ diffRequestPresentables.add(new DiffRequestPresentableProxy() {
+ @Override
+ protected DiffRequestPresentable init() {
+ if (isConflictingChange(change)) {
+ TextFilePatch patch = preloader.getPatch(shelvedChange);
+ if (patch == null) return null;
+
+ final FilePath pathBeforeRename = context.getPathBeforeRename(f);
+
+ final ApplyPatchForBaseRevisionTexts threeTexts = ApplyPatchForBaseRevisionTexts.create(project, f, pathBeforeRename, patch);
+ if ((threeTexts == null) || (threeTexts.getStatus() == null) || (ApplyPatchStatus.FAILURE.equals(threeTexts.getStatus()))) {
+ return null;
+ }
+
+ return new MergedDiffRequestPresentable(project, threeTexts, f, "Shelved Version");
+ }
+ else {
+ return new ChangeDiffRequestPresentable(project, change);
+ }
}
-
- diffRequestPresentables.add(new MergedDiffRequestPresentable(project, threeTexts, f, "Shelved Version"));
- }
- else {
- diffRequestPresentables.add(new ChangeDiffRequestPresentable(project, change));
- }
+ });
}
catch (IOException e) {
continue;
ChangesViewBalloonProblemNotifier.showMe(project, "Show Diff: Cannot find base for: " + StringUtil.join(missing, ",\n"), MessageType.WARNING);
}
- ShowDiffAction.showDiffImpl(project, diffRequestPresentables, toSelectIdx, ShowDiffAction.DiffExtendUIFactory.NONE, true);
+ ShowDiffAction.showDiffImpl(project, diffRequestPresentables, toSelectIdx, ShowDiffAction.DiffExtendUIFactory.NONE, false);
}
private static class PatchesPreloader {
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.openapi.vcs.configurable.VcsGeneralConfigurationPanel">
- <grid id="7e224" binding="myPanel" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="7e224" binding="myPanel" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="7" y="16" width="868" height="558"/>
<properties/>
<border type="none"/>
<children>
- <grid id="ec55" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
- <margin top="0" left="0" bottom="0" right="0"/>
- <constraints>
- <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties/>
- <border type="none"/>
- <children/>
- </grid>
<vspacer id="5b902">
<constraints>
- <grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+ <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="e714c" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
- <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
</grid>
</children>
</grid>
- <grid id="a5aa5" binding="myPromptsPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="4ec1c" binding="myAddConfirmationPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
- <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
- <minimum-size width="300" height="-1"/>
- </grid>
- </constraints>
- <properties/>
- <border type="etched" title-resource-bundle="messages/VcsBundle" title-key="border.display.dialog.when.commands.invoked"/>
- <children/>
- </grid>
- <hspacer id="308c6">
- <constraints>
- <grid row="3" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
- </constraints>
- </hspacer>
- <grid id="8145c" binding="myRemoveConfirmationPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
- <margin top="0" left="0" bottom="0" right="0"/>
- <constraints>
- <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
- <border type="etched" title="Files Deletion"/>
+ <border type="etched" title="When files are created"/>
<children>
- <component id="ca721" class="javax.swing.JLabel" binding="myRemoveConfirmationLabel">
+ <component id="61373" class="javax.swing.JRadioButton" binding="myShowDialogOnAddingFile">
<constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
- <text resource-bundle="messages/VcsBundle" key="label.after.deletion.group"/>
+ <margin top="2" left="2" bottom="2" right="2"/>
+ <text resource-bundle="messages/VcsBundle" key="radio.after.creation.show.options"/>
</properties>
</component>
- <component id="1256b" class="javax.swing.JRadioButton" binding="myShowDialogOnRemovingFile">
+ <component id="3cc74" class="javax.swing.JRadioButton" binding="myPerformActionOnAddingFile">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
- <margin top="2" left="2" bottom="2" right="2"/>
- <text resource-bundle="messages/VcsBundle" key="radio.after.deletion.show.options"/>
+ <text resource-bundle="messages/VcsBundle" key="radio.after.creation.add.silently"/>
</properties>
</component>
- <component id="f0ee1" class="javax.swing.JRadioButton" binding="myPerformActionOnRemovingFile">
+ <component id="7fc5c" class="javax.swing.JRadioButton" binding="myDoNothingOnAddingFile">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
- <margin top="2" left="2" bottom="2" right="2"/>
- <text resource-bundle="messages/VcsBundle" key="radio.after.deletion.remove.silently"/>
+ <text resource-bundle="messages/VcsBundle" key="radio.after.creation.do.not.add"/>
</properties>
</component>
- <component id="daddb" class="javax.swing.JRadioButton" binding="myDoNothingOnRemovingFile">
+ </children>
+ </grid>
+ <grid id="19911" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <margin top="0" left="0" bottom="0" right="0"/>
+ <constraints>
+ <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties/>
+ <border type="etched" title="When empty changelist becomes inactive"/>
+ <children>
+ <component id="7b546" class="javax.swing.JRadioButton">
<constraints>
- <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
- <preferred-size width="97" height="23"/>
- </grid>
+ <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<margin top="2" left="2" bottom="2" right="2"/>
- <text resource-bundle="messages/VcsBundle" key="radio.after.deletion.do.not.remove"/>
+ <text value="Show options before removing"/>
+ </properties>
+ </component>
+ <component id="59f74" class="javax.swing.JRadioButton">
+ <constraints>
+ <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <text value="Remove silently"/>
+ </properties>
+ </component>
+ <component id="49213" class="javax.swing.JRadioButton">
+ <constraints>
+ <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ </constraints>
+ <properties>
+ <text value="Do not remove"/>
</properties>
</component>
</children>
</grid>
- <grid id="4ec1c" binding="myAddConfirmationPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <grid id="8145c" binding="myRemoveConfirmationPanel" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+ <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
- <border type="etched" title="Files Creation"/>
+ <border type="etched" title="When files are deleted"/>
<children>
- <component id="5d24" class="javax.swing.JLabel" binding="myAddConfirmationLabel">
+ <component id="1256b" class="javax.swing.JRadioButton" binding="myShowDialogOnRemovingFile">
<constraints>
- <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
- <text resource-bundle="messages/VcsBundle" key="label.after.creation."/>
+ <margin top="2" left="2" bottom="2" right="2"/>
+ <text resource-bundle="messages/VcsBundle" key="radio.after.deletion.show.options"/>
</properties>
</component>
- <component id="61373" class="javax.swing.JRadioButton" binding="myShowDialogOnAddingFile">
+ <component id="f0ee1" class="javax.swing.JRadioButton" binding="myPerformActionOnRemovingFile">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<margin top="2" left="2" bottom="2" right="2"/>
- <text resource-bundle="messages/VcsBundle" key="radio.after.creation.show.options"/>
- </properties>
- </component>
- <component id="3cc74" class="javax.swing.JRadioButton" binding="myPerformActionOnAddingFile">
- <constraints>
- <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
- </constraints>
- <properties>
- <text resource-bundle="messages/VcsBundle" key="radio.after.creation.add.silently"/>
+ <text resource-bundle="messages/VcsBundle" key="radio.after.deletion.remove.silently"/>
</properties>
</component>
- <component id="7fc5c" class="javax.swing.JRadioButton" binding="myDoNothingOnAddingFile">
+ <component id="daddb" class="javax.swing.JRadioButton" binding="myDoNothingOnRemovingFile">
<constraints>
- <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+ <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
+ <preferred-size width="97" height="23"/>
+ </grid>
</constraints>
<properties>
- <text resource-bundle="messages/VcsBundle" key="radio.after.creation.do.not.add"/>
+ <margin top="2" left="2" bottom="2" right="2"/>
+ <text resource-bundle="messages/VcsBundle" key="radio.after.deletion.do.not.remove"/>
</properties>
</component>
</children>
</grid>
+ <grid id="a5aa5" binding="myPromptsPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+ <margin top="0" left="0" bottom="0" right="0"/>
+ <constraints>
+ <grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
+ <minimum-size width="300" height="-1"/>
+ </grid>
+ </constraints>
+ <properties/>
+ <border type="etched" title-resource-bundle="messages/VcsBundle" title-key="border.display.dialog.when.commands.invoked"/>
+ <children/>
+ </grid>
+ <hspacer id="308c6">
+ <constraints>
+ <grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+ </constraints>
+ </hspacer>
</children>
</grid>
<buttonGroups>
<member id="f0ee1"/>
<member id="daddb"/>
</group>
+ <group name="myEmptyChangelistRemovingGroup" bound="true">
+ <member id="7b546"/>
+ <member id="59f74"/>
+ <member id="49213"/>
+ </group>
</buttonGroups>
</form>
*/
package com.intellij.openapi.vcs.configurable;
-import com.intellij.openapi.application.ApplicationNamesInfo;
import com.intellij.openapi.options.Configurable;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.project.Project;
private JPanel myAddConfirmationPanel;
private JCheckBox myCbOfferToMoveChanges;
private JComboBox myFailedCommitChangelistCombo;
- private JLabel myRemoveConfirmationLabel;
- private JLabel myAddConfirmationLabel;
+ private ButtonGroup myEmptyChangelistRemovingGroup;
public VcsGeneralConfigurationPanel(final Project project) {
myPromptsPanel.setSize(myPromptsPanel.getPreferredSize());
- myAddConfirmationLabel.setText(VcsBundle.message("add.confirmation.label.text", ApplicationNamesInfo.getInstance().getProductName()));
- myRemoveConfirmationLabel.setText(VcsBundle.message("remove.confirmation.label.text", ApplicationNamesInfo.getInstance().getProductName()));
}
public void apply() throws ConfigurationException {
settings.FORCE_NON_EMPTY_COMMENT = myForceNonEmptyComment.isSelected();
settings.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT = myCbOfferToMoveChanges.isSelected();
+ settings.REMOVE_EMPTY_INACTIVE_CHANGELISTS = getSelected(myEmptyChangelistRemovingGroup);
settings.MOVE_TO_FAILED_COMMIT_CHANGELIST = getFailedCommitConfirm();
for (VcsShowOptionsSettingImpl setting : myPromptOptions.keySet()) {
return VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY;
}
+ private static VcsShowConfirmationOption.Value getSelected(ButtonGroup group) {
+ switch (UIUtil.getSelectedButton(group)) {
+ case 0:
+ return VcsShowConfirmationOption.Value.SHOW_CONFIRMATION;
+ case 1:
+ return VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY;
+ }
+ return VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY;
+ }
private ReadonlyStatusHandlerImpl getReadOnlyStatusHandler() {
return ((ReadonlyStatusHandlerImpl)ReadonlyStatusHandler.getInstance(myProject));
if (settings.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT != myCbOfferToMoveChanges.isSelected()){
return true;
}
+ if (settings.REMOVE_EMPTY_INACTIVE_CHANGELISTS != getSelected(myEmptyChangelistRemovingGroup)){
+ return true;
+ }
if (!Comparing.equal(getFailedCommitConfirm(), settings.MOVE_TO_FAILED_COMMIT_CHANGELIST)) {
return true;
VcsConfiguration settings = VcsConfiguration.getInstance(myProject);
myForceNonEmptyComment.setSelected(settings.FORCE_NON_EMPTY_COMMENT);
myCbOfferToMoveChanges.setSelected(settings.OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT);
+ int id = settings.REMOVE_EMPTY_INACTIVE_CHANGELISTS.getId();
+ UIUtil.setSelectedButton(myEmptyChangelistRemovingGroup, id == 0 ? 0 : id == 1 ? 2 : 1);
myShowReadOnlyStatusDialog.setSelected(getReadOnlyStatusHandler().getState().SHOW_DIALOG);
if (settings.MOVE_TO_FAILED_COMMIT_CHANGELIST == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY) {
myFailedCommitChangelistCombo.setSelectedIndex(0);
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
public class StaticMethodOnlyUsedInOneClassInspection
extends BaseInspection {
}
public BaseInspectionVisitor buildVisitor() {
- return new StaticmethodOnlyUsedInOneClassVisitor();
+ return new StaticMethodOnlyUsedInOneClassVisitor();
}
- private static class StaticmethodOnlyUsedInOneClassVisitor
+ private static class StaticMethodOnlyUsedInOneClassVisitor
extends BaseInspectionVisitor {
@Override public void visitMethod(PsiMethod method) {
}
private static class UsageProcessor implements Processor<PsiReference> {
-
- private PsiClass usageClass = null;
+ private final AtomicReference<PsiClass> foundClass = new AtomicReference<PsiClass>();
public boolean process(PsiReference reference) {
ProgressManager.checkCanceled();
final PsiElement element = reference.getElement();
- final PsiClass usageClass =
- ClassUtils.getContainingClass(element);
- synchronized (this) {
- if (this.usageClass != null &&
- !this.usageClass.equals(usageClass)) {
- this.usageClass = null;
- return false;
- }
- this.usageClass = usageClass;
- }
- return true;
+ PsiClass usageClass = ClassUtils.getContainingClass(element);
+ if (usageClass == null) return true;
+ if (foundClass.compareAndSet(null, usageClass)) return true;
+ PsiClass aClass = foundClass.get();
+ return usageClass.getManager().areElementsEquivalent(aClass, usageClass);
}
/**
final String name = method.getName();
final GlobalSearchScope scope =
GlobalSearchScope.allScope(method.getProject());
- final FindUsagesCostProcessor costProcessor =
- new FindUsagesCostProcessor();
- searchHelper.processAllFilesWithWord(name, scope,
- costProcessor, true);
- if (costProcessor.isCostTooHigh()) {
- return null;
- }
+ if (searchHelper.isCheapEnoughToSearch(name, scope, null)
+ == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return null;
progressManager.runProcess(new Runnable() {
public void run() {
final Query<PsiReference> query =
MethodReferencesSearch.search(method);
- query.forEach(UsageProcessor.this);
+ if (!query.forEach(UsageProcessor.this)) {
+ foundClass.set(null);
+ }
}
}, null);
- synchronized (this) {
- return usageClass;
- }
- }
-
- private static class FindUsagesCostProcessor
- implements Processor<PsiFile> {
-
- private final AtomicInteger counter = new AtomicInteger();
- private volatile boolean costTooHigh = false;
-
- public boolean process(PsiFile psiFile) {
- if (counter.incrementAndGet() >= 10) {
- costTooHigh = true;
- return false;
- }
- return true;
- }
-
- public boolean isCostTooHigh() {
- return costTooHigh;
- }
+ return foundClass.get();
}
}
}
import com.siyeh.ig.BaseInspectionVisitor;
import org.jetbrains.annotations.NotNull;
-import java.util.Collection;
-
public class InterfaceWithOnlyOneDirectInheritorInspection
extends BaseInspection {
ClassInheritorsSearch.search(aClass, searchScope, false).forEach(new PsiElementProcessorAdapter<PsiClass>(processor));
}
}, null);
- final Collection<PsiClass> collection = processor.getCollection();
- return collection.size() == 1;
+ return !processor.isOverflow();
}
}
}
}
}
- private static GroovyTemplatesFactory myInstance = null;
+ private static class GroovyTemplatesFactoryHolder {
+ private static final GroovyTemplatesFactory myInstance = new GroovyTemplatesFactory();
+ }
public static GroovyTemplatesFactory getInstance() {
- if (myInstance == null) {
- myInstance = new GroovyTemplatesFactory();
- }
- return myInstance;
+ return GroovyTemplatesFactoryHolder.myInstance;
}
private final ArrayList<String> myCustomTemplates = new ArrayList<String>();
buffer.append("no parameters");
}
else if (element instanceof GrVariable) {
- final PsiType type = ((GrVariable)element).getTypeGroovy();
+ final PsiElement parent = context.getParameterOwner().getParent();
+ final PsiType type;
+ if (parent instanceof GrMethodCallExpression) {
+ type = ((GrMethodCallExpression)parent).getInvokedExpression().getType();
+ }
+ else {
+ type = ((GrVariable)element).getTypeGroovy();
+ }
if (type instanceof GrClosureType) {
GrClosureParameter[] parameters = ((GrClosureType)type).getSignature().getParameters();
if (parameters.length > 0) {
public Map<String, PsiType> join(ArrayList<Map<String, PsiType>> ins) {
if (ins.size() == 0) return new HashMap<String, PsiType>();
-
+
Map<String, PsiType> result = new HashMap<String, PsiType>(ins.get(0));
for (int i = 1; i < ins.size(); i++) {
if (result.containsKey(name)) {
final PsiType t2 = result.get(name);
if (t1 != null && t2 != null) {
- if (t1.isAssignableFrom(t2)) result.put(name, t1);
- else if (t2.isAssignableFrom(t1)) result.put(name, t2);
- else result.put(name, TypesUtil.getLeastUpperBound(t1, t2, myManager));
- } else {
+ result.put(name, TypesUtil.getLeastUpperBound(t1, t2, myManager));
+ }
+ else {
result.put(name, null);
}
}
final PsiType t2 = e2.get(name);
if (t1 == null || t2 == null) {
if (t1 != null || t2 != null) return false;
- } else {
+ }
+ else {
if (!t1.equals(t2)) return false;
}
}
if (signature.isVarargs()) {
if (isApplicable(params, args, params.length - 1, args.length, manager, scope)) return true;
-
PsiType lastType = params[params.length - 1].getType();
assert lastType instanceof PsiArrayType;
+ if (TypesUtil.isAssignableByMethodCallConversion(lastType, args[args.length - 1], manager, scope)) return true;
+
PsiType varargType = ((PsiArrayType)lastType).getComponentType();
for (int argCount = args.length - 1; argCount >= notOptional; argCount--) {
final PsiClass clazz = getContainingClass();
name = GroovyPropertyUtils.capitalize(name);
GrAccessorMethod getter1 = new GrAccessorMethodImpl(this, false, "get" + name);
- if (hasContradictingMethods(getter1, clazz)) getter1 = null;
-
- GrAccessorMethod getter2 = null;
- if (PsiType.BOOLEAN.equals(getDeclaredType())) {
- getter2 = new GrAccessorMethodImpl(this, false, "is" + name);
- if (hasContradictingMethods(getter2, clazz)) getter2 = null;
- }
+ if (!hasContradictingMethods(getter1, clazz)) {
+ GrAccessorMethod getter2 = null;
+ if (PsiType.BOOLEAN.equals(getDeclaredType())) {
+ getter2 = new GrAccessorMethodImpl(this, false, "is" + name);
+ if (hasContradictingMethods(getter2, clazz)) getter2 = null;
+ }
- if (getter1 != null || getter2 != null) {
- if (getter1 != null && getter2 != null) {
+ if (getter2 != null) {
myGetters = new GrAccessorMethod[]{getter1, getter2};
}
- else if (getter1 != null) {
- myGetters = new GrAccessorMethod[]{getter1};
- }
else {
- myGetters = new GrAccessorMethod[]{getter2};
+ myGetters = new GrAccessorMethod[]{getter1};
}
}
-
}
myGettersInitialized = true;
final boolean isLValue = PsiUtil.isLValue(refExpr);
String[] names;
names = isLValue ? GroovyPropertyUtils.suggestSettersName(name) : GroovyPropertyUtils.suggestGettersName(name);
- List<GroovyResolveResult> list = new ArrayList<GroovyResolveResult>();
for (String getterName : names) {
AccessorResolverProcessor accessorResolver = new AccessorResolverProcessor(getterName, refExpr, !isLValue);
resolveImpl(refExpr, accessorResolver);
- list.addAll(Arrays.asList(accessorResolver.getCandidates()));
+ final GroovyResolveResult[] candidates = accessorResolver.getCandidates();
+ if (candidates.length > 0) return candidates;
}
- if (list.size() > 0) return list.toArray(new GroovyResolveResult[list.size()]);
if (fieldCandidates.length > 0) return fieldCandidates;
EnumSet<ClassHint.ResolveKind> kinds = refExpr.getParent() instanceof GrReferenceExpression
private static final Function<GrMethod, PsiType> ourTypesCalculator = new NullableFunction<GrMethod, PsiType>() {
public PsiType fun(GrMethod method) {
PsiType nominal = getNominalType(method);
- if (nominal != null && nominal.equals(PsiType.VOID)) return nominal;
+ if (PsiType.VOID.equals(nominal)) return nominal;
PsiType inferred = getInferredType(method);
if (nominal == null) {
if (inferred == null) {
myParameters[i] = new GrClosureParameterImpl(parameters[i], substitutor);
}
if (length > 0) {
- myIsVarargs = parameters[length - 1].isVarArgs() || myParameters[length - 1].getType() instanceof PsiArrayType;
+ myIsVarargs = /*parameters[length - 1].isVarArgs() ||*/ myParameters[length - 1].getType() instanceof PsiArrayType;
}
else {
myIsVarargs = false;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod;
+import org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.TypesUtil;
import java.beans.Introspector;
* @author ilyas
*/
public class GroovyPropertyUtils {
+ private static final String IS_PREFIX = "is";
+ private static final String GET_PREFIX = "get";
+
private GroovyPropertyUtils() {
}
if (method == null || method.isConstructor()) return false;
if (method.getParameterList().getParametersCount() != 0) return false;
if (!isGetterName(method.getName())) return false;
+ if (method.getName().startsWith(IS_PREFIX) &&
+ !CommonClassNames.JAVA_LANG_BOOLEAN
+ .equals(TypesUtil.boxPrimitiveType(method.getReturnType(), method.getManager(), method.getResolveScope()).getCanonicalText())) {
+ return false;
+ }
return (propertyName == null || propertyName.equals(getPropertyNameByGetter(method))) && method.getReturnType() != PsiType.VOID;
}
}
@NonNls String methodName = getterMethod.getName();
- if (methodName.startsWith("get") && methodName.length() > 3) {
+ if (methodName.startsWith(GET_PREFIX) && methodName.length() > 3) {
return decapitalize(methodName.substring(3));
}
- else if (methodName.startsWith("is") && methodName.length() > 2 && PsiType.BOOLEAN.equals(getterMethod.getReturnType())) {
+ else if (methodName.startsWith(IS_PREFIX) &&
+ methodName.length() > 2 &&
+ CommonClassNames.JAVA_LANG_BOOLEAN.equals(TypesUtil.boxPrimitiveType(getterMethod.getReturnType(), getterMethod.getManager(),
+ getterMethod.getResolveScope()).getCanonicalText())) {
return decapitalize(methodName.substring(2));
}
return methodName;
}
public static boolean isGetterName(@NotNull String name) {
- if (name.startsWith("get") && name.length() > 3 && isUpperCase(name.charAt(3))) return true;
- if (name.startsWith("is") && name.length() > 2 && isUpperCase(name.charAt(2))) return true;
+ if (name.startsWith(GET_PREFIX) && name.length() > 3 && isUpperCase(name.charAt(3))) return true;
+ if (name.startsWith(IS_PREFIX) && name.length() > 2 && isUpperCase(name.charAt(2))) return true;
return false;
}
+ /**
+ * Returns getter names in priority order
+ * @param name property name
+ * @return getter names
+ */
public static String[] suggestGettersName(@NotNull String name) {
- return new String[]{"get"+capitalize(name), "is"+capitalize(name)};
+ return new String[]{IS_PREFIX + capitalize(name), GET_PREFIX + capitalize(name)};
}
public static String[] suggestSettersName(@NotNull String name) {
public void testStringAndGStringUpperBound() throws Exception {doTest();}
public void testWithMethod() throws Exception {doTest();}
+ public void testByteArrayArgument() throws Exception {doTest();}
public void testForLoopWithNestedEndlessLoop() throws Exception {doTest(new UnassignedVariableAccessInspection());}
public void testIfIncrementElseReturn() throws Exception {doTest(new UnusedDefInspection()); }
PsiElement resolved = ref.resolve();
assertTrue(resolved instanceof GrReferenceExpression);
}
+
+ public void testBooleanProperty() throws Exception {
+ myFixture.configureByText("Abc.groovy", """class A{
+ boolean getFoo(){return true}
+ boolean isFoo(){return false}
+ }
+ print new A().f<caret>oo""");
+ def ref = findReference()
+ def resolved = ref.resolve();
+ assertNotNull resolved
+ assertEquals resolved.getName(), "isFoo"
+ }
+
+ public void testExplicitBooleanProperty() throws Exception {
+ myFixture.configureByText("Abc.groovy", """class A{
+ boolean foo
+ }
+ print new A().f<caret>oo""");
+ def ref = findReference()
+ def resolved = ref.resolve();
+ assertNotNull resolved
+ assertEquals resolved.getName(), "isFoo"
+ }
}
\ No newline at end of file
--- /dev/null
+def foo(byte[] b) {}
+def bar(byte[] b) {
+ foo(b)
+ foo<warning descr="'foo' in 'ByteArrayArgument' cannot be applied to '(java.lang.Integer)'">(239)</warning>
+}
\ No newline at end of file
" <relativePath><caret>xxx</relativePath>" +
"</parent>");
- IntentionAction i = getIntentionAtCaret("Fix relative path");
+ IntentionAction i = getIntentionAtCaret("Fix Relative Path");
assertNotNull(i);
myFixture.launchAction(i);
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiReference;
-import com.intellij.psi.impl.search.PsiSearchHelperImpl;
import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.search.PsiSearchHelper;
import com.intellij.psi.search.searches.ReferencesSearch;
import com.intellij.util.Processor;
import com.intellij.util.SmartList;
original.setText(PropertiesBundle.message("searching.for.property.key.progress.text", property.getUnescapedKey()));
}
- PsiSearchHelperImpl.Result cheapEnough = ((PsiSearchHelperImpl)file.getManager().getSearchHelper()).isItCheapEnoughToSearch(file, property.getName(), searchScope);
- if (cheapEnough == PsiSearchHelperImpl.Result.TOO_MANY_OCCURRENCES) return true;
+ String name = property.getName();
+ if (name == null) return true;
+ PsiSearchHelper.SearchCostResult cheapEnough = file.getManager().getSearchHelper().isCheapEnoughToSearch(name, searchScope, file);
+ if (cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return true;
- final PsiReference usage = cheapEnough == PsiSearchHelperImpl.Result.ZERO_OCCURRENCES ? null :
+ final PsiReference usage = cheapEnough == PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES ? null :
ReferencesSearch.search(property, searchScope, false).findFirst();
- if (usage == null) {
- final ASTNode propertyNode = property.getNode();
- assert propertyNode != null;
+ if (usage != null) {
+ return true;
+ }
+ final ASTNode propertyNode = property.getNode();
+ assert propertyNode != null;
- ASTNode[] nodes = propertyNode.getChildren(null);
- PsiElement key = nodes.length == 0 ? property : nodes[0].getPsi();
- String description = PropertiesBundle.message("unused.property.problem.descriptor.name");
- ProblemDescriptor descriptor = manager.createProblemDescriptor(key, description, RemovePropertyLocalFix.INSTANCE, ProblemHighlightType.LIKE_UNUSED_SYMBOL,
- isOnTheFly);
- synchronized (descriptors) {
- descriptors.add(descriptor);
- }
+ ASTNode[] nodes = propertyNode.getChildren(null);
+ PsiElement key = nodes.length == 0 ? property : nodes[0].getPsi();
+ String description = PropertiesBundle.message("unused.property.problem.descriptor.name");
+ ProblemDescriptor descriptor = manager.createProblemDescriptor(key, description, RemovePropertyLocalFix.INSTANCE, ProblemHighlightType.LIKE_UNUSED_SYMBOL,
+ isOnTheFly);
+ synchronized (descriptors) {
+ descriptors.add(descriptor);
}
return true;
import java.awt.event.KeyEvent;
public class MergeSourceDetailsAction extends AnAction implements DumbAware {
- private static Icon myIcon;
@Override
public void update(AnActionEvent e) {
e.getPresentation().setEnabled(enabled(e));
}
+ private static class IconHolder {
+ private static final Icon myIcon = IconLoader.getIcon("/icons/mergeSourcesDetails.png");
+ }
+
private Icon getIcon() {
- if (myIcon == null) {
- myIcon = IconLoader.getIcon("/icons/mergeSourcesDetails.png");
- }
- return myIcon;
+ return IconHolder.myIcon;
}
public void registerSelf(final JComponent comp) {