Java Code Examples for org.eclipse.jdt.core.IBuffer

The following examples show how to use org.eclipse.jdt.core.IBuffer. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: lapse-plus   Source File: LapseView.java    License: GNU General Public License v3.0 6 votes vote down vote up
private CompilationUnit internalSetInput(IOpenable input) throws CoreException {
	IBuffer buffer = input.getBuffer();
	if (buffer == null) {
		JavaPlugin.logErrorMessage("Input has no buffer"); //$NON-NLS-1$
	}
	if (input instanceof ICompilationUnit) {
		fParser.setSource((ICompilationUnit) input);
	} else {
		fParser.setSource((IClassFile) input);
	}

	try {
		CompilationUnit root = (CompilationUnit) fParser.createAST(null);
		log("Recomputed the AST for " + buffer.getUnderlyingResource().getName());
						
		if (root == null) {
			JavaPlugin.logErrorMessage("Could not create AST"); //$NON-NLS-1$
		}

		return root;
	} catch (RuntimeException e) {
		JavaPlugin.logErrorMessage("Could not create AST:\n" + e.getMessage()); //$NON-NLS-1$
		return null;
	}
}
 
Example 2
private String getContents(IClassFile cf) {
    String source = null;
    if (cf != null) {
        try {
            IBuffer buffer = cf.getBuffer();
            if (buffer != null) {
                source = buffer.getContents();
            }
        } catch (JavaModelException e) {
            logger.log(Level.SEVERE, String.format("Failed to parse the source contents of the class file: %s", e.toString()), e);
        }
        if (source == null) {
            source = "";
        }
    }
    return source;
}
 
Example 3
Source Project: eclipse.jdt.ls   Source File: JDTUtils.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates a range for the given offset and length for an {@link IOpenable}
 *
 * @param openable
 * @param offset
 * @param length
 * @return
 * @throws JavaModelException
 */
public static Range toRange(IOpenable openable, int offset, int length) throws JavaModelException{
	Range range = newRange();
	if (offset > 0 || length > 0) {
		int[] loc = null;
		int[] endLoc = null;
		IBuffer buffer = openable.getBuffer();
		if (buffer != null) {
			loc = JsonRpcHelpers.toLine(buffer, offset);
			endLoc = JsonRpcHelpers.toLine(buffer, offset + length);
		}
		if (loc == null) {
			loc = new int[2];
		}
		if (endLoc == null) {
			endLoc = new int[2];
		}
		setPosition(range.getStart(), loc);
		setPosition(range.getEnd(), endLoc);
	}
	return range;
}
 
Example 4
Source Project: eclipse.jdt.ls   Source File: Util.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private static boolean isJustWhitespaceOrComment(int start, int end, IBuffer buffer) {
	if (start == end) {
		return true;
	}
	Assert.isTrue(start <= end);
	String trimmedText = buffer.getText(start, end - start).trim();
	if (0 == trimmedText.length()) {
		return true;
	} else {
		IScanner scanner = ToolFactory.createScanner(false, false, false, null);
		scanner.setSource(trimmedText.toCharArray());
		try {
			return scanner.getNextToken() == ITerminalSymbols.TokenNameEOF;
		} catch (InvalidInputException e) {
			return false;
		}
	}
}
 
Example 5
@Override
public String getSource(IClassFile classFile, IProgressMonitor monitor) throws CoreException {
	String source = null;
	try {
		IBuffer buffer = classFile.getBuffer();
		if (buffer == null) {
			ProjectsManager projectsManager = JavaLanguageServerPlugin.getProjectsManager();
			if (projectsManager != null) {
				Optional<IBuildSupport> bs = projectsManager.getBuildSupport(classFile.getJavaProject().getProject());
				if (bs.isPresent()) {
					bs.get().discoverSource(classFile, monitor);
				}
			}
			buffer = classFile.getBuffer();
		}
		if (buffer != null) {
			source = buffer.getContents();
			JavaLanguageServerPlugin.logInfo("ClassFile contents request completed");
		}
	} catch (JavaModelException e) {
		JavaLanguageServerPlugin.logException("Exception getting java element ", e);
	}
	return source;
}
 
