Skip to content

Commit

Permalink
issue #16: Make the hyperlinking faster / use less IO - set cache to …
Browse files Browse the repository at this point in the history
…10s and use it also for opening

(still need to refactor the caching aspect into a separate class, but this will be handled in #17)
  • Loading branch information
markiewb committed Jan 21, 2015
1 parent 66cba81 commit 0443410
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public class ResourceHyperlinkProvider implements HyperlinkProviderExt {
public static final String MAVEN_TYPE_OTHER = "Resources"; //NOI18N
public static final String MAVEN_TYPE_TEST_OTHER = "TestResources"; //NOI18N
public static final String MAVEN_TYPE_GEN_SOURCES = "GeneratedSources"; //NOI18N
public static Cache<ResultTO> cache = new Cache<ResultTO>();
private static final int EXPIRE_CACHE_IN_SECONDS = 2;
public static final Cache<ResultTO> cache = new Cache<ResultTO>();
private static final int EXPIRE_CACHE_IN_SECONDS = 10;

public static void openInEditor(FileObject fileToOpen) {
DataObject fileDO;
Expand Down Expand Up @@ -363,7 +363,12 @@ private void updateCacheIfNecessary(Document doc, int offset) {

@Override
public void performClickAction(Document doc, int position, HyperlinkType type) {
ResultTO matches = findResources(doc, position);
updateCacheIfNecessary(doc, position);
if (null == cache.matches) {
return;
}

ResultTO matches = cache.matches;
if (matches.isValid()) {
Collection<FileObject> foundMatches = matches.foundFiles;
final Project project = FileOwnerQuery.getOwner(NbEditorUtilities.getFileObject(doc));
Expand Down Expand Up @@ -440,6 +445,9 @@ private Collection<FileObject> findByClassName(FileObject fo, String fqnClassNam
ClassPath bootCp = ClassPath.getClassPath(fo, ClassPath.BOOT);
ClassPath compileCp = ClassPath.getClassPath(fo, ClassPath.COMPILE);
ClassPath sourcePath = ClassPath.getClassPath(fo, ClassPath.SOURCE);
if (null == bootCp || null == compileCp || null == sourcePath) {
return files;
}
final ClasspathInfo info = ClasspathInfo.create(bootCp, compileCp, sourcePath);
int lastIndexOfDot = fqnClassName.lastIndexOf(".");
String simpleClassName;
Expand Down

0 comments on commit 0443410

Please sign in to comment.