use of org.python.pydev.shared_core.parsing.IParserObserver in project Pydev by fabioz.
the class PyGoToDefinition method run.
/**
* Overrides the run and calls -- and the whole default refactoring cycle from the beggining,
* because unlike most refactoring operations, this one can work with dirty editors.
* @return
*/
@Override
public void run(IAction action) {
workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IEditorPart[] dirtyEditors = workbenchWindow.getActivePage().getDirtyEditors();
Set<PyEdit> askReparse = new HashSet<PyEdit>();
for (IEditorPart iEditorPart : dirtyEditors) {
if (iEditorPart instanceof PyEdit) {
PyEdit pyEdit = (PyEdit) iEditorPart;
long astModificationTimeStamp = pyEdit.getAstModificationTimeStamp();
IDocument doc = pyEdit.getDocument();
if (astModificationTimeStamp != -1 && astModificationTimeStamp == (((IDocumentExtension4) doc).getModificationStamp())) {
// All OK, the ast is synched!
} else {
askReparse.add(pyEdit);
}
}
}
if (askReparse.size() == 0) {
findDefinitionsAndOpen(true);
} else {
// We don't have a match: ask for a reparse
Object lock = new Object();
for (PyEdit pyEdit : askReparse) {
IParserObserver observer = new FindParserObserver(pyEdit, askReparse, lock);
PyParser parser = pyEdit.getParser();
// it will analyze when the next parse is finished
parser.addParseListener(observer);
parser.forceReparse();
}
}
}
use of org.python.pydev.shared_core.parsing.IParserObserver in project Pydev by fabioz.
the class PyParser method fireParserError.
/**
* stock listener implementation event is fired when parse fails
* @param original
*/
@Override
@SuppressWarnings("unchecked")
protected void fireParserError(ErrorParserInfoForObservers info) {
super.fireParserError(info);
List<IParserObserver> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_PARSER_OBSERVER);
for (IParserObserver observer : participants) {
if (observer instanceof IParserObserver3) {
((IParserObserver3) observer).parserError(info);
} else if (observer instanceof IParserObserver2) {
((IParserObserver2) observer).parserError(info.error, info.file, info.doc, info.argsToReparse);
} else {
observer.parserError(info.error, info.file, info.doc);
}
}
}
use of org.python.pydev.shared_core.parsing.IParserObserver in project Pydev by fabioz.
the class PyParser method fireParserChanged.
/**
* stock listener implementation event is fired whenever we get a new root
* @param original
*/
@Override
@SuppressWarnings("unchecked")
protected void fireParserChanged(ChangedParserInfoForObservers info) {
super.fireParserChanged(info);
List<IParserObserver> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_PARSER_OBSERVER);
for (IParserObserver observer : participants) {
try {
if (observer instanceof IParserObserver3) {
((IParserObserver3) observer).parserChanged(info);
} else if (observer instanceof IParserObserver2) {
((IParserObserver2) observer).parserChanged(info.root, info.file, info.doc, info.argsToReparse);
} else {
observer.parserChanged(info.root, info.file, info.doc, info.docModificationStamp);
}
} catch (Exception e) {
Log.log(e);
}
}
}
Aggregations