Example 6
/**
 * Gets a reader for an IMember's Javadoc comment content from the source attachment.
 * The content does contain only the text from the comment without the Javadoc leading star characters.
 * Returns <code>null</code> if the member does not contain a Javadoc comment or if no source is available.
 * @param member The member to get the Javadoc of.
 * @return Returns a reader for the Javadoc comment content or <code>null</code> if the member
 * does not contain a Javadoc comment or if no source is available
 * @throws JavaModelException is thrown when the elements javadoc can not be accessed
 * @since 3.4
 */
private static Reader internalGetContentReader(IMember member) throws JavaModelException {
	IBuffer buf= member.getOpenable().getBuffer();
	if (buf == null) {
		return null; // no source attachment found
	}

	ISourceRange javadocRange= member.getJavadocRange();
	if (javadocRange != null) {
		JavaDocCommentReader reader= new JavaDocCommentReader(buf, javadocRange.getOffset(), javadocRange.getOffset() + javadocRange.getLength() - 1);
		if (!containsOnlyInheritDoc(reader, javadocRange.getLength())) {
			reader.reset();
			return reader;
		}
	}

	return null;
}
 
Example 7
Source Project: eclipse.jdt.ls   Source File: JsonRpcHelpers.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private static <T> T convert(IOpenable openable, Function<IDocument, T> consumer) throws JavaModelException {
	Assert.isNotNull(openable, "openable");
	boolean mustClose = false;
	try {
		if (!openable.isOpen()) {
			openable.open(new NullProgressMonitor());
			mustClose = openable.isOpen();
		}
		IBuffer buffer = openable.getBuffer();
		return consumer.apply(toDocument(buffer));
	} finally {
		if (mustClose) {
			try {
				openable.close();
			} catch (JavaModelException e) {
				JavaLanguageServerPlugin.logException("Error when closing openable: " + openable, e);
			}
		}
	}
}
 
Example 8
public static void codeComplete(ICompilationUnit cu, int position, CompletionRequestor requestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException {
	if (!(cu instanceof CompilationUnit)) {
		return;
	}

	if (requestor == null) {
		throw new IllegalArgumentException("Completion requestor cannot be null"); //$NON-NLS-1$
	}

	IBuffer buffer = cu.getBuffer();
	if (buffer == null) {
		return;
	}

	if (position < -1 || position > buffer.getLength()) {
		throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.INDEX_OUT_OF_BOUNDS));
	}

	JavaProject project = (JavaProject) cu.getJavaProject();
	ModelBasedSearchableEnvironment environment = new ModelBasedSearchableEnvironment(project, owner, requestor.isTestCodeExcluded());
	environment.setUnitToSkip((CompilationUnit) cu);

	// code complete
	CompletionEngine engine = new CompletionEngine(environment, requestor, project.getOptions(true), project, owner, monitor);
	engine.complete((CompilationUnit) cu, position, 0, cu);
}
 
Example 9
Source Project: jd-eclipse   Source File: JDClassFileEditor.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected static void cleanupBuffer(IClassFile file) {
	IBuffer buffer = BufferManager.getDefaultBufferManager().getBuffer(file);

	if (buffer != null) {
		try {
			// Remove the buffer
			Method method = BufferManager.class.getDeclaredMethod("removeBuffer", new Class[] {IBuffer.class});
			method.setAccessible(true);
			method.invoke(BufferManager.getDefaultBufferManager(), new Object[] {buffer});				
		} catch (Exception e) {
			JavaDecompilerPlugin.getDefault().getLog().log(new Status(
				Status.ERROR, JavaDecompilerPlugin.PLUGIN_ID, 
				0, e.getMessage(), e));
		}
	}
}
 
Example 10
Source Project: jenerate   Source File: JavaCodeFormatterImpl.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Examines a string and returns the first line delimiter found.
 */
private static String getLineDelimiterUsed(IJavaElement elem) throws JavaModelException {
    ICompilationUnit cu = (ICompilationUnit) elem.getAncestor(IJavaElement.COMPILATION_UNIT);
    if (cu != null && cu.exists()) {
        IBuffer buf = cu.getBuffer();
        int length = buf.getLength();
        for (int i = 0; i < length; i++) {
            char ch = buf.getChar(i);
            if (ch == SWT.CR) {
                if (i + 1 < length) {
                    if (buf.getChar(i + 1) == SWT.LF) {
                        return "\r\n";
                    }
                }
                return "\r";
            } else if (ch == SWT.LF) {
                return "\n";
            }
        }
    }
    return System.getProperty("line.separator", "\n");
}
 
