/** * Checks whether all includes exists, if they are outside of the project, add a link to the file * to the project * * @param includes */ private void processIncludes(List<OutlineNode> includes, IEditorInput input) { IProject project = getCurrentProject(); if (project == null) return; IFile referFile = (IFile) input.getAdapter(IFile.class); if (referFile == null) return; for (OutlineNode node : includes) { IFile f = null; IFile mainTexFile = TexlipseProperties.getProjectSourceFile(project); if (mainTexFile != null) { // Includes are always relative to the main file f = TexProjectParser.findIFile(node.getName(), mainTexFile, project); } if (f == null) { // Try finding it relative to refering file f = TexProjectParser.findIFile(node.getName(), referFile, project); } if (f == null) { MarkerHandler marker = MarkerHandler.getInstance(); String errorMsg = MessageFormat.format( TexlipsePlugin.getResourceString("parseErrorIncludeNotFound"), new Object[] {node.getName()}); marker.createErrorMarker(referFile, errorMsg, node.getBeginLine()); } } }
/** * Handles a single node when traversing the outline tree. Used recursively. * * @param node * @param document * @param parentDepth * @param newOutlineInput * @return */ private int addNodePosition( OutlineNode node, IDocument document, int parentDepth, TexOutlineInput newOutlineInput) { // add the Document position int beginOffset = 0; int length = 0; Position position = null; try { beginOffset = document.getLineOffset(node.getBeginLine() - 1); if (node.getEndLine() - 1 == document.getNumberOfLines()) length = document.getLength() - beginOffset; else length = document.getLineOffset(node.getEndLine() - 1) - beginOffset; position = new Position(beginOffset, length); document.addPosition("__outline", position); } catch (BadLocationException bpe) { throw new OperationCanceledException(); } catch (BadPositionCategoryException bpce) { throw new OperationCanceledException(); } node.setPosition(position); // add node to outline input newOutlineInput.addNode(node); // iterate through the children List<OutlineNode> children = node.getChildren(); int maxDepth = parentDepth + 1; if (children != null) { for (Iterator<OutlineNode> iter = children.iterator(); iter.hasNext(); ) { int localDepth = addNodePosition(iter.next(), document, parentDepth + 1, newOutlineInput); if (localDepth > maxDepth) { maxDepth = localDepth; } } } return maxDepth; }