Skip to content

Instantly share code, notes, and snippets.

@johnlindquist
Created April 26, 2012 07:15
Show Gist options
  • Save johnlindquist/2497090 to your computer and use it in GitHub Desktop.
Save johnlindquist/2497090 to your computer and use it in GitHub Desktop.
package org.angularjs;
import com.intellij.CommonBundle;
import com.intellij.codeInspection.InspectionProfile;
import com.intellij.codeInspection.ModifiableModel;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.htmlInspections.HtmlUnknownAttributeInspection;
import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
import com.intellij.psi.impl.source.xml.XmlAttributeImpl;
import java.io.IOException;
public class AngularJSAutoCompleteSupport extends AbstractProjectComponent {
private final Project project;
protected AngularJSAutoCompleteSupport(Project project) {
super(project);
this.project = project;
}
@Override
public void initComponent() {
final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(project);
final InspectionProfile inspectionProfile = profileManager.getInspectionProfile();
final ModifiableModel model = inspectionProfile.getModifiableModel();
LocalInspectionToolWrapper wrapper = (LocalInspectionToolWrapper) inspectionProfile.getInspectionTool(HtmlUnknownAttributeInspection.ATTRIBUTE_SHORT_NAME, new XmlAttributeImpl());
HtmlUnknownAttributeInspection unknownAttributeInspection = wrapper != null ? (HtmlUnknownAttributeInspection) wrapper.getTool() : null;
assert unknownAttributeInspection != null;
unknownAttributeInspection.addCustomPropertyName("john");
try {
model.commit();
}
catch (IOException e) {
Messages.showErrorDialog(project, e.getMessage(), CommonBundle.getErrorTitle());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment