本文整理汇总了Java中com.google.gwt.eclipse.core.editors.java.GWTPartitions类的典型用法代码示例。如果您正苦于以下问题:Java GWTPartitions类的具体用法?Java GWTPartitions怎么用?Java GWTPartitions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GWTPartitions类属于com.google.gwt.eclipse.core.editors.java包,在下文中一共展示了GWTPartitions类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getEnclosingJsniRegion
import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //导入依赖的package包/类
public static ITypedRegion getEnclosingJsniRegion(ITextSelection selection,
IDocument document) {
try {
ITypedRegion region = TextUtilities.getPartition(document,
GWTPartitions.GWT_PARTITIONING, selection.getOffset(), false);
if (region.getType().equals(GWTPartitions.JSNI_METHOD)) {
int regionEnd = region.getOffset() + region.getLength();
int selectionEnd = selection.getOffset() + selection.getLength();
// JSNI region should entirely contain the selection
if (region.getOffset() <= selection.getOffset()
&& regionEnd >= selectionEnd) {
return region;
}
}
} catch (BadLocationException e) {
GWTPluginLog.logError(e);
}
return null;
}
示例2: format
import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //导入依赖的package包/类
/**
* Returns a text edit that formats the given document according to the given settings.
*
* @param document
* The document to format.
* @param javaFormattingPrefs
* The formatting preferences for Java, used to determine the method level indentation.
* @param javaScriptFormattingPrefs
* The formatting preferences for JavaScript. See org.eclipse.wst.jsdt.internal.formatter
* .DefaultCodeFormatterOptions and org.eclipse.wst.jsdt.core.formatter.DefaultCodeFormatterConstants
* @param originalJsniMethods
* The original jsni methods to use if the formatter fails to format the method. The original jsni
* Strings must be in the same order that the jsni methods occur in the document. This is to work around
* the Java formatter blasting the jsni tabbing for the format-on-save action. May be null.
* @return A text edit that when applied to the document, will format the jsni methods.
*/
@SuppressWarnings("unchecked")
public TextEdit format(IDocument document, Map javaFormattingPrefs, Map javaScriptFormattingPrefs, Range range) {
TextEdit combinedEdit = new MultiTextEdit();
ITypedRegion[] regions = computePartitioning(document, range);
// Format all JSNI blocks in the document
int i = 0;
for (ITypedRegion region : regions) {
if (region.getType().equals(GWTPartitions.JSNI_METHOD)) {
String originalJsniMethod = null;
TextEdit edit = format(document, new TypedPosition(region), javaFormattingPrefs,
javaScriptFormattingPrefs, originalJsniMethod);
if (edit != null) {
combinedEdit.addChild(edit);
}
i++;
}
}
return combinedEdit;
}
示例3: computePartitioning
import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //导入依赖的package包/类
private static ITypedRegion[] computePartitioning(IDocument document, Range range) {
ArrayList<ITypedRegion> iTypedRegions = new ArrayList<ITypedRegion>();
String str = document.get();
String prefix = "/*-";
String postfix = "-*/";
int startIndex = 0;
int endIndex = 0;
while (startIndex != -1) {
startIndex = str.indexOf(prefix, startIndex);
endIndex = str.indexOf(postfix, startIndex);
if (startIndex != -1 && endIndex != -1) {
endIndex = endIndex + 3;
if (isInRange(range, startIndex, endIndex)) {
iTypedRegions.add(new TypedRegion(startIndex, endIndex - startIndex, GWTPartitions.JSNI_METHOD));
}
startIndex += prefix.length();
}
}
return iTypedRegions.toArray(new ITypedRegion[iTypedRegions.size()]);
}
示例4: format
import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //导入依赖的package包/类
private TextEdit format(IDocument document, Range range) {
TextEdit combinedEdit = new MultiTextEdit();
ITypedRegion[] regions = computePartitioning(document, range);
// Format all JSNI blocks in the document
int i = 0;
for (ITypedRegion region : regions) {
if (region.getType().equals(GWTPartitions.JSNI_METHOD)) {
TextEdit edit = format(document, new TypedPosition(region));
if (edit != null) {
combinedEdit.addChild(edit);
}
i++;
}
}
return combinedEdit;
}
示例5: computePartitioning
import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //导入依赖的package包/类
private static ITypedRegion[] computePartitioning(IDocument document, Range range) {
ArrayList<ITypedRegion> iTypedRegions = new ArrayList<ITypedRegion>();
String str = document.get();
String prefix = "/**";
String postfix = "*/";
int startIndex = 0;
int endIndex = 0;
while (startIndex != -1) {
startIndex = str.indexOf(prefix, startIndex);
endIndex = str.indexOf(postfix, startIndex);
if (startIndex != -1 && endIndex != -1) {
endIndex = endIndex + 3;
if (isInRange(range, startIndex, endIndex)) {
iTypedRegions.add(new TypedRegion(startIndex, endIndex - startIndex, GWTPartitions.JSNI_METHOD));
}
startIndex += prefix.length();
}
}
return iTypedRegions.toArray(new ITypedRegion[iTypedRegions.size()]);
}
示例6: testGetEnclosingJsniRegionSelectionInsideJsni
import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //导入依赖的package包/类
public void testGetEnclosingJsniRegionSelectionInsideJsni() {
IRegion selRegion = RegionConverter.convertWindowsRegion(169, 3, testClass.getContents());
ITextSelection sel = new TextSelection(selRegion.getOffset(), selRegion.getLength());
ITypedRegion jsniRegion = JsniParser.getEnclosingJsniRegion(sel, getTestClassDocument());
assertNotNull(jsniRegion);
assertEquals(GWTPartitions.JSNI_METHOD, jsniRegion.getType());
IRegion expectedJsniRegion = RegionConverter.convertWindowsRegion(121, 234, testClass.getContents());
assertEquals(expectedJsniRegion.getOffset(), jsniRegion.getOffset());
assertEquals(expectedJsniRegion.getLength(), jsniRegion.getLength());
}
示例7: testGetEnclosingJsniRegionSelectionIsJsni
import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //导入依赖的package包/类
public void testGetEnclosingJsniRegionSelectionIsJsni() {
IRegion selRegion = RegionConverter.convertWindowsRegion(121, 234, testClass.getContents());
ITextSelection sel = new TextSelection(selRegion.getOffset(), selRegion.getLength());
ITypedRegion jsniRegion = JsniParser.getEnclosingJsniRegion(sel, getTestClassDocument());
assertNotNull(jsniRegion);
assertEquals(GWTPartitions.JSNI_METHOD, jsniRegion.getType());
IRegion expectedJsniRegion = RegionConverter.convertWindowsRegion(121, 234, testClass.getContents());
assertEquals(expectedJsniRegion.getOffset(), jsniRegion.getOffset());
assertEquals(expectedJsniRegion.getLength(), jsniRegion.getLength());
}
示例8: run
import com.google.gwt.eclipse.core.editors.java.GWTPartitions; //导入依赖的package包/类
public void run(IAction action) {
if (targetEditor == null) {
GWTPluginLog.logWarning("targetEditor is null");
return;
}
IEditorInput editorInput = targetEditor.getEditorInput();
IResource resource = (IResource) editorInput.getAdapter(IResource.class);
ITextEditor javaEditor = (ITextEditor) targetEditor;
ITextSelection sel = (ITextSelection) javaEditor.getSelectionProvider().getSelection();
IDocument document = javaEditor.getDocumentProvider().getDocument(
javaEditor.getEditorInput());
IDocumentExtension3 document3 = (IDocumentExtension3) document;
IDocumentPartitioner gwtPartitioner = document3.getDocumentPartitioner(GWTPartitions.GWT_PARTITIONING);
String[] partitionings = document3.getPartitionings();
String partitioning = (gwtPartitioner != null
? GWTPartitions.GWT_PARTITIONING : IJavaPartitions.JAVA_PARTITIONING);
ITypedRegion[] types;
try {
types = TextUtilities.computePartitioning(document, partitioning,
sel.getOffset(), sel.getLength(), false);
} catch (BadLocationException e) {
GWTPluginLog.logError(e);
return;
}
String msg = "File: " + resource.getName();
msg += "\nPartitionings: ";
for (String part : partitionings) {
msg += "\n" + part;
}
msg += "\n\nContent types: ";
for (ITypedRegion type : types) {
msg += "\n" + type.getType();
}
msg += "\n\nSelection range: (offset = " + sel.getOffset() + ", length = "
+ sel.getLength() + ")";
MessageDialog.openInformation(targetEditor.getSite().getShell(),
"Selection Info", msg);
}