mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 15:52:01 +07:00
removed aliases from JDK annotations
javadoc
This commit is contained in:
@@ -190,32 +190,33 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
|
||||
final PsiNameValuePair[] value) {
|
||||
final Project project = listOwner.getProject();
|
||||
final PsiFile containingFile = listOwner.getContainingFile();
|
||||
if (containingFile instanceof PsiJavaFile) {
|
||||
final String packageName = ((PsiJavaFile)containingFile).getPackageName();
|
||||
final VirtualFile virtualFile = containingFile.getVirtualFile();
|
||||
LOG.assertTrue(virtualFile != null);
|
||||
final List<OrderEntry> entries = ProjectRootManager.getInstance(project).getFileIndex().getOrderEntriesForFile(virtualFile);
|
||||
if (!entries.isEmpty()) {
|
||||
for (final OrderEntry entry : entries) {
|
||||
if (!(entry instanceof ModuleOrderEntry)) {
|
||||
final VirtualFile[] virtualFiles = AnnotationOrderRootType.getFiles(entry);
|
||||
if (virtualFiles.length > 0) {
|
||||
chooseRootAndAnnotateExternally(listOwner, annotationFQName, fromFile, project, packageName, virtualFile, virtualFiles, value);
|
||||
}
|
||||
else {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() || ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
return;
|
||||
}
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
setupRootAndAnnotateExternally(entry, project, listOwner, annotationFQName, fromFile, packageName, virtualFile, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!(containingFile instanceof PsiJavaFile)) {
|
||||
return;
|
||||
}
|
||||
final String packageName = ((PsiJavaFile)containingFile).getPackageName();
|
||||
final VirtualFile virtualFile = containingFile.getVirtualFile();
|
||||
LOG.assertTrue(virtualFile != null);
|
||||
final List<OrderEntry> entries = ProjectRootManager.getInstance(project).getFileIndex().getOrderEntriesForFile(virtualFile);
|
||||
if (entries.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (final OrderEntry entry : entries) {
|
||||
if (entry instanceof ModuleOrderEntry) continue;
|
||||
final VirtualFile[] virtualFiles = AnnotationOrderRootType.getFiles(entry);
|
||||
if (virtualFiles.length > 0) {
|
||||
chooseRootAndAnnotateExternally(listOwner, annotationFQName, fromFile, project, packageName, virtualFile, virtualFiles, value);
|
||||
}
|
||||
else {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode() || ApplicationManager.getApplication().isHeadlessEnvironment()) {
|
||||
return;
|
||||
}
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
setupRootAndAnnotateExternally(entry, project, listOwner, annotationFQName, fromFile, packageName, virtualFile, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,27 +227,28 @@ public class ExternalAnnotationsManagerImpl extends ExternalAnnotationsManager {
|
||||
descriptor.setTitle(ProjectBundle.message("external.annotations.root.chooser.title", entry.getPresentableName()));
|
||||
descriptor.setDescription(ProjectBundle.message("external.annotations.root.chooser.description"));
|
||||
final VirtualFile file = FileChooser.chooseFile(project, descriptor);
|
||||
if (file != null) {
|
||||
new WriteCommandAction(project) {
|
||||
protected void run(final Result result) throws Throwable {
|
||||
appendChosenAnnotationsRoot(entry, file);
|
||||
final List<XmlFile> xmlFiles = findExternalAnnotationsFile(listOwner);
|
||||
if (xmlFiles != null) { //file already exists under appeared content root
|
||||
if (!CodeInsightUtilBase.preparePsiElementForWrite(xmlFiles.get(0))) return;
|
||||
annotateExternally(listOwner, annotationFQName, xmlFiles.get(0), fromFile, value);
|
||||
}
|
||||
else {
|
||||
final XmlFile annotationsXml = createAnnotationsXml(file, packageName);
|
||||
if (annotationsXml != null) {
|
||||
final List<XmlFile> createdFiles = new ArrayList<XmlFile>();
|
||||
createdFiles.add(annotationsXml);
|
||||
myExternalAnnotations.put(getFQN(packageName, virtualFile), createdFiles);
|
||||
}
|
||||
annotateExternally(listOwner, annotationFQName, annotationsXml, fromFile, value);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
new WriteCommandAction(project) {
|
||||
protected void run(final Result result) throws Throwable {
|
||||
appendChosenAnnotationsRoot(entry, file);
|
||||
final List<XmlFile> xmlFiles = findExternalAnnotationsFile(listOwner);
|
||||
if (xmlFiles != null) { //file already exists under appeared content root
|
||||
if (!CodeInsightUtilBase.preparePsiElementForWrite(xmlFiles.get(0))) return;
|
||||
annotateExternally(listOwner, annotationFQName, xmlFiles.get(0), fromFile, value);
|
||||
}
|
||||
else {
|
||||
final XmlFile annotationsXml = createAnnotationsXml(file, packageName);
|
||||
if (annotationsXml != null) {
|
||||
final List<XmlFile> createdFiles = new ArrayList<XmlFile>();
|
||||
createdFiles.add(annotationsXml);
|
||||
myExternalAnnotations.put(getFQN(packageName, virtualFile), createdFiles);
|
||||
}
|
||||
annotateExternally(listOwner, annotationFQName, annotationsXml, fromFile, value);
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void chooseRootAndAnnotateExternally(final PsiModifierListOwner listOwner, final String annotationFQName, @NotNull final PsiFile fromFile,
|
||||
|
||||
@@ -30,10 +30,7 @@ import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PropertyUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.slicer.*;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.Processor;
|
||||
@@ -395,6 +392,13 @@ public class MagicConstantInspection extends LocalInspectionTool {
|
||||
new Function<PsiAnnotationMemberValue, String>() {
|
||||
@Override
|
||||
public String fun(PsiAnnotationMemberValue value) {
|
||||
if (value instanceof PsiReferenceExpression) {
|
||||
PsiElement resolved = ((PsiReferenceExpression)value).resolve();
|
||||
if (resolved instanceof PsiVariable) {
|
||||
return PsiFormatUtil.formatVariable((PsiVariable)resolved, PsiFormatUtilBase.SHOW_NAME |
|
||||
PsiFormatUtilBase.SHOW_CONTAINING_CLASS, PsiSubstitutor.EMPTY);
|
||||
}
|
||||
}
|
||||
return value.getText();
|
||||
}
|
||||
}, ", ");
|
||||
|
||||
@@ -432,4 +432,18 @@
|
||||
<description>Must be one of the: Const.X, Const.Y</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>X.java</file>
|
||||
<line>238</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Magic Constant</problem_class>
|
||||
<description>Must be one of the: Calendar.JANUARY, Calendar.FEBRUARY, Calendar.MARCH, Calendar.APRIL, Calendar.MAY, Calendar.JUNE, Calendar.JULY, Calendar.AUGUST, Calendar.SEPTEMBER, Calendar.OCTOBER, Calendar.NOVEMBER, Calendar.DECEMBER</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>X.java</file>
|
||||
<line>239</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Magic Constant</problem_class>
|
||||
<description>Must be one of the: SwingConstants.LEFT, SwingConstants.CENTER, SwingConstants.RIGHT, SwingConstants.LEADING, SwingConstants.TRAILING</description>
|
||||
</problem>
|
||||
|
||||
</problems>
|
||||
|
||||
@@ -232,4 +232,11 @@ public class X {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ExternalAnnotations {
|
||||
void f() {
|
||||
java.util.Calendar.getInstance().set(2000,9,0)
|
||||
new javax.swing.JLabel("text", 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,12 @@ package com.intellij.codeInspection;
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
|
||||
import com.intellij.codeInspection.magicConstant.MagicConstantInspection;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.SdkModificator;
|
||||
import com.intellij.openapi.roots.AnnotationOrderRootType;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
|
||||
public class MagicConstantInspectionTest extends InspectionTestCase {
|
||||
@@ -35,41 +41,21 @@ public class MagicConstantInspectionTest extends InspectionTestCase {
|
||||
return JavaTestUtil.getJavaTestDataPath() + "/inspection";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getTestProjectSdk() {
|
||||
// add JDK annotations
|
||||
Sdk sdk = super.getTestProjectSdk();
|
||||
SdkModificator sdkModificator = sdk.getSdkModificator();
|
||||
VirtualFile root = LocalFileSystem.getInstance().findFileByPath(PathManager.getHomePath() + "/jdkAnnotations");
|
||||
sdkModificator.addRoot(root, AnnotationOrderRootType.getInstance());
|
||||
sdkModificator.commitChanges();
|
||||
|
||||
return sdk;
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest("magic/" + getTestName(true), new LocalInspectionToolWrapper(new MagicConstantInspection()), "jdk 1.7");
|
||||
}
|
||||
|
||||
public void testSimple() throws Exception { doTest(); }
|
||||
|
||||
|
||||
|
||||
//{
|
||||
// SecurityManager securityManager = System.getSecurityManager();
|
||||
// securityManager.checkMemberAccess(getClass(), 948);
|
||||
//
|
||||
// Font font = null;
|
||||
// new Cursor() ;
|
||||
// JOptionPane.showConfirmDialog(null, null, null, 0, );
|
||||
// JList l = null;
|
||||
// l.getSelectionModel().setSelectionMode();
|
||||
// new JSplitPane(9);
|
||||
// MouseWheelEvent event = new MouseWheelEvent(null,0,0,0,0,0,0,false,0,0,0 );
|
||||
// Pattern p = Pattern.compile("", Pattern.CANON_EQ);
|
||||
// JTree t = null; t.getSelectionModel().setSelectionMode();
|
||||
//
|
||||
// TitledBorder border = new TitledBorder(null,"",0,0);
|
||||
// new JLabel("text", )
|
||||
// Calendar calendar = Calendar.getInstance();
|
||||
// new Font("Arial", )
|
||||
//}
|
||||
|
||||
//public static Font createFont() {
|
||||
// return new Font("Arial", );
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -5,7 +5,7 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -15,122 +15,45 @@
|
||||
*/
|
||||
package org.intellij.lang.annotations;
|
||||
|
||||
import javax.naming.event.NamingEvent;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.BevelBorder;
|
||||
import javax.swing.border.EtchedBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.geom.Arc2D;
|
||||
import java.lang.reflect.Member;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.util.Calendar;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
@SuppressWarnings("EmptyClass")
|
||||
public class JdkConstants {
|
||||
@MagicConstant(flagsFromClass = java.lang.reflect.Modifier.class)
|
||||
public @interface Modifier {}
|
||||
|
||||
@MagicConstant(intValues = {SwingConstants.LEFT, SwingConstants.CENTER, SwingConstants.RIGHT, SwingConstants.LEADING, SwingConstants.TRAILING})
|
||||
public @interface HorizontalAlignment {}
|
||||
|
||||
@MagicConstant(intValues = {FlowLayout.LEFT, FlowLayout.CENTER, FlowLayout.RIGHT, FlowLayout.LEADING, FlowLayout.TRAILING})
|
||||
public @interface FlowLayoutAlignment {}
|
||||
|
||||
@MagicConstant(intValues = {BasicStroke.CAP_BUTT, BasicStroke.CAP_ROUND, BasicStroke.CAP_SQUARE})
|
||||
public @interface BasicStrokeCap {}
|
||||
|
||||
@MagicConstant(intValues = {BasicStroke.JOIN_BEVEL, BasicStroke.JOIN_MITER, BasicStroke.JOIN_ROUND})
|
||||
public @interface BasicStrokeJoin {}
|
||||
|
||||
@MagicConstant(valuesFromClass = Cursor.class)
|
||||
public @interface CursorType {}
|
||||
|
||||
@MagicConstant(flagsFromClass = InputEvent.class)
|
||||
public @interface InputEventMask {}
|
||||
|
||||
@MagicConstant(intValues = {Label.LEFT, Label.CENTER, Label.RIGHT})
|
||||
public @interface LabelAlignment {}
|
||||
|
||||
@MagicConstant(intValues = {Adjustable.HORIZONTAL, Adjustable.VERTICAL})
|
||||
public @interface AdjustableOrientation {}
|
||||
|
||||
@MagicConstant(intValues = {Calendar.JANUARY, Calendar.FEBRUARY, Calendar.MARCH, Calendar.APRIL, Calendar.MAY, Calendar.JUNE, Calendar.JULY, Calendar.AUGUST, Calendar.SEPTEMBER, Calendar.OCTOBER, Calendar.NOVEMBER, Calendar.DECEMBER })
|
||||
@MagicConstant(intValues = {Calendar.JANUARY, Calendar.FEBRUARY, Calendar.MARCH, Calendar.APRIL, Calendar.MAY, Calendar.JUNE, Calendar.JULY, Calendar.AUGUST, Calendar.SEPTEMBER, Calendar.OCTOBER, Calendar.NOVEMBER, Calendar.DECEMBER})
|
||||
public @interface CalendarMonth {}
|
||||
|
||||
@MagicConstant(flagsFromClass = Pattern.class)
|
||||
public @interface PatternFlags {}
|
||||
|
||||
@MagicConstant(valuesFromClass = ZipEntry.class)
|
||||
public @interface ZipEntryMethod {}
|
||||
|
||||
@MagicConstant(valuesFromClass = BoxLayout.class)
|
||||
public @interface BoxLayoutAxis {}
|
||||
|
||||
@MagicConstant(intValues = {JComponent.WHEN_FOCUSED,JComponent.WHEN_IN_FOCUSED_WINDOW,JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT })
|
||||
public @interface JComponentCondition {}
|
||||
|
||||
@MagicConstant(intValues = {JOptionPane.INFORMATION_MESSAGE,JOptionPane.WARNING_MESSAGE,JOptionPane.ERROR_MESSAGE,JOptionPane.QUESTION_MESSAGE,JOptionPane.PLAIN_MESSAGE })
|
||||
public @interface JOptionPaneMessageType {}
|
||||
|
||||
@MagicConstant(intValues = {JOptionPane.DEFAULT_OPTION, JOptionPane.YES_NO_OPTION, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.OK_CANCEL_OPTION})
|
||||
public @interface JOptionPaneOptionType {}
|
||||
|
||||
@MagicConstant(intValues = {JSplitPane.HORIZONTAL_SPLIT,JSplitPane.VERTICAL_SPLIT})
|
||||
public @interface JSplitPaneOrientation {}
|
||||
|
||||
@MagicConstant(flags = {HierarchyEvent.PARENT_CHANGED,HierarchyEvent.DISPLAYABILITY_CHANGED,HierarchyEvent.SHOWING_CHANGED})
|
||||
public @interface HierarchyEventChangedFlags {}
|
||||
|
||||
@MagicConstant(intValues = {ItemEvent.SELECTED, ItemEvent.DESELECTED})
|
||||
public @interface ItemEventStateChange {}
|
||||
|
||||
@MagicConstant(intValues = {JFileChooser.FILES_ONLY, JFileChooser.DIRECTORIES_ONLY, JFileChooser.FILES_AND_DIRECTORIES})
|
||||
public @interface JFileChooserFileSelectionMode{}
|
||||
|
||||
@MagicConstant(valuesFromClass = ListSelectionModel.class)
|
||||
public @interface ListSelectionMode{}
|
||||
|
||||
@MagicConstant(valuesFromClass = TreeSelectionModel.class)
|
||||
public @interface TreeSelectionMode{}
|
||||
|
||||
@MagicConstant(intValues = {BevelBorder.RAISED, BevelBorder.LOWERED})
|
||||
public @interface BevelBorderType {}
|
||||
|
||||
@MagicConstant(intValues = {EtchedBorder.RAISED, EtchedBorder.LOWERED})
|
||||
public @interface EtchedBorderType {}
|
||||
|
||||
@MagicConstant(intValues = {TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.LEFT, TitledBorder.CENTER, TitledBorder.RIGHT, TitledBorder.LEADING, TitledBorder.TRAILING})
|
||||
public @interface TitledBorderJustification {}
|
||||
|
||||
@MagicConstant(intValues = {TitledBorder.ABOVE_TOP, TitledBorder.TOP, TitledBorder.BELOW_TOP, TitledBorder.ABOVE_BOTTOM, TitledBorder.BOTTOM, TitledBorder.BELOW_BOTTOM, TitledBorder.DEFAULT_POSITION})
|
||||
public @interface TitledBorderTitlePosition {}
|
||||
|
||||
@MagicConstant(intValues = {AdjustmentEvent.UNIT_INCREMENT, AdjustmentEvent.UNIT_DECREMENT, AdjustmentEvent.BLOCK_INCREMENT, AdjustmentEvent.BLOCK_DECREMENT, AdjustmentEvent.TRACK})
|
||||
public @interface AdjustmentEventType {}
|
||||
|
||||
@MagicConstant(intValues = {MouseWheelEvent.WHEEL_UNIT_SCROLL, MouseWheelEvent.WHEEL_BLOCK_SCROLL})
|
||||
public @interface MouseWheelEventType {}
|
||||
|
||||
@MagicConstant(intValues = {Arc2D.OPEN, Arc2D.CHORD, Arc2D.PIE})
|
||||
public @interface Arc2DType {}
|
||||
|
||||
@MagicConstant(intValues = {TableModelEvent.INSERT, TableModelEvent.UPDATE, TableModelEvent.DELETE})
|
||||
public @interface TableModelEventType {}
|
||||
|
||||
@MagicConstant(valuesFromClass = ListDataEvent.class)
|
||||
public @interface ListDataEventType {}
|
||||
|
||||
@MagicConstant(valuesFromClass = NamingEvent.class)
|
||||
public @interface NamingEventType {}
|
||||
|
||||
@MagicConstant(valuesFromClass = Member.class)
|
||||
public @interface SecurityManagerMemberAccess {}
|
||||
|
||||
|
||||
@MagicConstant(flags = {Font.PLAIN, Font.BOLD, Font.ITALIC})
|
||||
public @interface FontStyle {}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,124 @@ package org.intellij.lang.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Documented
|
||||
/**
|
||||
* <p>This annotation indended to help IDEA to detect and auto-complete int and String constants used as an enumeration.
|
||||
* For example, in the {@link java.awt.Label#Label(String, int)} constructor the <tt><b>alignment</b></tt> parameter can be one of the following
|
||||
* int constants: {@link java.awt.Label#LEFT}, {@link java.awt.Label#CENTER} or {@link java.awt.Label#RIGHT}
|
||||
*
|
||||
* <p>So, if <tt>@MagicConstant</tt> annotation applied to this constructor, IDEA will check the constructor usages for the allowed values.
|
||||
* <p>E.g.<br>
|
||||
* <pre>{@code
|
||||
* new Label("text", 0); // 0 is not allowed
|
||||
* new Label("text", Label.LEFT); // OK
|
||||
* }</pre>
|
||||
*
|
||||
* <p>
|
||||
* <tt>@MagicConstant</tt> can be applied to:
|
||||
* <ul>
|
||||
* <li> Field, local variable, parameter.
|
||||
*
|
||||
* <br>E.g. <br>
|
||||
* <pre>{@code @MagicConstant(intValues = {TOP, CENTER, BOTTOM})
|
||||
* int textPosition;
|
||||
* }</pre>
|
||||
* IDEA will check expressions assigned to the variable for allowed values:
|
||||
* <pre>{@code
|
||||
* textPosition = 0; // not allowed
|
||||
* textPosition = TOP; // OK
|
||||
* }</pre>
|
||||
*
|
||||
* <li> Method
|
||||
*
|
||||
* <br>E.g.<br>
|
||||
* <pre>{@code @MagicConstant(flagsFromClass = java.lang.reflect.Modifier.class)
|
||||
* public native int getModifiers();
|
||||
* }</pre>
|
||||
*
|
||||
* IDEA will analyse getModifiers() method calls and check if its return value is used with allowed values:<br>
|
||||
* <pre>{@code
|
||||
* if (aClass.getModifiers() == 3) // not allowed
|
||||
* if (aClass.getModifiers() == Modifier.PUBLIC) // OK
|
||||
* }</pre>
|
||||
*
|
||||
* <li>Annotation class<br>
|
||||
* Annotation class annotated with <tt>@MagicConstant</tt> created alias you can use to annotate
|
||||
* everything as if it was annotated with <tt>@MagicConstant</tt> itself.
|
||||
*
|
||||
* <br>E.g.<br>
|
||||
* <pre>{@code @MagicConstant(flags = {Font.PLAIN, Font.BOLD, Font.ITALIC}) }</pre>
|
||||
* <pre>{@code @interface FontStyle {} }</pre>
|
||||
*
|
||||
* IDEA will check constructs annotated with @FontStyle for allowed values:<br>
|
||||
* <tt>@FontStyle int myStyle = 3; // not allowed<br></tt>
|
||||
* <tt>@FontStyle int myStyle = Font.BOLD | Font.ITALIC; // OK</tt><br>
|
||||
* </tt>
|
||||
*
|
||||
* </ul>
|
||||
*
|
||||
* The <tt>@MagicConstant</tt> annotation has SOURCE retention, i.e. it is removed upon compilation and does not create any runtime overhead.
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE,
|
||||
ElementType.ANNOTATION_TYPE, // to subclass
|
||||
@Target({
|
||||
ElementType.FIELD, ElementType.PARAMETER, ElementType.LOCAL_VARIABLE,
|
||||
ElementType.ANNOTATION_TYPE,
|
||||
ElementType.METHOD
|
||||
})
|
||||
public @interface MagicConstant {
|
||||
Class valuesFromClass() default void.class;
|
||||
Class flagsFromClass() default void.class; // int constants which can be combined via | (bitwise or) operator. 0 and -1 are considered acceptable values.
|
||||
String[] stringValues() default {};
|
||||
/**
|
||||
* @return int values (typically named constants) which are allowed here.
|
||||
* E.g.
|
||||
* <tt>
|
||||
* void setConfirmOpenNewProject(@MagicConstant(intValues = {OPEN_PROJECT_ASK, OPEN_PROJECT_NEW_WINDOW, OPEN_PROJECT_SAME_WINDOW})
|
||||
* int confirmOpenNewProject);
|
||||
* </tt>
|
||||
*/
|
||||
long[] intValues() default {};
|
||||
long[] flags() default {}; // int constants which can be combined via | (bitwise or) operator. 0 and -1 are considered acceptable values.
|
||||
|
||||
/**
|
||||
* @return String values (typically named constants) which are allowed here.
|
||||
*/
|
||||
String[] stringValues() default {};
|
||||
|
||||
/**
|
||||
* @return allowed int flags (i.e. values (typically named constants) which can be combined with bitwise or operator (|).
|
||||
* Also 0 and -1 are considered allowed.
|
||||
* E.g.
|
||||
* <tt>
|
||||
* @MagicConstant(flags = {HierarchyEvent.PARENT_CHANGED,HierarchyEvent.DISPLAYABILITY_CHANGED,HierarchyEvent.SHOWING_CHANGED})
|
||||
* int hFlags;
|
||||
*
|
||||
* hFlags = 3; // not allowed
|
||||
* if (hFlags & (HierarchyEvent.PARENT_CHANGED | HierarchyEvent.SHOWING_CHANGED) != 0); // OK
|
||||
* </tt>
|
||||
*/
|
||||
long[] flags() default {};
|
||||
|
||||
/**
|
||||
* @return allowed values which are defined in the specified class public static final constants.
|
||||
*
|
||||
* E.g.
|
||||
* <tt>
|
||||
* @MagicConstant(valuesFromClass = Cursor.class)
|
||||
* int cursorType;
|
||||
*
|
||||
* cursorType = 11; // not allowed;
|
||||
* cursorType = Cursor.E_RESIZE_CURSOR; // OK
|
||||
* </tt>
|
||||
*/
|
||||
Class valuesFromClass() default void.class;
|
||||
|
||||
|
||||
/**
|
||||
* @return allowed int flags which are defined in the specified class public static final constants.
|
||||
*
|
||||
* E.g.
|
||||
* <tt>@MagicConstant(flagsFromClass = java.awt.InputEvent.class)
|
||||
* int eventMask;
|
||||
*
|
||||
* eventMask = 10; // not allowed;
|
||||
* eventMask = InputEvent.CTRL_MASK | InputEvent.ALT_MASK; // OK
|
||||
* </tt>
|
||||
*/
|
||||
Class flagsFromClass() default void.class;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ package com.intellij.openapi.editor.markup;
|
||||
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import com.intellij.util.containers.StripedLockConcurrentHashMap;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -33,7 +34,7 @@ public class AttributesFlyweight {
|
||||
@NotNull
|
||||
public static AttributesFlyweight create(Color foreground,
|
||||
Color background,
|
||||
@TextAttributes.FontStyle int fontType,
|
||||
@JdkConstants.FontStyle int fontType,
|
||||
Color effectColor,
|
||||
EffectType effectType,
|
||||
Color errorStripeColor) {
|
||||
@@ -43,7 +44,7 @@ public class AttributesFlyweight {
|
||||
|
||||
private final Color myForeground;
|
||||
private final Color myBackground;
|
||||
@TextAttributes.FontStyle
|
||||
@JdkConstants.FontStyle
|
||||
private final int myFontType;
|
||||
private final Color myEffectColor ;
|
||||
private final EffectType myEffectType;
|
||||
@@ -51,7 +52,7 @@ public class AttributesFlyweight {
|
||||
|
||||
private AttributesFlyweight(Color foreground,
|
||||
Color background,
|
||||
@TextAttributes.FontStyle int fontType,
|
||||
@JdkConstants.FontStyle int fontType,
|
||||
Color effectColor,
|
||||
EffectType effectType,
|
||||
Color errorStripeColor) {
|
||||
@@ -82,7 +83,7 @@ public class AttributesFlyweight {
|
||||
return myBackground;
|
||||
}
|
||||
|
||||
@TextAttributes.FontStyle
|
||||
@JdkConstants.FontStyle
|
||||
public int getFontType() {
|
||||
return myFontType;
|
||||
}
|
||||
@@ -107,7 +108,7 @@ public class AttributesFlyweight {
|
||||
return create(myForeground, back, myFontType, myEffectColor, myEffectType, myErrorStripeColor);
|
||||
}
|
||||
|
||||
public AttributesFlyweight withFontType(@TextAttributes.FontStyle int fontType) {
|
||||
public AttributesFlyweight withFontType(@JdkConstants.FontStyle int fontType) {
|
||||
return create(myForeground, myBackground, fontType, myEffectColor, myEffectType, myErrorStripeColor);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package com.intellij.openapi.editor.markup;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.*;
|
||||
import org.intellij.lang.annotations.MagicConstant;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jdom.Element;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -61,7 +61,7 @@ public class TextAttributes implements JDOMExternalizable, Cloneable {
|
||||
public Color FOREGROUND = null;
|
||||
public Color BACKGROUND = null;
|
||||
|
||||
@FontStyle
|
||||
@JdkConstants.FontStyle
|
||||
public int FONT_TYPE = Font.PLAIN;
|
||||
|
||||
public Color EFFECT_COLOR = null;
|
||||
@@ -141,7 +141,7 @@ public class TextAttributes implements JDOMExternalizable, Cloneable {
|
||||
myAttrs = AttributesFlyweight.create(null, null, Font.PLAIN, null, EffectType.BOXED, null);
|
||||
}
|
||||
|
||||
public TextAttributes(Color foregroundColor, Color backgroundColor, Color effectColor, EffectType effectType, @FontStyle int fontType) {
|
||||
public TextAttributes(Color foregroundColor, Color backgroundColor, Color effectColor, EffectType effectType, @JdkConstants.FontStyle int fontType) {
|
||||
myAttrs = AttributesFlyweight.create(foregroundColor, backgroundColor, fontType, effectColor, effectType, null);
|
||||
}
|
||||
|
||||
@@ -199,15 +199,12 @@ public class TextAttributes implements JDOMExternalizable, Cloneable {
|
||||
myAttrs = myAttrs.withEffectType(effectType);
|
||||
}
|
||||
|
||||
@FontStyle
|
||||
@JdkConstants.FontStyle
|
||||
public int getFontType() {
|
||||
return myAttrs.getFontType();
|
||||
}
|
||||
|
||||
@MagicConstant(flags = {Font.PLAIN, Font.BOLD, Font.ITALIC})
|
||||
public @interface FontStyle {}
|
||||
|
||||
public void setFontType(@FontStyle int type) {
|
||||
public void setFontType(@JdkConstants.FontStyle int type) {
|
||||
if (type < 0 || type > 3) {
|
||||
LOG.error("Wrong font type: " + type);
|
||||
type = 0;
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.editor.markup.EffectType;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.intellij.lang.annotations.MagicConstant;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -191,7 +192,7 @@ public final class SimpleTextAttributes {
|
||||
return new SimpleTextAttributes(attributes.getBackgroundColor(), foregroundColor, attributes.getEffectColor(), style);
|
||||
}
|
||||
|
||||
@TextAttributes.FontStyle
|
||||
@JdkConstants.FontStyle
|
||||
public int getFontStyle() {
|
||||
return myStyle & FONT_MASK;
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ import com.intellij.openapi.editor.impl.ComplementaryFontsRegistry;
|
||||
import com.intellij.openapi.editor.impl.EditorImpl;
|
||||
import com.intellij.openapi.editor.impl.FontInfo;
|
||||
import com.intellij.openapi.editor.impl.IterationState;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -420,16 +420,16 @@ public class EditorUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static FontInfo fontForChar(final char c, @TextAttributes.FontStyle int style, Editor editor) {
|
||||
public static FontInfo fontForChar(final char c, @JdkConstants.FontStyle int style, Editor editor) {
|
||||
EditorColorsScheme colorsScheme = editor.getColorsScheme();
|
||||
return ComplementaryFontsRegistry.getFontAbleToDisplay(c, colorsScheme.getEditorFontSize(), style, colorsScheme.getEditorFontName());
|
||||
}
|
||||
|
||||
public static int charWidth(char c, @TextAttributes.FontStyle int fontType, Editor editor) {
|
||||
public static int charWidth(char c, @JdkConstants.FontStyle int fontType, Editor editor) {
|
||||
return fontForChar(c, fontType, editor).charWidth(c, editor.getContentComponent());
|
||||
}
|
||||
|
||||
public static int getSpaceWidth(@TextAttributes.FontStyle int fontType, Editor editor) {
|
||||
public static int getSpaceWidth(@JdkConstants.FontStyle int fontType, Editor editor) {
|
||||
int width = charWidth(' ', fontType, editor);
|
||||
return width > 0 ? width : 1;
|
||||
}
|
||||
@@ -560,7 +560,7 @@ public class EditorUtil {
|
||||
* from <code>[1; tab size]</code> (check {@link #nextTabStop(int, Editor)} for more details)
|
||||
* @return width in pixels required for target text representation
|
||||
*/
|
||||
public static int textWidth(@NotNull Editor editor, CharSequence text, int start, int end, @TextAttributes.FontStyle int fontType, int x) {
|
||||
public static int textWidth(@NotNull Editor editor, CharSequence text, int start, int end, @JdkConstants.FontStyle int fontType, int x) {
|
||||
int result = 0;
|
||||
for (int i = start; i < end; i++) {
|
||||
char c = text.charAt(i);
|
||||
|
||||
@@ -16,10 +16,10 @@
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import gnu.trove.TIntHashSet;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ComplementaryFontsRegistry {
|
||||
public int mySize;
|
||||
public int myStyle;
|
||||
|
||||
public FontKey(@NotNull String familyName, final int size, @TextAttributes.FontStyle int style) {
|
||||
public FontKey(@NotNull String familyName, final int size, @JdkConstants.FontStyle int style) {
|
||||
myFamilyName = familyName;
|
||||
mySize = size;
|
||||
myStyle = style;
|
||||
@@ -118,7 +118,7 @@ public class ComplementaryFontsRegistry {
|
||||
return Pair.create(found ? styledFamilyName : familyName, found ? Font.PLAIN : style);
|
||||
}
|
||||
|
||||
public static FontInfo getFontAbleToDisplay(char c, int size, @TextAttributes.FontStyle int style, @NotNull String defaultFontFamily) {
|
||||
public static FontInfo getFontAbleToDisplay(char c, int size, @JdkConstants.FontStyle int style, @NotNull String defaultFontFamily) {
|
||||
synchronized (lock) {
|
||||
Pair<String, Integer> p = fontFamily(defaultFontFamily, style);
|
||||
if (ourSharedKeyInstance.mySize == size &&
|
||||
|
||||
@@ -18,8 +18,8 @@ package com.intellij.openapi.editor.impl;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -120,14 +120,14 @@ public class DefaultEditorTextRepresentationHelper implements EditorTextRepresen
|
||||
private static class Key {
|
||||
public String fontName;
|
||||
private int fontSize;
|
||||
@TextAttributes.FontStyle private int fontType;
|
||||
@JdkConstants.FontStyle private int fontType;
|
||||
private char c;
|
||||
|
||||
private Key() {
|
||||
this(null, 0, 0, ' ');
|
||||
}
|
||||
|
||||
Key(String fontName, int fontSize, @TextAttributes.FontStyle int fontType, char c) {
|
||||
Key(String fontName, int fontSize, @JdkConstants.FontStyle int fontType, char c) {
|
||||
this.fontName = fontName;
|
||||
this.fontSize = fontSize;
|
||||
this.fontType = fontType;
|
||||
|
||||
@@ -1147,7 +1147,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
* @return width required to represent given char with the given settings on a screen;
|
||||
* <code>'0'</code> if given char is a line break
|
||||
*/
|
||||
private int charToVisibleWidth(char c, @TextAttributes.FontStyle int fontType, int currentX) {
|
||||
private int charToVisibleWidth(char c, @JdkConstants.FontStyle int fontType, int currentX) {
|
||||
if (c == '\n') {
|
||||
return 0;
|
||||
}
|
||||
@@ -2112,7 +2112,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
|
||||
private int drawSoftWrapAwareBackground(Graphics g, Color backColor, CharSequence text, int start, int end, Point position,
|
||||
@TextAttributes.FontStyle int fontType, Color defaultBackground, Rectangle clip, TIntHashSet softWrapsToSkip,
|
||||
@JdkConstants.FontStyle int fontType, Color defaultBackground, Rectangle clip, TIntHashSet softWrapsToSkip,
|
||||
boolean[] caretRowPainted)
|
||||
{
|
||||
int startToUse = start;
|
||||
@@ -2146,7 +2146,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
return position.x;
|
||||
}
|
||||
|
||||
private void drawSoftWrap(Graphics g, SoftWrap softWrap, Point position, @TextAttributes.FontStyle int fontType, Color backColor,
|
||||
private void drawSoftWrap(Graphics g, SoftWrap softWrap, Point position, @JdkConstants.FontStyle int fontType, Color backColor,
|
||||
boolean drawCustomBackgroundAtSoftWrapVirtualSpace, Color defaultBackground, Rectangle clip,
|
||||
boolean[] caretRowPainted)
|
||||
{
|
||||
@@ -2204,7 +2204,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
* @param fontType current font type
|
||||
*/
|
||||
private void paintSelectionOnFirstSoftWrapLineIfNecessary(Graphics g, Point position, Rectangle clip, Color defaultBackground,
|
||||
@TextAttributes.FontStyle int fontType)
|
||||
@JdkConstants.FontStyle int fontType)
|
||||
{
|
||||
// There is a possible case that the user performed selection at soft wrap virtual space. We need to paint corresponding background
|
||||
// there then.
|
||||
@@ -2262,7 +2262,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
* @param softWrap target soft wrap which second line virtual space may contain selection
|
||||
*/
|
||||
private void paintSelectionOnSecondSoftWrapLineIfNecessary(Graphics g, Point position, Rectangle clip, Color defaultBackground,
|
||||
@TextAttributes.FontStyle int fontType, SoftWrap softWrap)
|
||||
@JdkConstants.FontStyle int fontType, SoftWrap softWrap)
|
||||
{
|
||||
// There is a possible case that the user performed selection at soft wrap virtual space. We need to paint corresponding background
|
||||
// there then.
|
||||
@@ -2297,7 +2297,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
drawBackground(g, getColorsScheme().getColor(EditorColors.SELECTION_BACKGROUND_COLOR), width, position, defaultBackground, clip);
|
||||
}
|
||||
|
||||
private int drawBackground(Graphics g, Color backColor, CharSequence text, Point position, @TextAttributes.FontStyle int fontType, Color defaultBackground,
|
||||
private int drawBackground(Graphics g, Color backColor, CharSequence text, Point position, @JdkConstants.FontStyle int fontType, Color defaultBackground,
|
||||
Rectangle clip)
|
||||
{
|
||||
int width = getTextSegmentWidth(text, position.x, fontType, clip);
|
||||
@@ -2671,7 +2671,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
Rectangle clip,
|
||||
Color effectColor,
|
||||
EffectType effectType,
|
||||
@TextAttributes.FontStyle int fontType,
|
||||
@JdkConstants.FontStyle int fontType,
|
||||
Color fontColor,
|
||||
Ref<LogicalPosition> startDrawingLogicalPosition)
|
||||
{
|
||||
@@ -2687,7 +2687,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
Rectangle clip,
|
||||
Color effectColor,
|
||||
EffectType effectType,
|
||||
@TextAttributes.FontStyle int fontType,
|
||||
@JdkConstants.FontStyle int fontType,
|
||||
Color fontColor,
|
||||
Ref<LogicalPosition> startDrawingLogicalPosition) {
|
||||
int startToUse = start;
|
||||
@@ -2803,7 +2803,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
Rectangle clip,
|
||||
@Nullable Color effectColor,
|
||||
@Nullable EffectType effectType,
|
||||
@TextAttributes.FontStyle int fontType,
|
||||
@JdkConstants.FontStyle int fontType,
|
||||
Color fontColor) {
|
||||
if (start >= end) return position.x;
|
||||
|
||||
@@ -2822,7 +2822,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
Rectangle clip,
|
||||
Color effectColor,
|
||||
EffectType effectType,
|
||||
@TextAttributes.FontStyle int fontType,
|
||||
@JdkConstants.FontStyle int fontType,
|
||||
Color fontColor) {
|
||||
boolean isInClip = getLineHeight() + position.y >= clip.y && position.y <= clip.y + clip.height;
|
||||
|
||||
@@ -2842,7 +2842,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
int y,
|
||||
Color effectColor,
|
||||
EffectType effectType,
|
||||
@TextAttributes.FontStyle int fontType,
|
||||
@JdkConstants.FontStyle int fontType,
|
||||
Color fontColor,
|
||||
final Rectangle clip) {
|
||||
int xStart = x;
|
||||
@@ -2914,7 +2914,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
final Graphics g,
|
||||
int x,
|
||||
final int y,
|
||||
@TextAttributes.FontStyle final int fontType,
|
||||
@JdkConstants.FontStyle final int fontType,
|
||||
final Color fontColor,
|
||||
final Rectangle clip) {
|
||||
int endX = x;
|
||||
@@ -2972,7 +2972,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
}
|
||||
}
|
||||
|
||||
private void drawCharsCached(Graphics g, char[] data, int start, int end, int x, int y, @TextAttributes.FontStyle int fontType, Color color) {
|
||||
private void drawCharsCached(Graphics g, char[] data, int start, int end, int x, int y, @JdkConstants.FontStyle int fontType, Color color) {
|
||||
if (!myForceRefreshFont && myCommonSpaceWidth > 0 && myLastCache != null && spacesOnly(data, start, end)) {
|
||||
myLastCache.addContent(g, data, start, end, x, y, null);
|
||||
}
|
||||
@@ -3044,7 +3044,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
UIUtil.drawLine(g, x + WAVE_SEGMENT_LENGTH / 2, y, x + WAVE_SEGMENT_LENGTH, y + WAVE_HEIGHT);
|
||||
}
|
||||
|
||||
private int getTextSegmentWidth(CharSequence text, int xStart, @TextAttributes.FontStyle int fontType, Rectangle clip) {
|
||||
private int getTextSegmentWidth(CharSequence text, int xStart, @JdkConstants.FontStyle int fontType, Rectangle clip) {
|
||||
int x = xStart;
|
||||
|
||||
final int textLength = text.length();
|
||||
@@ -3089,7 +3089,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
return myDescent;
|
||||
}
|
||||
|
||||
FontMetrics getFontMetrics(@TextAttributes.FontStyle int fontType) {
|
||||
FontMetrics getFontMetrics(@JdkConstants.FontStyle int fontType) {
|
||||
if (myPlainFontMetrics == null) {
|
||||
assertIsDispatchThread();
|
||||
myPlainFontMetrics = myEditorComponent.getFontMetrics(myScheme.getFont(EditorFontType.PLAIN));
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ public interface EditorTextRepresentationHelper {
|
||||
* @param x <code>'x'</code> offset from the visual line start
|
||||
* @return width in pixels necessary for the target text sub-sequence representation
|
||||
*/
|
||||
int textWidth(@NotNull CharSequence text, int start, int end, @TextAttributes.FontStyle int fontType, int x);
|
||||
int textWidth(@NotNull CharSequence text, int start, int end, @JdkConstants.FontStyle int fontType, int x);
|
||||
|
||||
/**
|
||||
* This is specification of {@link #textWidth(CharSequence, int, int, int, int)} in case of the single character
|
||||
@@ -71,5 +71,5 @@ public interface EditorTextRepresentationHelper {
|
||||
* @param fontType font type used for the given char representation
|
||||
* @return width in pixels necessary for the target char representation
|
||||
*/
|
||||
int charWidth(char c, @TextAttributes.FontStyle int fontType);
|
||||
int charWidth(char c, @JdkConstants.FontStyle int fontType);
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package com.intellij.openapi.editor.impl;
|
||||
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import gnu.trove.TIntHashSet;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -28,12 +28,12 @@ public class FontInfo {
|
||||
private final String myFamilyName;
|
||||
private final Font myFont;
|
||||
private final int mySize;
|
||||
@TextAttributes.FontStyle private final int myStyle;
|
||||
@JdkConstants.FontStyle private final int myStyle;
|
||||
private final TIntHashSet mySafeCharacters = new TIntHashSet();
|
||||
private FontMetrics myFontMetrics = null;
|
||||
private final int[] charWidth = new int[128];
|
||||
|
||||
public FontInfo(final String familyName, final int size, @TextAttributes.FontStyle int style) {
|
||||
public FontInfo(final String familyName, final int size, @JdkConstants.FontStyle int style) {
|
||||
myFamilyName = familyName;
|
||||
mySize = size;
|
||||
myStyle = style;
|
||||
@@ -80,7 +80,7 @@ public class FontInfo {
|
||||
return mySize;
|
||||
}
|
||||
|
||||
@TextAttributes.FontStyle
|
||||
@JdkConstants.FontStyle
|
||||
public int getStyle() {
|
||||
return myStyle;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.intellij.openapi.editor.impl.*;
|
||||
import com.intellij.openapi.editor.impl.softwrap.*;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -1113,7 +1114,7 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
|
||||
public int rangeEndOffset;
|
||||
public int tokenStartOffset;
|
||||
public int tokenEndOffset;
|
||||
@TextAttributes.FontStyle
|
||||
@JdkConstants.FontStyle
|
||||
public int fontType;
|
||||
public boolean notifyListenersOnLineStartPosition;
|
||||
public boolean skipToLineEnd;
|
||||
@@ -1140,7 +1141,7 @@ public class SoftWrapApplianceManager implements SoftWrapFoldingListener, Docume
|
||||
return getSpaceWidth(fontType);
|
||||
}
|
||||
|
||||
public int getSpaceWidth(@TextAttributes.FontStyle int fontType) {
|
||||
public int getSpaceWidth(@JdkConstants.FontStyle int fontType) {
|
||||
int result = fontType2spaceWidth.get(fontType);
|
||||
if (result <= 0) {
|
||||
result = EditorUtil.getSpaceWidth(fontType, myEditor);
|
||||
|
||||
Reference in New Issue
Block a user