本文整理汇总了Java中org.eclipse.jface.text.ITypedRegion.getType方法的典型用法代码示例。如果您正苦于以下问题:Java ITypedRegion.getType方法的具体用法?Java ITypedRegion.getType怎么用?Java ITypedRegion.getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.ITypedRegion
的用法示例。
在下文中一共展示了ITypedRegion.getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: shouldProcess
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
protected boolean shouldProcess(ITypedRegion typedRegion) {
String type = typedRegion.getType();
if (partitionMapperExtension != null) {
if (partitionMapperExtension.isMultiLineComment(type) || partitionMapperExtension.isSingleLineComment(type)) {
return true;
}
if (STRING_LITERAL_PARTITION.equals(type)) {
return true;
}
return false;
}
if (STRING_LITERAL_PARTITION.equals(type)
|| SL_COMMENT_PARTITION.equals(type)
|| COMMENT_PARTITION.equals(type)) {
return true;
}
return false;
}
示例3: isInsidePartition
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
/**
* DOCUMENT ME!
*
* @param offset
* DOCUMENT ME!
* @param partitions
* DOCUMENT ME!
* @param include_start
* DOCUMENT ME!
* @param doc
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static boolean isInsidePartition(int offset, String[] partitions, boolean include_start, IDocument doc)
{
try
{
ITypedRegion partition = doc.getPartition(offset);
if (include_start || (offset != partition.getOffset()))
{
String type = partition.getType();
for (int i = 0; i < partitions.length; i++)
{
if (type.equals(partitions[i])) { return true; }
}
}
}
catch (BadLocationException e)
{
}
return false;
}
示例4: computeCommentFolding
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
@Override
protected void computeCommentFolding(final IXtextDocument xtextDocument,
final IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor, final ITypedRegion typedRegion,
final boolean initiallyFolded) throws BadLocationException {
final int offset = typedRegion.getOffset();
final int length = typedRegion.getLength();
final Matcher matcher = getTextPatternInComment().matcher(xtextDocument.get(offset, length));
((GamaFoldingRegionAcceptor) foldingRegionAcceptor).type = typedRegion.getType();
if (matcher.find()) {
final TextRegion significant = new TextRegion(offset + matcher.start(), 0);
((IFoldingRegionAcceptorExtension<ITextRegion>) foldingRegionAcceptor).accept(offset, length,
initiallyFolded, significant);
} else {
((IFoldingRegionAcceptorExtension<ITextRegion>) foldingRegionAcceptor).accept(offset, length,
initiallyFolded);
}
}
示例5: isInsertClosingBracket
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
@Override
public boolean isInsertClosingBracket(IDocument doc, int offset) throws BadLocationException {
if (offset >= 2) {
ITypedRegion prevPartition = doc.getPartition(offset - 1);
String prevPartitionType = prevPartition.getType();
if (TerminalsTokenTypeToPartitionMapper.SL_COMMENT_PARTITION.equals(prevPartitionType)) {
return false;
}
if (TokenTypeToPartitionMapper.REG_EX_PARTITION.equals(prevPartitionType)) {
return prevPartition.getLength() == 1;
}
}
return SingleLineTerminalsStrategy.DEFAULT.isInsertClosingBracket(doc, offset);
}
示例6: printPartition
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
/**
* Prints partition information
* @param region
* @param document
*/
public static void printPartition(ITypedRegion region, IDocument document)
{
if (region == null)
{
return;
}
try
{
StringBuffer messageBuffer = new StringBuffer();
String location = "[" + region.getOffset() + ":" + region.getLength() + "]";
if (region instanceof TLCRegion)
{
TLCRegion tlcRegion = (TLCRegion) region;
messageBuffer.append("TLC:" + tlcRegion.getMessageCode() + " " + tlcRegion.getSeverity() + " "
+ location);
} else
{
int offset = region.getOffset();
int printLength = Math.min(region.getLength(), 255);
String type = region.getType();
Assert.isTrue(type.equals(TagBasedTLCOutputTokenScanner.DEFAULT_CONTENT_TYPE));
String head = document.get(offset, printLength);
messageBuffer.append("OUTPUT:" + location + ": >" + head + "< ...");
}
TLCUIActivator.getDefault().logDebug(messageBuffer.toString());
} catch (BadLocationException e)
{
TLCUIActivator.getDefault().logError("Error printing partition", e);
}
}
示例7: isAttribute
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
/**
* Utilizado para determinar se a palavra corrente que está sendo digitada é
* um atributo. Irá retornar verdadeiro se encontrar o padrão no âmbito da
* atual partição Tem que melhorar ainda. Falta verificar se é o valor de um
* atributo.
*/
public boolean isAttribute(int documentOffset) {
ITypedRegion region;
try {
region = getPartition(documentOffset);
if (region.getType() == XMLPartitionScanner.XML_START_TAG)
return !isTagname(documentOffset)
&& !isAttributeValue(documentOffset);
return false;
} catch (BadLocationException e) {
return false;
}
}
示例8: isEndTagName
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
/**
*
* @param documentOffset
* @return
*/
public boolean isEndTagName(int documentOffset) {
ITypedRegion region;
try {
region = getPartition(documentOffset);
if (region.getType() == XMLPartitionScanner.XML_END_TAG)
return true;
return false;
} catch (BadLocationException e) {
return false;
}
}
示例9: getAttributesTyped
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
public List<String> getAttributesTyped(int offset) {
List list = new ArrayList<String>();
try {
ITypedRegion region = getPartition(offset);
if (region.getType() == XMLPartitionScanner.XML_START_TAG) {
String currentPartition = get(region.getOffset(),
region.getLength());
int lt_pos = currentPartition.substring(1).indexOf('<');
// If the input text is not a well-formed XML, getPartition
// can return something like that:
// "<area id=''... <area id='...' coord='...' .../>
//
// If that happens, we will cut the currentPartition text until
// we find the first "<" (it does not include initial from
// openning tag).
if(lt_pos >= 0)
currentPartition = currentPartition.substring(0, lt_pos+1);
Pattern p = Pattern.compile("\\s[a-zA-Z]+");
Matcher m = p.matcher(currentPartition); // get a matcher
// object
while (m.find()) {
list.add(currentPartition.substring(m.start() + 1, m.end()));
}
}
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
示例10: isEscapedPartition
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
/**
* DOCUMENT ME!
*
* @param offset
* DOCUMENT ME!
* @param doc
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public static boolean isEscapedPartition(int offset, IDocument doc)
{
try
{
ITypedRegion partition = doc.getPartition(offset);
String type = partition.getType();
if ((offset != partition.getOffset())
&& (type.equals("__javadoc_partition") || type.equals("__comment_partition") || type.equals("__comment1_partition") || type.equals("__string_partition"))) { return true; }
}
catch (BadLocationException e)
{
}
return false;
}
示例11: getParentTagRegion
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
public TagRegion getParentTagRegion(final IDocument document,
final int offset, final String parentTagName) {
IDocumentPartitioner partitioner = null;
try {
TagRegion result = null;
final String closeParentTag = "/" + parentTagName;
partitioner = createTagPartitioner(document, new String[] {
parentTagName, closeParentTag });
ITypedRegion tagRegion = partitioner.getPartition(offset);
// get parent
tagRegion = partitioner.getPartition(tagRegion.getOffset() - 1);
if (!IDocument.DEFAULT_CONTENT_TYPE.equals(tagRegion.getType())
&& !closeParentTag.equals(tagRegion.getType())) {
List<ElementRegion> attrRegions = parseTag(document, tagRegion,
ATTRS);
result = new TagRegion(tagRegion.getType(), null, null,
attrRegions);
}
return result;
} finally {
if (partitioner != null) {
partitioner.disconnect();
}
}
}
示例12: getConstantsMap
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
public Map<String, String> getConstantsMap(final IDocument document) {
IDocumentPartitioner partitioner = null;
try {
Map<String, String> constants = new HashMap<String, String>();
final String[] tags = new String[] {
StrutsXmlConstants.CONSTANT_TAG, COMMENT_TOKEN };
// create tag partitioner
partitioner = createTagPartitioner(document, tags);
// get tags regions
ITypedRegion[] tagRegions = partitioner.computePartitioning(0,
document.getLength());
for (ITypedRegion tagRegion : tagRegions) {
if (!IDocument.DEFAULT_CONTENT_TYPE.equals(tagRegion.getType())
&& !COMMENT_TOKEN.equals(tagRegion.getType())) {
List<ElementRegion> attrRegions = parseTag(document,
tagRegion, new String[] {
StrutsXmlConstants.NAME_ATTR,
StrutsXmlConstants.VALUE_ATTR });
TagRegion t = new TagRegion(tagRegion.getType(), null,
null, attrRegions);
constants
.put(t.getAttrValue(StrutsXmlConstants.NAME_ATTR,
null), t.getAttrValue(
StrutsXmlConstants.VALUE_ATTR, null));
}
}
return constants;
} finally {
if (partitioner != null) {
partitioner.disconnect();
}
}
}
示例13: fetchAttrsRegions
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
private List<ElementRegion> fetchAttrsRegions(IDocument document,
ITypedRegion[] regions) {
List<ElementRegion> attrRegions = new ArrayList<ElementRegion>();
if (regions != null) {
String attrName = null;
for (ITypedRegion r : regions) {
// only legal types
if (!IDocument.DEFAULT_CONTENT_TYPE.equals(r.getType())) {
boolean quotesToken = DOUBLE_QUOTES_TOKEN.equals(r
.getType())
|| SINGLE_QUOTES_TOKEN.equals(r.getType());
if (attrName != null && quotesToken) {
try {
// get value w/o quotes
String val = document.get(r.getOffset() + 1,
r.getLength() - 2);
attrRegions.add(new ElementRegion(attrName, val, r
.getOffset() + 1));
} catch (BadLocationException e) {
e.printStackTrace();
}
// set name to null
attrName = null;
} else if (!quotesToken) {
attrName = r.getType();
}
}
}
}
return attrRegions;
}
示例14: parseRequiredPartitions
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
private void parseRequiredPartitions(final ITypedRegion changedPartition)
throws BadLocationException {
PARSE_AREA changedArea = null;
String changedPartitionString;
if (changedPartition != null) {
switch (changedPartition.getType()) {
case RelationModelPartitionScanner.RELATION_MODEL_OPTION:
changedArea = KodkodAnalyzer.PARSE_AREA.OPTIONS;
changedPartitionString = this.getPartitionString(
this.getPartition(RelationModelPartitionScanner.RELATION_MODEL_OPTION));
break;
case RelationModelPartitionScanner.RELATION_MODEL_UNIVERSE:
changedArea = KodkodAnalyzer.PARSE_AREA.UNIVERSE;
changedPartitionString = this.getPartitionString(
this.getPartition(RelationModelPartitionScanner.RELATION_MODEL_UNIVERSE));
this.runParser(changedPartitionString, changedArea);
break;
case RelationModelPartitionScanner.RELATION_MODEL_REL_BOUND:
changedArea = KodkodAnalyzer.PARSE_AREA.RELATION;
changedPartitionString = this.getPartitionString(
this.getPartition(RelationModelPartitionScanner.RELATION_MODEL_UNIVERSE));
final String relBoundString = this.getPartitionString(
this.getPartition(RelationModelPartitionScanner.RELATION_MODEL_REL_BOUND));
changedPartitionString += relBoundString;
this.runParser(changedPartitionString, changedArea);
break;
case RelationModelPartitionScanner.DEFAULT_CONTENT_TYPE:
changedArea = KodkodAnalyzer.PARSE_AREA.FORMULAS;
changedPartitionString = this.document.get();
this.runParser(changedPartitionString, changedArea);
break;
default:
break;
}
} else {
changedPartitionString = this.document.get();
changedArea = KodkodAnalyzer.PARSE_AREA.FULL_DOCUMENT;
this.runParser(changedPartitionString, changedArea);
}
}
示例15: isAttributeValue
import org.eclipse.jface.text.ITypedRegion; //导入方法依赖的package包/类
public boolean isAttributeValue(int offset) {
ITypedRegion region;
startAttributeValueOffset = -1;
try {
region = getPartition(offset--);
if (region.getType() == XMLPartitionScanner.XML_START_TAG) {
int partitionOffset = region.getOffset();
currentAttribute = "";
// System.out
// .println(
// "Verificando se está digitando o valor de um atributo");
boolean firstQuote = true;
boolean findingAttributeName = false;
int beginAttributeName = -1, endAttributeName = -1;
while (true && offset >= partitionOffset) {
char ch = getChar(offset--);
if (findingAttributeName) {
if (Character.isJavaIdentifierPart(ch) || ch == ':') {
if (endAttributeName == -1) {
endAttributeName = offset;
}
continue;
}
if (Character.isWhitespace(ch)
&& endAttributeName != -1) {
currentAttribute = get(offset + 2, endAttributeName
- (offset));
return true;
}
if (Character.isWhitespace(ch))
continue;
return false;
}
if (ch == '\'' || ch == '\"') {
if (firstQuote) {
startAttributeValueOffset = offset + 1;
firstQuote = false;
continue;
}
return false;
}
if (ch == '=')
findingAttributeName = true;
}
}
return false;
} catch (BadLocationException e) {
return false;
}
}