Example 11
Source Project: jenerate   Source File: JavaCodeFormatterImpl.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Evaluates the indentation used by a Java element. (in tabulators)
 */
private int getUsedIndentation(IJavaElement elem) throws JavaModelException {
    if (elem instanceof ISourceReference) {
        ICompilationUnit cu = (ICompilationUnit) elem.getAncestor(IJavaElement.COMPILATION_UNIT);
        if (cu != null) {
            IBuffer buf = cu.getBuffer();
            int offset = ((ISourceReference) elem).getSourceRange().getOffset();
            int i = offset;
            // find beginning of line
            while (i > 0 && !isLineDelimiterChar(buf.getChar(i - 1))) {
                i--;
            }
            return computeIndent(buf.getText(i, offset - i), getTabWidth());
        }
    }
    return 0;
}
 
Example 12
private static String getFieldSource(IField field, SourceTuple tuple) throws CoreException {
	if (Flags.isEnum(field.getFlags())) {
		String source= field.getSource();
		if (source != null)
			return source;
	} else {
		if (tuple.node == null) {
			ASTParser parser= ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
			parser.setSource(tuple.unit);
			tuple.node= (CompilationUnit) parser.createAST(null);
		}
		FieldDeclaration declaration= ASTNodeSearchUtil.getFieldDeclarationNode(field, tuple.node);
		if (declaration.fragments().size() == 1)
			return getSourceOfDeclararationNode(field, tuple.unit);
		VariableDeclarationFragment declarationFragment= ASTNodeSearchUtil.getFieldDeclarationFragmentNode(field, tuple.node);
		IBuffer buffer= tuple.unit.getBuffer();
		StringBuffer buff= new StringBuffer();
		buff.append(buffer.getText(declaration.getStartPosition(), ((ASTNode) declaration.fragments().get(0)).getStartPosition() - declaration.getStartPosition()));
		buff.append(buffer.getText(declarationFragment.getStartPosition(), declarationFragment.getLength()));
		buff.append(";"); //$NON-NLS-1$
		return buff.toString();
	}
	return ""; //$NON-NLS-1$
}
 
Example 13
private void initCallTextAndLineNumber() {
	if (fCallText != null)
		return;

    IBuffer buffer= getBufferForMember();
    if (buffer == null || buffer.getLength() < fEnd) { //binary, without source attachment || buffer contents out of sync (bug 121900)
    	fCallText= ""; //$NON-NLS-1$
    	fLineNumber= UNKNOWN_LINE_NUMBER;
    	return;
    }

    fCallText= buffer.getText(fStart, (fEnd - fStart));

    if (fLineNumber == UNKNOWN_LINE_NUMBER) {
        Document document= new Document(buffer.getContents());
        try {
            fLineNumber= document.getLineOfOffset(fStart) + 1;
        } catch (BadLocationException e) {
            JavaPlugin.log(e);
        }
    }
}
 
Example 14
private static boolean isJustWhitespaceOrComment(int start, int end, IBuffer buffer) {
	if (start == end)
		return true;
	Assert.isTrue(start <= end);
	String trimmedText= buffer.getText(start, end - start).trim();
	if (0 == trimmedText.length()) {
		return true;
	} else {
		IScanner scanner= ToolFactory.createScanner(false, false, false, null);
		scanner.setSource(trimmedText.toCharArray());
		try {
			return scanner.getNextToken() == ITerminalSymbols.TokenNameEOF;
		} catch (InvalidInputException e) {
			return false;
		}
	}
}
 
Example 15
/**
 * Returns the source of the given node from the location where it was parsed.
 * @param node the node to get the source from
 * @param extendedRange if set, the extended ranges of the nodes should ne used
 * @param removeIndent if set, the indentation is removed.
 * @return return the source for the given node or null if accessing the source failed.
 */
