mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Implement documentSetup and documentCreation extension point
for CDT
This commit is contained in:
parent
43b14542a6
commit
d324df3b25
6 changed files with 241 additions and 2 deletions
|
@ -1,3 +1,15 @@
|
|||
2004-04-20 Alain Magloire
|
||||
|
||||
In Eclipse-3.0 things changes to set partition scanner
|
||||
on the Document Provider, it is now an extension point.
|
||||
Implement "documentCreation" and "documentSetup" extension points.
|
||||
|
||||
* plugin.xml
|
||||
* plugin.properties
|
||||
* src/org/eclipse/cdt/internal/ui/editor/CDocumentFactory.java
|
||||
* src/org/eclipse/cdt/internal/ui/editor/CDocumentSetupParticipant.java
|
||||
* src/org/eclipse/cdt/internal/ui/editor/PartiallySynchronizedDocument.java
|
||||
|
||||
2004-04-20 David Inglis
|
||||
|
||||
Work in progress CPath UI changes
|
||||
|
|
|
@ -151,3 +151,6 @@ HideHeaderFiles.label= Header files
|
|||
HideHeaderFiles.description= Hides all Header files
|
||||
|
||||
WorkInProgress.name=Work In Progress
|
||||
|
||||
cDocumentFactory=C Document Factory
|
||||
cDocumentSetupParticipant=C Document Setup Participant
|
|
@ -205,6 +205,27 @@
|
|||
</description>
|
||||
</wizard>
|
||||
</extension>
|
||||
|
||||
<!-- Define the document provider and partitionner for the CEditor -->
|
||||
<extension
|
||||
id="org.eclipse.cdt.ui.CDocumentSetupParticipant"
|
||||
name="%cDocumentSetupParticipant"
|
||||
point="org.eclipse.core.filebuffers.documentSetup">
|
||||
<participant
|
||||
extensions="c, cc, cpp, cxx, h, hh, hpp"
|
||||
class="org.eclipse.cdt.internal.ui.editor.CDocumentSetupParticipant">
|
||||
</participant>
|
||||
</extension>
|
||||
<extension
|
||||
id="org.eclipse.cdt.ui.CDocumentFactory"
|
||||
name="%cDocumentFactory"
|
||||
point="org.eclipse.core.filebuffers.documentCreation">
|
||||
<factory
|
||||
extensions="c, cc, cpp, cxx, h, hh, hpp"
|
||||
class="org.eclipse.cdt.internal.ui.editor.CDocumentFactory">
|
||||
</factory>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
id="org.eclipse.cdt.ui.ceditor"
|
||||
point="org.eclipse.ui.editors">
|
||||
|
@ -623,7 +644,7 @@
|
|||
id="org.eclipse.cdt.ui.CSearchResultPage">
|
||||
</viewPage>
|
||||
</extension>
|
||||
<!--
|
||||
-->
|
||||
<extension
|
||||
point="org.eclipse.ui.propertyPages">
|
||||
<page
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
***********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import org.eclipse.core.filebuffers.IDocumentFactory;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
|
||||
/**
|
||||
* CDocumentFactory
|
||||
*/
|
||||
public class CDocumentFactory implements IDocumentFactory {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CDocumentFactory() {
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.core.filebuffers.IDocumentFactory#createDocument()
|
||||
*/
|
||||
public IDocument createDocument() {
|
||||
return new PartiallySynchronizedDocument();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
***********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.text.CTextTools;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
|
||||
/**
|
||||
* CDocumentSetupParticipant
|
||||
*/
|
||||
public class CDocumentSetupParticipant implements IDocumentSetupParticipant {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public CDocumentSetupParticipant() {
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.core.filebuffers.IDocumentSetupParticipant#setup(org.eclipse.jface.text.IDocument)
|
||||
*/
|
||||
public void setup(IDocument document) {
|
||||
CTextTools tools= CUIPlugin.getDefault().getTextTools();
|
||||
tools.setupCDocument(document);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003,2004 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
***********************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import org.eclipse.jface.text.BadLocationException;
|
||||
import org.eclipse.jface.text.BadPositionCategoryException;
|
||||
import org.eclipse.jface.text.Document;
|
||||
import org.eclipse.jface.text.ISynchronizable;
|
||||
import org.eclipse.jface.text.Position;
|
||||
|
||||
|
||||
/**
|
||||
* Document that can also be used by a background reconciler.
|
||||
*/
|
||||
public class PartiallySynchronizedDocument extends Document implements ISynchronizable {
|
||||
|
||||
private final Object fInternalLockObject= new Object();
|
||||
private Object fLockObject;
|
||||
|
||||
/*
|
||||
* @see org.eclipse.jface.text.ISynchronizable#setLockObject(java.lang.Object)
|
||||
*/
|
||||
public void setLockObject(Object lockObject) {
|
||||
fLockObject= lockObject;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.jface.text.ISynchronizable#getLockObject()
|
||||
*/
|
||||
public Object getLockObject() {
|
||||
return fLockObject == null ? fInternalLockObject : fLockObject;
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IDocumentExtension#startSequentialRewrite(boolean)
|
||||
*/
|
||||
public void startSequentialRewrite(boolean normalized) {
|
||||
synchronized (getLockObject()) {
|
||||
super.startSequentialRewrite(normalized);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IDocumentExtension#stopSequentialRewrite()
|
||||
*/
|
||||
public void stopSequentialRewrite() {
|
||||
synchronized (getLockObject()) {
|
||||
super.stopSequentialRewrite();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IDocument#get()
|
||||
*/
|
||||
public String get() {
|
||||
synchronized (getLockObject()) {
|
||||
return super.get();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IDocument#get(int, int)
|
||||
*/
|
||||
public String get(int offset, int length) throws BadLocationException {
|
||||
synchronized (getLockObject()) {
|
||||
return super.get(offset, length);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IDocument#getChar(int)
|
||||
*/
|
||||
public char getChar(int offset) throws BadLocationException {
|
||||
synchronized (getLockObject()) {
|
||||
return super.getChar(offset);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IDocument#replace(int, int, String)
|
||||
*/
|
||||
public void replace(int offset, int length, String text) throws BadLocationException {
|
||||
synchronized (getLockObject()) {
|
||||
super.replace(offset, length, text);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see IDocument#set(String)
|
||||
*/
|
||||
public void set(String text) {
|
||||
synchronized (getLockObject()) {
|
||||
super.set(text);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.jface.text.AbstractDocument#addPosition(java.lang.String, org.eclipse.jface.text.Position)
|
||||
*/
|
||||
public void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException {
|
||||
synchronized (getLockObject()) {
|
||||
super.addPosition(category, position);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.jface.text.AbstractDocument#removePosition(java.lang.String, org.eclipse.jface.text.Position)
|
||||
*/
|
||||
public void removePosition(String category, Position position) throws BadPositionCategoryException {
|
||||
synchronized (getLockObject()) {
|
||||
super.removePosition(category, position);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.jface.text.AbstractDocument#getPositions(java.lang.String)
|
||||
*/
|
||||
public Position[] getPositions(String category) throws BadPositionCategoryException {
|
||||
synchronized (getLockObject()) {
|
||||
return super.getPositions(category);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue