private void highlightHeader(final PsiTreeChangeEvent psiTreeChangeEvent) { final PsiFile file = psiTreeChangeEvent.getFile(); if (null == file) { return; } final Editor editor = PsiUtilBase.findEditor(file); if (null == editor) { return; } impexHeaderNameHighlighterService.highlightCurrentHeader(editor); impexColumnHighlighterService.highlightCurrentColumn(editor); }
@Override protected void updatePsi(PsiTreeChangeEvent event) { boolean runState = myRunState; super.updatePsi(event); if (!runState && myResourceDepends != null && !myUpdateRenderer) { PsiFile psiFile = event.getFile(); if (psiFile == null) { return; } VirtualFile file = psiFile.getVirtualFile(); if (file == null) { return; } for (VirtualFile resourceDir : myResourceDepends) { if (VfsUtilCore.isAncestor(resourceDir, file, false)) { myUpdateRenderer = true; break; } } } }
protected void updatePsi(PsiTreeChangeEvent event) { boolean runState = myRunState; if (myRunState && myFile == event.getFile()) { addRequest(); } if (!runState && !myUpdateRenderer) { PsiFile psiFile = event.getFile(); if (psiFile == null) { return; } VirtualFile file = psiFile.getVirtualFile(); if (file == null) { //ignore } } }
private void handleEvent(final PsiTreeChangeEvent event) { if(event.getParent() != null) { PsiFile containingFile = event.getParent().getContainingFile(); if(containingFile instanceof PropertiesFile) { LOG.debug("Received PSI change event for properties file"); myAlarm.cancelRequest(myRefreshPropertiesRequest); myAlarm.addRequest(myRefreshPropertiesRequest, 500, ModalityState.stateForComponent(GuiEditor.this)); } else if(containingFile instanceof PsiPlainTextFile && containingFile.getFileType().equals(GuiFormFileType.INSTANCE)) { // quick check if relevant String resourceName = FormEditingUtil.buildResourceName(containingFile); if(myDocument.getText().indexOf(resourceName) >= 0) { LOG.debug("Received PSI change event for nested form"); // TODO[yole]: handle multiple nesting myAlarm.cancelRequest(mySynchronizeRequest); myAlarm.addRequest(mySynchronizeRequest, 500, ModalityState.stateForComponent(GuiEditor.this)); } } } }
/** * Handle when callers of FileManagerImpl.invalidateAllPsi() send this event. * Basically we need to listen to property change events here that are not file * oriented, but instead are PSI-oriented, and that pretty much rip out all psi * from underneath this cache. */ @Override public void propertyChanged( @NotNull PsiTreeChangeEvent event ) { PsiFile file = event.getFile(); String propertyName = event.getPropertyName(); if( file == null && (propertyName == null || propertyName.equals( PsiTreeChangeEvent.PROP_FILE_TYPES ) || propertyName.equals( PsiTreeChangeEvent.PROP_ROOTS )) ) { refreshed(); } }
public PropertiesAnchorizer(Project project) { PsiManager.getInstance(project).addPsiTreeChangeListener(new PsiTreeChangeAdapter() { @Override public void childRemoved(@NotNull PsiTreeChangeEvent event) { final PsiElement removed = event.getChild(); if (removed instanceof IProperty) { myAnchors.remove(removed); } } }); }
public void testEditingInDocComment() throws Exception { final Ref<Boolean> gotIt = new Ref<Boolean>(false); getPsiManager().addPsiTreeChangeListener(new PsiTreeChangeAdapter() { @Override public void childReplaced(@NotNull PsiTreeChangeEvent event) { gotIt.set(true); } }); GroovyFile file = GroovyPsiElementFactory.getInstance(myProject).createGroovyFile("/** This is doc comment*/class C{}", true, null); final PsiDocumentManager docManager = PsiDocumentManager.getInstance(myProject); final Document doc = docManager.getDocument(file); assertNotNull(doc); CommandProcessor.getInstance().executeCommand(myProject, new Runnable() { @Override public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { doc.insertString(3, " "); docManager.commitDocument(doc); } }); } }, "file text set", this ); assertTrue(gotIt.get()); }
@Override public void propertyChanged(@NotNull final PsiTreeChangeEvent event) { if(PsiTreeChangeEvent.PROP_ROOTS.equals(event.getPropertyName())) { myAlarm.cancelRequest(myRefreshPropertiesRequest); myAlarm.addRequest(myRefreshPropertiesRequest, 500, ModalityState.stateForComponent(GuiEditor.this)); } }
private void maybeInvalidate(PsiTreeChangeEvent event) { PsiFile file = event.getFile(); if (file == null) { return; } VirtualFile virtualFile = file.getVirtualFile(); synchronized (filesToScan) { filesToScan.add(virtualFile); } }
@Override public void beforeChildAddition(@NotNull final PsiTreeChangeEvent psiTreeChangeEvent) { //this.highlightHeader(psiTreeChangeEvent); }
@Override public void beforeChildRemoval(@NotNull final PsiTreeChangeEvent psiTreeChangeEvent) { //this.highlightHeader(psiTreeChangeEvent); }
@Override public void beforeChildReplacement(@NotNull final PsiTreeChangeEvent psiTreeChangeEvent) { //this.highlightHeader(psiTreeChangeEvent); }
@Override public void beforeChildMovement(@NotNull final PsiTreeChangeEvent psiTreeChangeEvent) { //this.highlightHeader(psiTreeChangeEvent); }
@Override public void beforeChildrenChange(@NotNull final PsiTreeChangeEvent psiTreeChangeEvent) { //this.highlightHeader(psiTreeChangeEvent); }
@Override public void beforePropertyChange(@NotNull final PsiTreeChangeEvent psiTreeChangeEvent) { //this.highlightHeader(psiTreeChangeEvent); }
@Override public void childAdded(@NotNull final PsiTreeChangeEvent psiTreeChangeEvent) { this.highlightHeader(psiTreeChangeEvent); }
@Override public void childRemoved(@NotNull final PsiTreeChangeEvent psiTreeChangeEvent) { this.highlightHeader(psiTreeChangeEvent); }
@Override public void childReplaced(@NotNull final PsiTreeChangeEvent psiTreeChangeEvent) { this.highlightHeader(psiTreeChangeEvent); }
@Override public void childrenChanged(@NotNull final PsiTreeChangeEvent psiTreeChangeEvent) { // this.highlightHeader(psiTreeChangeEvent); }
@Override public void childMoved(@NotNull final PsiTreeChangeEvent psiTreeChangeEvent) { this.highlightHeader(psiTreeChangeEvent); }
@Override public void propertyChanged(@NotNull final PsiTreeChangeEvent psiTreeChangeEvent) { //this.highlightHeader(psiTreeChangeEvent); }
@Override public void childAdded(@NotNull PsiTreeChangeEvent event) { onChange(event.getFile()); }
@Override public void childRemoved(@NotNull PsiTreeChangeEvent event) { onChange(event.getFile()); }
@Override public void childReplaced(@NotNull PsiTreeChangeEvent event) { onChange(event.getFile()); }
@Override public void childMoved(@NotNull PsiTreeChangeEvent event) { onChange(event.getFile()); }
@Override public void childrenChanged(@NotNull PsiTreeChangeEvent event) { onChange(event.getFile()); }
@Override public void propertyChanged(@NotNull PsiTreeChangeEvent event) { onChange(event.getFile()); }
@Override public void beforeChildAddition(@NotNull PsiTreeChangeEvent event) { myBuffer.append("beforeChildAddition\n"); }
@Override public void beforeChildRemoval(@NotNull PsiTreeChangeEvent event) { myBuffer.append("beforeChildRemoval\n"); }
@Override public void beforeChildReplacement(@NotNull PsiTreeChangeEvent event) { myBuffer.append("beforeChildReplacement\n"); }
@Override public void beforeChildMovement(@NotNull PsiTreeChangeEvent event) { myBuffer.append("beforeChildMovement\n"); }
@Override public void beforeChildrenChange(@NotNull PsiTreeChangeEvent event) { myBuffer.append("beforeChildrenChange\n"); }
@Override public void beforePropertyChange(@NotNull PsiTreeChangeEvent event) { myBuffer.append("beforePropertyChange " + event.getPropertyName() + "\n"); }
@Override public void childAdded(@NotNull PsiTreeChangeEvent event) { myBuffer.append("childAdded\n"); }
@Override public void childRemoved(@NotNull PsiTreeChangeEvent event) { myBuffer.append("childRemoved\n"); }
@Override public void childReplaced(@NotNull PsiTreeChangeEvent event) { myBuffer.append("childReplaced\n"); }
@Override public void childrenChanged(@NotNull PsiTreeChangeEvent event) { myBuffer.append("childrenChanged\n"); }
@Override public void childMoved(@NotNull PsiTreeChangeEvent event) { myBuffer.append("childMoved\n"); }
@Override public void propertyChanged(@NotNull PsiTreeChangeEvent event) { myBuffer.append("propertyChanged " + event.getPropertyName() + "\n"); }