本文整理汇总了Java中org.eclipse.jface.text.ITypedRegion类的典型用法代码示例。如果您正苦于以下问题:Java ITypedRegion类的具体用法?Java ITypedRegion怎么用?Java ITypedRegion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ITypedRegion类属于org.eclipse.jface.text包,在下文中一共展示了ITypedRegion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDamageRegion
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
@Override
public IRegion getDamageRegion(ITypedRegion partition, DocumentEvent event, boolean documentPartitioningChanged) {
if (!documentPartitioningChanged) {
try {
IRegion info = fDocument.getLineInformationOfOffset(event.getOffset());
int start = Math.max(partition.getOffset(), info.getOffset());
int end = event.getOffset() + (event.getText() == null ? event.getLength() : event.getText().length());
if (info.getOffset() <= end && end <= info.getOffset() + info.getLength()) {
// optimize the case of the same line
end = info.getOffset() + info.getLength();
} else{
end = endOfLineOf(end);
}
end = Math.min(partition.getOffset() + partition.getLength(), end);
return new Region(start, end - start);
} catch (BadLocationException x) {
}
}
return partition;
}
示例2: getPartition
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
private ITypedRegion getPartition(final String partitionContentType) {
final IDocumentExtension3 extension = (IDocumentExtension3) this.document;
ITypedRegion[] computePartitioning = null;
try {
computePartitioning = extension.computePartitioning(IDocumentExtension3.DEFAULT_PARTITIONING,
0, this.document.getLength(), false);
} catch (BadLocationException | BadPartitioningException e) {
e.printStackTrace();
}
for (final ITypedRegion iTypedRegion : computePartitioning) {
if (iTypedRegion.getType().equals(partitionContentType)) {
return iTypedRegion;
}
}
return null;
}
示例3: reconcile
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
@Override
public void reconcile(final IRegion partition) {
if (this.document == null) {
return;
}
try {
final ITypedRegion[] partitionRegions =
this.document.computePartitioning(partition.getOffset(), partition.getLength());
for (int i = 0; i < partitionRegions.length; i++) {
if (partitionRegions[i].getType().equals(MetaModelPartitionScanner.META_MODEL_REASON)) {
this.reconcile(null, partitionRegions[i]);
}
}
} catch (final BadLocationException e) {
e.printStackTrace();
}
}
示例4: computeCommentFolding
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
@Override
protected void computeCommentFolding(IXtextDocument xtextDocument,
IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor, ITypedRegion typedRegion,
boolean initiallyFolded) {
String text;
try {
text = xtextDocument.get(typedRegion.getOffset(), typedRegion.getLength());
int lines = Strings.countLines(text);
if (shouldCreateCommentFolding(lines)) {
boolean collapse = shouldCollapse(typedRegion, lines);
super.computeCommentFolding(xtextDocument, foldingRegionAcceptor, typedRegion, collapse);
}
} catch (BadLocationException e) {
log.error(e, e);
}
}
示例5: getHoverInfo
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
public String getHoverInfo( ITextViewer textViewer, IRegion hoverRegion){
int offset = hoverRegion.getOffset();
if (hoverRegion != null) {
try {
if (hoverRegion.getLength() > -1) {
IDocument doc = textViewer.getDocument();
// String key = textViewer.getDocument().get(offset, hoverRegion.getLength());
// ITypedRegion region = doc.getPartition(offset);
ITypedRegion partitionType = textViewer.getDocument().getPartition(offset);
IRegion reg2 = doc.getLineInformationOfOffset(offset);
String lineText = doc.get(reg2.getOffset(), reg2.getLength());
// if(BaseUtils.isEmpty(key)){
// key = BaseUtils.getKeyFromLine(lineText);
// return HAssistInfoMap.getInfo(key);
// }
String key = DocumentUtils.getKeyFromLine(lineText);
return LazyObjects.getInfoMap("Headers").getInfo(key);
}
} catch (BadLocationException x) {
}
}
return "JavaEditorMessages.getString(MyTextHover.emptySelection)";
}
示例6: printPartitions
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
public void printPartitions( IDocument document){
StringBuilder buffer = new StringBuilder();
ITypedRegion[] partitions = computePartitioning(0, document.getLength());
for (int i = 0; i < partitions.length; i++) {
try {
buffer.append("Partition type: " + partitions[i].getType() + ", offset: " + partitions[i].getOffset() + ", length: " + partitions[i].getLength());
buffer.append("\n");
buffer.append("Text:\n");
buffer.append(document.get(partitions[i].getOffset(), partitions[i].getLength()));
buffer.append("\n---------------------------\n\n\n");
} catch (BadLocationException e) {
e.printStackTrace();
}
}
System.out.print(buffer);
}
示例7: addTagStart
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
/**
* Add start of coverage
* @param start
*/
public void addTagStart(ITypedRegion start)
{
// Assert.isTrue(inTag() && !inTag() == !hasUserPartitions(),
// "Found user partitions which have not been removed. This is a bug.");
ITypedRegion userRegion = getUserRegion();
if (userRegion != null)
{
stack.push(userRegion);
}
TLCRegion startRegion = new TLCRegion(start.getOffset(), start.getLength(), start.getType());
startRegion.setMessageCode(getMessageCode(start, START));
startRegion.setSeverity(getSeverity(start));
// add start to stack
stack.push(startRegion);
}
示例8: getFindStart
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
/**
* Returns array of elements from top of the stack with start as the last element (call pop until the start is found)
* @param code
* @return
*/
private ITypedRegion[] getFindStart(int code)
{
Assert.isTrue(!stack.isEmpty(), "Bug. Empty stack, start tag expected");
Vector<ITypedRegion> elements = new Vector<ITypedRegion>();
while (!stack.isEmpty())
{
ITypedRegion region = (ITypedRegion) stack.pop();
elements.add(region);
if (TagBasedTLCOutputTokenScanner.TAG_OPEN.equals(region.getType()))
{
TLCRegion startRegion = (TLCRegion) region;
Assert.isTrue(startRegion.getMessageCode() == code, "Found a non-matching start. This is a bug.");
// found a match
break;
} else
{
// not a start tag
// but something else, e.G. user partition
}
}
return (ITypedRegion[]) elements.toArray(new ITypedRegion[elements.size()]);
}
示例9: onOutput
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
public void onOutput(ITypedRegion region, String text) {
// a) just store the region
this.regions.add(region);
// b) convert to TLCState if TLCRegion
if (region instanceof TLCRegion) {
TLCRegion tlcRegion = (TLCRegion) region;
int severity = tlcRegion.getSeverity();
switch (severity) {
case MP.STATE:
TLCState state = TLCState.parseState(text, "bogusModelName");
this.states.add(state);
return;
}
}
// c) unexpected content
this.garbage = true;
}
示例10: uncommentSelection
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
public void uncommentSelection(ITypedRegion region, IDocument doc){
int offset = region.getOffset();
int endOffset = region.getOffset() + (region.getLength() - commentBegin.length() - commentEnd.length());
if(!region.getType().equals("__xml_comment"))
return; // we should ignore if the region is not a comment
try {
doc.replace(offset, commentBegin.length(), ""); // remove start comment
if(doc.get(endOffset, commentEnd.length()).equals(commentEnd))
doc.replace(endOffset, commentEnd.length(), ""); // remove end comment
} catch (BadLocationException e) {
e.printStackTrace();
}
}
示例11: getCharStart
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
private Integer getCharStart(int lineNumber, int columnNumber) {
try {
int lineStartChar = document.getLineOffset(lineNumber - 1);
Integer charEnd = getCharEnd(lineNumber, columnNumber);
if (charEnd != null) {
ITypedRegion typedRegion = document.getPartition(charEnd
.intValue() - 2);
int partitionStartChar = typedRegion.getOffset();
return new Integer(partitionStartChar);
} else
return new Integer(lineStartChar);
} catch (BadLocationException e) {
e.printStackTrace();
return null;
}
}
示例12: printPartitions
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
public void printPartitions(IDocument document) {
StringBuffer buffer = new StringBuffer();
ITypedRegion[] partitions = computePartitioning(0, document.getLength());
for (int i = 0; i < partitions.length; i++) {
try {
buffer.append("Partition type: " + partitions[i].getType()
+ ", offset: " + partitions[i].getOffset()
+ ", length: " + partitions[i].getLength());
buffer.append("\n");
buffer.append("Text:\n");
buffer.append(document.get(partitions[i].getOffset(),
partitions[i].getLength()));
buffer.append("\n---------------------------\n\n\n");
} catch (BadLocationException e) {
e.printStackTrace();
}
}
System.out.print(buffer);
}
示例13: getCurrentTagname
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
public String getCurrentTagname(int documentOffset) {
try {
ITypedRegion region = getPartition(documentOffset);
int partitionOffset = region.getOffset();
int readLength = region.getLength();
ColorManager colorManager = new ColorManager();
scanner = new XMLTagScanner(colorManager);
String text = get(partitionOffset, readLength);
int p = 0;
char ch;
String tagname = "";
ch = text.charAt(0);
while (true) {
if (p + 1 >= text.length()
|| !Character.isJavaIdentifierPart(text.charAt(p + 1)))
break;
ch = text.charAt(++p);
tagname += ch;
}
return tagname;
} catch (BadLocationException e) {
e.printStackTrace();
}
return "";
}
示例14: getNextEndTagPartition
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
public ITypedRegion getNextEndTagPartition(String tagname, int offset) {
ITypedRegion partition;
try {
partition = getPartition(offset);
while (partition != null) {
if (partition.getType().equals(XMLPartitionScanner.XML_END_TAG)) {
if (getCurrentEndTagName(partition.getOffset()).equals(
tagname))
return partition;
}
partition = getNextPartition(partition);
}
} catch (Exception e) {
return null;
}
return null;
}
示例15: removeElement
import org.eclipse.jface.text.ITypedRegion; //导入依赖的package包/类
public boolean removeElement(String id, int offset) {
try {
int elementOffset = getElementOffset(id);
ITypedRegion region = getNextTagPartition(elementOffset);
String tag = get(region.getOffset(), region.getLength());
if (tag.endsWith("/>"))
replace(region.getOffset(), region.getLength(), "");
else {
String tagname = getCurrentTagname(offset);
ITypedRegion endTagRegion = getNextEndTagPartition(tagname,
offset);
int begin = region.getOffset();
int end = endTagRegion.getOffset() + endTagRegion.getLength()
- begin;
replace(begin, end, "");
}
return true;
} catch (BadLocationException e) {
return true; // or false?
}
}