use of org.python.pydev.core.IInfo in project Pydev by fabioz.
the class TreeIO method dumpTreeToBuffer.
/**
* Tree is written as:
* line 1= tree size
* cub|2|CubeColourDialog!13&999@CUBIC!263@cube!202&999@
*/
public static void dumpTreeToBuffer(SortedMap<String, Set<IInfo>> tree, FastStringBuffer tempBuf, Map<String, Integer> strToInt) {
Set<Entry<String, Set<IInfo>>> entrySet = tree.entrySet();
Iterator<Entry<String, Set<IInfo>>> it = entrySet.iterator();
tempBuf.append(entrySet.size());
tempBuf.append('\n');
while (it.hasNext()) {
Entry<String, Set<IInfo>> next = it.next();
tempBuf.append(next.getKey());
Set<IInfo> value = next.getValue();
tempBuf.append('|');
tempBuf.append(value.size());
tempBuf.append('|');
Iterator<IInfo> it2 = value.iterator();
Integer integer;
while (it2.hasNext()) {
IInfo info = it2.next();
tempBuf.append(info.getName());
tempBuf.append(NAME_CHAR_SEPARATOR);
String path = info.getPath();
if (path != null) {
integer = strToInt.get(path);
if (integer == null) {
integer = strToInt.size() + 1;
strToInt.put(path, integer);
}
tempBuf.append(integer);
tempBuf.append(PATH_CHAR_SEPARATOR);
}
String file = info.getFile();
if (file != null) {
integer = strToInt.get(file);
if (integer == null) {
integer = strToInt.size() + 1;
strToInt.put(file, integer);
}
tempBuf.append(integer);
tempBuf.append(FILE_CHAR_SEPARATOR);
}
tempBuf.append(info.getLine());
tempBuf.append(LINE_CHAR_SEPARATOR);
tempBuf.append(info.getCol());
tempBuf.append(COL_CHAR_SEPARATOR);
String modName = info.getDeclaringModuleName();
integer = strToInt.get(modName);
if (integer == null) {
integer = strToInt.size() + 1;
strToInt.put(modName, integer);
}
int v = integer << 3;
v |= info.getType();
// Write a single for name+type
tempBuf.append(v);
tempBuf.append('@');
}
tempBuf.append('\n');
}
tempBuf.append("-- END TREE\n");
}
use of org.python.pydev.core.IInfo in project Pydev by fabioz.
the class AbstractAdditionalDependencyInfo method addInfoToModuleOnRestoreInsertCommand.
protected void addInfoToModuleOnRestoreInsertCommand(Tuple<ModulesKey, List<IInfo>> data) {
CompleteIndexKey key = new CompleteIndexKey(data.o1);
if (data.o1.file != null) {
key.lastModified = FileUtils.lastModified(data.o1.file);
}
completeIndex.add(key);
// current way (saves a list of iinfo)
for (Iterator<IInfo> it = data.o2.iterator(); it.hasNext(); ) {
IInfo info = it.next();
if (info.getPath() == null || info.getPath().length() == 0) {
this.add(info, TOP_LEVEL);
} else {
this.add(info, INNER);
}
}
}
use of org.python.pydev.core.IInfo in project Pydev by fabioz.
the class AbstractAdditionalDependencyInfo method addAstInfo.
@Override
public List<IInfo> addAstInfo(SimpleNode node, ModulesKey key, boolean generateDelta) {
List<IInfo> addAstInfo = new ArrayList<IInfo>();
if (node == null || key == null || key.name == null) {
return addAstInfo;
}
try {
synchronized (lock) {
addAstInfo = super.addAstInfo(node, key, generateDelta);
CompleteIndexKey completeIndexKey = new CompleteIndexKey(key);
if (key.file != null) {
completeIndexKey.lastModified = FileUtils.lastModified(key.file);
}
completeIndex.add(completeIndexKey);
}
} catch (Exception e) {
Log.log(e);
}
return addAstInfo;
}
use of org.python.pydev.core.IInfo in project Pydev by fabioz.
the class IOUtils method addAstInfo.
/**
* Adds ast info information for a module.
*
* @param m the module we want to add to the info
*/
public List<IInfo> addAstInfo(SimpleNode node, ModulesKey key, boolean generateDelta) {
List<IInfo> createdInfos = new ArrayList<IInfo>();
if (node == null || key.name == null) {
return createdInfos;
}
try {
Tuple<DefinitionsASTIteratorVisitor, Iterator<ASTEntry>> tup = getInnerEntriesForAST(node);
if (DebugSettings.DEBUG_ANALYSIS_REQUESTS) {
org.python.pydev.shared_core.log.ToLogFile.toLogFile(this, "Adding ast info to: " + key.name);
}
try {
Iterator<ASTEntry> entries = tup.o2;
FastStack<SimpleNode> tempStack = new FastStack<SimpleNode>(10);
synchronized (this.lock) {
synchronized (ObjectsInternPool.lock) {
final String file = key.file != null ? ObjectsInternPool.internUnsynched(key.file.toString()) : null;
key.name = ObjectsInternPool.internUnsynched(key.name);
while (entries.hasNext()) {
ASTEntry entry = entries.next();
IInfo infoCreated = null;
if (entry.parent == null) {
// we only want those that are in the global scope
if (entry.node instanceof ClassDef) {
// no intern construct (locked in this loop)
NameTok name = (NameTok) ((ClassDef) entry.node).name;
ClassInfo info = new ClassInfo(ObjectsInternPool.internUnsynched(name.id), key.name, null, false, getNature(), file, name.beginLine, name.beginColumn);
add(info, TOP_LEVEL);
infoCreated = info;
} else if (entry.node instanceof FunctionDef) {
// no intern construct (locked in this loop)
NameTok name = (NameTok) ((FunctionDef) entry.node).name;
FuncInfo info2 = new FuncInfo(ObjectsInternPool.internUnsynched(name.id), key.name, null, false, getNature(), file, name.beginLine, name.beginColumn);
add(info2, TOP_LEVEL);
infoCreated = info2;
} else {
// it is an assign
infoCreated = this.addAssignTargets(entry, key.name, TOP_LEVEL, null, false, file);
}
} else {
if (entry.node instanceof ClassDef || entry.node instanceof FunctionDef) {
// ok, it has a parent, so, let's check to see if the path we got only has class definitions
// as the parent (and get that path)
Tuple<String, Boolean> pathToRoot = this.getPathToRoot(entry, false, false, tempStack);
if (pathToRoot != null && pathToRoot.o1 != null && pathToRoot.o1.length() > 0) {
if (entry.node instanceof ClassDef) {
NameTok name = ((NameTok) ((ClassDef) entry.node).name);
ClassInfo info = new ClassInfo(ObjectsInternPool.internUnsynched(name.id), key.name, ObjectsInternPool.internUnsynched(pathToRoot.o1), false, getNature(), file, name.beginLine, name.beginColumn);
add(info, INNER);
infoCreated = info;
} else {
// FunctionDef
NameTok name = ((NameTok) ((FunctionDef) entry.node).name);
FuncInfo info2 = new FuncInfo(ObjectsInternPool.internUnsynched(name.id), key.name, ObjectsInternPool.internUnsynched(pathToRoot.o1), false, getNature(), file, name.beginLine, name.beginColumn);
add(info2, INNER);
infoCreated = info2;
}
}
} else {
// it is an assign
Tuple<String, Boolean> pathToRoot = this.getPathToRoot(entry, true, false, tempStack);
if (pathToRoot != null && pathToRoot.o1 != null && pathToRoot.o1.length() > 0) {
infoCreated = this.addAssignTargets(entry, key.name, INNER, pathToRoot.o1, pathToRoot.o2, file);
}
}
}
if (infoCreated != null) {
createdInfos.add(infoCreated);
}
}
// end while
}
// end lock ObjectsPool.lock
}
// end this.lock
} catch (Exception e) {
Log.log(e);
}
} catch (Exception e) {
Log.log(e);
}
return createdInfos;
}
use of org.python.pydev.core.IInfo in project Pydev by fabioz.
the class IOUtils method getAllTokens.
/**
* @return all the tokens that are in this info (top level or inner)
*/
public Collection<IInfo> getAllTokens() {
synchronized (lock) {
Collection<Set<IInfo>> lInfo = this.topLevelInitialsToInfo.values();
ArrayList<IInfo> toks = new ArrayList<IInfo>();
for (Set<IInfo> list : lInfo) {
for (IInfo info : list) {
toks.add(info);
}
}
lInfo = this.innerInitialsToInfo.values();
for (Set<IInfo> list : lInfo) {
for (IInfo info : list) {
toks.add(info);
}
}
return toks;
}
}
Aggregations