public static String getNodeSource(ASTNode node, boolean extendedRange, boolean removeIndent) {
	ASTNode root= node.getRoot();
	if (root instanceof CompilationUnit) {
		CompilationUnit astRoot= (CompilationUnit) root;
		ITypeRoot typeRoot= astRoot.getTypeRoot();
		try {
			if (typeRoot != null && typeRoot.getBuffer() != null) {
				IBuffer buffer= typeRoot.getBuffer();
				int offset= extendedRange ? astRoot.getExtendedStartPosition(node) : node.getStartPosition();
				int length= extendedRange ? astRoot.getExtendedLength(node) : node.getLength();
				String str= buffer.getText(offset, length);
				if (removeIndent) {
					IJavaProject project= typeRoot.getJavaProject();
					int indent= StubUtility.getIndentUsed(buffer, node.getStartPosition(), project);
					str= Strings.changeIndent(str, indent, project, new String(), typeRoot.findRecommendedLineSeparator());
				}
				return str;
			}
		} catch (JavaModelException e) {
			// ignore
		}
	}
	return null;
}
 
Example 16
private int getNameEnd(IBuffer doc, int pos) {
	if (pos > 0) {
		if (Character.isWhitespace(doc.getChar(pos - 1))) {
			return pos;
		}
	}
	int len= doc.getLength();
	while (pos < len) {
		char ch= doc.getChar(pos);
		if (!Character.isJavaIdentifierPart(ch)) {
			return pos;
		}
		pos++;
	}
	return pos;
}
 
Example 17
/**
 * Gets a reader for an IMember's Javadoc comment content from the source attachment.
 * The content does contain only the text from the comment without the Javadoc leading star characters.
 * Returns <code>null</code> if the member does not contain a Javadoc comment or if no source is available.
 * @param member The member to get the Javadoc of.
 * @return Returns a reader for the Javadoc comment content or <code>null</code> if the member
 * does not contain a Javadoc comment or if no source is available
 * @throws JavaModelException is thrown when the elements javadoc can not be accessed
 * @since 3.4
 */
private static Reader internalGetContentReader(IMember member) throws JavaModelException {
	IBuffer buf= member.getOpenable().getBuffer();
	if (buf == null) {
		return null; // no source attachment found
	}

	ISourceRange javadocRange= member.getJavadocRange();
	if (javadocRange != null) {
		JavaDocCommentReader reader= new JavaDocCommentReader(buf, javadocRange.getOffset(), javadocRange.getOffset() + javadocRange.getLength() - 1);
		if (!containsOnlyInheritDoc(reader, javadocRange.getLength())) {
			reader.reset();
			return reader;
		}
	}

	return null;
}
 
Example 18
private static String getHTMLContentFromSource(IMember member) throws JavaModelException {
	IBuffer buf= member.getOpenable().getBuffer();
	if (buf == null) {
		return null; // no source attachment found
	}

	ISourceRange javadocRange= member.getJavadocRange();
	if (javadocRange == null) {
		if (canInheritJavadoc(member)) {
			// Try to use the inheritDoc algorithm.
			String inheritedJavadoc= javadoc2HTML(member, "/***/"); //$NON-NLS-1$
			if (inheritedJavadoc != null && inheritedJavadoc.length() > 0) {
				return inheritedJavadoc;
			}
		}
		return getJavaFxPropertyDoc(member);
	}

	String rawJavadoc= buf.getText(javadocRange.getOffset(), javadocRange.getLength());
	return javadoc2HTML(member, rawJavadoc);
}
 
Example 19
/**
 * @see org.eclipse.jdt.internal.core.JavaModelOperation#executeOperation()
 */
protected void executeOperation() throws JavaModelException {
	try {
		beginTask(Messages.operation_sortelements, getMainAmountOfWork());
		CompilationUnit copy = (CompilationUnit) this.elementsToProcess[0];
		ICompilationUnit unit = copy.getPrimary();
		IBuffer buffer = copy.getBuffer();
		if (buffer  == null) {
			return;
		}
		char[] bufferContents = buffer.getCharacters();
		String result = processElement(unit, bufferContents);
		if (!CharOperation.equals(result.toCharArray(), bufferContents)) {
			copy.getBuffer().setContents(result);
		}
		worked(1);
	} finally {
		done();
	}
}
 
