mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 23:39:39 +07:00
optimisation: do not load document during smart pointer creation
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -416,4 +416,22 @@ public class SmartPsiElementPointersTest extends CodeInsightTestCase {
|
||||
Assert.assertNotNull(pointer1.getRange());
|
||||
}
|
||||
}
|
||||
|
||||
public void testSmartPointerCreationDoesNotLoadDocument() {
|
||||
PsiPackage aPackage = myJavaFacade.findPackage("java.io");
|
||||
SmartPointerManagerImpl smartPointerManager = (SmartPointerManagerImpl)SmartPointerManager.getInstance(myProject);
|
||||
for (PsiClass aClass : aPackage.getClasses()) {
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
|
||||
PsiFile file = aClass.getContainingFile();
|
||||
Document document = documentManager.getCachedDocument(file);
|
||||
if (document == null) { //ignore already loaded documents
|
||||
SmartPsiElementPointer pointer = smartPointerManager.createSmartPsiElementPointer(aClass);
|
||||
assertNull(documentManager.getCachedDocument(file));
|
||||
//System.out.println("file = " + file);
|
||||
}
|
||||
else {
|
||||
System.out.println("already loaded file = " + file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
* Copyright 2000-2014 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.
|
||||
@@ -62,14 +62,14 @@ public class SelfElementInfo implements SmartPointerElementInfo {
|
||||
|
||||
myProject = project;
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
|
||||
Document document = documentManager.getDocument(containingFile);
|
||||
if (document == null || documentManager.isUncommited(document)) {
|
||||
Document document = documentManager.getCachedDocument(containingFile);
|
||||
if (document != null && documentManager.isUncommited(document)) {
|
||||
mySyncMarkerIsValid = false;
|
||||
return;
|
||||
}
|
||||
|
||||
mySyncMarkerIsValid = true;
|
||||
setRange(range);
|
||||
else {
|
||||
mySyncMarkerIsValid = true;
|
||||
setRange(range);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setRange(@NotNull Segment range) {
|
||||
|
||||
Reference in New Issue
Block a user