Example 20
private void removeAndInsertNew(IBuffer buffer, int contentOffset, int contentEnd, ArrayList stringsToInsert, MultiTextEdit resEdit) {
	int pos= contentOffset;
	for (int i= 0; i < stringsToInsert.size(); i++) {
		String curr= (String) stringsToInsert.get(i);
		int idx= findInBuffer(buffer, curr, pos, contentEnd);
		if (idx != -1) {
			if (idx != pos) {
				resEdit.addChild(new DeleteEdit(pos, idx - pos));
			}
			pos= idx + curr.length();
		} else {
			resEdit.addChild(new InsertEdit(pos, curr));
		}
	}
	if (pos < contentEnd) {
		resEdit.addChild(new DeleteEdit(pos, contentEnd - pos));
	}
}
 
Example 21
@Override
public IBuffer createBuffer(ICompilationUnit workingCopy) {
	ICompilationUnit original= workingCopy.getPrimary();
	IResource resource= original.getResource();
	if (resource instanceof IFile) {
		return new DocumentAdapter(workingCopy, (IFile)resource);
	}
	return DocumentAdapter.Null;
}
 
Example 22
Source Project: eclipse.jdt.ls   Source File: Util.java    License: Eclipse Public License 2.0 5 votes vote down vote up
static boolean rangeIncludesNonWhitespaceOutsideRange(ISourceRange selection, ISourceRange nodes, IBuffer buffer) {
	if (!covers(selection, nodes)) {
		return false;
	}

	//TODO: skip leading comments. Consider that leading line comment must be followed by newline!
	if (!isJustWhitespace(selection.getOffset(), nodes.getOffset(), buffer)) {
		return true;
	}
	if (!isJustWhitespaceOrComment(nodes.getOffset() + nodes.getLength(), selection.getOffset() + selection.getLength(), buffer)) {
		return true;
	}
	return false;
}
 
Example 23
Source Project: eclipse.jdt.ls   Source File: Util.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private static boolean isJustWhitespace(int start, int end, IBuffer buffer) {
	if (start == end) {
		return true;
	}
	Assert.isTrue(start <= end);
	return 0 == buffer.getText(start, end - start).trim().length();
}
 
Example 24
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
	if (filterMatch(match)) {
		return;
	}

	/*
	 * Processing is done in collector to reuse the buffer which was
	 * already required by the search engine to locate the matches.
	 */
	// [start, end[ include qualification.
	IJavaElement element = SearchUtils.getEnclosingJavaElement(match);
	int accuracy = match.getAccuracy();
	int start = match.getOffset();
	int length = match.getLength();
	boolean insideDocComment = match.isInsideDocComment();
	IResource res = match.getResource();
	if (element.getAncestor(IJavaElement.IMPORT_DECLARATION) != null) {
		collectMatch(TypeReference.createImportReference(element, accuracy, start, length, insideDocComment, res));
	} else {
		ICompilationUnit unit = (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT);
		if (unit != null) {
			IBuffer buffer = unit.getBuffer();
			String matchText = buffer.getText(start, length);
			if (fSource.isDefaultPackage()) {
				collectMatch(TypeReference.createSimpleReference(element, accuracy, start, length, insideDocComment, res, matchText));
			} else {
				// assert: matchText doesn't start nor end with comment
				int simpleNameStart = getLastSimpleNameStart(matchText);
				if (simpleNameStart != 0) {
					collectMatch(TypeReference.createQualifiedReference(element, accuracy, start, length, insideDocComment, res, start + simpleNameStart));
				} else {
					collectMatch(TypeReference.createSimpleReference(element, accuracy, start, length, insideDocComment, res, matchText));
				}
			}
		}
	}
}
 
Example 25
Source Project: eclipse.jdt.ls   Source File: NLSUtil.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private static int findLineEnd(ICompilationUnit cu, int position) throws JavaModelException {
	IBuffer buffer= cu.getBuffer();
	int length= buffer.getLength();
	for (int i= position; i < length; i++) {
		if (IndentManipulation.isLineDelimiterChar(buffer.getChar(i))) {
			return i;
		}
	}
	return length;
}
 
Example 26
public JavaDocCommentReader(IBuffer buf, int start, int end) {
	fBuffer= buf;
	fStartPos= start + 3;
	fEndPos= end - 2;

	reset();
}
 
Example 27
/**
 * @param method
 *            the method
 * @return the Javadoc content access for the given method, or <code>null</code>
 *         if no Javadoc could be found in source
 * @throws JavaModelException
 *             unexpected problem
 */
private JavadocContentAccess2 getJavadocContentAccess(IMethod method) throws JavaModelException {
	Object cached = fContentAccesses.get(method);
	if (cached != null) {
		return (JavadocContentAccess2) cached;
	}
	if (fContentAccesses.containsKey(method)) {
		return null;
	}

	IBuffer buf = method.getOpenable().getBuffer();
	if (buf == null) { // no source attachment found
		fContentAccesses.put(method, null);
		return null;
	}

	ISourceRange javadocRange = method.getJavadocRange();
	if (javadocRange == null) {
		fContentAccesses.put(method, null);
		return null;
	}

	String rawJavadoc = buf.getText(javadocRange.getOffset(), javadocRange.getLength());
	Javadoc javadoc = getJavadocNode(method, rawJavadoc);
	if (javadoc == null) {
		fContentAccesses.put(method, null);
		return null;
	}

	JavadocContentAccess2 contentAccess = new JavadocContentAccess2(method, javadoc, rawJavadoc, this);
	fContentAccesses.put(method, contentAccess);
	return contentAccess;
}
 
Example 28
Source Project: eclipse.jdt.ls   Source File: QuickFixProcessor.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private static int moveBack(int offset, int start, String ignoreCharacters, ICompilationUnit cu) {
	try {
		IBuffer buf = cu.getBuffer();
		while (offset >= start) {
			if (ignoreCharacters.indexOf(buf.getChar(offset - 1)) == -1) {
				return offset;
			}
			offset--;
		}
	} catch (JavaModelException e) {
		// use start
	}
	return start;
}
 
Example 29
Source Project: eclipse.jdt.ls   Source File: JsonRpcHelpers.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Returns an {@link IDocument} for the given buffer.
 * The implementation tries to avoid copying the buffer unless required.
 * The returned document may or may not be connected to the buffer.
 *
 * @param buffer a buffer
 * @return a document with the same contents as the buffer or <code>null</code> is the buffer is <code>null</code>
 */
public static IDocument toDocument(IBuffer buffer) {
	if (buffer == null) {
		return null;
	}
	if (buffer instanceof IDocument) {
		return (IDocument) buffer;
	} else if (buffer instanceof org.eclipse.jdt.ls.core.internal.DocumentAdapter) {
		IDocument document = ((org.eclipse.jdt.ls.core.internal.DocumentAdapter) buffer).getDocument();
		if (document != null) {
			return document;
		}
	}
	return new org.eclipse.jdt.internal.core.DocumentAdapter(buffer);
}
 
Example 30
@Before
public void initProjectManager() throws Exception {
	clientRequests.clear();

	logListener = new SimpleLogListener();
	Platform.addLogListener(logListener);
	preferences = new Preferences();
	preferences.setRootPaths(Collections.singleton(new Path(getWorkingProjectDirectory().getAbsolutePath())));
	if (preferenceManager == null) {
		preferenceManager = mock(PreferenceManager.class);
	}
	initPreferenceManager(true);

	oldPreferenceManager = JavaLanguageServerPlugin.getPreferencesManager();
	JavaLanguageServerPlugin.setPreferencesManager(preferenceManager);
	projectsManager = new SyntaxProjectsManager(preferenceManager);
	monitor = new NullProgressMonitor();
	WorkingCopyOwner.setPrimaryBufferProvider(new WorkingCopyOwner() {
		@Override
		public IBuffer createBuffer(ICompilationUnit workingCopy) {
			ICompilationUnit original= workingCopy.getPrimary();
			IResource resource= original.getResource();
			if (resource instanceof IFile) {
				return new DocumentAdapter(workingCopy, (IFile)resource);
			}
			return DocumentAdapter.Null;
		}
	});
}